/usr/include/flint/flint.h is in libflint-dev 2.4.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | /*=============================================================================
This file is part of FLINT.
FLINT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FLINT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2009 William Hart
******************************************************************************/
#ifndef FLINT_H
#define FLINT_H
#undef ulong
#define ulong ulongxx /* ensure vendor doesn't typedef ulong */
#include <sys/param.h> /* for BSD define */
#include <gmp.h>
#include <mpfr.h>
#include <stdio.h>
#include <stdlib.h> /* for alloca on FreeBSD */
#if !defined(BSD) && !defined(__MINGW64__) && !defined(__MINGW32__)
/* MinGW and FreeBSD have alloca, but not alloca.h */
#include <alloca.h>
#endif
#if defined(__MINGW32__)
#include <malloc.h> /* for alloca on MinGW */
#endif
#include "limits.h"
#include "longlong.h"
#include "config.h"
#undef ulong
#if HAVE_GC
#include "gc.h"
#endif
#if WANT_ASSERT
#include <assert.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* flint version number */
#define __FLINT_VERSION 2
#define __FLINT_VERSION_MINOR 4
#define __FLINT_VERSION_PATCHLEVEL 4
#define FLINT_VERSION "2.4.4"
#define __FLINT_RELEASE (__FLINT_VERSION * 10000 + \
__FLINT_VERSION_MINOR * 100 + \
__FLINT_VERSION_PATCHLEVEL)
/*
Check mpir and mpfr version numbers
*/
#if __GNU_MP_VERSION < 5
#error GMP 5.0.0 or MPIR 2.6.0 or later are required
#endif
#if MPFR_VERSION_MAJOR < 3
#error MPFR 3.0.0 or later is required
#endif
/*
We define alternative key words for "asm" and "inline", allowing
the code to be compiled with the "-ansi" flag under GCC
*/
#ifndef __GNUC__
#define __asm__ asm
#define __inline__ inline
#endif
extern char version[];
#define ulong mp_limb_t
#define slong mp_limb_signed_t
void * flint_malloc(size_t size);
void * flint_realloc(void * ptr, size_t size);
void * flint_calloc(size_t num, size_t size);
void flint_free(void * ptr);
typedef void (*flint_cleanup_function_t)(void);
void flint_register_cleanup_function(flint_cleanup_function_t cleanup_function);
void flint_cleanup(void);
#if defined(_WIN64)
#define WORD_FMT "%ll"
#define WORD(xx) (xx##LL)
#define UWORD(xx) (xx##ULL)
#define UWORD_MAX ULLONG_MAX
#define UWORD_MIN ULLONG_MIN
#define WORD_MAX LLONG_MAX
#define WORD_MIN LLONG_MIN
#else
#define WORD_FMT "%l"
#define WORD(xx) (xx##L)
#define UWORD(xx) (xx##UL)
#define UWORD_MAX ULONG_MAX
#define UWORD_MIN ULONG_MIN
#define WORD_MAX LONG_MAX
#define WORD_MIN LONG_MIN
#endif
#if GMP_LIMB_BITS == 64
#define FLINT_BITS 64
#define FLINT_D_BITS 53
#define FLINT64 1
#else
#define FLINT_BITS 32
#define FLINT_D_BITS 31
#endif
#define mp_bitcnt_t ulong
#if HAVE_TLS
#define FLINT_TLS_PREFIX __thread
#else
#define FLINT_TLS_PREFIX
#endif
int flint_get_num_threads(void);
void flint_set_num_threads(int num_threads);
int flint_test_multiplier(void);
typedef struct
{
gmp_randstate_t gmp_state;
int gmp_init;
mp_limb_t __randval;
mp_limb_t __randval2;
} flint_rand_s;
typedef flint_rand_s flint_rand_t[1];
static __inline__
void flint_randinit(flint_rand_t state)
{
state->gmp_init = 0;
#if FLINT64
state->__randval = UWORD(13845646450878251009);
state->__randval2 = UWORD(13142370077570254774);
#else
state->__randval = UWORD(4187301858);
state->__randval2 = UWORD(3721271368);
#endif
}
static __inline__
void _flint_rand_init_gmp(flint_rand_t state)
{
if (!state->gmp_init)
{
gmp_randinit_default(state->gmp_state);
state->gmp_init = 1;
}
}
static __inline__
void flint_randclear(flint_rand_t state)
{
if (state->gmp_init)
gmp_randclear(state->gmp_state);
}
#if HAVE_GC
#define FLINT_GC_INIT() GC_init()
#else
#define FLINT_GC_INIT()
#endif
#define FLINT_TEST_INIT(xxx) \
flint_rand_t xxx; \
FLINT_GC_INIT(); \
flint_randinit(xxx)
#define FLINT_TEST_CLEANUP(xxx) \
flint_randclear(xxx); \
flint_cleanup();
/*
We define this here as there is no mpfr.h
*/
typedef __mpfr_struct mpfr;
#if WANT_ASSERT
#define FLINT_ASSERT(param) assert(param)
#else
#define FLINT_ASSERT(param)
#endif
#define FLINT_MAX(x, y) ((x) > (y) ? (x) : (y))
#define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x))
#define FLINT_ABS(x) ((slong)(x) < 0 ? (-(x)) : (x))
#define MP_PTR_SWAP(x, y) \
do { \
mp_limb_t * __txxx; \
__txxx = x; \
x = y; \
y = __txxx; \
} while (0)
#define r_shift(in, shift) \
((shift == FLINT_BITS) ? WORD(0) : ((in) >> (shift)))
#define l_shift(in, shift) \
((shift == FLINT_BITS) ? WORD(0) : ((in) << (shift)))
#ifdef NEED_CLZ_TAB
extern const unsigned char __flint_clz_tab[128];
#endif
static __inline__
unsigned int FLINT_BIT_COUNT(mp_limb_t x)
{
unsigned int zeros = FLINT_BITS;
if (x) count_leading_zeros(zeros, x);
return FLINT_BITS - zeros;
}
#define FLINT_FLOG2(k) (FLINT_BIT_COUNT(k) - 1)
#define FLINT_CLOG2(k) FLINT_BIT_COUNT((k) - 1)
#define flint_mpn_zero(xxx, nnn) \
do \
{ \
slong ixxx; \
for (ixxx = 0; ixxx < (nnn); ixxx++) \
(xxx)[ixxx] = UWORD(0); \
} while (0)
#define flint_mpn_copyi(xxx, yyy, nnn) \
do { \
slong ixxx; \
for (ixxx = 0; ixxx < (nnn); ixxx++) \
(xxx)[ixxx] = (yyy)[ixxx]; \
} while (0)
#define flint_mpn_copyd(xxx, yyy, nnn) \
do { \
slong ixxx; \
for (ixxx = nnn - 1; ixxx >= 0; ixxx--) \
(xxx)[ixxx] = (yyy)[ixxx]; \
} while (0)
#define flint_mpn_store(xxx, nnn, yyy) \
do \
{ \
slong ixxx; \
for (ixxx = 0; ixxx < nnn; ixxx++) \
(xxx)[ixxx] = yyy; \
} while (0)
/* compatibility between gmp and mpir */
#ifndef mpn_com_n
#define mpn_com_n mpn_com
#endif
#ifndef mpn_neg_n
#define mpn_neg_n mpn_neg
#endif
#ifndef mpn_tdiv_q
/* substitute for mpir's mpn_tdiv_q */
static __inline__
void mpn_tdiv_q(mp_ptr qp,
mp_srcptr np, mp_size_t nn,
mp_srcptr dp, mp_size_t dn)
{
mp_ptr _scratch = (mp_ptr) flint_malloc(dn * sizeof(mp_limb_t));
mpn_tdiv_qr(qp, _scratch, 0, np, nn, dp, dn);
flint_free(_scratch);
}
#endif
/* temporary allocation */
#define TMP_INIT \
typedef struct __tmp_struct { \
void * block; \
struct __tmp_struct * next; \
} __tmp_t; \
__tmp_t * __tmp_root; \
__tmp_t * __tpx
#define TMP_START \
__tmp_root = NULL
#define TMP_ALLOC(size) \
((size) > 8192 ? \
(__tpx = alloca(sizeof(__tmp_t)), \
__tpx->next = __tmp_root, \
__tmp_root = __tpx, \
__tpx->block = flint_malloc(size)) : \
alloca(size))
#define TMP_END \
while (__tmp_root) { \
flint_free(__tmp_root->block); \
__tmp_root = __tmp_root->next; \
}
int parse_fmt(int * floating, const char * fmt);
size_t flint_printf(const char * str, ...); /* flint version of printf */
size_t flint_fprintf(FILE * f, const char * str, ...); /* flint version of fprintf */
size_t flint_sprintf(char * s, const char * str, ...); /* flint version of sprintf */
int flint_scanf(const char * str, ...); /* flint version of scanf */
int flint_fscanf(FILE * f, const char * str, ...); /* flint version of fscanf */
int flint_sscanf(const char * s, const char * str, ...); /* flint version of sscanf */
#include "gmpcompat.h"
#ifdef __cplusplus
}
#endif
#endif
|