strtold.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Read decimal floating point numbers.
  2. This file is part of the GNU C Library.
  3. Copyright (C) 1995-2019 Free Software Foundation, Inc.
  4. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. /* The actual implementation for all floating point sizes is in strtod.c.
  17. These macros tell it to produce the `float' version, `strtof'. */
  18. #include <bits/floatn.h>
  19. #include <bits/long-double.h>
  20. #if __HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128
  21. # define strtof128 __hide_strtof128
  22. # define wcstof128 __hide_wcstof128
  23. #endif
  24. #if __HAVE_FLOAT64X_LONG_DOUBLE
  25. # define strtof64x __hide_strtof64x
  26. # define wcstof64x __hide_wcstof64x
  27. #endif
  28. #ifdef __LONG_DOUBLE_MATH_OPTIONAL
  29. # include <wchar.h>
  30. # define NEW(x) NEW1(x)
  31. # define NEW1(x) __new_##x
  32. long double ____new_strtold_internal (const char *, char **, int);
  33. long double __new_strtold (const char *, char **);
  34. long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
  35. long double __new_wcstold (const wchar_t *, wchar_t **);
  36. libc_hidden_proto (____new_strtold_internal)
  37. libc_hidden_proto (____new_wcstold_internal)
  38. libc_hidden_proto (__new_strtold)
  39. libc_hidden_proto (__new_wcstold)
  40. #else
  41. # define NEW(x) x
  42. #endif
  43. #define FLOAT long double
  44. #define FLT LDBL
  45. #ifdef USE_WIDE_CHAR
  46. # define STRTOF NEW (wcstold)
  47. # define STRTOF_L __wcstold_l
  48. #else
  49. # define STRTOF NEW (strtold)
  50. # define STRTOF_L __strtold_l
  51. #endif
  52. #include "strtod.c"
  53. #ifdef __LONG_DOUBLE_MATH_OPTIONAL
  54. # include <math_ldbl_opt.h>
  55. # ifdef USE_WIDE_CHAR
  56. long_double_symbol (libc, __new_wcstold, wcstold);
  57. long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
  58. libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
  59. # else
  60. long_double_symbol (libc, __new_strtold, strtold);
  61. long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
  62. libc_hidden_ver (____new_strtold_internal, __strtold_internal)
  63. # endif
  64. #endif
  65. #if __HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128
  66. # undef strtof128
  67. # undef wcstof128
  68. # ifdef USE_WIDE_CHAR
  69. weak_alias (NEW (wcstold), wcstof128)
  70. # else
  71. weak_alias (NEW (strtold), strtof128)
  72. # endif
  73. #endif
  74. #if __HAVE_FLOAT64X_LONG_DOUBLE
  75. # undef strtof64x
  76. # undef wcstof64x
  77. # ifdef USE_WIDE_CHAR
  78. weak_alias (NEW (wcstold), wcstof64x)
  79. # else
  80. weak_alias (NEW (strtold), strtof64x)
  81. # endif
  82. #endif