[BACK]Return to gdtoaimp.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gdtoa

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/gdtoa/gdtoaimp.h between version 1.1.1.2 and 1.6

version 1.1.1.2, 2011/03/19 16:26:37 version 1.6, 2007/02/03 16:44:02
Line 1 
Line 1 
   /* $NetBSD$ */
   
 /****************************************************************  /****************************************************************
   
 The author of this software is David M. Gay.  The author of this software is David M. Gay.
Line 79  THIS SOFTWARE.
Line 81  THIS SOFTWARE.
  */   */
   
 /*  /*
  * #define IEEE_8087 for IEEE-arithmetic machines where the least   * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least
  *      significant byte has the lowest address.   *      significant byte has the lowest address.
  * #define IEEE_MC68k for IEEE-arithmetic machines where the most   * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most
  *      significant byte has the lowest address.   *      significant byte has the lowest address.
  * #define Long int on machines with 32-bit ints and 64-bit longs.   * #define Long int on machines with 32-bit ints and 64-bit longs.
  * #define Sudden_Underflow for IEEE-format machines without gradual   * #define Sudden_Underflow for IEEE-format machines without gradual
Line 94  THIS SOFTWARE.
Line 96  THIS SOFTWARE.
  * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines   * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
  *      that use extended-precision instructions to compute rounded   *      that use extended-precision instructions to compute rounded
  *      products and quotients) with IBM.   *      products and quotients) with IBM.
  * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic   * #define ROUND_BIASED for IEEE-format with biased rounding.
  *      that rounds toward +Infinity.  
  * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased  
  *      rounding when the underlying floating-point arithmetic uses  
  *      unbiased rounding.  This prevent using ordinary floating-point  
  *      arithmetic when the result could be computed with one rounding error.  
  * #define Inaccurate_Divide for IEEE-format with correctly rounded   * #define Inaccurate_Divide for IEEE-format with correctly rounded
  *      products but inaccurate quotients, e.g., for Intel i860.   *      products but inaccurate quotients, e.g., for Intel i860.
  * #define NO_LONG_LONG on machines that do not have a "long long"   * #define NO_LONG_LONG on machines that do not have a "long long"
Line 118  THIS SOFTWARE.
Line 115  THIS SOFTWARE.
  * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)   * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
  *      if memory is available and otherwise does something you deem   *      if memory is available and otherwise does something you deem
  *      appropriate.  If MALLOC is undefined, malloc will be invoked   *      appropriate.  If MALLOC is undefined, malloc will be invoked
  *      directly -- and assumed always to succeed.  Similarly, if you   *      directly -- and assumed always to succeed.
  *      want something other than the system's free() to be called to  
  *      recycle memory acquired from MALLOC, #define FREE to be the  
  *      name of the alternate routine.  (FREE or free is only called in  
  *      pathological cases, e.g., in a gdtoa call after a gdtoa return in  
  *      mode 3 with thousands of digits requested.)  
  * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making   * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
  *      memory allocations from a private pool of memory when possible.   *      memory allocations from a private pool of memory when possible.
  *      When used, the private pool is PRIVATE_MEM bytes long:  2304 bytes,   *      When used, the private pool is PRIVATE_MEM bytes long:  2304 bytes,
Line 136  THIS SOFTWARE.
Line 128  THIS SOFTWARE.
  *      conversions of IEEE doubles in single-threaded executions with   *      conversions of IEEE doubles in single-threaded executions with
  *      8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with   *      8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with
  *      4-byte pointers, PRIVATE_MEM >= 7112 appears adequate.   *      4-byte pointers, PRIVATE_MEM >= 7112 appears adequate.
  * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK   * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
  *      #defined automatically on IEEE systems.  On such systems,   *      Infinity and NaN (case insensitively).
  *      when INFNAN_CHECK is #defined, strtod checks  
  *      for Infinity and NaN (case insensitively).  
  *      When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,   *      When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
  *      strtodg also accepts (case insensitively) strings of the form   *      strtodg also accepts (case insensitively) strings of the form
  *      NaN(x), where x is a string of hexadecimal digits (optionally   *      NaN(x), where x is a string of hexadecimal digits and spaces;
  *      preceded by 0x or 0X) and spaces; if there is only one string   *      if there is only one string of hexadecimal digits, it is taken
  *      of hexadecimal digits, it is taken for the fraction bits of the   *      for the fraction bits of the resulting NaN; if there are two or
  *      resulting NaN; if there are two or more strings of hexadecimal   *      more strings of hexadecimal digits, each string is assigned
  *      digits, each string is assigned to the next available sequence   *      to the next available sequence of 32-bit words of fractions
  *      of 32-bit words of fractions bits (starting with the most   *      bits (starting with the most significant), right-aligned in
  *      significant), right-aligned in each sequence.   *      each sequence.
  *      Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)"  
  *      is consumed even when ... has the wrong form (in which case the  
  *      "(...)" is consumed but ignored).  
  * #define MULTIPLE_THREADS if the system offers preemptively scheduled   * #define MULTIPLE_THREADS if the system offers preemptively scheduled
  *      multiple threads.  In this case, you must provide (or suitably   *      multiple threads.  In this case, you must provide (or suitably
  *      #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed   *      #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
Line 163  THIS SOFTWARE.
Line 150  THIS SOFTWARE.
  *      dtoa.  You may do so whether or not MULTIPLE_THREADS is #defined.   *      dtoa.  You may do so whether or not MULTIPLE_THREADS is #defined.
  * #define IMPRECISE_INEXACT if you do not care about the setting of   * #define IMPRECISE_INEXACT if you do not care about the setting of
  *      the STRTOG_Inexact bits in the special case of doing IEEE double   *      the STRTOG_Inexact bits in the special case of doing IEEE double
  *      precision conversions (which could also be done by the strtod in   *      precision conversions (which could also be done by the strtog in
  *      dtoa.c).   *      dtoa.c).
  * #define NO_HEX_FP to disable recognition of C9x's hexadecimal   * #define NO_HEX_FP to disable recognition of C9x's hexadecimal
  *      floating-point constants.   *      floating-point constants.
Line 172  THIS SOFTWARE.
Line 159  THIS SOFTWARE.
  * #define NO_STRING_H to use private versions of memcpy.   * #define NO_STRING_H to use private versions of memcpy.
  *      On some K&R systems, it may also be necessary to   *      On some K&R systems, it may also be necessary to
  *      #define DECLARE_SIZE_T in this case.   *      #define DECLARE_SIZE_T in this case.
    * #define YES_ALIAS to permit aliasing certain double values with
    *      arrays of ULongs.  This leads to slightly better code with
    *      some compilers and was always used prior to 19990916, but it
    *      is not strictly legal and can cause trouble with aggressively
    *      optimizing compilers (e.g., gcc 2.95.1 under -O2).
  * #define USE_LOCALE to use the current locale's decimal_point value.   * #define USE_LOCALE to use the current locale's decimal_point value.
  */   */
   
   /* #define IEEE_{BIG,LITTLE}_ENDIAN in ${ARCHDIR}/gdtoa/arith.h */
   
   #include <stdint.h>
   #define Short   int16_t
   #define UShort uint16_t
   #define Long    int32_t
   #define ULong  uint32_t
   #define LLong   int64_t
   #define ULLong uint64_t
   
   #define INFNAN_CHECK
   #ifdef _REENTRANT
   #define MULTIPLE_THREADS
   #endif
   #define USE_LOCALE
   
 #ifndef GDTOAIMP_H_INCLUDED  #ifndef GDTOAIMP_H_INCLUDED
 #define GDTOAIMP_H_INCLUDED  #define GDTOAIMP_H_INCLUDED
 #include "gdtoa.h"  #include "gdtoa.h"
 #include "gd_qnan.h"  #include "gd_qnan.h"
 #ifdef Honor_FLT_ROUNDS  
 #include <fenv.h>  
 #endif  
   
 #ifdef DEBUG  #ifdef DEBUG
 #include "stdio.h"  #include "stdio.h"
Line 205  extern Char *MALLOC ANSI((size_t));
Line 210  extern Char *MALLOC ANSI((size_t));
   
 #undef IEEE_Arith  #undef IEEE_Arith
 #undef Avoid_Underflow  #undef Avoid_Underflow
 #ifdef IEEE_MC68k  #ifdef IEEE_BIG_ENDIAN
 #define IEEE_Arith  #define IEEE_Arith
 #endif  #endif
 #ifdef IEEE_8087  #ifdef IEEE_LITTLE_ENDIAN
 #define IEEE_Arith  #define IEEE_Arith
 #endif  #endif
   
Line 261  extern Char *MALLOC ANSI((size_t));
Line 266  extern Char *MALLOC ANSI((size_t));
 #define n_bigtens 2  #define n_bigtens 2
 #endif  #endif
   
 #ifndef __MATH_H__  
 #include "math.h"  #include "math.h"
 #endif  
   
 #ifdef __cplusplus  #ifdef __cplusplus
 extern "C" {  extern "C" {
 #endif  #endif
   
 #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1  #if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
 Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.  Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.
 #endif  #endif
   
 typedef union { double d; ULong L[2]; } U;  typedef union { double d; ULong L[2]; } U;
   
 #ifdef IEEE_8087  #ifdef YES_ALIAS
 #define word0(x) (x)->L[1]  #define dval(x) x
 #define word1(x) (x)->L[0]  #ifdef IEEE_LITTLE_ENDIAN
   #define word0(x) ((ULong *)&x)[1]
   #define word1(x) ((ULong *)&x)[0]
   #else
   #define word0(x) ((ULong *)&x)[0]
   #define word1(x) ((ULong *)&x)[1]
   #endif
   #else /* !YES_ALIAS */
   #ifdef IEEE_LITTLE_ENDIAN
   #define word0(x) ( /* LINTED */ (U*)&x)->L[1]
   #define word1(x) ( /* LINTED */ (U*)&x)->L[0]
 #else  #else
 #define word0(x) (x)->L[0]  #define word0(x) ( /* LINTED */ (U*)&x)->L[0]
 #define word1(x) (x)->L[1]  #define word1(x) ( /* LINTED */ (U*)&x)->L[1]
 #endif  #endif
 #define dval(x) (x)->d  #define dval(x) ( /* LINTED */ (U*)&x)->d
   #endif /* YES_ALIAS */
   
 /* The following definition of Storeinc is appropriate for MIPS processors.  /* The following definition of Storeinc is appropriate for MIPS processors.
  * An alternative that might be better on some machines is   * An alternative that might be better on some machines is
  * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)   * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
  */   */
 #if defined(IEEE_8087) + defined(VAX)  #if defined(IEEE_LITTLE_ENDIAN) + defined(VAX)
 #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \  #define Storeinc(a,b,c) \
 ((unsigned short *)a)[0] = (unsigned short)c, a++)   (((unsigned short *)(void *)a)[1] = (unsigned short)b, \
 #else    ((unsigned short *)(void *)a)[0] = (unsigned short)c, \
 #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \    a++)
 ((unsigned short *)a)[1] = (unsigned short)c, a++)  #else
   #define Storeinc(a,b,c) \
    (((unsigned short *)(void *)a)[0] = (unsigned short)b, \
     ((unsigned short *)(void *)a)[1] = (unsigned short)c, \
     a++)
 #endif  #endif
   
 /* #define P DBL_MANT_DIG */  /* #define P DBL_MANT_DIG */
Line 396  typedef union { double d; ULong L[2]; } 
Line 414  typedef union { double d; ULong L[2]; } 
   
 #ifndef IEEE_Arith  #ifndef IEEE_Arith
 #define ROUND_BIASED  #define ROUND_BIASED
 #else  
 #ifdef ROUND_BIASED_without_Round_Up  
 #undef  ROUND_BIASED  
 #define ROUND_BIASED  
 #endif  
 #endif  #endif
   
 #ifdef RND_PRODQUOT  #ifdef RND_PRODQUOT
Line 459  extern double rnd_prod(double, double), 
Line 472  extern double rnd_prod(double, double), 
 #ifndef MULTIPLE_THREADS  #ifndef MULTIPLE_THREADS
 #define ACQUIRE_DTOA_LOCK(n)    /*nothing*/  #define ACQUIRE_DTOA_LOCK(n)    /*nothing*/
 #define FREE_DTOA_LOCK(n)       /*nothing*/  #define FREE_DTOA_LOCK(n)       /*nothing*/
   #else
   #include "reentrant.h"
   
   extern mutex_t __gdtoa_locks[2];
   
   #define ACQUIRE_DTOA_LOCK(n)    \
           do {                                                    \
                   if (__isthreaded)                               \
                           mutex_lock(&__gdtoa_locks[n]);          \
           } while (/* CONSTCOND */ 0)
   #define FREE_DTOA_LOCK(n)       \
           do {                                                    \
                   if (__isthreaded)                               \
                           mutex_unlock(&__gdtoa_locks[n]);        \
           } while (/* CONSTCOND */ 0)
 #endif  #endif
   
 #define Kmax 9  #define Kmax 15
   
  struct   struct
 Bigint {  Bigint {
Line 482  extern void memcpy_D2A ANSI((void*, cons
Line 510  extern void memcpy_D2A ANSI((void*, cons
 #define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))  #define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
 #endif /* NO_STRING_H */  #endif /* NO_STRING_H */
   
 #define Balloc Balloc_D2A  #define Balloc          __Balloc_D2A
 #define Bfree Bfree_D2A  #define Bfree           __Bfree_D2A
 #define ULtoQ ULtoQ_D2A  #define ULtoQ           __ULtoQ_D2A
 #define ULtof ULtof_D2A  #define ULtof           __ULtof_D2A
 #define ULtod ULtod_D2A  #define ULtod           __ULtod_D2A
 #define ULtodd ULtodd_D2A  #define ULtodd          __ULtodd_D2A
 #define ULtox ULtox_D2A  #define ULtox           __ULtox_D2A
 #define ULtoxL ULtoxL_D2A  #define ULtoxL          __ULtoxL_D2A
 #define any_on any_on_D2A  #define any_on          __any_on_D2A
 #define b2d b2d_D2A  #define b2d             __b2d_D2A
 #define bigtens bigtens_D2A  #define bigtens         __bigtens_D2A
 #define cmp cmp_D2A  #define cmp             __cmp_D2A
 #define copybits copybits_D2A  #define copybits        __copybits_D2A
 #define d2b d2b_D2A  #define d2b             __d2b_D2A
 #define decrement decrement_D2A  #define decrement       __decrement_D2A
 #define diff diff_D2A  #define diff            __diff_D2A
 #define dtoa_result dtoa_result_D2A  #define dtoa_result     __dtoa_result_D2A
 #define g__fmt g__fmt_D2A  #define g__fmt          __g__fmt_D2A
 #define gethex gethex_D2A  #define gethex          __gethex_D2A
 #define hexdig hexdig_D2A  #define hexdig          __hexdig_D2A
 #define hexnan hexnan_D2A  #define hexdig_init_D2A __hexdig_init_D2A
 #define hi0bits(x) hi0bits_D2A((ULong)(x))  #define hexnan          __hexnan_D2A
 #define i2b i2b_D2A  #define hi0bits         __hi0bits_D2A
 #define increment increment_D2A  #define hi0bits_D2A     __hi0bits_D2A
 #define lo0bits lo0bits_D2A  #define i2b             __i2b_D2A
 #define lshift lshift_D2A  #define increment       __increment_D2A
 #define match match_D2A  #define lo0bits         __lo0bits_D2A
 #define mult mult_D2A  #define lshift          __lshift_D2A
 #define multadd multadd_D2A  #define match           __match_D2A
 #define nrv_alloc nrv_alloc_D2A  #define mult            __mult_D2A
 #define pow5mult pow5mult_D2A  #define multadd         __multadd_D2A
 #define quorem quorem_D2A  #define nrv_alloc       __nrv_alloc_D2A
 #define ratio ratio_D2A  #define pow5mult        __pow5mult_D2A
 #define rshift rshift_D2A  #define quorem          __quorem_D2A
 #define rv_alloc rv_alloc_D2A  #define ratio           __ratio_D2A
 #define s2b s2b_D2A  #define rshift          __rshift_D2A
 #define set_ones set_ones_D2A  #define rv_alloc        __rv_alloc_D2A
 #define strcp strcp_D2A  #define s2b             __s2b_D2A
 #define strtoIg strtoIg_D2A  #define set_ones        __set_ones_D2A
 #define sum sum_D2A  #define strcp           __strcp_D2A
 #define tens tens_D2A  #define strcp_D2A       __strcp_D2A
 #define tinytens tinytens_D2A  #define strtoIg         __strtoIg_D2A
 #define tinytens tinytens_D2A  #define sum             __sum_D2A
 #define trailz trailz_D2A  #define tens            __tens_D2A
 #define ulp ulp_D2A  #define tinytens        __tinytens_D2A
   #define tinytens        __tinytens_D2A
   #define trailz          __trailz_D2A
   #define ulp             __ulp_D2A
   
  extern char *dtoa_result;   extern char *dtoa_result;
  extern CONST double bigtens[], tens[], tinytens[];   extern CONST double bigtens[], tens[], tinytens[];
Line 545  extern void memcpy_D2A ANSI((void*, cons
Line 576  extern void memcpy_D2A ANSI((void*, cons
  extern int cmp ANSI((Bigint*, Bigint*));   extern int cmp ANSI((Bigint*, Bigint*));
  extern void copybits ANSI((ULong*, int, Bigint*));   extern void copybits ANSI((ULong*, int, Bigint*));
  extern Bigint *d2b ANSI((double, int*, int*));   extern Bigint *d2b ANSI((double, int*, int*));
  extern void decrement ANSI((Bigint*));   extern int decrement ANSI((Bigint*));
  extern Bigint *diff ANSI((Bigint*, Bigint*));   extern Bigint *diff ANSI((Bigint*, Bigint*));
  extern char *dtoa ANSI((double d, int mode, int ndigits,   extern char *dtoa ANSI((double d, int mode, int ndigits,
                         int *decpt, int *sign, char **rve));                          int *decpt, int *sign, char **rve));
  extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t));   extern char *g__fmt ANSI((char*, char*, char*, int, ULong));
  extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int));   extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int));
  extern void hexdig_init_D2A(Void);   extern void hexdig_init_D2A(Void);
  extern int hexnan ANSI((CONST char**, FPI*, ULong*));   extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*));
  extern int hi0bits_D2A ANSI((ULong));   extern int hi0bits_D2A ANSI((ULong));
  extern Bigint *i2b ANSI((int));   extern Bigint *i2b ANSI((int));
  extern Bigint *increment ANSI((Bigint*));   extern Bigint *increment ANSI((Bigint*));
  extern int lo0bits ANSI((ULong*));   extern int lo0bits ANSI((ULong*));
  extern Bigint *lshift ANSI((Bigint*, int));   extern Bigint *lshift ANSI((Bigint*, int));
  extern int match ANSI((CONST char**, char*));   extern int match ANSI((CONST char**, CONST char*));
  extern Bigint *mult ANSI((Bigint*, Bigint*));   extern Bigint *mult ANSI((Bigint*, Bigint*));
  extern Bigint *multadd ANSI((Bigint*, int, int));   extern Bigint *multadd ANSI((Bigint*, int, int));
  extern char *nrv_alloc ANSI((char*, char **, int));   extern char *nrv_alloc ANSI((CONST char*, char **, size_t));
  extern Bigint *pow5mult ANSI((Bigint*, int));   extern Bigint *pow5mult ANSI((Bigint*, int));
  extern int quorem ANSI((Bigint*, Bigint*));   extern int quorem ANSI((Bigint*, Bigint*));
  extern double ratio ANSI((Bigint*, Bigint*));   extern double ratio ANSI((Bigint*, Bigint*));
  extern void rshift ANSI((Bigint*, int));   extern void rshift ANSI((Bigint*, int));
  extern char *rv_alloc ANSI((int));   extern char *rv_alloc ANSI((size_t));
  extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int));   extern Bigint *s2b ANSI((CONST char*, int, int, ULong));
  extern Bigint *set_ones ANSI((Bigint*, int));   extern Bigint *set_ones ANSI((Bigint*, int));
  extern char *strcp ANSI((char*, const char*));   extern char *strcp ANSI((char*, const char*));
  extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*));   extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*));
  extern double strtod ANSI((const char *s00, char **se));   extern double strtod ANSI((const char *s00, char **se));
  extern Bigint *sum ANSI((Bigint*, Bigint*));   extern Bigint *sum ANSI((Bigint*, Bigint*));
  extern int trailz ANSI((Bigint*));   extern int trailz ANSI((CONST Bigint*));
  extern double ulp ANSI((U*));   extern double ulp ANSI((double));
   
 #ifdef __cplusplus  #ifdef __cplusplus
 }  }
Line 589  extern void memcpy_D2A ANSI((void*, cons
Line 620  extern void memcpy_D2A ANSI((void*, cons
  * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)   * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
  */   */
 #ifdef IEEE_Arith  #ifdef IEEE_Arith
 #ifndef NO_INFNAN_CHECK  #ifdef IEEE_BIG_ENDIAN
 #undef INFNAN_CHECK  
 #define INFNAN_CHECK  
 #endif  
 #ifdef IEEE_MC68k  
 #define _0 0  #define _0 0
 #define _1 1  #define _1 1
 #ifndef NAN_WORD0  #ifndef NAN_WORD0

Legend:
Removed from v.1.1.1.2  
changed lines
  Added in v.1.6

CVSweb <webmaster@jp.NetBSD.org>