/usr/include/NTL/ctools.h is in libntl-dev 5.4.2-4.1build1.
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 | #ifndef NTL_ctools__H
#define NTL_ctools__H
#include <NTL/config.h>
#include <NTL/mach_desc.h>
/*
* Resolve double-word integer types.
*
* Unfortunately, there is no "standard" way to do this.
* On 32-bit machines, 'long long' usually works (but not
* on MSVC++ or BORLAND), and on 64-bit machines, there is
* no standard. However, most compilers do offer *some*
* non-standard double-word type.
*
* Note that C99 creates a standard header <stdint.h>,
* but it is not clear how widely this is implemented yet,
* and for example, GCC does not provide a type int128_t
* in <stdint.h> on 64-bit machines.
*/
#if (defined(NTL_LONG_LONG_TYPE))
#define NTL_LL_TYPE NTL_LONG_LONG_TYPE
#elif (NTL_BITS_PER_LONG == 64 && defined(__GNUC__))
#define NTL_LL_TYPE __int128_t
#elif (NTL_BITS_PER_LONG == 32 && (defined(_MSC_VER) || defined(__BORLANDC__)))
#define NTL_LL_TYPE __int64
#elif (NTL_BITS_PER_LONG == 64 && (defined(_MSC_VER) || defined(__BORLANDC__)))
#define NTL_LL_TYPE __int128
#endif
#if (!defined(NTL_LL_TYPE))
#define NTL_LL_TYPE long long
#endif
#if (defined(NTL_UNSIGNED_LONG_LONG_TYPE))
#define NTL_ULL_TYPE NTL_UNSIGNED_LONG_LONG_TYPE
#elif (NTL_BITS_PER_LONG == 64 && defined(__GNUC__))
#define NTL_ULL_TYPE __uint128_t
#elif (NTL_BITS_PER_LONG == 32 && (defined(_MSC_VER) || defined(__BORLANDC__)))
#define NTL_ULL_TYPE unsigned __int64
#elif (NTL_BITS_PER_LONG == 64 && (defined(_MSC_VER) || defined(__BORLANDC__)))
#define NTL_ULL_TYPE unsigned __int128
#endif
#if (!defined(NTL_ULL_TYPE))
#define NTL_ULL_TYPE unsigned long long
#endif
/********************************************************/
#define NTL_OVFBND (1L << (NTL_BITS_PER_LONG-4))
/*
* NTL_OVFBND is the general bound used throughout NTL to keep various
* integer values comfortably bounded away from an integer overflow
* condition. Do not change this value!
*/
#if ((NTL_BITS_PER_SIZE_T-1) < (NTL_BITS_PER_LONG-4))
#define NTL_OVFBND1 (1L << (NTL_BITS_PER_SIZE_T-1))
#else
#define NTL_OVFBND1 NTL_OVFBND
#endif
/*
* NTL_OVFBND1 is a smaller bound than NTL_OVF when size_t is
* narrower than long. This prevents overflow on calls to malloc
* and realloc.
*/
#define NTL_OVERFLOW(n, a, b) \
(((b) >= NTL_OVFBND) || (((long) (n)) > 0 && (((a) >= NTL_OVFBND) || \
(((long) (n)) >= (NTL_OVFBND-((long)(b))+((long)(a))-1)/((long)(a))))))
/*
* NTL_OVERFLOW(n, a, b) returns 1 if n*a + b >= NTL_OVFBND,
* and returns 0 otherwise. The value n is effectively treated as type long,
* while the values a and b may be *any* integral type. It is assumed that
* n >= 0, a > 0, and b >= 0. Care is taken to ensure that overflow does
* not occur. If a and b are constants, and n has no side effects,
* a good optimizing compiler will * translate this into a single test
* of the form n >= c, where c is a constant.
*/
#define NTL_OVERFLOW1(n, a, b) \
(((b) >= NTL_OVFBND1) || (((long) (n)) > 0 && (((a) >= NTL_OVFBND1) || \
(((long) (n)) >= (NTL_OVFBND1-((long)(b))+((long)(a))-1)/((long)(a))))))
/*
* NTL_OVERFLOW1 is the same as NTL_OVERFLOW, except that it uses the
* bound NTL_OVFBND1 instead of NTL_OVFBND.
*/
#define NTL_MALLOC(n, a, b) \
(NTL_OVERFLOW1(n, a, b) ? ((void *) 0) : \
((void *) malloc(((long)(n))*((long)(a)) + ((long)(b)))))
/*
* NTL_MALLOC(n, a, b) returns 0 if a*n + b >= NTL_OVFBND1, and otherwise
* returns malloc(n*a + b).
* The programmer must ensure that the name "malloc" is visible
* at the point in the source code where this macro is expanded.
*/
#define NTL_SNS_MALLOC(n, a, b) \
(NTL_OVERFLOW1(n, a, b) ? ((void *) 0) : \
((void *) NTL_SNS malloc(((long)(n))*((long)(a)) + ((long)(b)))))
/*
* NTL_SNS_MALLOC is the same as NTL_MALLOC, except that the call
* to malloc is prefixed by NTL_SNS.
*/
#define NTL_REALLOC(p, n, a, b) \
(NTL_OVERFLOW1(n, a, b) ? ((void *) 0) : \
((void *) realloc((p), ((long)(n))*((long)(a)) + ((long)(b)))))
/*
* NTL_REALLOC(n, a, b) returns 0 if a*n + b >= NTL_OVFBND1, and otherwise
* returns realloc(p, n*a + b).
* The programmer must ensure that the name "realloc" is visible
* at the point in the source code where this macro is expanded.
*/
#define NTL_SNS_REALLOC(p, n, a, b) \
(NTL_OVERFLOW1(n, a, b) ? ((void *) 0) : \
((void *) NTL_SNS realloc((p), ((long)(n))*((long)(a)) + ((long)(b)))))
/*
* NTL_SNS_REALLOC is the same as NTL_REALLOC, except that the call
* to realloc is prefixed by NTL_SNS.
*/
#define NTL_MAX_ALLOC_BLOCK (40000)
/*
* NTL_MAX_ALLOC_BLOCK is the number of bytes that are allocated in
* a single block in a number of places throughout NTL (for
* vec_ZZ_p, ZZVec, vec_GF2X, and GF2XVec).
*/
#define NTL_ULONG_TO_LONG(a) \
((((unsigned long) a) >> (NTL_BITS_PER_LONG-1)) ? \
(((long) (((unsigned long) a) - ((unsigned long) NTL_MIN_LONG))) + \
NTL_MIN_LONG) : \
((long) a))
/*
* This macro converts from unsigned long to signed long. It is portable
* among platforms for which a long has a 2's complement representation
* of the same width as an unsigned long. While it avoids assumptions
* about the behavior of non-standard conversions, a good optimizing
* compiler should turn it into the identity function.
*/
#define NTL_UINT_TO_INT(a) \
((((unsigned int) a) >> (NTL_BITS_PER_INT-1)) ? \
(((int) (((unsigned int) a) - ((unsigned int) NTL_MIN_INT))) + \
NTL_MIN_INT) : \
((int) a))
/*
* This macro converts from unsigned int to signed int. It is portable
* among platforms for which an int has a 2's complement representation
* of the same width as an unsigned int. While it avoids assumptions
* about the behavior of non-standard conversions, a good optimizing
* compiler should turn it into the identity function.
*/
#if (defined(__cplusplus) && !defined(NTL_CXX_ONLY))
extern "C" {
#endif
long _ntl_IsFinite(double *p);
/* This forces a double into memory, and tests if it is "normal";
that means, not NaN, not +/- infinity, not denormalized, etc.
Forcing into memory is sometimes necessary on machines
with "extended" double precision registers (e.g., Intel x86s)
to force the standard IEEE format. */
void _ntl_ForceToMem(double *p);
/* This is do-nothing routine that has the effect of forcing
a double into memory (see comment above). */
double _ntl_ldexp(double x, long e);
#if (defined(__cplusplus) && !defined(NTL_CXX_ONLY))
}
#endif
#endif
|