Further attempt to fix the intmax_t issue in mpirxx.h.

This commit is contained in:
wbhart 2012-10-12 20:01:18 +00:00
parent 0bd7795b9f
commit 9d90f9c742
2 changed files with 23 additions and 12 deletions

View File

@ -42,6 +42,15 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include <cfloat>
#include <mpir.h>
#ifdef MSC_VER /* needed for definition of LLONG_MAX */
# include <limits.h>
#endif
#ifdef LLONG_MAX
#if LLONG_MAX != LONG_MAX
#define MPIRXX_HAVE_LLONG 1
#endif
#endif
/**************** Function objects ****************/
/* Any evaluation of a __gmp_expr ends up calling one of these functions
@ -1505,7 +1514,7 @@ void __gmp_set_expr(mpf_ptr, const __gmp_expr<T, U> &);
#define __GMPP_DECLARE_COMPOUND_OPERATOR(fun) \
template <class T, class U> \
__gmp_expr<value_type, value_type> & fun(const __gmp_expr<T, U> &);
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
#define __GMPN_DECLARE_COMPOUND_OPERATOR(fun) \
__gmp_expr & fun(signed char); \
__gmp_expr & fun(unsigned char); \
@ -1578,13 +1587,13 @@ public:
__gmp_expr(signed long int l) { mpz_init_set_si(mp, l); }
__gmp_expr(unsigned long int l) { mpz_init_set_ui(mp, l); }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr(signed long long int l) { mpz_init_set_si(mp, l); }
__gmp_expr(unsigned long long int l) { mpz_init_set_ui(mp, l); }
#endif
#if defined( _STDINT_H ) || defined ( _STDINT_H_ ) || defined ( _STDINT )
#ifndef LLONG_MAX
#ifndef MPIRXX_HAVE_LLONG
#if INTMAX_MAX != LONG_MAX
__gmp_expr(intmax_t l) { mpz_init_set_sx(mp, l); }
__gmp_expr(uintmax_t l) { mpz_init_set_ux(mp, l); }
@ -1652,13 +1661,13 @@ public:
__gmp_expr & operator=(signed long int i) { mpz_set_si(mp, i); return *this; }
__gmp_expr & operator=(unsigned long int i) { mpz_set_ui(mp, i); return *this; }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr & operator=(signed long long int i) { mpz_set_si(mp, i); return *this; }
__gmp_expr & operator=(unsigned long long int i) { mpz_set_ui(mp, i); return *this; }
#endif
#if defined( _STDINT_H ) || defined ( _STDINT_H_ ) || defined ( _STDINT )
#ifndef LLONG_MAX
#ifndef MPIRXX_HAVE_LLONG
#if INTMAX_MAX != LONG_MAX
__gmp_expr & operator=(intmax_t i) { mpz_set_sx(mp, i); return *this; }
__gmp_expr & operator=(uintmax_t i) { mpz_set_ux(mp, i); return *this; }
@ -1776,7 +1785,7 @@ public:
__gmp_expr(signed long int l) { mpq_init(mp); mpq_set_si(mp, l, 1); }
__gmp_expr(unsigned long int l) { mpq_init(mp); mpq_set_ui(mp, l, 1); }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr(signed long long int l) { mpq_init(mp); mpq_set_si(mp, l, 1); }
__gmp_expr(unsigned long long int l) { mpq_init(mp); mpq_set_ui(mp, l, 1); }
#endif
@ -1858,7 +1867,7 @@ public:
__gmp_expr & operator=(unsigned long int l)
{ mpq_set_ui(mp, l, 1); return *this; }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr & operator=(signed long long int l)
{ mpq_set_si(mp, l, 1); return *this; }
__gmp_expr & operator=(unsigned long long int l)
@ -1993,7 +2002,7 @@ public:
__gmp_expr(unsigned long int s, mp_bitcnt_t prec)
{ mpf_init2(mp, prec); mpf_set_ui(mp, s); }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr(signed long long int s) { mpf_init_set_si(mp, s); }
__gmp_expr(signed long long int s, mp_bitcnt_t prec)
{ mpf_init2(mp, prec); mpf_set_si(mp, s); }
@ -2077,7 +2086,7 @@ public:
__gmp_expr & operator=(unsigned long int l)
{ mpf_set_ui(mp, l); return *this; }
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
__gmp_expr & operator=(signed long long int l)
{ mpf_set_si(mp, l); return *this; }
__gmp_expr & operator=(unsigned long long int l)
@ -2998,7 +3007,7 @@ __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, double)
#define __GMPNLD_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \
__GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, long double)
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
#define __GMPN_DEFINE_BINARY_FUNCTION(fun, eval_fun) \
__GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed char) \
__GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned char) \
@ -3088,7 +3097,7 @@ __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, double)
#define __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \
__GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, long double)
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
#define __GMPN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \
__GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed char) \
__GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned char) \
@ -3159,7 +3168,7 @@ __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, double)
#define __GMPNLD_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \
__GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, long double)
#ifdef LLONG_MAX
#ifdef MPIRXX_HAVE_LLONG
#define __GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \
__GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed char) \
__GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned char) \

View File

@ -120,6 +120,7 @@ check_mpz (void)
b = a; ASSERT_ALWAYS(b == 3456789012UL);
}
#ifdef MPIRXX_HAVE_LLONG
// operator=(unsigned long int)
{
unsigned long long int a = 0x1234567812345678;
@ -135,6 +136,7 @@ check_mpz (void)
b = a;
ASSERT_ALWAYS(b == (mpir_si)0xfedcba9876543210);
}
#endif
// operator=(float)
{