Disable libm-test test name beautification for M_* constants.
[glibc.git] / stdlib / strtol.c
blob22ab264cfe157af02bc397c6eed95d63b6b92b32
1 /* Convert string representation of a number into an integer value.
2 Copyright (C) 1991-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <stdlib.h>
20 #include <wchar.h>
21 #include <locale/localeinfo.h>
23 #ifndef UNSIGNED
24 # define UNSIGNED 0
25 # define INT LONG int
26 #else
27 # define INT unsigned LONG int
28 #endif
30 #if UNSIGNED
31 # ifdef USE_WIDE_CHAR
32 # ifdef QUAD
33 # define strtol wcstoull
34 # define __strtol_l __wcstoull_l
35 # else
36 # define strtol wcstoul
37 # define __strtol_l __wcstoul_l
38 # endif
39 # else
40 # ifdef QUAD
41 # define strtol strtoull
42 # define __strtol_l __strtoull_l
43 # else
44 # define strtol strtoul
45 # define __strtol_l __strtoul_l
46 # endif
47 # endif
48 #else
49 # ifdef USE_WIDE_CHAR
50 # ifdef QUAD
51 # define strtol wcstoll
52 # define __strtol_l __wcstoll_l
53 # else
54 # define strtol wcstol
55 # define __strtol_l __wcstol_l
56 # endif
57 # else
58 # ifdef QUAD
59 # define strtol strtoll
60 # define __strtol_l __strtoll_l
61 # endif
62 # endif
63 #endif
66 /* If QUAD is defined, we are defining `strtoll' or `strtoull',
67 operating on `long long int's. */
68 #ifdef QUAD
69 # define LONG long long
70 #else
71 # define LONG long
72 #endif
75 #ifdef USE_WIDE_CHAR
76 # define STRING_TYPE wchar_t
77 #else
78 # define STRING_TYPE char
79 #endif
82 #define INTERNAL(X) INTERNAL1(X)
83 #define INTERNAL1(X) __##X##_internal
86 extern INT INTERNAL (__strtol_l) (const STRING_TYPE *, STRING_TYPE **, int,
87 int, __locale_t);
90 INT
91 INTERNAL (strtol) (nptr, endptr, base, group)
92 const STRING_TYPE *nptr;
93 STRING_TYPE **endptr;
94 int base;
95 int group;
97 return INTERNAL (__strtol_l) (nptr, endptr, base, group, _NL_CURRENT_LOCALE);
99 libc_hidden_def (INTERNAL (strtol))
103 strtol (nptr, endptr, base)
104 const STRING_TYPE *nptr;
105 STRING_TYPE **endptr;
106 int base;
108 return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
110 libc_hidden_def (strtol)