From 9abe9eded16c3b642450f04363c17bada6ab1c86 Mon Sep 17 00:00:00 2001 From: gladman Date: Sat, 19 Mar 2011 09:28:07 +0000 Subject: [PATCH] change mechanism for detecting stdint.h --- gmp-h.in | 10 +--------- mpz/get_sx.c | 4 ++-- mpz/get_ux.c | 4 ++-- mpz/iset_sx.c | 4 ++-- mpz/iset_ux.c | 4 ++-- mpz/set_sx.c | 4 ++-- mpz/set_ux.c | 4 ++-- tests/mpz/t-get_sx.c | 3 +-- tests/mpz/t-set_sx.c | 3 +-- 9 files changed, 15 insertions(+), 25 deletions(-) diff --git a/gmp-h.in b/gmp-h.in index a630d170..4378d3d5 100644 --- a/gmp-h.in +++ b/gmp-h.in @@ -53,14 +53,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #endif #undef __need_size_t -#ifdef HAVE_STDINT_H -#if defined (__cplusplus) -# include /* for intmax_t/uintmax_t */ -# else -# include /* for intmax_t/uintmax_t */ -# endif -#endif - /* Instantiated by configure. */ #if ! defined (__GMP_WITHIN_CONFIGURE) @DEFN_LONG_LONG_LIMB@ @@ -1188,7 +1180,7 @@ __GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); /****** Integer (i.e. Z) routines for intmaax_t/uintmax_t types ******/ -#ifdef HAVE_STDINT_H +#if defined( _STDINT_H ) || defined ( _STDINT_H_ ) || defined ( _STDINT ) #define __GMP_BITS_PER_UINTMAX (8*sizeof(uintmax_t)) diff --git a/mpz/get_sx.c b/mpz/get_sx.c index e78e1d7e..e960cd94 100644 --- a/mpz/get_sx.c +++ b/mpz/get_sx.c @@ -21,7 +21,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -33,7 +33,7 @@ MA 02110-1301, USA. */ intmax_t mpz_get_sx (mpz_srcptr z) { -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 uintmax_t v = (intmax_t)(z->_mp_size ? z->_mp_d[0] : 0); #else uintmax_t v = 0, n = MIN(NLIMBS, ABS(z->_mp_size)); diff --git a/mpz/get_ux.c b/mpz/get_ux.c index 0eafab14..684e10b9 100644 --- a/mpz/get_ux.c +++ b/mpz/get_ux.c @@ -21,7 +21,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -33,7 +33,7 @@ MA 02110-1301, USA. */ uintmax_t mpz_get_ux (mpz_srcptr z) { -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 return (uintmax_t)(z->_mp_size ? z->_mp_d[0] : 0); #else uintmax_t v = 0, n = MIN(NLIMBS, ABS(z->_mp_size)); diff --git a/mpz/iset_sx.c b/mpz/iset_sx.c index 69a39c98..1acd055f 100644 --- a/mpz/iset_sx.c +++ b/mpz/iset_sx.c @@ -20,7 +20,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -36,7 +36,7 @@ mpz_init_set_sx (mpz_ptr z, intmax_t v) z->_mp_d = (mp_ptr) (*__gmp_allocate_func) (MAX(1, NLIMBS) * BYTES_PER_MP_LIMB); z->_mp_alloc = MAX(1, NLIMBS); -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 z->_mp_d[0] = (mp_limb_t)uv; z->_mp_size = v < 0 ? -NLIMBS : v ? NLIMBS : 0; #else diff --git a/mpz/iset_ux.c b/mpz/iset_ux.c index a79337c2..d1e8c278 100644 --- a/mpz/iset_ux.c +++ b/mpz/iset_ux.c @@ -20,7 +20,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -36,7 +36,7 @@ mpz_init_set_ux (mpz_ptr z, uintmax_t v) z->_mp_d = (mp_ptr) (*__gmp_allocate_func) (MAX(1, NLIMBS) * BYTES_PER_MP_LIMB); z->_mp_alloc = MAX(1, NLIMBS); -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 z->_mp_d[0] = (mp_limb_t)v; z->_mp_size = (v ? NLIMBS : 0); #else diff --git a/mpz/set_sx.c b/mpz/set_sx.c index fead8d84..be1c525d 100644 --- a/mpz/set_sx.c +++ b/mpz/set_sx.c @@ -20,7 +20,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -33,7 +33,7 @@ void mpz_set_sx (mpz_ptr z, intmax_t v) { uintmax_t i, uv = (v < 0 ? -v : v); -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 z->_mp_d[0] = (mp_limb_t)uv; z->_mp_size = v < 0 ? -NLIMBS : v ? NLIMBS : 0; #else diff --git a/mpz/set_ux.c b/mpz/set_ux.c index 0bcb271c..0555530e 100644 --- a/mpz/set_ux.c +++ b/mpz/set_ux.c @@ -20,7 +20,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H +#include #include "mpir.h" #include "gmp-impl.h" @@ -33,7 +33,7 @@ void mpz_set_ux (mpz_ptr z, uintmax_t v) { uintmax_t i, uv; -#if GMP_NUMB_BITS >= 8 * SIZEOF_UINTMAX_T +#if NLIMBS == 1 z->_mp_d[0] = (mp_limb_t)v; z->_mp_size = (v ? NLIMBS : 0); #else diff --git a/tests/mpz/t-get_sx.c b/tests/mpz/t-get_sx.c index a2f9b2c7..3ffe0173 100644 --- a/tests/mpz/t-get_sx.c +++ b/tests/mpz/t-get_sx.c @@ -21,10 +21,9 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H - #include #include +#include #include "mpir.h" #include "gmp-impl.h" #include "tests.h" diff --git a/tests/mpz/t-set_sx.c b/tests/mpz/t-set_sx.c index 6955c817..3e0fc168 100644 --- a/tests/mpz/t-set_sx.c +++ b/tests/mpz/t-set_sx.c @@ -20,10 +20,9 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define HAVE_STDINT_H - #include #include +#include #include "mpir.h" #include "gmp-impl.h" #include "tests.h"