From ca64896d49b70fc0ffec711a079167c972fe635e Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 16:47:21 +0200 Subject: 1.4 --- library/GMP/include/gmp.h | 9 +++- library/GMP/include/gmpxx.h | 98 +++++++++++++++++++++++++++++++++----------- library/GMP/lib/libgmp.a | Bin 392834 -> 393164 bytes library/GMP/lib/libgmp.la | 2 +- library/GMP/lib/libgmpxx.a | Bin 24784 -> 24784 bytes library/GMP/lib/libgmpxx.la | 2 +- 6 files changed, 84 insertions(+), 27 deletions(-) (limited to 'library/GMP') diff --git a/library/GMP/include/gmp.h b/library/GMP/include/gmp.h index 1268c74d..fa86f2dc 100644 --- a/library/GMP/include/gmp.h +++ b/library/GMP/include/gmp.h @@ -421,7 +421,7 @@ typedef __mpq_struct *mpq_ptr; GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 inline semantics, unless -fgnu89-inline is used. */ #ifdef __GNUC__ -#ifdef __GNUC_STDC_INLINE__ +#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__)) #else #define __GMP_EXTERN_INLINE extern __inline__ @@ -518,6 +518,7 @@ typedef __mpq_struct *mpq_ptr; #if defined (__cplusplus) extern "C" { +#include #ifdef _GMP_H_HAVE_FILE using std::FILE; #endif @@ -2173,10 +2174,14 @@ enum GMP_ERROR_INVALID_ARGUMENT = 8 }; +/* Define CC and CFLAGS which were used to build this version of GMP */ +#define __GMP_CC "gcc" +#define __GMP_CFLAGS "-m32 -O2 -fomit-frame-pointer -mtune=k8 -march=k8 -mno-cygwin" + /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ #define __GNU_MP_VERSION 4 #define __GNU_MP_VERSION_MINOR 2 -#define __GNU_MP_VERSION_PATCHLEVEL 2 +#define __GNU_MP_VERSION_PATCHLEVEL 3 #define __GMP_H__ #endif /* __GMP_H__ */ diff --git a/library/GMP/include/gmpxx.h b/library/GMP/include/gmpxx.h index 76a72678..6472707a 100644 --- a/library/GMP/include/gmpxx.h +++ b/library/GMP/include/gmpxx.h @@ -1,6 +1,6 @@ /* gmpxx.h -- C++ class wrapper for GMP types. -*- C++ -*- -Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2006, 2008 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -37,6 +37,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include /* for strlen */ #include #include +#include #include @@ -655,22 +656,83 @@ struct __gmp_binary_modulus } }; +// Max allocations for plain types when converted to mpz_t +// FIXME: how do we get the proper max "double" exponent? +#define __GMP_DBL_LIMBS (2 + DBL_MAX_EXP / GMP_NUMB_BITS) +#define __GMP_ULI_LIMBS (1 + (8 * sizeof (long) - 1) / GMP_NUMB_BITS) + +#define __GMPXX_TMP_UI \ + mpz_t temp; \ + mp_limb_t limbs[__GMP_ULI_LIMBS]; \ + temp->_mp_d = limbs; \ + temp->_mp_alloc = __GMP_ULI_LIMBS; \ + mpz_set_ui (temp, l) +#define __GMPXX_TMP_SI \ + mpz_t temp; \ + mp_limb_t limbs[__GMP_ULI_LIMBS]; \ + temp->_mp_d = limbs; \ + temp->_mp_alloc = __GMP_ULI_LIMBS; \ + mpz_set_si (temp, l) +#define __GMPXX_TMP_D \ + mpz_t temp; \ + mp_limb_t limbs[__GMP_DBL_LIMBS]; \ + temp->_mp_d = limbs; \ + temp->_mp_alloc = __GMP_DBL_LIMBS; \ + mpz_set_d (temp, d) + struct __gmp_binary_and { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_and(z, w, v); } + + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMP_UI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { __GMPXX_TMP_UI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMP_SI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { __GMPXX_TMP_SI; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMP_D; mpz_and (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMP_D; mpz_and (z, w, temp); } }; struct __gmp_binary_ior { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_ior(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMP_UI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { __GMPXX_TMP_UI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMP_SI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { __GMPXX_TMP_SI; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMP_D; mpz_ior (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMP_D; mpz_ior (z, w, temp); } }; struct __gmp_binary_xor { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_xor(z, w, v); } + static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) + { __GMPXX_TMP_UI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) + { __GMPXX_TMP_UI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) + { __GMPXX_TMP_SI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) + { __GMPXX_TMP_SI; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, mpz_srcptr w, double d) + { __GMPXX_TMP_D; mpz_xor (z, w, temp); } + static void eval(mpz_ptr z, double d, mpz_srcptr w) + { __GMPXX_TMP_D; mpz_xor (z, w, temp); } }; struct __gmp_binary_lshift @@ -686,7 +748,7 @@ struct __gmp_binary_lshift struct __gmp_binary_rshift { static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) - { mpz_tdiv_q_2exp(z, w, l); } + { mpz_fdiv_q_2exp(z, w, l); } static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) { mpq_div_2exp(q, r, l); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) @@ -1291,13 +1353,17 @@ struct __gmp_rand_function /* this is much the same as gmp_allocated_string in gmp-impl.h since gmp-impl.h is not publicly available, I redefine it here I use a different name to avoid possible clashes */ + +extern "C" { + typedef void (*__gmp_freefunc_t) (void *, size_t); +} struct __gmp_alloc_cstring { char *str; __gmp_alloc_cstring(char *s) { str = s; } ~__gmp_alloc_cstring() { - void (*freefunc) (void *, size_t); + __gmp_freefunc_t freefunc; mp_get_memory_functions (NULL, NULL, &freefunc); (*freefunc) (str, std::strlen(str)+1); } @@ -1616,9 +1682,9 @@ public: __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) __GMP_DECLARE_COMPOUND_OPERATOR(operator%=) - __GMPP_DECLARE_COMPOUND_OPERATOR(operator&=) - __GMPP_DECLARE_COMPOUND_OPERATOR(operator|=) - __GMPP_DECLARE_COMPOUND_OPERATOR(operator^=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator&=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator|=) + __GMP_DECLARE_COMPOUND_OPERATOR(operator^=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) @@ -3006,9 +3072,6 @@ __GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) #define __GMPZ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR(mpz, fun, eval_fun) -#define __GMPZZ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ -__GMPP_DEFINE_COMPOUND_OPERATOR(mpz, fun, eval_fun) - #define __GMPQ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR(mpq, fun, eval_fun) @@ -3109,9 +3172,9 @@ __GMPZ_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator%=, __gmp_binary_modulus) -__GMPZZ_DEFINE_COMPOUND_OPERATOR(operator&=, __gmp_binary_and) -__GMPZZ_DEFINE_COMPOUND_OPERATOR(operator|=, __gmp_binary_ior) -__GMPZZ_DEFINE_COMPOUND_OPERATOR(operator^=, __gmp_binary_xor) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator&=, __gmp_binary_and) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator|=, __gmp_binary_ior) +__GMPZ_DEFINE_COMPOUND_OPERATOR(operator^=, __gmp_binary_xor) __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) @@ -3269,7 +3332,6 @@ public: #undef __GMP_DECLARE_INCREMENT_OPERATOR #undef __GMPZQ_DEFINE_EXPR -#undef __GMP_DEFINE_TERNARY_EXPR #undef __GMP_DEFINE_UNARY_FUNCTION #undef __GMP_DEFINE_UNARY_TYPE_FUNCTION @@ -3294,15 +3356,7 @@ public: #undef __GMPN_DEFINE_BINARY_TYPE_FUNCTION #undef __GMP_DEFINE_BINARY_TYPE_FUNCTION -#undef __GMPP_DECLARE_COMPOUND_OPERATOR -#undef __GMPN_DECLARE_COMPOUND_OPERATOR -#undef __GMP_DECLARE_COMPOUND_OPERATOR - -#undef __GMP_DECLARE_COMPOUND_OPERATOR_UI -#undef __GMP_DECLARE_INCREMENT_OPERATOR - #undef __GMPZ_DEFINE_COMPOUND_OPERATOR -#undef __GMPZZ_DEFINE_COMPOUND_OPERATOR #undef __GMPZN_DEFINE_COMPOUND_OPERATOR #undef __GMPZNN_DEFINE_COMPOUND_OPERATOR #undef __GMPZNS_DEFINE_COMPOUND_OPERATOR @@ -3319,8 +3373,6 @@ public: #undef __GMPN_DEFINE_COMPOUND_OPERATOR #undef __GMP_DEFINE_COMPOUND_OPERATOR -#undef __GMPZ_DEFINE_COMPOUND_OPERATOR -#undef __GMPZZ_DEFINE_COMPOUND_OPERATOR #undef __GMPQ_DEFINE_COMPOUND_OPERATOR #undef __GMPF_DEFINE_COMPOUND_OPERATOR diff --git a/library/GMP/lib/libgmp.a b/library/GMP/lib/libgmp.a index 041ee6c7..e53850ec 100644 Binary files a/library/GMP/lib/libgmp.a and b/library/GMP/lib/libgmp.a differ diff --git a/library/GMP/lib/libgmp.la b/library/GMP/lib/libgmp.la index ee6e9a74..a0e34d40 100644 --- a/library/GMP/lib/libgmp.la +++ b/library/GMP/lib/libgmp.la @@ -19,7 +19,7 @@ dependency_libs='' # Version information for libgmp. current=7 age=4 -revision=2 +revision=3 # Is this an already installed library? installed=yes diff --git a/library/GMP/lib/libgmpxx.a b/library/GMP/lib/libgmpxx.a index 90ca1d40..3c4452d3 100644 Binary files a/library/GMP/lib/libgmpxx.a and b/library/GMP/lib/libgmpxx.a differ diff --git a/library/GMP/lib/libgmpxx.la b/library/GMP/lib/libgmpxx.la index e608eba7..dbb77dd0 100644 --- a/library/GMP/lib/libgmpxx.la +++ b/library/GMP/lib/libgmpxx.la @@ -19,7 +19,7 @@ dependency_libs=' /c/gmp/lib/libgmp.la' # Version information for libgmpxx. current=4 age=0 -revision=2 +revision=3 # Is this an already installed library? installed=yes -- cgit