strtod.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /* Copyright (C) 2000, 2003 Manuel Novoa III
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Library General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Library General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Library General Public
  14. * License along with this library; if not, write to the Free
  15. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. /* Notes:
  18. *
  19. * The primary objective of this implementation was minimal size and
  20. * portablility, while providing robustness and resonable accuracy.
  21. *
  22. * This implementation depends on IEEE floating point behavior and expects
  23. * to be able to generate +/- infinity as a result.
  24. *
  25. * There are a number of compile-time options below.
  26. */
  27. /* July 27, 2003
  28. *
  29. * General cleanup and some minor size optimizations.
  30. * Change implementation to support __strtofpmax() rather than strtod().
  31. * Now all the strto{floating pt}() funcs are implemented in terms of
  32. * of the internal __strtofpmax() function.
  33. * Support "nan", "inf", and "infinity" strings (case-insensitive).
  34. * Support hexadecimal floating point notation.
  35. * Support wchar variants.
  36. * Support xlocale variants.
  37. *
  38. * TODO:
  39. *
  40. * Consider accumulating blocks of digits in longs to save floating pt mults.
  41. * This would likely be much better on anything that only supported floats
  42. * where DECIMAL_DIG == 9. Actually, if floats have FLT_MAX_10_EXP == 38,
  43. * we could calculate almost all the exponent multipliers (p_base) in
  44. * long arithmetic as well.
  45. */
  46. /**********************************************************************/
  47. /* OPTIONS */
  48. /**********************************************************************/
  49. /* Defined if we want to recognize "nan", "inf", and "infinity". (C99) */
  50. #define _STRTOD_NAN_INF_STRINGS 1
  51. /* Defined if we want support hexadecimal floating point notation. (C99) */
  52. /* Note! Now controlled by uClibc configuration. See below. */
  53. #define _STRTOD_HEXADECIMAL_FLOATS 1
  54. /* Defined if we want to scale with a O(log2(exp)) multiplications.
  55. * This is generally a good thing to do unless you are really tight
  56. * on space and do not expect to convert values of large magnitude. */
  57. #define _STRTOD_LOG_SCALING 1
  58. /* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
  59. *
  60. * Clearing any of the options below this point is not advised (or tested).
  61. *
  62. * WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! */
  63. /* Defined if we want strtod to set errno appropriately. */
  64. /* NOTE: Implies all options below. */
  65. #define _STRTOD_ERRNO 1
  66. /* Defined if we want support for the endptr arg. */
  67. /* Implied by _STRTOD_ERRNO. */
  68. #define _STRTOD_ENDPTR 1
  69. /* Defined if we want to prevent overflow in accumulating the exponent. */
  70. /* Implied by _STRTOD_ERRNO. */
  71. #define _STRTOD_RESTRICT_EXP 1
  72. /* Defined if we want to process mantissa digits more intelligently. */
  73. /* Implied by _STRTOD_ERRNO. */
  74. #define _STRTOD_RESTRICT_DIGITS 1
  75. /* Defined if we want to skip scaling 0 for the exponent. */
  76. /* Implied by _STRTOD_ERRNO. */
  77. #define _STRTOD_ZERO_CHECK 1
  78. /**********************************************************************/
  79. /* Don't change anything that follows. */
  80. /**********************************************************************/
  81. #ifdef _STRTOD_ERRNO
  82. #undef _STRTOD_ENDPTR
  83. #undef _STRTOD_RESTRICT_EXP
  84. #undef _STRTOD_RESTRICT_DIGITS
  85. #undef _STRTOD_ZERO_CHECK
  86. #define _STRTOD_ENDPTR 1
  87. #define _STRTOD_RESTRICT_EXP 1
  88. #define _STRTOD_RESTRICT_DIGITS 1
  89. #define _STRTOD_ZERO_CHECK 1
  90. #endif
  91. /**********************************************************************/
  92. #define _ISOC99_SOURCE 1
  93. #define _GNU_SOURCE
  94. #include <stdlib.h>
  95. #include <string.h>
  96. #include <ctype.h>
  97. #include <errno.h>
  98. #include <limits.h>
  99. #include <float.h>
  100. #include <bits/uClibc_fpmax.h>
  101. #include <locale.h>
  102. #ifdef __UCLIBC_HAS_WCHAR__
  103. #include <wchar.h>
  104. #include <wctype.h>
  105. #include <bits/uClibc_uwchar.h>
  106. #endif
  107. #ifdef __UCLIBC_HAS_XLOCALE__
  108. #include <xlocale.h>
  109. #endif /* __UCLIBC_HAS_XLOCALE__ */
  110. /* Handle _STRTOD_HEXADECIMAL_FLOATS via uClibc config now. */
  111. #undef _STRTOD_HEXADECIMAL_FLOATS
  112. #ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
  113. #define _STRTOD_HEXADECIMAL_FLOATS 1
  114. #endif /* __UCLIBC_HAS_HEXADECIMAL_FLOATS__ */
  115. /**********************************************************************/
  116. #undef _STRTOD_FPMAX
  117. #if FPMAX_TYPE == 3
  118. #define NEED_STRTOLD_WRAPPER
  119. #define NEED_STRTOD_WRAPPER
  120. #define NEED_STRTOF_WRAPPER
  121. #elif FPMAX_TYPE == 2
  122. #define NEED_STRTOD_WRAPPER
  123. #define NEED_STRTOF_WRAPPER
  124. #elif FPMAX_TYPE == 1
  125. #define NEED_STRTOF_WRAPPER
  126. #else
  127. #error unknown FPMAX_TYPE!
  128. #endif
  129. extern void __fp_range_check(__fpmax_t y, __fpmax_t x);
  130. /**********************************************************************/
  131. #ifdef _STRTOD_RESTRICT_DIGITS
  132. #define EXP_DENORM_ADJUST DECIMAL_DIG
  133. #define MAX_ALLOWED_EXP (DECIMAL_DIG + EXP_DENORM_ADJUST - FPMAX_MIN_10_EXP)
  134. #if MAX_ALLOWED_EXP > INT_MAX
  135. #error size assumption violated for MAX_ALLOWED_EXP
  136. #endif
  137. #else
  138. /* We want some excess if we're not restricting mantissa digits. */
  139. #define MAX_ALLOWED_EXP ((20 - FPMAX_MIN_10_EXP) * 2)
  140. #endif
  141. #if defined(_STRTOD_RESTRICT_DIGITS) || defined(_STRTOD_ENDPTR) || defined(_STRTOD_HEXADECIMAL_FLOATS)
  142. #undef _STRTOD_NEED_NUM_DIGITS
  143. #define _STRTOD_NEED_NUM_DIGITS 1
  144. #endif
  145. /**********************************************************************/
  146. #if defined(L___strtofpmax) || defined(L___strtofpmax_l) || defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
  147. #if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
  148. #define __strtofpmax __wcstofpmax
  149. #define __strtofpmax_l __wcstofpmax_l
  150. #define Wchar wchar_t
  151. #ifdef __UCLIBC_DO_XLOCALE
  152. #define ISSPACE(C) iswspace_l((C), locale_arg)
  153. #else
  154. #define ISSPACE(C) iswspace((C))
  155. #endif
  156. #else /* defined(L___wcstofpmax) || defined(L___wcstofpmax) */
  157. #define Wchar char
  158. #ifdef __UCLIBC_DO_XLOCALE
  159. #define ISSPACE(C) isspace_l((C), locale_arg)
  160. #else
  161. #define ISSPACE(C) isspace((C))
  162. #endif
  163. #endif /* defined(L___wcstofpmax) || defined(L___wcstofpmax) */
  164. #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
  165. __fpmax_t __strtofpmax(const Wchar *str, Wchar **endptr, int exponent_power)
  166. {
  167. return __strtofpmax_l(str, endptr, exponent_power, __UCLIBC_CURLOCALE);
  168. }
  169. #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
  170. __fpmax_t __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
  171. __LOCALE_PARAM )
  172. {
  173. __fpmax_t number;
  174. __fpmax_t p_base = 10; /* Adjusted to 16 in the hex case. */
  175. Wchar *pos0;
  176. #ifdef _STRTOD_ENDPTR
  177. Wchar *pos1;
  178. #endif
  179. Wchar *pos = (Wchar *) str;
  180. int exponent_temp;
  181. int negative; /* A flag for the number, a multiplier for the exponent. */
  182. #ifdef _STRTOD_NEED_NUM_DIGITS
  183. int num_digits;
  184. #endif
  185. #ifdef __UCLIBC_HAS_LOCALE__
  186. const char *decpt = __LOCALE_PTR->decimal_point;
  187. #if defined(L___wcstofpmax) || defined(L___wcstofpmax)
  188. wchar_t decpt_wc = __LOCALE_PTR->decimal_point;
  189. #else
  190. int decpt_len = __LOCALE_PTR->decimal_point_len;
  191. #endif
  192. #endif
  193. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  194. Wchar expchar = 'e';
  195. Wchar *poshex = NULL;
  196. __uint16_t is_mask = _ISdigit;
  197. #define EXPCHAR expchar
  198. #define IS_X_DIGIT(C) __isctype((C), is_mask)
  199. #else /* _STRTOD_HEXADECIMAL_FLOATS */
  200. #define EXPCHAR 'e'
  201. #define IS_X_DIGIT(C) isdigit((C))
  202. #endif /* _STRTOD_HEXADECIMAL_FLOATS */
  203. while (ISSPACE(*pos)) { /* Skip leading whitespace. */
  204. ++pos;
  205. }
  206. negative = 0;
  207. switch(*pos) { /* Handle optional sign. */
  208. case '-': negative = 1; /* Fall through to increment position. */
  209. case '+': ++pos;
  210. }
  211. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  212. if ((*pos == '0') && (((pos[1])|0x20) == 'x')) {
  213. poshex = ++pos; /* Save position of 'x' in case no digits */
  214. ++pos; /* and advance past it. */
  215. is_mask = _ISxdigit; /* Used by IS_X_DIGIT. */
  216. expchar = 'p'; /* Adjust exponent char. */
  217. p_base = 16; /* Adjust base multiplier. */
  218. }
  219. #endif
  220. number = 0.;
  221. #ifdef _STRTOD_NEED_NUM_DIGITS
  222. num_digits = -1;
  223. #endif
  224. /* exponent_power = 0; */
  225. pos0 = NULL;
  226. LOOP:
  227. while (IS_X_DIGIT(*pos)) { /* Process string of (hex) digits. */
  228. #ifdef _STRTOD_RESTRICT_DIGITS
  229. if (num_digits < 0) { /* First time through? */
  230. ++num_digits; /* We've now seen a digit. */
  231. }
  232. if (num_digits || (*pos != '0')) { /* Had/have nonzero. */
  233. ++num_digits;
  234. if (num_digits <= DECIMAL_DIG) { /* Is digit significant? */
  235. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  236. number = number * p_base
  237. + (isdigit(*pos)
  238. ? (*pos - '0')
  239. : (((*pos)|0x20) - ('a' - 10)));
  240. #else /* _STRTOD_HEXADECIMAL_FLOATS */
  241. number = number * p_base + (*pos - '0');
  242. #endif /* _STRTOD_HEXADECIMAL_FLOATS */
  243. }
  244. }
  245. #else /* _STRTOD_RESTRICT_DIGITS */
  246. #ifdef _STRTOD_NEED_NUM_DIGITS
  247. ++num_digits;
  248. #endif
  249. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  250. number = number * p_base
  251. + (isdigit(*pos)
  252. ? (*pos - '0')
  253. : (((*pos)|0x20) - ('a' - 10)));
  254. #else /* _STRTOD_HEXADECIMAL_FLOATS */
  255. number = number * p_base + (*pos - '0');
  256. #endif /* _STRTOD_HEXADECIMAL_FLOATS */
  257. #endif /* _STRTOD_RESTRICT_DIGITS */
  258. ++pos;
  259. }
  260. #ifdef __UCLIBC_HAS_LOCALE__
  261. #if defined(L___wcstofpmax) || defined(L___wcstofpmax)
  262. if (!pos0 && (*pos == decpt_wc)) { /* First decimal point? */
  263. pos0 = ++pos;
  264. goto LOOP;
  265. }
  266. #else
  267. if (!pos0 && !memcmp(pos, decpt, decpt_len)) { /* First decimal point? */
  268. pos0 = (pos += decpt_len);
  269. goto LOOP;
  270. }
  271. #endif
  272. #else /* __UCLIBC_HAS_LOCALE__ */
  273. if ((*pos == '.') && !pos0) { /* First decimal point? */
  274. pos0 = ++pos; /* Save position of decimal point */
  275. goto LOOP; /* and process rest of digits. */
  276. }
  277. #endif /* __UCLIBC_HAS_LOCALE__ */
  278. #ifdef _STRTOD_NEED_NUM_DIGITS
  279. if (num_digits<0) { /* Must have at least one digit. */
  280. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  281. if (poshex) { /* Back up to '0' in '0x' prefix. */
  282. pos = poshex;
  283. goto DONE;
  284. }
  285. #endif /* _STRTOD_HEXADECIMAL_FLOATS */
  286. #ifdef _STRTOD_NAN_INF_STRINGS
  287. if (!pos0) { /* No decimal point, so check for inf/nan. */
  288. /* Note: nan is the first string so 'number = i/0.;' works. */
  289. static const char nan_inf_str[] = "\05nan\0\012infinity\0\05inf\0";
  290. int i = 0;
  291. #ifdef __UCLIBC_HAS_LOCALE__
  292. /* Avoid tolower problems for INFINITY in the tr_TR locale. (yuk)*/
  293. #undef _tolower
  294. #define _tolower(C) ((C)|0x20)
  295. #endif /* __UCLIBC_HAS_LOCALE__ */
  296. do {
  297. /* Unfortunately, we have no memcasecmp(). */
  298. int j = 0;
  299. while (_tolower(pos[j]) == nan_inf_str[i+1+j]) {
  300. ++j;
  301. if (!nan_inf_str[i+1+j]) {
  302. number = i / 0.;
  303. if (negative) { /* Correct for sign. */
  304. number = -number;
  305. }
  306. pos += nan_inf_str[i] - 2;
  307. goto DONE;
  308. }
  309. }
  310. i += nan_inf_str[i];
  311. } while (nan_inf_str[i]);
  312. }
  313. #endif /* STRTOD_NAN_INF_STRINGS */
  314. #ifdef _STRTOD_ENDPTR
  315. pos = (Wchar *) str;
  316. #endif
  317. goto DONE;
  318. }
  319. #endif /* _STRTOD_NEED_NUM_DIGITS */
  320. #ifdef _STRTOD_RESTRICT_DIGITS
  321. if (num_digits > DECIMAL_DIG) { /* Adjust exponent for skipped digits. */
  322. exponent_power += num_digits - DECIMAL_DIG;
  323. }
  324. #endif
  325. if (pos0) {
  326. exponent_power += pos0 - pos; /* Adjust exponent for decimal point. */
  327. }
  328. #ifdef _STRTOD_HEXADECIMAL_FLOATS
  329. if (poshex) {
  330. exponent_power *= 4; /* Above is 2**4, but below is 2. */
  331. p_base = 2;
  332. }
  333. #endif /* _STRTOD_HEXADECIMAL_FLOATS */
  334. if (negative) { /* Correct for sign. */
  335. number = -number;
  336. }
  337. /* process an exponent string */
  338. if (((*pos)|0x20) == EXPCHAR) {
  339. #ifdef _STRTOD_ENDPTR
  340. pos1 = pos;
  341. #endif
  342. negative = 1;
  343. switch(*++pos) { /* Handle optional sign. */
  344. case '-': negative = -1; /* Fall through to increment pos. */
  345. case '+': ++pos;
  346. }
  347. pos0 = pos;
  348. exponent_temp = 0;
  349. while (isdigit(*pos)) { /* Process string of digits. */
  350. #ifdef _STRTOD_RESTRICT_EXP
  351. if (exponent_temp < MAX_ALLOWED_EXP) { /* Avoid overflow. */
  352. exponent_temp = exponent_temp * 10 + (*pos - '0');
  353. }
  354. #else
  355. exponent_temp = exponent_temp * 10 + (*pos - '0');
  356. #endif
  357. ++pos;
  358. }
  359. #ifdef _STRTOD_ENDPTR
  360. if (pos == pos0) { /* No digits? */
  361. pos = pos1; /* Back up to {e|E}/{p|P}. */
  362. } /* else */
  363. #endif
  364. exponent_power += negative * exponent_temp;
  365. }
  366. #ifdef _STRTOD_ZERO_CHECK
  367. if (number == 0.) {
  368. goto DONE;
  369. }
  370. #endif
  371. /* scale the result */
  372. #ifdef _STRTOD_LOG_SCALING
  373. exponent_temp = exponent_power;
  374. if (exponent_temp < 0) {
  375. exponent_temp = -exponent_temp;
  376. }
  377. while (exponent_temp) {
  378. if (exponent_temp & 1) {
  379. if (exponent_power < 0) {
  380. /* Warning... caluclating a factor for the exponent and
  381. * then dividing could easily be faster. But doing so
  382. * might cause problems when dealing with denormals. */
  383. number /= p_base;
  384. } else {
  385. number *= p_base;
  386. }
  387. }
  388. exponent_temp >>= 1;
  389. p_base *= p_base;
  390. }
  391. #else /* _STRTOD_LOG_SCALING */
  392. while (exponent_power) {
  393. if (exponent_power < 0) {
  394. number /= p_base;
  395. exponent_power++;
  396. } else {
  397. number *= p_base;
  398. exponent_power--;
  399. }
  400. }
  401. #endif /* _STRTOD_LOG_SCALING */
  402. #ifdef _STRTOD_ERRNO
  403. if (__FPMAX_ZERO_OR_INF_CHECK(number)) {
  404. __set_errno(ERANGE);
  405. }
  406. #endif
  407. DONE:
  408. #ifdef _STRTOD_ENDPTR
  409. if (endptr) {
  410. *endptr = pos;
  411. }
  412. #endif
  413. return number;
  414. }
  415. #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
  416. #endif
  417. /**********************************************************************/
  418. #ifdef L___fp_range_check
  419. #if defined(NEED_STRTOF_WRAPPER) || defined(NEED_STRTOD_WRAPPER)
  420. extern void __fp_range_check(__fpmax_t y, __fpmax_t x)
  421. {
  422. if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */
  423. && (y != 0) /* y is not 0 (could have x>0, y==0 if underflow) */
  424. && !__FPMAX_ZERO_OR_INF_CHECK(x) /* x is not 0 or +/- infinity */
  425. ) {
  426. __set_errno(ERANGE); /* Then x is not in y's range. */
  427. }
  428. }
  429. #endif
  430. #endif
  431. /**********************************************************************/
  432. #if defined(L_strtof) || defined(L_strtof_l) || defined(L_wcstof) || defined(L_wcstof_l)
  433. #if defined(NEED_STRTOF_WRAPPER)
  434. #if defined(L_wcstof) || defined(L_wcstof_l)
  435. #define strtof wcstof
  436. #define strtof_l wcstof_l
  437. #define __strtof __wcstof
  438. #define __strtof_l __wcstof_l
  439. #define __strtofpmax __wcstofpmax
  440. #define __strtofpmax_l __wcstofpmax_l
  441. #define Wchar wchar_t
  442. #else
  443. #define Wchar char
  444. #endif
  445. float __XL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
  446. {
  447. #if FPMAX_TYPE == 1
  448. return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  449. #else
  450. __fpmax_t x;
  451. float y;
  452. x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  453. y = (float) x;
  454. __fp_range_check(y, x);
  455. return y;
  456. #endif
  457. }
  458. __XL_ALIAS(strtof)
  459. #endif
  460. #endif
  461. /**********************************************************************/
  462. #if defined(L_strtod) || defined(L_strtod_l) || defined(L_wcstod) || defined(L_wcstod_l)
  463. #if defined(NEED_STRTOD_WRAPPER)
  464. #if defined(L_wcstod) || defined(L_wcstod_l)
  465. #define strtod wcstod
  466. #define strtod_l wcstod_l
  467. #define __strtod __wcstod
  468. #define __strtod_l __wcstod_l
  469. #define __strtofpmax __wcstofpmax
  470. #define __strtofpmax_l __wcstofpmax_l
  471. #define Wchar wchar_t
  472. #else
  473. #define Wchar char
  474. #endif
  475. double __XL(strtod)(const Wchar *__restrict str,
  476. Wchar **__restrict endptr __LOCALE_PARAM )
  477. {
  478. #if FPMAX_TYPE == 2
  479. return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  480. #else
  481. __fpmax_t x;
  482. double y;
  483. x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  484. y = (double) x;
  485. __fp_range_check(y, x);
  486. return y;
  487. #endif
  488. }
  489. __XL_ALIAS(strtod)
  490. #endif
  491. #endif
  492. /**********************************************************************/
  493. #if defined(L_strtold) || defined(L_strtold_l) || defined(L_wcstold) || defined(L_wcstold_l)
  494. #if defined(NEED_STRTOLD_WRAPPER)
  495. #if defined(L_wcstold) || defined(L_wcstold_l)
  496. #define strtold wcstold
  497. #define strtold_l wcstold_l
  498. #define __strtold __wcstold
  499. #define __strtold_l __wcstold_l
  500. #define __strtofpmax __wcstofpmax
  501. #define __strtofpmax_l __wcstofpmax_l
  502. #define Wchar wchar_t
  503. #else
  504. #define Wchar char
  505. #endif
  506. long double __XL(strtold)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
  507. {
  508. #if FPMAX_TYPE == 3
  509. return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  510. #else
  511. __fpmax_t x;
  512. long double y;
  513. x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
  514. y = (long double) x;
  515. __fp_range_check(y, x);
  516. return y;
  517. #endif
  518. }
  519. __XL_ALIAS(strtold)
  520. #endif
  521. #endif
  522. /**********************************************************************/