Index: lib/External/isl/isl_int_sioimath.h =================================================================== --- lib/External/isl/isl_int_sioimath.h +++ lib/External/isl/isl_int_sioimath.h @@ -20,6 +20,13 @@ #define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array)) +// MSVC C compiler can not digest the key word "inline" +#ifdef _MSC_VER +#define ISL_C_INLINE __inline +#else +#define ISL_C_INLINE inline +#endif + /* The type to represent integers optimized for small values. It is either a * pointer to an mp_int ( = mpz_t*; big representation) or an int32_t (small * represenation) with a discriminator at the least significant bit. In big @@ -91,14 +98,14 @@ /* Return whether the argument is stored in small representation. */ -inline int isl_sioimath_is_small(isl_sioimath val) +ISL_C_INLINE int isl_sioimath_is_small(isl_sioimath val) { return val & 0x00000001; } /* Return whether the argument is stored in big representation. */ -inline int isl_sioimath_is_big(isl_sioimath val) +ISL_C_INLINE int isl_sioimath_is_big(isl_sioimath val) { return !isl_sioimath_is_small(val); } @@ -106,7 +113,7 @@ /* Get the number of an isl_int in small representation. Result is undefined if * val is not stored in that format. */ -inline int32_t isl_sioimath_get_small(isl_sioimath val) +ISL_C_INLINE int32_t isl_sioimath_get_small(isl_sioimath val) { return val >> 32; } @@ -114,7 +121,7 @@ /* Get the number of an in isl_int in big representation. Result is undefined if * val is not stored in that format. */ -inline mp_int isl_sioimath_get_big(isl_sioimath val) +ISL_C_INLINE mp_int isl_sioimath_get_big(isl_sioimath val) { return (mp_int)(uintptr_t) val; } @@ -125,7 +132,7 @@ * representation. If there is no such branch, then a single shift is still * cheaper than introducing branching code. */ -inline int isl_sioimath_decode_small(isl_sioimath val, int32_t *small) +ISL_C_INLINE int isl_sioimath_decode_small(isl_sioimath val, int32_t *small) { *small = isl_sioimath_get_small(val); return isl_sioimath_is_small(val); @@ -133,7 +140,7 @@ /* Return 1 if val is stored in big representation and store its value to big. */ -inline int isl_sioimath_decode_big(isl_sioimath val, mp_int *big) +ISL_C_INLINE int isl_sioimath_decode_big(isl_sioimath val, mp_int *big) { *big = isl_sioimath_get_big(val); return isl_sioimath_is_big(val); @@ -141,14 +148,14 @@ /* Encode a small representation into an isl_int. */ -inline isl_sioimath isl_sioimath_encode_small(int32_t val) +ISL_C_INLINE isl_sioimath isl_sioimath_encode_small(int32_t val) { return ((isl_sioimath) val) << 32 | 0x00000001; } /* Encode a big representation. */ -inline isl_sioimath isl_sioimath_encode_big(mp_int val) +ISL_C_INLINE isl_sioimath isl_sioimath_encode_big(mp_int val) { return (isl_sioimath)(uintptr_t) val; } @@ -209,19 +216,19 @@ (used) = i; \ } while (0) -inline void isl_siomath_uint32_to_digits(uint32_t num, mp_digit *digits, +ISL_C_INLINE void isl_siomath_uint32_to_digits(uint32_t num, mp_digit *digits, mp_size *used) { ISL_SIOIMATH_TO_DIGITS(num, digits, *used); } -inline void isl_siomath_ulong_to_digits(unsigned long num, mp_digit *digits, +ISL_C_INLINE void isl_siomath_ulong_to_digits(unsigned long num, mp_digit *digits, mp_size *used) { ISL_SIOIMATH_TO_DIGITS(num, digits, *used); } -inline void isl_siomath_uint64_to_digits(uint64_t num, mp_digit *digits, +ISL_C_INLINE void isl_siomath_uint64_to_digits(uint64_t num, mp_digit *digits, mp_size *used) { ISL_SIOIMATH_TO_DIGITS(num, digits, *used); @@ -236,7 +243,7 @@ * The name derives from its indented use: getting the big representation of an * input (src) argument. */ -inline mp_int isl_sioimath_bigarg_src(isl_sioimath arg, +ISL_C_INLINE mp_int isl_sioimath_bigarg_src(isl_sioimath arg, isl_sioimath_scratchspace_t *scratch) { mp_int big; @@ -263,7 +270,7 @@ /* Create a temporary IMath mp_int for a signed long. */ -inline mp_int isl_sioimath_siarg_src(signed long arg, +ISL_C_INLINE mp_int isl_sioimath_siarg_src(signed long arg, isl_sioimath_scratchspace_t *scratch) { unsigned long num; @@ -284,7 +291,7 @@ /* Create a temporary IMath mp_int for an int64_t. */ -inline mp_int isl_sioimath_si64arg_src(int64_t arg, +ISL_C_INLINE mp_int isl_sioimath_si64arg_src(int64_t arg, isl_sioimath_scratchspace_t *scratch) { uint64_t num; @@ -305,7 +312,7 @@ /* Create a temporary IMath mp_int for an unsigned long. */ -inline mp_int isl_sioimath_uiarg_src(unsigned long arg, +ISL_C_INLINE mp_int isl_sioimath_uiarg_src(unsigned long arg, isl_sioimath_scratchspace_t *scratch) { scratch->big.digits = scratch->digits; @@ -320,7 +327,7 @@ * Callers may use the fact that the value _is_ preserved if the presentation * was big before. */ -inline mp_int isl_sioimath_reinit_big(isl_sioimath_ptr ptr) +ISL_C_INLINE mp_int isl_sioimath_reinit_big(isl_sioimath_ptr ptr) { if (isl_sioimath_is_small(*ptr)) *ptr = isl_sioimath_encode_big(mp_int_alloc()); @@ -329,7 +336,7 @@ /* Set ptr to a number in small representation. */ -inline void isl_sioimath_set_small(isl_sioimath_ptr ptr, int32_t val) +ISL_C_INLINE void isl_sioimath_set_small(isl_sioimath_ptr ptr, int32_t val) { if (isl_sioimath_is_big(*ptr)) mp_int_free(isl_sioimath_get_big(*ptr)); @@ -338,7 +345,7 @@ /* Set ptr to val, choosing small representation if possible. */ -inline void isl_sioimath_set_int32(isl_sioimath_ptr ptr, int32_t val) +ISL_C_INLINE void isl_sioimath_set_int32(isl_sioimath_ptr ptr, int32_t val) { if (ISL_SIOIMATH_SMALL_MIN <= val && val <= ISL_SIOIMATH_SMALL_MAX) { isl_sioimath_set_small(ptr, val); @@ -350,7 +357,7 @@ /* Assign an int64_t number using small representation if possible. */ -inline void isl_sioimath_set_int64(isl_sioimath_ptr ptr, int64_t val) +ISL_C_INLINE void isl_sioimath_set_int64(isl_sioimath_ptr ptr, int64_t val) { if (ISL_SIOIMATH_SMALL_MIN <= val && val <= ISL_SIOIMATH_SMALL_MAX) { isl_sioimath_set_small(ptr, val); @@ -364,7 +371,7 @@ /* Convert to big representation while preserving the current number. */ -inline void isl_sioimath_promote(isl_sioimath_ptr dst) +ISL_C_INLINE void isl_sioimath_promote(isl_sioimath_ptr dst) { int32_t small; @@ -378,7 +385,7 @@ /* Convert to small representation while preserving the current number. Does * nothing if dst doesn't fit small representation. */ -inline void isl_sioimath_try_demote(isl_sioimath_ptr dst) +ISL_C_INLINE void isl_sioimath_try_demote(isl_sioimath_ptr dst) { mp_small small; @@ -394,14 +401,14 @@ /* Initialize an isl_int. The implicit value is 0 in small representation. */ -inline void isl_sioimath_init(isl_sioimath_ptr dst) +ISL_C_INLINE void isl_sioimath_init(isl_sioimath_ptr dst) { *dst = isl_sioimath_encode_small(0); } /* Free the resources taken by an isl_int. */ -inline void isl_sioimath_clear(isl_sioimath_ptr dst) +ISL_C_INLINE void isl_sioimath_clear(isl_sioimath_ptr dst) { if (isl_sioimath_is_small(*dst)) return; @@ -411,7 +418,7 @@ /* Copy the value of one isl_int to another. */ -inline void isl_sioimath_set(isl_sioimath_ptr dst, isl_sioimath_src val) +ISL_C_INLINE void isl_sioimath_set(isl_sioimath_ptr dst, isl_sioimath_src val) { if (isl_sioimath_is_small(val)) { isl_sioimath_set_small(dst, isl_sioimath_get_small(val)); @@ -423,7 +430,7 @@ /* Store a signed long into an isl_int. */ -inline void isl_sioimath_set_si(isl_sioimath_ptr dst, long val) +ISL_C_INLINE void isl_sioimath_set_si(isl_sioimath_ptr dst, long val) { if (ISL_SIOIMATH_SMALL_MIN <= val && val <= ISL_SIOIMATH_SMALL_MAX) { isl_sioimath_set_small(dst, val); @@ -435,7 +442,7 @@ /* Store an unsigned long into an isl_int. */ -inline void isl_sioimath_set_ui(isl_sioimath_ptr dst, unsigned long val) +ISL_C_INLINE void isl_sioimath_set_ui(isl_sioimath_ptr dst, unsigned long val) { if (val <= ISL_SIOIMATH_SMALL_MAX) { isl_sioimath_set_small(dst, val); @@ -447,7 +454,7 @@ /* Return whether a number can be represented by a signed long. */ -inline int isl_sioimath_fits_slong(isl_sioimath_src val) +ISL_C_INLINE int isl_sioimath_fits_slong(isl_sioimath_src val) { mp_small dummy; @@ -460,7 +467,7 @@ /* Return a number as signed long. Result is undefined if the number cannot be * represented as long. */ -inline long isl_sioimath_get_si(isl_sioimath_src val) +ISL_C_INLINE long isl_sioimath_get_si(isl_sioimath_src val) { mp_small result; @@ -473,7 +480,7 @@ /* Return whether a number can be represented as unsigned long. */ -inline int isl_sioimath_fits_ulong(isl_sioimath_src val) +ISL_C_INLINE int isl_sioimath_fits_ulong(isl_sioimath_src val) { mp_usmall dummy; @@ -486,7 +493,7 @@ /* Return a number as unsigned long. Result is undefined if the number cannot be * represented as unsigned long. */ -inline unsigned long isl_sioimath_get_ui(isl_sioimath_src val) +ISL_C_INLINE unsigned long isl_sioimath_get_ui(isl_sioimath_src val) { mp_usmall result; @@ -499,7 +506,7 @@ /* Return a number as floating point value. */ -inline double isl_sioimath_get_d(isl_sioimath_src val) +ISL_C_INLINE double isl_sioimath_get_d(isl_sioimath_src val) { mp_int big; double result = 0; @@ -524,7 +531,7 @@ * The largest possible string from small representation is 12 characters *("-2147483647"). */ -inline char *isl_sioimath_get_str(isl_sioimath_src val) +ISL_C_INLINE char *isl_sioimath_get_str(isl_sioimath_src val) { char *result; @@ -539,7 +546,7 @@ /* Return the absolute value. */ -inline void isl_sioimath_abs(isl_sioimath_ptr dst, isl_sioimath_src arg) +ISL_C_INLINE void isl_sioimath_abs(isl_sioimath_ptr dst, isl_sioimath_src arg) { if (isl_sioimath_is_small(arg)) { isl_sioimath_set_small(dst, labs(isl_sioimath_get_small(arg))); @@ -551,7 +558,7 @@ /* Return the negation of a number. */ -inline void isl_sioimath_neg(isl_sioimath_ptr dst, isl_sioimath_src arg) +ISL_C_INLINE void isl_sioimath_neg(isl_sioimath_ptr dst, isl_sioimath_src arg) { if (isl_sioimath_is_small(arg)) { isl_sioimath_set_small(dst, -isl_sioimath_get_small(arg)); @@ -566,7 +573,7 @@ * isl_sioimath can be copied bytewise; nothing depends on its address. It can * also be stored in a CPU register. */ -inline void isl_sioimath_swap(isl_sioimath_ptr lhs, isl_sioimath_ptr rhs) +ISL_C_INLINE void isl_sioimath_swap(isl_sioimath_ptr lhs, isl_sioimath_ptr rhs) { isl_sioimath tmp = *lhs; *lhs = *rhs; @@ -578,7 +585,7 @@ * On LP64 unsigned long exceeds the range of an int64_t, therefore we check in * advance whether small representation possibly overflows. */ -inline void isl_sioimath_add_ui(isl_sioimath_ptr dst, isl_sioimath lhs, +ISL_C_INLINE void isl_sioimath_add_ui(isl_sioimath_ptr dst, isl_sioimath lhs, unsigned long rhs) { int32_t smalllhs; @@ -601,7 +608,7 @@ * ISL_SIOIMATH_SMALL_MIN-rhs>=INT64_MIN we can do the calculation using int64_t * without risking an overflow. */ -inline void isl_sioimath_sub_ui(isl_sioimath_ptr dst, isl_sioimath lhs, +ISL_C_INLINE void isl_sioimath_sub_ui(isl_sioimath_ptr dst, isl_sioimath lhs, unsigned long rhs) { int32_t smalllhs; @@ -620,7 +627,7 @@ /* Sum of two isl_ints. */ -inline void isl_sioimath_add(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_add(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -641,7 +648,7 @@ /* Subtract two isl_ints. */ -inline void isl_sioimath_sub(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_sub(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -662,7 +669,7 @@ /* Multiply two isl_ints. */ -inline void isl_sioimath_mul(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_mul(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -684,7 +691,7 @@ /* Shift lhs by rhs bits to the left and store the result in dst. Effectively, * this operation computes 'lhs * 2^rhs'. */ -inline void isl_sioimath_mul_2exp(isl_sioimath_ptr dst, isl_sioimath lhs, +ISL_C_INLINE void isl_sioimath_mul_2exp(isl_sioimath_ptr dst, isl_sioimath lhs, unsigned long rhs) { isl_sioimath_scratchspace_t scratchlhs; @@ -701,7 +708,7 @@ /* Multiply an isl_int and a signed long. */ -inline void isl_sioimath_mul_si(isl_sioimath_ptr dst, isl_sioimath lhs, +ISL_C_INLINE void isl_sioimath_mul_si(isl_sioimath_ptr dst, isl_sioimath lhs, signed long rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -721,7 +728,7 @@ /* Multiply an isl_int and an unsigned long */ -inline void isl_sioimath_mul_ui(isl_sioimath_ptr dst, isl_sioimath lhs, +ISL_C_INLINE void isl_sioimath_mul_ui(isl_sioimath_ptr dst, isl_sioimath lhs, unsigned long rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -744,7 +751,7 @@ * cases. * Note: 0^0 == 1 */ -inline void isl_sioimath_pow_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_pow_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, unsigned long rhs) { isl_sioimath_scratchspace_t scratchlhs, scratchrhs; @@ -792,7 +799,7 @@ /* Fused multiply-add. */ -inline void isl_sioimath_addmul(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_addmul(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath tmp; @@ -804,7 +811,7 @@ /* Fused multiply-add with an unsigned long. */ -inline void isl_sioimath_addmul_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_addmul_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, unsigned long rhs) { isl_sioimath tmp; @@ -816,7 +823,7 @@ /* Fused multiply-subtract. */ -inline void isl_sioimath_submul(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_submul(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath tmp; @@ -828,7 +835,7 @@ /* Fused multiply-add with an unsigned long. */ -inline void isl_sioimath_submul_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_submul_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, unsigned long rhs) { isl_sioimath tmp; @@ -845,7 +852,7 @@ /* Divide lhs by rhs, rounding to zero (Truncate). */ -inline void isl_sioimath_tdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_tdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -866,7 +873,7 @@ /* Divide lhs by an unsigned long rhs, rounding to zero (Truncate). */ -inline void isl_sioimath_tdiv_q_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_tdiv_q_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, unsigned long rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -893,7 +900,7 @@ /* Divide lhs by rhs, rounding to positive infinity (Ceil). */ -inline void isl_sioimath_cdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_cdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { int32_t lhssmall, rhssmall; @@ -922,7 +929,7 @@ /* Divide lhs by rhs, rounding to negative infinity (Floor). */ -inline void isl_sioimath_fdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_fdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -952,7 +959,7 @@ /* Compute the division of lhs by a rhs of type unsigned long, rounding towards * negative infinity (Floor). */ -inline void isl_sioimath_fdiv_q_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_fdiv_q_ui(isl_sioimath_ptr dst, isl_sioimath_src lhs, unsigned long rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -977,7 +984,7 @@ /* Get the remainder of: lhs divided by rhs rounded towards negative infinite * (Floor). */ -inline void isl_sioimath_fdiv_r(isl_sioimath_ptr dst, isl_sioimath_src lhs, +ISL_C_INLINE void isl_sioimath_fdiv_r(isl_sioimath_ptr dst, isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -1005,7 +1012,7 @@ * -1 for a negative number * 0 if the number is zero */ -inline int isl_sioimath_sgn(isl_sioimath_src arg) +ISL_C_INLINE int isl_sioimath_sgn(isl_sioimath_src arg) { int32_t small; @@ -1020,7 +1027,7 @@ * -1 if lhs < rhs * 0 if lhs = rhs */ -inline int isl_sioimath_cmp(isl_sioimath_src lhs, isl_sioimath_src rhs) +ISL_C_INLINE int isl_sioimath_cmp(isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; int32_t lhssmall, rhssmall; @@ -1043,7 +1050,7 @@ /* As isl_sioimath_cmp, but with signed long rhs. */ -inline int isl_sioimath_cmp_si(isl_sioimath_src lhs, signed long rhs) +ISL_C_INLINE int isl_sioimath_cmp_si(isl_sioimath_src lhs, signed long rhs) { int32_t lhssmall; @@ -1058,7 +1065,7 @@ * -1 if |lhs| < |rhs| * 0 if |lhs| = |rhs| */ -inline int isl_sioimath_abs_cmp(isl_sioimath_src lhs, isl_sioimath_src rhs) +ISL_C_INLINE int isl_sioimath_abs_cmp(isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; int32_t lhssmall, rhssmall; @@ -1077,7 +1084,7 @@ /* Return whether lhs is divisible by rhs. */ -inline int isl_sioimath_is_divisible_by(isl_sioimath_src lhs, +ISL_C_INLINE int isl_sioimath_is_divisible_by(isl_sioimath_src lhs, isl_sioimath_src rhs) { isl_sioimath_scratchspace_t lhsscratch, rhsscratch; @@ -1105,7 +1112,7 @@ * The hash code for a number in small and big representation must be identical * on the same machine because small representation if not obligatory if fits. */ -inline uint32_t isl_sioimath_hash(isl_sioimath_src arg, uint32_t hash) +ISL_C_INLINE uint32_t isl_sioimath_hash(isl_sioimath_src arg, uint32_t hash) { int32_t small; int i; @@ -1136,7 +1143,7 @@ * of binary digits in that representation, which can be much larger than the * smallest possible solution. */ -inline size_t isl_sioimath_sizeinbase(isl_sioimath_src arg, int base) +ISL_C_INLINE size_t isl_sioimath_sizeinbase(isl_sioimath_src arg, int base) { int32_t small;