Avoid PLT references from __get_clockfreq on powerpc
[glibc.git] / stdlib / strtol.c
blob44e2af472ddc41440e9d2206e6a1a81af852f9be
1 /* Convert string representation of a number into an integer value.
2 Copyright (C) 1991,92,94,95,96,97,98,99,2000,2001,2002,2003,2004,2007
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <stdlib.h>
21 #include <wchar.h>
22 #include <locale/localeinfo.h>
24 #ifndef UNSIGNED
25 # define UNSIGNED 0
26 # define INT LONG int
27 #else
28 # define INT unsigned LONG int
29 #endif
31 #if UNSIGNED
32 # ifdef USE_WIDE_CHAR
33 # ifdef QUAD
34 # define strtol wcstoull
35 # define __strtol_l __wcstoull_l
36 # else
37 # define strtol wcstoul
38 # define __strtol_l __wcstoul_l
39 # endif
40 # else
41 # ifdef QUAD
42 # define strtol strtoull
43 # define __strtol_l __strtoull_l
44 # else
45 # define strtol strtoul
46 # define __strtol_l __strtoul_l
47 # endif
48 # endif
49 #else
50 # ifdef USE_WIDE_CHAR
51 # ifdef QUAD
52 # define strtol wcstoll
53 # define __strtol_l __wcstoll_l
54 # else
55 # define strtol wcstol
56 # define __strtol_l __wcstol_l
57 # endif
58 # else
59 # ifdef QUAD
60 # define strtol strtoll
61 # define __strtol_l __strtoll_l
62 # endif
63 # endif
64 #endif
67 /* If QUAD is defined, we are defining `strtoll' or `strtoull',
68 operating on `long long int's. */
69 #ifdef QUAD
70 # define LONG long long
71 #else
72 # define LONG long
73 #endif
76 #ifdef USE_WIDE_CHAR
77 # define STRING_TYPE wchar_t
78 #else
79 # define STRING_TYPE char
80 #endif
83 #define INTERNAL(X) INTERNAL1(X)
84 #define INTERNAL1(X) __##X##_internal
87 extern INT INTERNAL (__strtol_l) (const STRING_TYPE *, STRING_TYPE **, int,
88 int, __locale_t);
91 INT
92 INTERNAL (strtol) (nptr, endptr, base, group)
93 const STRING_TYPE *nptr;
94 STRING_TYPE **endptr;
95 int base;
96 int group;
98 return INTERNAL (__strtol_l) (nptr, endptr, base, group, _NL_CURRENT_LOCALE);
100 libc_hidden_def (INTERNAL (strtol))
104 strtol (nptr, endptr, base)
105 const STRING_TYPE *nptr;
106 STRING_TYPE **endptr;
107 int base;
109 return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
111 libc_hidden_def (strtol)