]>
Commit | Line | Data |
---|---|---|
3d9156a7 A |
1 | --- gdtoaimp.h.orig 2005-01-20 20:12:37.000000000 -0800 |
2 | +++ gdtoaimp.h 2005-02-17 02:10:26.000000000 -0800 | |
3 | @@ -167,6 +167,7 @@ | |
4 | ||
5 | #ifndef GDTOAIMP_H_INCLUDED | |
6 | #define GDTOAIMP_H_INCLUDED | |
7 | +#include <xlocale.h> | |
8 | #include "gdtoa.h" | |
9 | #include "gd_qnan.h" | |
10 | ||
11 | @@ -175,8 +176,11 @@ | |
12 | #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} | |
13 | #endif | |
14 | ||
15 | +#include "limits.h" | |
16 | #include "stdlib.h" | |
17 | #include "string.h" | |
18 | +#include "libc_private.h" | |
19 | +#include "spinlock.h" | |
20 | ||
21 | #ifdef KR_headers | |
22 | #define Char char | |
23 | @@ -190,6 +194,9 @@ | |
24 | #define MALLOC malloc | |
25 | #endif | |
26 | ||
27 | +#define INFNAN_CHECK | |
28 | +#define USE_LOCALE | |
29 | + | |
30 | #undef IEEE_Arith | |
31 | #undef Avoid_Underflow | |
32 | #ifdef IEEE_MC68k | |
33 | @@ -449,10 +456,16 @@ | |
34 | #define ALL_ON 0xffff | |
35 | #endif | |
36 | ||
37 | -#ifndef MULTIPLE_THREADS | |
38 | -#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ | |
39 | -#define FREE_DTOA_LOCK(n) /*nothing*/ | |
40 | -#endif | |
41 | +#define MULTIPLE_THREADS | |
42 | +extern spinlock_t __gdtoa_locks[2]; | |
43 | +#define ACQUIRE_DTOA_LOCK(n) do { \ | |
44 | + if (__isthreaded) \ | |
45 | + _SPINLOCK(&__gdtoa_locks[n]); \ | |
46 | +} while(0) | |
47 | +#define FREE_DTOA_LOCK(n) do { \ | |
48 | + if (__isthreaded) \ | |
49 | + _SPINUNLOCK(&__gdtoa_locks[n]); \ | |
50 | +} while(0) | |
51 | ||
52 | #define Kmax 15 | |
53 | ||
54 | @@ -475,51 +488,89 @@ | |
55 | #define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) | |
56 | #endif /* NO_STRING_H */ | |
57 | ||
58 | -#define Balloc Balloc_D2A | |
59 | -#define Bfree Bfree_D2A | |
60 | -#define ULtoQ ULtoQ_D2A | |
61 | -#define ULtof ULtof_D2A | |
62 | -#define ULtod ULtod_D2A | |
63 | -#define ULtodd ULtodd_D2A | |
64 | -#define ULtox ULtox_D2A | |
65 | -#define ULtoxL ULtoxL_D2A | |
66 | -#define any_on any_on_D2A | |
67 | -#define b2d b2d_D2A | |
68 | -#define bigtens bigtens_D2A | |
69 | -#define cmp cmp_D2A | |
70 | -#define copybits copybits_D2A | |
71 | -#define d2b d2b_D2A | |
72 | -#define decrement decrement_D2A | |
73 | -#define diff diff_D2A | |
74 | -#define dtoa_result dtoa_result_D2A | |
75 | -#define g__fmt g__fmt_D2A | |
76 | -#define gethex gethex_D2A | |
77 | -#define hexdig hexdig_D2A | |
78 | -#define hexnan hexnan_D2A | |
79 | -#define hi0bits(x) hi0bits_D2A((ULong)(x)) | |
80 | -#define i2b i2b_D2A | |
81 | -#define increment increment_D2A | |
82 | -#define lo0bits lo0bits_D2A | |
83 | -#define lshift lshift_D2A | |
84 | -#define match match_D2A | |
85 | -#define mult mult_D2A | |
86 | -#define multadd multadd_D2A | |
87 | -#define nrv_alloc nrv_alloc_D2A | |
88 | -#define pow5mult pow5mult_D2A | |
89 | -#define quorem quorem_D2A | |
90 | -#define ratio ratio_D2A | |
91 | -#define rshift rshift_D2A | |
92 | -#define rv_alloc rv_alloc_D2A | |
93 | -#define s2b s2b_D2A | |
94 | -#define set_ones set_ones_D2A | |
95 | -#define strcp strcp_D2A | |
96 | -#define strtoIg strtoIg_D2A | |
97 | -#define sum sum_D2A | |
98 | -#define tens tens_D2A | |
99 | -#define tinytens tinytens_D2A | |
100 | -#define tinytens tinytens_D2A | |
101 | -#define trailz trailz_D2A | |
102 | -#define ulp ulp_D2A | |
103 | +/* | |
104 | + * Paranoia: Protect exported symbols, including ones in files we don't | |
105 | + * compile right now. The standard strtof and strtod survive. | |
106 | + */ | |
107 | +#define dtoa __dtoa | |
108 | +#define gdtoa __gdtoa | |
109 | +#define freedtoa __freedtoa | |
110 | +#define strtodg __strtodg | |
111 | +#define g_ddfmt __g_ddfmt | |
112 | +#define g_dfmt __g_dfmt | |
113 | +#define g_ffmt __g_ffmt | |
114 | +#define g_Qfmt __g_Qfmt | |
115 | +#define g_xfmt __g_xfmt | |
116 | +#define g_xLfmt __g_xLfmt | |
117 | +#define strtoId __strtoId | |
118 | +#define strtoIdd __strtoIdd | |
119 | +#define strtoIf __strtoIf | |
120 | +#define strtoIQ __strtoIQ | |
121 | +#define strtoIx __strtoIx | |
122 | +#define strtoIxL __strtoIxL | |
123 | +#define strtord __strtord | |
124 | +#define strtordd __strtordd | |
125 | +#define strtorf __strtorf | |
126 | +#define strtorQ __strtorQ | |
127 | +#define strtorx __strtorx | |
128 | +#define strtorxL __strtorxL | |
129 | +#define strtodI __strtodI | |
130 | +#define strtopd __strtopd | |
131 | +#define strtopdd __strtopdd | |
132 | +#define strtopf __strtopf | |
133 | +#define strtopQ __strtopQ | |
134 | +#define strtopx __strtopx | |
135 | +#define strtopxL __strtopxL | |
136 | + | |
137 | +/* Protect gdtoa-internal symbols */ | |
138 | +#define Balloc __Balloc_D2A | |
139 | +#define Bfree __Bfree_D2A | |
140 | +#define ULtoQ __ULtoQ_D2A | |
141 | +#define ULtof __ULtof_D2A | |
142 | +#define ULtod __ULtod_D2A | |
143 | +#define ULtodd __ULtodd_D2A | |
144 | +#define ULtox __ULtox_D2A | |
145 | +#define ULtoxL __ULtoxL_D2A | |
146 | +#define any_on __any_on_D2A | |
147 | +#define b2d __b2d_D2A | |
148 | +#define bigtens __bigtens_D2A | |
149 | +#define cmp __cmp_D2A | |
150 | +#define copybits __copybits_D2A | |
151 | +#define d2b __d2b_D2A | |
152 | +#define decrement __decrement_D2A | |
153 | +#define diff __diff_D2A | |
154 | +#define dtoa_result __dtoa_result_D2A | |
155 | +#define g__fmt __g__fmt_D2A | |
156 | +#define gethex __gethex_D2A | |
157 | +#define hexdig __hexdig_D2A | |
158 | +#define hexdig_init_D2A __hexdig_init_D2A | |
159 | +#define hexnan __hexnan_D2A | |
160 | +#define hi0bits __hi0bits_D2A | |
161 | +#define hi0bits_D2A __hi0bits_D2A | |
162 | +#define i2b __i2b_D2A | |
163 | +#define increment __increment_D2A | |
164 | +#define lo0bits __lo0bits_D2A | |
165 | +#define lshift __lshift_D2A | |
166 | +#define match __match_D2A | |
167 | +#define mult __mult_D2A | |
168 | +#define multadd __multadd_D2A | |
169 | +#define nrv_alloc __nrv_alloc_D2A | |
170 | +#define pow5mult __pow5mult_D2A | |
171 | +#define quorem __quorem_D2A | |
172 | +#define ratio __ratio_D2A | |
173 | +#define rshift __rshift_D2A | |
174 | +#define rv_alloc __rv_alloc_D2A | |
175 | +#define s2b __s2b_D2A | |
176 | +#define set_ones __set_ones_D2A | |
177 | +#define strcp __strcp_D2A | |
178 | +#define strcp_D2A __strcp_D2A | |
179 | +#define strtoIg __strtoIg_D2A | |
180 | +#define sum __sum_D2A | |
181 | +#define tens __tens_D2A | |
182 | +#define tinytens __tinytens_D2A | |
183 | +#define tinytens __tinytens_D2A | |
184 | +#define trailz __trailz_D2A | |
185 | +#define ulp __ulp_D2A | |
186 | ||
187 | extern char *dtoa_result; | |
188 | extern CONST double bigtens[], tens[], tinytens[]; | |
189 | @@ -542,8 +593,11 @@ | |
190 | extern Bigint *diff ANSI((Bigint*, Bigint*)); | |
191 | extern char *dtoa ANSI((double d, int mode, int ndigits, | |
192 | int *decpt, int *sign, char **rve)); | |
193 | + extern void freedtoa ANSI((char*)); | |
194 | + extern char *gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, | |
195 | + int mode, int ndigits, int *decpt, char **rve)); | |
196 | extern char *g__fmt ANSI((char*, char*, char*, int, ULong)); | |
197 | - extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int)); | |
198 | + extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int, locale_t)); | |
199 | extern void hexdig_init_D2A(Void); | |
200 | extern int hexnan ANSI((CONST char**, FPI*, ULong*)); | |
201 | extern int hi0bits_D2A ANSI((ULong)); | |
202 | @@ -563,8 +617,29 @@ | |
203 | extern Bigint *s2b ANSI((CONST char*, int, int, ULong)); | |
204 | extern Bigint *set_ones ANSI((Bigint*, int)); | |
205 | extern char *strcp ANSI((char*, const char*)); | |
206 | + extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*, locale_t)); | |
207 | + | |
208 | + extern int strtoId ANSI((CONST char *, char **, double *, double *)); | |
209 | + extern int strtoIdd ANSI((CONST char *, char **, double *, double *)); | |
210 | + extern int strtoIf ANSI((CONST char *, char **, float *, float *)); | |
211 | extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); | |
212 | + extern int strtoIQ ANSI((CONST char *, char **, void *, void *)); | |
213 | + extern int strtoIx ANSI((CONST char *, char **, void *, void *)); | |
214 | + extern int strtoIxL ANSI((CONST char *, char **, void *, void *)); | |
215 | extern double strtod ANSI((const char *s00, char **se)); | |
216 | + extern double strtod_l ANSI((const char *s00, char **se, locale_t)); | |
217 | + extern int strtopQ ANSI((CONST char *, char **, Void *)); | |
218 | + extern int strtopf ANSI((CONST char *, char **, float *)); | |
219 | + extern int strtopd ANSI((CONST char *, char **, double *)); | |
220 | + extern int strtopdd ANSI((CONST char *, char **, double *, locale_t)); | |
221 | + extern int strtopx ANSI((CONST char *, char **, Void *, locale_t)); | |
222 | + extern int strtopxL ANSI((CONST char *, char **, Void *)); | |
223 | + extern int strtord ANSI((CONST char *, char **, int, double *)); | |
224 | + extern int strtordd ANSI((CONST char *, char **, int, double *)); | |
225 | + extern int strtorf ANSI((CONST char *, char **, int, float *)); | |
226 | + extern int strtorQ ANSI((CONST char *, char **, int, void *)); | |
227 | + extern int strtorx ANSI((CONST char *, char **, int, void *)); | |
228 | + extern int strtorxL ANSI((CONST char *, char **, int, void *)); | |
229 | extern Bigint *sum ANSI((Bigint*, Bigint*)); | |
230 | extern int trailz ANSI((Bigint*)); | |
231 | extern double ulp ANSI((double)); |