16 #ifndef MISC_AUXILIARY_H
17 #define MISC_AUXILIARY_H
20 #include "libpolysconfig.h"
34 #define SI_INTEGER_VARIANT 2
38 #define SI_BIGINT_VARIANT 1
48 #if ULONG_MAX == 0xffffffffUL
50 #elif ULONG_MAX == 0xffffffffffffffffULL
53 #error "Unexpected max for unsigned long"
59 #define SIZEOF_LONG (LONG_BIT/CHAR_BIT)
64 #include <sys/types.h>
66 typedef long long int64;
67 #elif SIZEOF_LONG == 8
70 #error "Unexpected SIZEOF_LONG"
79 #ifndef BIT_SIZEOF_LONG
80 #define BIT_SIZEOF_LONG ((CHAR_BIT)*(SIZEOF_LONG))
86 #if (SIZEOF_LONG == 8)
108 #define NULLp ((void*)NULL)
114 int const mask =
v >> (
sizeof(int) *
CHAR_BIT - 1);
115 return ((
v + mask) ^ mask);
123 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
124 const unsigned int S[] = {1, 2, 4, 8, 16};
127 if (
v &
b[4]) {
v >>= S[4]; r |= S[4]; }
128 if (
v &
b[3]) {
v >>= S[3]; r |= S[3]; }
129 if (
v &
b[2]) {
v >>= S[2]; r |= S[2]; }
130 if (
v &
b[1]) {
v >>= S[1]; r |= S[1]; }
131 if (
v &
b[0]) {
v >>= S[0]; r |= S[0]; }
139 #if defined(__cplusplus)
140 static inline int si_max(
const int a,
const int b) {
return (a>
b) ? a :
b; }
141 static inline int si_min(
const int a,
const int b) {
return (a<
b) ? a :
b; }
142 static inline long si_max(
const long a,
const long b) {
return (a>
b) ? a :
b; }
143 static inline unsigned long si_max(
const unsigned long a,
const unsigned long b) {
return (a>
b) ? a :
b; }
144 static inline long si_min(
const long a,
const long b) {
return (a<
b) ? a :
b; }
145 static inline unsigned long si_min(
const unsigned long a,
const unsigned long b) {
return (a<
b) ? a :
b; }
147 #define si_max(A,B) ((A) > (B) ? (A) : (B))
148 #define si_min(A,B) ((A) < (B) ? (A) : (B))
300 #define OM_SING_KEEP 1000
334 # define FORCE_INLINE inline
337 #if defined(_MSC_VER)
338 # define FORCE_INLINE __forceinline
339 #elif defined(__GNUC__) && __GNUC__ > 3
340 # define FORCE_INLINE inline __attribute__ ((always_inline))
342 # define FORCE_INLINE inline
345 # define FORCE_INLINE inline
352 #define DO_PRAGMA(x) _Pragma (#x)
353 #define TODO(who, msg) DO_PRAGMA(message ("TODO [for " #who "]: " #msg))
357 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
358 #define _GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
360 #define _GNUC_PREREQ(maj, min) 0
363 #if _GNUC_PREREQ(3,3) && defined(__ELF__)
364 #define FORCE_INTERNAL __attribute__ ((visibility ("internal")))
366 #define FORCE_INTERNAL
369 #if _GNUC_PREREQ(3,3)
370 #define FORCE_DEPRECATED __attribute__ ((deprecated))
372 #define FORCE_DEPRECATED
376 # define BEGIN_CDECL extern "C" {
387 template<
typename A,
typename B>
403 return cast_A_to_B<A, void*>(a);
410 return cast_A_to_B<void*, A>(
p);
416 #define LIKELY(X) (__builtin_expect(!!(X), 1))
417 #define UNLIKELY(X) (__builtin_expect(!!(X), 0))
419 #define LIKELY(X) (X)
420 #define UNLIKELY(X) (X)
void * cast_A_to_vptr(A a)
static int si_max(const int a, const int b)
static int SI_LOG2(int v)
A cast_vptr_to_A(void *p)
static int si_min(const int a, const int b)
const Variable & v
< [in] a sqrfree bivariate poly