summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-07 14:40:47 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-07 14:40:47 +0000
commit2bc26fb8ca6e4e783f0ecc1a01430815bf9c50b2 (patch)
tree0f024e6c674a1f626e5a8231e7cda2d08e7ab120
parentc44bde008cebc99a76205f1329ac86fef8cf65c3 (diff)
downloadmpfr-2bc26fb8ca6e4e783f0ecc1a01430815bf9c50b2.tar.gz
Modify a few the allocation scheme without gmp-impl.h
Add pseudo-constants __MPFR_EXP_NAN, __MPFR_EXP_ZERO and __MPFR_EXP_INF for future (?) inlining of some functions. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2863 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--init2.c6
-rw-r--r--mpfr-gmp.c6
-rw-r--r--mpfr-gmp.h26
-rw-r--r--mpfr-impl.h24
-rw-r--r--mpfr.h8
5 files changed, 41 insertions, 29 deletions
diff --git a/init2.c b/init2.c
index 3c44e532c..6369f7396 100644
--- a/init2.c
+++ b/init2.c
@@ -37,8 +37,10 @@ mpfr_init2 (mpfr_ptr x, mp_prec_t p)
MPFR_ASSERTN( BITS_PER_MP_LIMB == BYTES_PER_MP_LIMB * CHAR_BIT
&& sizeof(mp_limb_t) == BYTES_PER_MP_LIMB );
- /* Check for correct EXP NAN in both mpfr.h and in mpfr-impl.h */
- MPFR_ASSERTN( __MPFR_EXP_NAN == MPFR_EXP_NAN );
+ /* Check for correct EXP NAN, ZERO & INF in both mpfr.h and in mpfr-impl.h */
+ MPFR_ASSERTN( __MPFR_EXP_NAN == MPFR_EXP_NAN );
+ MPFR_ASSERTN( __MPFR_EXP_ZERO == MPFR_EXP_ZERO );
+ MPFR_ASSERTN( __MPFR_EXP_INF == MPFR_EXP_INF );
/* p=1 is not allowed since the rounding to nearest even rule requires at
least two bits of mantissa: the neighbours of 3/2 are 1*2^0 and 1*2^1,
diff --git a/mpfr-gmp.c b/mpfr-gmp.c
index 5acf4f16a..d23e7c1dc 100644
--- a/mpfr-gmp.c
+++ b/mpfr-gmp.c
@@ -358,8 +358,8 @@ mpfr_default_free (void *blk_ptr, size_t blk_size)
void
mpfr_set_memory_functions (void *(*alloc_func) (size_t),
- void *(*realloc_func) (void *, size_t, size_t),
- void (*free_func) (void *, size_t))
+ void *(*realloc_func) (void *, size_t, size_t),
+ void (*free_func) (void *, size_t))
{
if (alloc_func == ((void*(*)(size_t)) 0))
alloc_func = mpfr_default_allocate;
@@ -373,5 +373,5 @@ mpfr_set_memory_functions (void *(*alloc_func) (size_t),
__gmp_free_func = free_func;
}
-#endif
+#endif /* Have gmp-impl.h */
diff --git a/mpfr-gmp.h b/mpfr-gmp.h
index 746a1704c..95397ab54 100644
--- a/mpfr-gmp.h
+++ b/mpfr-gmp.h
@@ -237,31 +237,33 @@ typedef __gmp_randstate_struct *gmp_randstate_ptr;
#undef _gmp_rand
#define _gmp_rand mpfr_rand_raw
-void _gmp_rand _MPFR_PROTO((mp_ptr, gmp_randstate_t, unsigned long int));
+void mpfr_rand_raw _MPFR_PROTO((mp_ptr, gmp_randstate_t, unsigned long int));
-/* Allocate func (define as internal in gmp) */
+/* Allocate func are defined in gmp-impl.h */
#undef __gmp_allocate_func
#undef __gmp_reallocate_func
#undef __gmp_free_func
-#undef __gmp_default_allocate
-#undef __gmp_default_reallocate
-#undef __gmp_default_free
-#undef mp_set_memory_functions
#define __gmp_allocate_func mpfr_allocate_func
#define __gmp_reallocate_func mpfr_reallocate_func
#define __gmp_free_func mpfr_free_func
-#define __gmp_default_allocate mpfr_default_allocate
-#define __gmp_default_reallocate mpfr_default_reallocate
-#define __gmp_default_free mpfr_default_free
-#define mp_set_memory_functions mpfr_set_memory_functions
extern void * (*__gmp_allocate_func) _MPFR_PROTO ((size_t));
extern void * (*__gmp_reallocate_func) _MPFR_PROTO ((void *, size_t, size_t));
extern void (*__gmp_free_func) _MPFR_PROTO ((void *, size_t));
+
+#undef __gmp_default_allocate
+#undef __gmp_default_reallocate
+#undef __gmp_default_free
+#define __gmp_default_allocate mpfr_default_allocate
+#define __gmp_default_reallocate mpfr_default_reallocate
+#define __gmp_default_free mpfr_default_free
void *__gmp_default_allocate _MPFR_PROTO ((size_t));
void *__gmp_default_reallocate _MPFR_PROTO ((void *, size_t, size_t));
void __gmp_default_free _MPFR_PROTO ((void *, size_t));
+
+#undef mp_set_memory_functions
+#define mp_set_memory_functions mpfr_set_memory_functions
void mp_set_memory_functions _MPFR_PROTO ((void *(*) (size_t),
- void *(*) (void *, size_t, size_t),
- void (*) (void *, size_t)));
+ void *(*) (void *, size_t, size_t),
+ void (*) (void *, size_t)));
#endif /* Gmp internal emulator */
diff --git a/mpfr-impl.h b/mpfr-impl.h
index db2e3a94e..6b64cb87c 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -61,14 +61,6 @@ MA 02111-1307, USA. */
#endif
#undef MPFR_NEED_LONGLONG_H
-#ifndef HAVE_STRCASECMP
-# define strcasecmp mpfr_strcasecmp
-#endif
-
-#ifndef HAVE_STRNCASECMP
-# define strncasecmp mpfr_strncasecmp
-#endif
-
/* Macros to detect STDC, GCC, GLIBC and GMP version */
#if defined(__STDC_VERSION__)
# define __MPFR_STDC(version) (__STDC_VERSION__>=(version))
@@ -77,7 +69,6 @@ MA 02111-1307, USA. */
#else
# define __MPFR_STDC(version) 0
#endif
-
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
# define __MPFR_GNUC(a, i) (MPFR_VERSION_NUM(__GNUC__,__GNUC_MINOR__,0)>=MPFR_VERSION_NUM(a,i,0))
#else
@@ -94,6 +85,16 @@ MA 02111-1307, USA. */
# define __MPFR_GMP(a, b, c) 0
#endif
+
+/* Define strcasecmp and strncasecmp if needed */
+#ifndef HAVE_STRCASECMP
+# define strcasecmp mpfr_strcasecmp
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# define strncasecmp mpfr_strncasecmp
+#endif
+
/* Check GMP */
#if GMP_NAIL_BITS != 0
# error "MPFR doesn't support nonzero values of GMP_NAIL_BITS"
@@ -192,7 +193,7 @@ typedef unsigned long int mpfr_uexp_t;
/* Theses macros help the compiler to determine if a test is
* likely or unlikely. */
-#if __GNUC__ >= 3
+#if __MPFR_GNUC(3,0)
# define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
# define MPFR_UNLIKELY(x) (__builtin_expect((x),0))
#else
@@ -482,6 +483,9 @@ typedef union { mp_size_t s; mp_limb_t l; } mpfr_size_limb_t;
(xp = (mp_ptr) TMP_ALLOC(BYTES_PER_MP_LIMB * ((size_t) s)), \
MPFR_TMP_INIT1(xp, x, p))
+/* Use it only for debug reasons */
+#define MPFR_DUMP(x) do { printf(#x"="); mpfr_dump(x); } while (0)
+
#if defined (__cplusplus)
extern "C" {
#endif
diff --git a/mpfr.h b/mpfr.h
index 7def63f3c..031fec56d 100644
--- a/mpfr.h
+++ b/mpfr.h
@@ -408,9 +408,13 @@ int mpfr_sum _MPFR_PROTO ((mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
/* DON'T USE THIS! */
#if __GMP_MP_SIZE_T_INT
-#define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned int)0)>>1))+2))
+#define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned int)0)>>1))+2))
+#define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned int)0)>>1))+1))
+#define __MPFR_EXP_INF ((mp_exp_t)((~((~(unsigned int)0)>>1))+3))
#else
-#define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned long)0)>>1))+2))
+#define __MPFR_EXP_NAN ((mp_exp_t)((~((~(unsigned long)0)>>1))+2))
+#define __MPFR_EXP_ZERO ((mp_exp_t)((~((~(unsigned long)0)>>1))+1))
+#define __MPFR_EXP_INF ((mp_exp_t)((~((~(unsigned long)0)>>1))+3))
#endif
#define MPFR_DECL_INIT(_x, _p) \