diff --git a/math/gmp/Makefile b/math/gmp/Makefile index 8769e4fb8ce1..7a4909e3dfc6 100644 --- a/math/gmp/Makefile +++ b/math/gmp/Makefile @@ -8,7 +8,7 @@ PORTNAME= libgmp PORTVERSION= 4.2.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= math devel MASTER_SITES= ${MASTER_SITE_GNU} MASTER_SITE_SUBDIR= gmp @@ -21,7 +21,7 @@ USE_AUTOTOOLS= libtool:15 GNU_CONFIGURE= yes CONFIGURE_ENV= MAKEINFO="makeinfo --no-split" CONFIGURE_ARGS= --enable-cxx -INSTALLS_SHLIB= yes +USE_LDCONFIG= yes INFO= gmp diff --git a/math/gmp/files/patch-gmpxx.h b/math/gmp/files/patch-gmpxx.h new file mode 100644 index 000000000000..039e4f45e1e6 --- /dev/null +++ b/math/gmp/files/patch-gmpxx.h @@ -0,0 +1,513 @@ +--- gmpxx.h.orig Sat Apr 8 21:15:38 2006 ++++ gmpxx.h Wed Feb 7 07:56:24 2007 +@@ -1277,92 +1277,6 @@ + { return -mpf_cmp_d(f, d); } + }; + +-struct __gmp_ternary_addmul // z = w + v * u +-{ +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, mpz_srcptr u) +- { mpz_set(z, w); mpz_addmul(z, v, u); } +- +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, unsigned long int l) +- { mpz_set(z, w); mpz_addmul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l, mpz_srcptr v) +- { mpz_set(z, w); mpz_addmul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, signed long int l) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_addmul_ui(z, v, l); +- else +- mpz_submul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, signed long int l, mpz_srcptr v) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_addmul_ui(z, v, l); +- else +- mpz_submul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, double d) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_addmul(z, v, temp); +- mpz_clear(temp); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, double d, mpz_srcptr v) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_addmul(z, temp, v); +- mpz_clear(temp); +- } +-}; +- +-struct __gmp_ternary_submul // z = w - v * u +-{ +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, mpz_srcptr u) +- { mpz_set(z, w); mpz_submul(z, v, u); } +- +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, unsigned long int l) +- { mpz_set(z, w); mpz_submul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l, mpz_srcptr v) +- { mpz_set(z, w); mpz_submul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, signed long int l) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_submul_ui(z, v, l); +- else +- mpz_addmul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, signed long int l, mpz_srcptr v) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_submul_ui(z, v, l); +- else +- mpz_addmul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, double d) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_submul(z, v, temp); +- mpz_clear(temp); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, double d, mpz_srcptr v) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_submul(z, temp, v); +- mpz_clear(temp); +- } +-}; +- + struct __gmp_rand_function + { + static void eval(mpz_ptr z, gmp_randstate_t s, unsigned long int l) +@@ -2862,417 +2776,6 @@ + __GMPZQ_DEFINE_EXPR(__gmp_binary_minus) + + +-/* Integer ternary expressions of the kind `a+b*c' or `a*b+c' can be +- evaluated directly via mpz_addmul */ +- +-// a + b * c +-#define __GMP_DEFINE_TERNARY_EXPR(eval_fun1, eval_fun2, eval_both) \ +- \ +-template <> \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1(), \ +- expr.val2.get_val2().get_mpz_t()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- temp.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, mpz_class, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, mpz_class, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val1()); \ +- eval_both::eval(z, expr.val1.get_mpz_t(), temp.get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, U, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, U, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val1()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), temp.get_mpz_t(), expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1(), temp.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val2.get_val1()); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), temp1.get_mpz_t(), temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, mpz_class, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, mpz_class, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- eval_both::eval(z, temp1.get_mpz_t(), temp2.get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, V, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, V, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), temp2.get_mpz_t(), expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), expr.val2.get_val1(), temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- __gmp_expr, eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- mpz_class temp3(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), temp2.get_mpz_t(), temp3.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; +- +- +-__GMP_DEFINE_TERNARY_EXPR(__gmp_binary_multiplies, __gmp_binary_plus, +- __gmp_ternary_addmul) +-__GMP_DEFINE_TERNARY_EXPR(__gmp_binary_multiplies, __gmp_binary_minus, +- __gmp_ternary_submul) + + /**************** Macros for defining functions ****************/ + /* Results of operators and functions are instances of __gmp_expr. diff --git a/math/gmp/files/patch-mpz_set_d.c b/math/gmp/files/patch-mpz_set_d.c new file mode 100644 index 000000000000..ec5c1a90b07a --- /dev/null +++ b/math/gmp/files/patch-mpz_set_d.c @@ -0,0 +1,12 @@ +--- mpz/set_d.c.orig Tue Mar 14 16:57:54 2006 ++++ mpz/set_d.c Wed Feb 7 07:56:31 2007 +@@ -56,6 +56,9 @@ + if (ALLOC(r) < rn) + _mpz_realloc (r, rn); + ++ if (rn <= 0) ++ rn = 0; ++ + rp = PTR (r); + + switch (rn) diff --git a/math/libgmp4/Makefile b/math/libgmp4/Makefile index 8769e4fb8ce1..7a4909e3dfc6 100644 --- a/math/libgmp4/Makefile +++ b/math/libgmp4/Makefile @@ -8,7 +8,7 @@ PORTNAME= libgmp PORTVERSION= 4.2.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= math devel MASTER_SITES= ${MASTER_SITE_GNU} MASTER_SITE_SUBDIR= gmp @@ -21,7 +21,7 @@ USE_AUTOTOOLS= libtool:15 GNU_CONFIGURE= yes CONFIGURE_ENV= MAKEINFO="makeinfo --no-split" CONFIGURE_ARGS= --enable-cxx -INSTALLS_SHLIB= yes +USE_LDCONFIG= yes INFO= gmp diff --git a/math/libgmp4/files/patch-gmpxx.h b/math/libgmp4/files/patch-gmpxx.h new file mode 100644 index 000000000000..039e4f45e1e6 --- /dev/null +++ b/math/libgmp4/files/patch-gmpxx.h @@ -0,0 +1,513 @@ +--- gmpxx.h.orig Sat Apr 8 21:15:38 2006 ++++ gmpxx.h Wed Feb 7 07:56:24 2007 +@@ -1277,92 +1277,6 @@ + { return -mpf_cmp_d(f, d); } + }; + +-struct __gmp_ternary_addmul // z = w + v * u +-{ +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, mpz_srcptr u) +- { mpz_set(z, w); mpz_addmul(z, v, u); } +- +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, unsigned long int l) +- { mpz_set(z, w); mpz_addmul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l, mpz_srcptr v) +- { mpz_set(z, w); mpz_addmul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, signed long int l) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_addmul_ui(z, v, l); +- else +- mpz_submul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, signed long int l, mpz_srcptr v) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_addmul_ui(z, v, l); +- else +- mpz_submul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, double d) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_addmul(z, v, temp); +- mpz_clear(temp); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, double d, mpz_srcptr v) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_addmul(z, temp, v); +- mpz_clear(temp); +- } +-}; +- +-struct __gmp_ternary_submul // z = w - v * u +-{ +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, mpz_srcptr u) +- { mpz_set(z, w); mpz_submul(z, v, u); } +- +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, unsigned long int l) +- { mpz_set(z, w); mpz_submul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l, mpz_srcptr v) +- { mpz_set(z, w); mpz_submul_ui(z, v, l); } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, signed long int l) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_submul_ui(z, v, l); +- else +- mpz_addmul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, signed long int l, mpz_srcptr v) +- { +- mpz_set(z, w); +- if (l >= 0) +- mpz_submul_ui(z, v, l); +- else +- mpz_addmul_ui(z, v, -l); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v, double d) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_submul(z, v, temp); +- mpz_clear(temp); +- } +- static void eval(mpz_ptr z, mpz_srcptr w, double d, mpz_srcptr v) +- { +- mpz_t temp; +- mpz_init_set_d(temp, d); +- mpz_set(z, w); +- mpz_submul(z, temp, v); +- mpz_clear(temp); +- } +-}; +- + struct __gmp_rand_function + { + static void eval(mpz_ptr z, gmp_randstate_t s, unsigned long int l) +@@ -2862,417 +2776,6 @@ + __GMPZQ_DEFINE_EXPR(__gmp_binary_minus) + + +-/* Integer ternary expressions of the kind `a+b*c' or `a*b+c' can be +- evaluated directly via mpz_addmul */ +- +-// a + b * c +-#define __GMP_DEFINE_TERNARY_EXPR(eval_fun1, eval_fun2, eval_both) \ +- \ +-template <> \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1(), \ +- expr.val2.get_val2().get_mpz_t()); } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- temp.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, mpz_class, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, mpz_class, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val1()); \ +- eval_both::eval(z, expr.val1.get_mpz_t(), temp.get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, U, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, U, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val1()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), temp.get_mpz_t(), expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, eval_fun1> >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), expr.val2.get_val1(), temp.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef mpz_class val1_type; \ +- typedef __gmp_expr, __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val2.get_val1()); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, expr.val1.get_mpz_t(), temp1.get_mpz_t(), temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr >, \ +- eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr \ +- > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp(expr.val1); \ +- eval_both::eval(z, temp.get_mpz_t(), expr.val2.get_val1(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), expr.val2.get_val1().get_mpz_t(), \ +- temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, mpz_class, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, mpz_class, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- eval_both::eval(z, temp1.get_mpz_t(), temp2.get_mpz_t(), \ +- expr.val2.get_val2().get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, V, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, V, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), temp2.get_mpz_t(), expr.val2.get_val2()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), expr.val2.get_val1(), temp2.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; \ +- \ +-template \ +-class __gmp_expr, \ +- __gmp_expr, \ +- __gmp_expr, eval_fun1> >, eval_fun2> > \ +-{ \ +-private: \ +- typedef __gmp_expr val1_type; \ +- typedef __gmp_expr, __gmp_expr, eval_fun1> > val2_type; \ +- \ +- __gmp_binary_expr expr; \ +-public: \ +- __gmp_expr(const val1_type &val1, const val2_type &val2) \ +- : expr(val1, val2) { } \ +- void eval(mpz_ptr z) const \ +- { \ +- mpz_class temp1(expr.val1); \ +- mpz_class temp2(expr.val2.get_val1()); \ +- mpz_class temp3(expr.val2.get_val2()); \ +- eval_both::eval \ +- (z, temp1.get_mpz_t(), temp2.get_mpz_t(), temp3.get_mpz_t()); \ +- } \ +- const val1_type & get_val1() const { return expr.val1; } \ +- const val2_type & get_val2() const { return expr.val2; } \ +- unsigned long int get_prec() const { return mpf_get_default_prec(); } \ +-}; +- +- +-__GMP_DEFINE_TERNARY_EXPR(__gmp_binary_multiplies, __gmp_binary_plus, +- __gmp_ternary_addmul) +-__GMP_DEFINE_TERNARY_EXPR(__gmp_binary_multiplies, __gmp_binary_minus, +- __gmp_ternary_submul) + + /**************** Macros for defining functions ****************/ + /* Results of operators and functions are instances of __gmp_expr. diff --git a/math/libgmp4/files/patch-mpz_set_d.c b/math/libgmp4/files/patch-mpz_set_d.c new file mode 100644 index 000000000000..ec5c1a90b07a --- /dev/null +++ b/math/libgmp4/files/patch-mpz_set_d.c @@ -0,0 +1,12 @@ +--- mpz/set_d.c.orig Tue Mar 14 16:57:54 2006 ++++ mpz/set_d.c Wed Feb 7 07:56:31 2007 +@@ -56,6 +56,9 @@ + if (ALLOC(r) < rn) + _mpz_realloc (r, rn); + ++ if (rn <= 0) ++ rn = 0; ++ + rp = PTR (r); + + switch (rn)