8799df82031e835b68ae6c179f58deb6fe32ab87
[platform/upstream/glibc.git] / sysdeps / ieee754 / ldbl-128ibm / strtold_l.c
1 /* Copyright (C) 1999, 2006, 2007 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
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
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #include <math.h>
19 #include <stdlib.h>
20 #include <wchar.h>
21 #include <xlocale.h>
22
23 /* The actual implementation for all floating point sizes is in strtod.c.
24    These macros tell it to produce the `long double' version, `strtold'.  */
25
26 #define FLOAT           long double
27 #define FLT             LDBL
28 #ifdef USE_WIDE_CHAR
29 extern long double ____new_wcstold_l (const wchar_t *, wchar_t **, __locale_t);
30 # define STRTOF         __new_wcstold_l
31 # define __STRTOF       ____new_wcstold_l
32 # define ____STRTOF_INTERNAL ____wcstold_l_internal
33 #else
34 extern long double ____new_strtold_l (const char *, char **, __locale_t);
35 # define STRTOF         __new_strtold_l
36 # define __STRTOF       ____new_strtold_l
37 # define ____STRTOF_INTERNAL ____strtold_l_internal
38 #endif
39 extern __typeof (__STRTOF) STRTOF;
40 libc_hidden_proto (__STRTOF)
41 libc_hidden_proto (STRTOF)
42 #define MPN2FLOAT       __mpn_construct_long_double
43 #define FLOAT_HUGE_VAL  HUGE_VALL
44 # define SET_MANTISSA(flt, mant) \
45   do { union ibm_extended_long_double u;                                      \
46        u.d = (flt);                                                           \
47        if ((mant & 0xfffffffffffffULL) == 0)                                  \
48          mant = 0x8000000000000ULL;                                           \
49        u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff;                           \
50        u.ieee.mantissa1 = (mant) & 0xffffffff;                                \
51        (flt) = u.d;                                                           \
52   } while (0)
53
54 #include <strtod_l.c>
55
56 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
57 # include <math_ldbl_opt.h>
58 # ifdef USE_WIDE_CHAR
59 weak_alias (____new_wcstold_l, ___new_wcstold_l);
60 long_double_symbol (libc, ___new_wcstold_l, wcstold_l);
61 long_double_symbol (libc, ____new_wcstold_l, __wcstold_l);
62 # else
63 weak_alias (____new_strtold_l, ___new_strtold_l);
64 long_double_symbol (libc, ___new_strtold_l, strtold_l);
65 long_double_symbol (libc, ____new_strtold_l, __strtold_l);
66 # endif
67 #endif