]> git.saurik.com Git - apple/libc.git/blob - gdtoa/FreeBSD/gdtoa_strtopx.c.patch
Libc-498.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / gdtoa_strtopx.c.patch
1 --- gdtoa_strtopx.c.orig 2007-04-03 12:19:28.000000000 -0700
2 +++ gdtoa_strtopx.c 2007-04-06 12:52:09.000000000 -0700
3 @@ -29,6 +29,8 @@
4 /* Please send bug reports to David M. Gay (dmg at acm dot org,
5 * with " at " changed at "@" and " dot " changed to "."). */
6
7 +#include "xlocale_private.h"
8 +
9 #include "gdtoaimp.h"
10
11 #undef _0
12 @@ -53,20 +55,34 @@
13
14 int
15 #ifdef KR_headers
16 -strtopx(s, sp, V) CONST char *s; char **sp; void *V;
17 +strtopx(s, sp, V, loc) CONST char *s; char **sp; void *V; locale_t loc;
18 #else
19 -strtopx(CONST char *s, char **sp, void *V)
20 +strtopx(CONST char *s, char **sp, void *V, locale_t loc)
21 #endif
22 {
23 - static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
24 + static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
25 ULong bits[2];
26 Long exp;
27 int k;
28 UShort *L = (UShort*)V;
29 + FPI *fpi = &fpi0, fpi1;
30 +#ifdef Honor_FLT_ROUNDS
31 + int rounding = Flt_Rounds;
32 +#endif
33
34 - k = strtodg(s, sp, &fpi, &exp, bits);
35 +#ifdef Honor_FLT_ROUNDS
36 + if (rounding != fpi0.rounding) {
37 + fpi1 = fpi0; /* for thread safety */
38 + fpi1.rounding = rounding;
39 + fpi = &fpi1;
40 + }
41 +#endif /* Honor_FLT_ROUNDS */
42 + k = strtodg(s, sp, fpi, &exp, bits, loc);
43 switch(k & STRTOG_Retmask) {
44 case STRTOG_NoNumber:
45 + L[0] = L[1] = L[2] = L[3] = L[4] = 0;
46 + return k; // avoid setting sign
47 +
48 case STRTOG_Zero:
49 L[0] = L[1] = L[2] = L[3] = L[4] = 0;
50 break;
51 @@ -87,7 +103,8 @@
52
53 case STRTOG_Infinite:
54 L[_0] = 0x7fff;
55 - L[_1] = L[_2] = L[_3] = L[_4] = 0;
56 + L[_1] = 0x8000; /* 4306392: to match gcc */
57 + L[_2] = L[_3] = L[_4] = 0;
58 break;
59
60 case STRTOG_NaN: