/*
* Copyright 2008-2009 Katholieke Universiteit Leuven
*
- * Use of this software is governed by the GNU LGPLv2.1 license
+ * Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege, K.U.Leuven, Departement
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
#define isl_int_get_ui(r) mpz_get_ui(r)
#define isl_int_get_d(r) mpz_get_d(r)
#define isl_int_get_str(r) mpz_get_str(0, 10, r)
+typedef void (*isl_int_print_gmp_free_t)(void *, size_t);
+#define isl_int_free_str(s) \
+ do { \
+ isl_int_print_gmp_free_t gmp_free; \
+ mp_get_memory_functions(NULL, NULL, &gmp_free); \
+ (*gmp_free)(s, strlen(s) + 1); \
+ } while (0)
#define isl_int_abs(r,i) mpz_abs(r,i)
#define isl_int_neg(r,i) mpz_neg(r,i)
#define isl_int_swap(i,j) mpz_swap(i,j)
#define isl_int_add(r,i,j) mpz_add(r,i,j)
#define isl_int_sub(r,i,j) mpz_sub(r,i,j)
#define isl_int_mul(r,i,j) mpz_mul(r,i,j)
+#define isl_int_mul_2exp(r,i,j) mpz_mul_2exp(r,i,j)
#define isl_int_mul_ui(r,i,j) mpz_mul_ui(r,i,j)
#define isl_int_pow_ui(r,i,j) mpz_pow_ui(r,i,j)
#define isl_int_addmul(r,i,j) mpz_addmul(r,i,j)
#define isl_int_fdiv_q_ui(r,i,j) mpz_fdiv_q_ui(r,i,j)
#define isl_int_read(r,s) mpz_set_str(r,s,10)
-typedef void (*isl_int_print_gmp_free_t)(void *, size_t);
#define isl_int_print(out,i,width) \
do { \
char *s; \
- isl_int_print_gmp_free_t gmp_free; \
s = mpz_get_str(0, 10, i); \
fprintf(out, "%*s", width, s); \
- mp_get_memory_functions(NULL, NULL, &gmp_free); \
- (*gmp_free)(s, strlen(s)+1); \
+ isl_int_free_str(s); \
} while (0)
#define isl_int_sgn(i) mpz_sgn(i)
static inline std::ostream &operator<<(std::ostream &os, isl_int i)
{
char *s;
- isl_gmp_free_t gmp_free;
s = mpz_get_str(0, 10, i);
os << s;
- mp_get_memory_functions(NULL, NULL, &gmp_free);
- (*gmp_free)(s, strlen(s)+1);
+ isl_int_free_str(s);
return os;
}
#endif