1 /**************************************************************** 2 3 The author of this software is David M. Gay. 4 5 Copyright (C) 1998 by Lucent Technologies 6 All Rights Reserved 7 8 Permission to use, copy, modify, and distribute this software and 9 its documentation for any purpose and without fee is hereby 10 granted, provided that the above copyright notice appear in all 11 copies and that both that the copyright notice and this 12 permission notice and warranty disclaimer appear in supporting 13 documentation, and that the name of Lucent or any of its entities 14 not be used in advertising or publicity pertaining to 15 distribution of the software without specific, written prior 16 permission. 17 18 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25 THIS SOFTWARE. 26 27 ****************************************************************/ 28 29 /* Please send bug reports to David M. Gay (dmg at acm dot org, 30 * with " at " changed at "@" and " dot " changed to "."). */ 31 32 #ifndef GDTOA_H_INCLUDED 33 #define GDTOA_H_INCLUDED 34 35 #if defined(_MSC_VER) 36 /* [RH] Generating arith.h strikes me as too cumbersome under Visual 37 * Studio, so here's the equivalent, given the limited number of 38 * architectures that MSC can target. (Itanium? Who cares about that?) 39 */ 40 #define IEEE_8087 41 #define Arith_Kind_ASL 1 42 #define Double_Align 43 #ifdef _M_X64 44 #define X64_bit_pointers 45 #endif 46 #elif defined(__APPLE__) 47 /* [BL] While generating the files may be easy, on OS X we have cross 48 * compiling to deal with, which means we can't run the generation 49 * program on the target. 50 */ 51 #if defined(__x86_64__) 52 #define IEEE_8087 53 #define Arith_Kind_ASL 1 54 #define Long int 55 #define Intcast (int)(long) 56 #define Double_Align 57 #define X64_bit_pointers 58 #elif defined(__i386__) 59 #define IEEE_8087 60 #define Arith_Kind_ASL 1 61 #else 62 #define IEEE_MC68k 63 #define Arith_Kind_ASL 2 64 #define Double_Align 65 #endif 66 #elif defined(__ANDROID__) 67 // [BL] Android is also cross compiled. 68 #define IEEE_8087 69 #define Arith_Kind_ASL 1 70 #else 71 #include "arith.h" 72 #endif 73 #include <stddef.h> /* for size_t */ 74 75 #ifndef Long 76 #define Long int 77 #endif 78 #ifndef ULong 79 typedef unsigned Long ULong; 80 #endif 81 #ifndef UShort 82 typedef unsigned short UShort; 83 #endif 84 85 #ifndef ANSI 86 #ifdef KR_headers 87 #define ANSI(x) () 88 #define Void /*nothing*/ 89 #else 90 #define ANSI(x) x 91 #define Void void 92 #endif 93 #endif /* ANSI */ 94 95 #ifndef CONST 96 #ifdef KR_headers 97 #define CONST /* blank */ 98 #else 99 #define CONST const 100 #endif 101 #endif /* CONST */ 102 103 enum { /* return values from strtodg */ 104 STRTOG_Zero = 0, 105 STRTOG_Normal = 1, 106 STRTOG_Denormal = 2, 107 STRTOG_Infinite = 3, 108 STRTOG_NaN = 4, 109 STRTOG_NaNbits = 5, 110 STRTOG_NoNumber = 6, 111 STRTOG_Retmask = 7, 112 113 /* The following may be or-ed into one of the above values. */ 114 115 STRTOG_Neg = 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ 116 STRTOG_Inexlo = 0x10, /* returned result rounded toward zero */ 117 STRTOG_Inexhi = 0x20, /* returned result rounded away from zero */ 118 STRTOG_Inexact = 0x30, 119 STRTOG_Underflow= 0x40, 120 STRTOG_Overflow = 0x80 121 }; 122 123 typedef struct 124 FPI { 125 int nbits; 126 int emin; 127 int emax; 128 int rounding; 129 int sudden_underflow; 130 int int_max; 131 } FPI; 132 133 enum { /* FPI.rounding values: same as FLT_ROUNDS */ 134 FPI_Round_zero = 0, 135 FPI_Round_near = 1, 136 FPI_Round_up = 2, 137 FPI_Round_down = 3 138 }; 139 140 #ifdef __cplusplus 141 extern "C" { 142 #endif 143 144 extern char* dtoa ANSI((double d, int mode, int ndigits, int *decpt, 145 int *sign, char **rve)); 146 extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, 147 int mode, int ndigits, int *decpt, char **rve)); 148 extern void freedtoa ANSI((char*)); 149 //extern float strtof ANSI((CONST char *, char **)); 150 //extern double strtod ANSI((CONST char *, char **)); 151 extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*)); 152 153 extern char* g_ddfmt ANSI((char*, double*, int, size_t)); 154 extern char* g_ddfmt_p ANSI((char*, double*, int, size_t, int)); 155 extern char* g_dfmt ANSI((char*, double*, int, size_t)); 156 extern char* g_dfmt_p ANSI((char*, double*, int, size_t, int)); 157 extern char* g_ffmt ANSI((char*, float*, int, size_t)); 158 extern char* g_ffmt_p ANSI((char*, float*, int, size_t, int)); 159 extern char* g_Qfmt ANSI((char*, void*, int, size_t)); 160 extern char* g_Qfmt_p ANSI((char*, void*, int, size_t, int)); 161 extern char* g_xfmt ANSI((char*, void*, int, size_t)); 162 extern char* g_xfmt_p ANSI((char*, void*, int, size_t, int)); 163 extern char* g_xLfmt ANSI((char*, void*, int, size_t)); 164 extern char* g_xLfmt_p ANSI((char*, void*, int, size_t, int)); 165 166 extern int strtoId ANSI((CONST char*, char**, double*, double*)); 167 extern int strtoIdd ANSI((CONST char*, char**, double*, double*)); 168 extern int strtoIf ANSI((CONST char*, char**, float*, float*)); 169 extern int strtoIQ ANSI((CONST char*, char**, void*, void*)); 170 extern int strtoIx ANSI((CONST char*, char**, void*, void*)); 171 extern int strtoIxL ANSI((CONST char*, char**, void*, void*)); 172 extern int strtord ANSI((CONST char*, char**, int, double*)); 173 extern int strtordd ANSI((CONST char*, char**, int, double*)); 174 extern int strtorf ANSI((CONST char*, char**, int, float*)); 175 extern int strtorQ ANSI((CONST char*, char**, int, void*)); 176 extern int strtorx ANSI((CONST char*, char**, int, void*)); 177 extern int strtorxL ANSI((CONST char*, char**, int, void*)); 178 #if 1 179 extern int strtodI ANSI((CONST char*, char**, double*)); 180 extern int strtopd ANSI((CONST char*, char**, double*)); 181 extern int strtopdd ANSI((CONST char*, char**, double*)); 182 extern int strtopf ANSI((CONST char*, char**, float*)); 183 extern int strtopQ ANSI((CONST char*, char**, void*)); 184 extern int strtopx ANSI((CONST char*, char**, void*)); 185 extern int strtopxL ANSI((CONST char*, char**, void*)); 186 #else 187 #define strtopd(s,se,x) strtord(s,se,1,x) 188 #define strtopdd(s,se,x) strtordd(s,se,1,x) 189 #define strtopf(s,se,x) strtorf(s,se,1,x) 190 #define strtopQ(s,se,x) strtorQ(s,se,1,x) 191 #define strtopx(s,se,x) strtorx(s,se,1,x) 192 #define strtopxL(s,se,x) strtorxL(s,se,1,x) 193 #endif 194 195 #ifdef __cplusplus 196 } 197 #endif 198 #endif /* GDTOA_H_INCLUDED */ 199