Rev 4921 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4921 | Rev 6099 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | */ |
29 | */ |
Line 30... | Line 30... | ||
30 | 30 | ||
31 | #include |
31 | #include |
Line -... | Line 32... | ||
- | 32 | #include "local.h" |
|
- | 33 | ||
- | 34 | #ifdef _HAVE_LONG_DOUBLE |
|
- | 35 | ||
- | 36 | #if defined (__x86_64__) || defined (__i386__) |
|
- | 37 | static const int map[] = { |
|
- | 38 | 1, /* round to nearest */ |
|
32 | #include "local.h" |
39 | 3, /* round to zero */ |
- | 40 | 2, /* round to negative infinity */ |
|
- | 41 | 0 /* round to positive infinity */ |
|
- | 42 | }; |
|
- | 43 | ||
- | 44 | int |
|
- | 45 | __flt_rounds(void) |
|
- | 46 | { |
|
- | 47 | int x; |
|
- | 48 | ||
- | 49 | /* Assume that the x87 and the SSE unit agree on the rounding mode. */ |
|
- | 50 | __asm("fnstcw %0" : "=m" (x)); |
|
- | 51 | return (map[(x >> 10) & 0x03]); |
|
- | 52 | } |
|
- | 53 | #define FLT_ROUNDS __flt_rounds() |
|
- | 54 | #else |
|
- | 55 | #define FLT_ROUNDS 0 |
|
- | 56 | #endif |
|
- | 57 | ||
- | 58 | long double |
|
- | 59 | _strtold_r (struct _reent *ptr, const char *__restrict s00, |
|
33 | 60 | char **__restrict se) |
|
- | 61 | { |
|
- | 62 | #ifdef _LDBL_EQ_DBL |
|
- | 63 | /* On platforms where long double is as wide as double. */ |
|
- | 64 | return _strtod_r (ptr, s00, se); |
|
- | 65 | #else |
|
- | 66 | long double result; |
|
- | 67 | ||
- | 68 | _strtorx_r (ptr, s00, se, FLT_ROUNDS, &result); |
|
- | 69 | return result; |
|
- | 70 | #endif |
|
34 | /* On platforms where long double is as wide as double. */ |
71 | } |
35 | #ifdef _LDBL_EQ_DBL |
72 | |
36 | long double |
73 | long double |
37 | strtold (const char *__restrict s00, char **__restrict se) |
74 | strtold (const char *__restrict s00, char **__restrict se) |
38 | { |
75 | { |
- | 76 | return _strtold_r (_REENT, s00, se); |
|
39 | return strtod(s00, se); |
77 | } |