16 #ifndef MISC_AUXILIARY_H 17 #define MISC_AUXILIARY_H 20 #include "libpolysconfig.h" 32 #define SI_INTEGER_VARIANT 2 36 #define SI_BIGINT_VARIANT 1 46 #if ULONG_MAX == 0xffffffffUL 48 #elif ULONG_MAX == 0xffffffffffffffffULL 51 #error "Unexpected max for unsigned long" 57 #define SIZEOF_LONG (LONG_BIT/CHAR_BIT) 62 #include <sys/types.h> 64 typedef long long int64;
65 #elif SIZEOF_LONG == 8 68 #error "Unexpected SIZEOF_LONG" 77 #ifndef BIT_SIZEOF_LONG 78 #define BIT_SIZEOF_LONG ((CHAR_BIT)*(SIZEOF_LONG)) 84 #if (SIZEOF_LONG == 8) 106 #define NULLp ((void*)NULL) 112 int const mask = v >> (
sizeof(int) *
CHAR_BIT - 1);
113 return ((v + mask) ^ mask);
121 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
122 const unsigned int S[] = {1, 2, 4, 8, 16};
125 if (v & b[4]) { v >>= S[4]; r |= S[4]; }
126 if (v & b[3]) { v >>= S[3]; r |= S[3]; }
127 if (v & b[2]) { v >>= S[2]; r |= S[2]; }
128 if (v & b[1]) { v >>= S[1]; r |= S[1]; }
129 if (v & b[0]) { v >>= S[0]; r |= S[0]; }
137 #if defined(__cplusplus) 138 static inline int si_max(
const int a,
const int b) {
return (a>b) ? a :
b; }
139 static inline int si_min(
const int a,
const int b) {
return (a<b) ? a :
b; }
140 static inline long si_max(
const long a,
const long b) {
return (a>b) ? a :
b; }
141 static inline unsigned long si_max(
const unsigned long a,
const unsigned long b) {
return (a>b) ? a :
b; }
142 static inline long si_min(
const long a,
const long b) {
return (a<b) ? a :
b; }
143 static inline unsigned long si_min(
const unsigned long a,
const unsigned long b) {
return (a<b) ? a :
b; }
145 #define si_max(A,B) ((A) > (B) ? (A) : (B)) 146 #define si_min(A,B) ((A) < (B) ? (A) : (B)) 298 #define OM_SING_KEEP 1000 332 # define FORCE_INLINE inline 335 #if defined(_MSC_VER) 336 # define FORCE_INLINE __forceinline 337 #elif defined(__GNUC__) && __GNUC__ > 3 338 # define FORCE_INLINE inline __attribute__ ((always_inline)) 340 # define FORCE_INLINE inline 343 # define FORCE_INLINE inline 350 #define DO_PRAGMA(x) _Pragma (#x) 351 #define TODO(who, msg) DO_PRAGMA(message ("TODO [for " #who "]: " #msg)) 355 #if defined(__GNUC__) && defined(__GNUC_MINOR__) 356 #define _GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 358 #define _GNUC_PREREQ(maj, min) 0 361 #if _GNUC_PREREQ(3,3) && defined(__ELF__) 362 #define FORCE_INTERNAL __attribute__ ((visibility ("internal"))) 364 #define FORCE_INTERNAL 367 #if _GNUC_PREREQ(3,3) 368 #define FORCE_DEPRECATED __attribute__ ((deprecated)) 370 #define FORCE_DEPRECATED 374 # define BEGIN_CDECL extern "C" { 385 template<
typename A,
typename B>
401 return cast_A_to_B<A, void*>(a);
408 return cast_A_to_B<void*, A>(
p);
414 #define LIKELY(X) (__builtin_expect(!!(X), 1)) 415 #define UNLIKELY(X) (__builtin_expect(!!(X), 0)) 417 #define LIKELY(X) (X) 418 #define UNLIKELY(X) (X)
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)
const Variable & v
< [in] a sqrfree bivariate poly
void * cast_A_to_vptr(A a)
static int SI_LOG2(int v)