16 #ifndef MISC_AUXILIARY_H
17 #define MISC_AUXILIARY_H
20 #include "libpolysconfig.h"
48 #ifndef HAVE_POLYEXTENSIONS
49 #undef HAVE_POLYEXTENSIONS
52 #ifndef DISABLE_GMP_CPP
53 #undef DISABLE_GMP_CPP
75 #define SI_INTEGER_VARIANT 2
79 #define SI_BIGINT_VARIANT 1
92 #if ULONG_MAX == 0xffffffffUL
94 #elif ULONG_MAX == 0xffffffffffffffffULL
97 #error "Unexpected max for unsigned long"
103 #define SIZEOF_LONG (LONG_BIT/CHAR_BIT)
108 #include <sys/types.h>
110 typedef long long int64;
111 #elif SIZEOF_LONG == 8
114 #error "Unexpected SIZEOF_LONG"
123 #ifndef BIT_SIZEOF_LONG
124 #define BIT_SIZEOF_LONG ((CHAR_BIT)*(SIZEOF_LONG))
130 #if (SIZEOF_LONG == 8)
152 #define NULLp ((void*)NULL)
157 #define ABS(x) ((x)<0?(-(x)):(x))
165 #if defined(__cplusplus)
166 static inline int si_max(
const int a,
const int b) {
return (a>b) ? a :
b; }
167 static inline int si_min(
const int a,
const int b) {
return (a<b) ? a :
b; }
168 static inline long si_max(
const long a,
const long b) {
return (a>b) ? a :
b; }
169 static inline unsigned long si_max(
const unsigned long a,
const unsigned long b) {
return (a>b) ? a :
b; }
170 static inline long si_min(
const long a,
const long b) {
return (a<b) ? a :
b; }
171 static inline unsigned long si_min(
const unsigned long a,
const unsigned long b) {
return (a<b) ? a :
b; }
173 #define si_max(A,B) ((A) > (B) ? (A) : (B))
174 #define si_min(A,B) ((A) < (B) ? (A) : (B))
181 #ifndef HAVE_MULT_MOD
189 #ifndef HAVE_GENERIC_ADD
190 #undef HAVE_GENERIC_ADD
341 #define OM_SING_KEEP 1000
375 # define FORCE_INLINE inline
378 #if defined(_MSC_VER)
379 # define FORCE_INLINE __forceinline
380 #elif defined(__GNUC__) && __GNUC__ > 3
381 # define FORCE_INLINE inline __attribute__ ((always_inline))
383 # define FORCE_INLINE inline
386 # define FORCE_INLINE inline
393 #define DO_PRAGMA(x) _Pragma (#x)
394 #define TODO(who, msg) DO_PRAGMA(message ("TODO [for " #who "]: " #msg))
398 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
399 #define _GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
401 #define _GNUC_PREREQ(maj, min) 0
404 #if _GNUC_PREREQ(3,3) && defined(__ELF__)
405 #define FORCE_INTERNAL __attribute__ ((visibility ("internal")))
407 #define FORCE_INTERNAL
410 #if _GNUC_PREREQ(3,3)
411 #define FORCE_DEPRECATED __attribute__ ((deprecated))
413 #define FORCE_DEPRECATED
417 # define BEGIN_CDECL extern "C" {
428 template<
typename A,
typename B>
444 return cast_A_to_B<A, void*>(
a);
451 return cast_A_to_B<void*, A>(
p);
static int si_min(const int a, const int b)
A cast_vptr_to_A(void *p)
static int si_max(const int a, const int b)
void * cast_A_to_vptr(A a)