Always do locking when iterating over list of streams (bug 15142)
[glibc.git] / stdlib / strtol.c
blobd1e3bfe12903997febdaf1f6b29cdb84a7af206f
1 /* Convert string representation of a number into an integer value.
2 Copyright (C) 1991-2017 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
85 #define SYM__(X) SYM__1 (X)
86 #define SYM__1(X) __ ## X
87 #define __strtol SYM__ (strtol)
90 extern INT INTERNAL (__strtol_l) (const STRING_TYPE *, STRING_TYPE **, int,
91 int, locale_t);
94 INT
95 INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
96 int base, int group)
98 return INTERNAL (__strtol_l) (nptr, endptr, base, group, _NL_CURRENT_LOCALE);
100 libc_hidden_def (INTERNAL (strtol))
104 __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
106 return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
108 weak_alias (__strtol, strtol)
109 libc_hidden_weak (strtol)