2.5-18.1
[platform/upstream/glibc.git] / sysdeps / ieee754 / ldbl-128ibm / strtold_l.c
1 /* Copyright (C) 1999, 2006 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, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 #include <math.h>
20 #include <stdlib.h>
21 #include <wchar.h>
22 #include <xlocale.h>
23
24 /* The actual implementation for all floating point sizes is in strtod.c.
25    These macros tell it to produce the `long double' version, `strtold'.  */
26
27 #define FLOAT           long double
28 #define FLT             LDBL
29 #ifdef USE_WIDE_CHAR
30 extern long double ____new_wcstold_l (const wchar_t *, wchar_t **, __locale_t);
31 # define STRTOF         __new_wcstold_l
32 # define __STRTOF       ____new_wcstold_l
33 # define ____STRTOF_INTERNAL ____wcstold_l_internal
34 #else
35 extern long double ____new_strtold_l (const char *, char **, __locale_t);
36 # define STRTOF         __new_strtold_l
37 # define __STRTOF       ____new_strtold_l
38 # define ____STRTOF_INTERNAL ____strtold_l_internal
39 #endif
40 #define MPN2FLOAT       __mpn_construct_long_double
41 #define FLOAT_HUGE_VAL  HUGE_VALL
42 # define SET_MANTISSA(flt, mant) \
43   do { union ibm_extended_long_double u;                                      \
44        u.d = (flt);                                                           \
45        if ((mant & 0xfffffffffffffULL) == 0)                                  \
46          mant = 0x8000000000000ULL;                                           \
47        u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff;                           \
48        u.ieee.mantissa1 = (mant) & 0xffffffff;                                \
49        (flt) = u.d;                                                           \
50   } while (0)
51
52 #include <strtod_l.c>
53
54 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
55 # include <math_ldbl_opt.h>
56 # ifdef USE_WIDE_CHAR
57 long_double_symbol (libc, __new_wcstold_l, wcstold_l);
58 long_double_symbol (libc, ____new_wcstold_l, __wcstold_l);
59 # else
60 long_double_symbol (libc, __new_strtold_l, strtold_l);
61 long_double_symbol (libc, ____new_strtold_l, __strtold_l);
62 # endif
63 #endif