public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-05-10 18:18 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-05-10 18:18 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7ea64470394c3df1d22fb1ad2ecc674b439d0889
commit 7ea64470394c3df1d22fb1ad2ecc674b439d0889
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-06-09 21:15 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 21:15 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5c9569123793a2e64c633acc5f5ba503871ed16f
commit 5c9569123793a2e64c633acc5f5ba503871ed16f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 ++--
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 76 insertions(+), 54 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index db83297bca..094c7ee285 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 064eaa08ae..c1595b672d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -155,7 +155,7 @@ read_sysfs_file (const char *fname)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -166,7 +166,7 @@ read_sysfs_file (const char *fname)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-06-09 13:11 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 13:11 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5c9569123793a2e64c633acc5f5ba503871ed16f
commit 5c9569123793a2e64c633acc5f5ba503871ed16f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 ++--
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 76 insertions(+), 54 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index db83297bca..094c7ee285 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 064eaa08ae..c1595b672d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -155,7 +155,7 @@ read_sysfs_file (const char *fname)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -166,7 +166,7 @@ read_sysfs_file (const char *fname)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-06-03 14:00 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-06-03 14:00 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3b3975fc9ef622ab4ae407a844e32d1842ac6632
commit 3b3975fc9ef622ab4ae407a844e32d1842ac6632
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 ++--
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 76 insertions(+), 54 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index db83297bca..094c7ee285 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 064eaa08ae..c1595b672d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -155,7 +155,7 @@ read_sysfs_file (const char *fname)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -166,7 +166,7 @@ read_sysfs_file (const char *fname)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-05-13 14:14 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-05-13 14:14 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cd6f1bf2d5aaa915f9cf83ec1d1ebcf640ad6973
commit cd6f1bf2d5aaa915f9cf83ec1d1ebcf640ad6973
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index db83297bca..094c7ee285 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-05-12 19:28 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 19:28 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=10583821fb8872ad5f6a9efd8d565d01e261b0a2
commit 10583821fb8872ad5f6a9efd8d565d01e261b0a2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-04-29 13:58 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-04-29 13:58 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8a51cbce7d3a71b0d8987a8a75a99079f2918cd3
commit 8a51cbce7d3a71b0d8987a8a75a99079f2918cd3
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-04-04 12:49 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-04-04 12:49 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=58f83857188299676423c31496f9882e80af0458
commit 58f83857188299676423c31496f9882e80af0458
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-31 19:01 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-31 19:01 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d8c50d32c46758cc591fc04e17b5c425ddce78d1
commit d8c50d32c46758cc591fc04e17b5c425ddce78d1
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-29 20:24 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-29 20:24 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3ffff5916a369f26db733dbcdb06c13c7b0c3a68
commit 3ffff5916a369f26db733dbcdb06c13c7b0c3a68
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index bcff909b2f..db4cd2f12f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-16 17:57 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-16 17:57 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=541a2a108e2b0d61cfd70710d7ca4a9a5b5df46e
commit 541a2a108e2b0d61cfd70710d7ca4a9a5b5df46e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 18dccd5924..13372e8d47 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-15 18:35 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-15 18:35 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=541a2a108e2b0d61cfd70710d7ca4a9a5b5df46e
commit 541a2a108e2b0d61cfd70710d7ca4a9a5b5df46e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 18dccd5924..13372e8d47 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-11 17:19 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-11 17:19 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=74b7463ab2fb5ab8a87f46c829e62057cc8e2d11
commit 74b7463ab2fb5ab8a87f46c829e62057cc8e2d11
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 18dccd5924..13372e8d47 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias
@ 2022-03-08 18:56 Adhemerval Zanella
0 siblings, 0 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2022-03-08 18:56 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=74b7463ab2fb5ab8a87f46c829e62057cc8e2d11
commit 74b7463ab2fb5ab8a87f46c829e62057cc8e2d11
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Mar 3 12:11:11 2022 -0300
Replace internal usage of strtol and wcstol for internal alias
To clean up the exported headers to have only one function prototype
with the ABI aliais (if any) it requires to use the internal alias
for all symbols, since to redirect the internal usage a new it
requires to redirect the symbol with an extra prototype (which this
patch tries to avoid).
The atoi is replace with __strtol due the optimization on stdlib.h.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Diff:
---
argp/argp-help.c | 2 +-
argp/argp-parse.c | 2 +-
iconv/gconv_conf.c | 2 +-
include/stdlib.h | 25 ++++++++++++++++---------
include/wchar.h | 24 ++++++++++++++++--------
inet/rexec.c | 2 +-
intl/plural-exp.c | 2 +-
nss/nss_files/files-parse.c | 4 ++++
posix/wordexp.c | 4 ++--
resolv/inet_addr.c | 2 +-
resolv/res_init.c | 6 +++---
stdlib/atof.c | 2 +-
stdlib/atoi.c | 2 +-
stdlib/atol.c | 2 +-
stdlib/atoll.c | 2 +-
stdlib/fmtmsg.c | 2 +-
stdlib/strtod.c | 7 +++++--
stdlib/strtol.c | 2 +-
stdlib/strtold.c | 18 +++++++++---------
sysdeps/posix/getaddrinfo.c | 1 +
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +++---
sysdeps/unix/sysv/linux/readonly-area.c | 4 ++--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
sysdeps/wordsize-64/strtol.c | 3 +--
time/tzset.c | 2 +-
26 files changed, 77 insertions(+), 55 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..f128313e06 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -210,7 +210,7 @@ fill_in_uparams (const struct argp_state *state)
}
else if (isdigit ((unsigned char) *arg))
{
- val = atoi (arg);
+ val = (int) __strtol (arg, NULL, 10);
while (isdigit ((unsigned char) *arg))
arg++;
SKIPWS (arg);
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 68dc45417b..13cd84dd33 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -147,7 +147,7 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_HANG:
- _argp_hang = atoi (arg ? arg : "3600");
+ _argp_hang = (int) __strtol (arg ? arg : "3600", NULL, 10);
while (_argp_hang-- > 0)
__sleep (1);
break;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f069e28323..989ccc479e 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -290,7 +290,7 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
char *endp;
*wp++ = '\0';
- cost_hi = strtol (rp, &endp, 10);
+ cost_hi = __strtol (rp, &endp, 10);
if (rp == endp || cost_hi < 1)
/* No useful information. */
cost_hi = 1;
diff --git a/include/stdlib.h b/include/stdlib.h
index 1c6f70b082..f1f313b15f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -221,15 +221,22 @@ libc_hidden_proto (____strtoul_l_internal)
libc_hidden_proto (____strtoull_l_internal)
#include <bits/floatn.h>
-libc_hidden_proto (strtof)
-libc_hidden_proto (strtod)
+extern __typeof (strtof) __strtof;
+libc_hidden_proto (__strtof)
+extern __typeof (strtod) __strtod;
+libc_hidden_proto (__strtod)
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
-libc_hidden_proto (strtold)
+extern __typeof (strtold) __strtold;
+libc_hidden_proto (__strtold)
#endif
-libc_hidden_proto (strtol)
-libc_hidden_proto (strtoll)
-libc_hidden_proto (strtoul)
-libc_hidden_proto (strtoull)
+extern __typeof (strtol) __strtol;
+libc_hidden_proto (__strtol)
+extern __typeof (strtoll) __strtoll;
+libc_hidden_proto (__strtoll)
+extern __typeof (strtoul) __strtoul;
+libc_hidden_proto (__strtoul)
+extern __typeof (strtoull) __strtoull;
+libc_hidden_proto (__strtoull)
libc_hidden_proto (atoi)
@@ -251,10 +258,10 @@ libc_hidden_proto (__wcstold_nan)
#include <bits/floatn.h>
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128) __strtof128;
+libc_hidden_proto (__strtof128)
extern __typeof (strtof128_l) __strtof128_l;
-
libc_hidden_proto (__strtof128_l)
-libc_hidden_proto (strtof128)
extern _Float128 __strtof128_nan (const char *, char **, char);
extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t);
diff --git a/include/wchar.h b/include/wchar.h
index 4267985625..781ad7c20e 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -71,13 +71,20 @@ libc_hidden_proto (__wcstol_internal)
libc_hidden_proto (__wcstoll_internal)
libc_hidden_proto (__wcstoul_internal)
libc_hidden_proto (__wcstoull_internal)
-libc_hidden_proto (wcstof)
-libc_hidden_proto (wcstod)
-libc_hidden_ldbl_proto (wcstold)
-libc_hidden_proto (wcstol)
-libc_hidden_proto (wcstoll)
-libc_hidden_proto (wcstoul)
-libc_hidden_proto (wcstoull)
+extern __typeof (wcstof) __wcstof;
+libc_hidden_proto (__wcstof)
+extern __typeof (wcstod) __wcstod;
+libc_hidden_proto (__wcstod)
+extern __typeof (wcstold) __wcstold;
+libc_hidden_ldbl_proto (__wcstold)
+extern __typeof (wcstol) __wcstol;
+libc_hidden_proto (__wcstol)
+extern __typeof (wcstoll) __wcstoll;
+libc_hidden_proto (__wcstoll)
+extern __typeof (wcstoul) __wcstoul;
+libc_hidden_proto (__wcstoul)
+extern __typeof (wcstoull) __wcstoull;
+libc_hidden_proto (__wcstoull)
extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
@@ -100,6 +107,8 @@ extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
attribute_hidden;
#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128) __wcstof128;
+libc_hidden_proto (__wcstof128)
extern __typeof (wcstof128_l) __wcstof128_l;
libc_hidden_proto (__wcstof128_l)
extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
@@ -110,7 +119,6 @@ extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
locale_t) attribute_hidden;
libc_hidden_proto (__wcstof128_internal)
-libc_hidden_proto (wcstof128)
#endif
libc_hidden_proto (__wcscasecmp_l)
diff --git a/inet/rexec.c b/inet/rexec.c
index 064e979d68..330282ac16 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -134,7 +134,7 @@ retry:
if (!getnameinfo(&sa2.sa, sa2len,
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
- port = atoi(servbuff);
+ port = (int) __strtol (servbuff, NULL, 10);
(void) sprintf(num, "%u", port);
(void) __write(s, num, strlen(num)+1);
{ socklen_t len = sizeof (from);
diff --git a/intl/plural-exp.c b/intl/plural-exp.c
index d5aec23b55..80b0a5afb1 100644
--- a/intl/plural-exp.c
+++ b/intl/plural-exp.c
@@ -120,7 +120,7 @@ EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
+ n = __strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index c90e293802..bd3266702e 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -53,6 +53,10 @@
# define STRUCTURE ENTNAME
#endif
+#if IS_IN(libc)
+# define strtoul __strtoul
+#endif
+
struct parser_data
{
diff --git a/posix/wordexp.c b/posix/wordexp.c
index d4cb9c734b..7bec5a73aa 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -564,7 +564,7 @@ eval_expr_val (char **expr, long int *result)
/* POSIX requires that decimal, octal, and hexadecimal constants are
recognized. Therefore we pass 0 as the third parameter to strtol. */
- *result = strtol (digit, expr, 0);
+ *result = __strtol (digit, expr, 0);
if (digit == *expr)
return WRDE_SYNTAX;
@@ -1398,7 +1398,7 @@ envsubst:
/* Is it a numeric parameter? */
else if (isdigit (env[0]))
{
- unsigned long n = strtoul (env, NULL, 10);
+ unsigned long n = __strtoul (env, NULL, 10);
if (n >= __libc_argc)
/* Substitute NULL. */
diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c
index 8059a23ec9..451531899d 100644
--- a/resolv/inet_addr.c
+++ b/resolv/inet_addr.c
@@ -130,7 +130,7 @@ inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
goto ret_0;
{
char *endp;
- unsigned long ul = strtoul (cp, &endp, 0);
+ unsigned long ul = __strtoul (cp, &endp, 0);
if (ul == ULONG_MAX && errno == ERANGE)
goto ret_0;
if (ul > 0xfffffffful)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cbc16ba021..a6d5364835 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -654,7 +654,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
/* Search for and process individual options. */
if (!strncmp (cp, "ndots:", sizeof ("ndots:") - 1))
{
- int i = atoi (cp + sizeof ("ndots:") - 1);
+ int i = (int) __strtol (cp + sizeof ("ndots:") - 1, NULL, 10);
if (i <= RES_MAXNDOTS)
parser->template.ndots = i;
else
@@ -662,7 +662,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "timeout:", sizeof ("timeout:") - 1))
{
- int i = atoi (cp + sizeof ("timeout:") - 1);
+ int i = (int) __strtol (cp + sizeof ("timeout:") - 1, NULL, 10);
if (i <= RES_MAXRETRANS)
parser->template.retrans = i;
else
@@ -670,7 +670,7 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options)
}
else if (!strncmp (cp, "attempts:", sizeof ("attempts:") - 1))
{
- int i = atoi (cp + sizeof ("attempts:") - 1);
+ int i = (int) __strtol (cp + sizeof ("attempts:") - 1, NULL, 10);
if (i <= RES_MAXRETRY)
parser->template.retry = i;
else
diff --git a/stdlib/atof.c b/stdlib/atof.c
index 782c6053eb..d208c6d329 100644
--- a/stdlib/atof.c
+++ b/stdlib/atof.c
@@ -24,5 +24,5 @@
double
atof (const char *nptr)
{
- return strtod (nptr, (char **) NULL);
+ return __strtod (nptr, (char **) NULL);
}
diff --git a/stdlib/atoi.c b/stdlib/atoi.c
index c977506b38..d7560121b7 100644
--- a/stdlib/atoi.c
+++ b/stdlib/atoi.c
@@ -24,6 +24,6 @@
int
atoi (const char *nptr)
{
- return (int) strtol (nptr, (char **) NULL, 10);
+ return (int) __strtol (nptr, (char **) NULL, 10);
}
libc_hidden_def (atoi)
diff --git a/stdlib/atol.c b/stdlib/atol.c
index 5706d6e143..77183bd051 100644
--- a/stdlib/atol.c
+++ b/stdlib/atol.c
@@ -24,5 +24,5 @@
long int
atol (const char *nptr)
{
- return strtol (nptr, (char **) NULL, 10);
+ return __strtol (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/atoll.c b/stdlib/atoll.c
index 05ad7c141b..5be05716e2 100644
--- a/stdlib/atoll.c
+++ b/stdlib/atoll.c
@@ -24,5 +24,5 @@
long long int
atoll (const char *nptr)
{
- return strtoll (nptr, (char **) NULL, 10);
+ return __strtoll (nptr, (char **) NULL, 10);
}
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 787a263d63..3e48800331 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -263,7 +263,7 @@ init (void)
/* Second field: severity level, a number. */
char *cp;
- level = strtol (sevlevel_var, &cp, 0);
+ level = __strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 98794f22da..ce54584dd2 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -61,6 +61,8 @@
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#define DOUBLEUNDESCORE(x) DOUBLEUNDESCORE1(x)
+#define DOUBLEUNDESCORE1(x) __##x
FLOAT
@@ -77,12 +79,13 @@ FLOAT
#ifdef weak_function
weak_function
#endif
-STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr)
+DOUBLEUNDESCORE (STRTOF) (const STRING_TYPE *nptr, STRING_TYPE **endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
#if defined _LIBC
-libc_hidden_def (STRTOF)
+weak_alias (DOUBLEUNDESCORE (STRTOF), STRTOF)
+libc_hidden_def (DOUBLEUNDESCORE (STRTOF))
#endif
#ifdef LONG_DOUBLE_COMPAT
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index be7719f493..7e9611fb27 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -106,4 +106,4 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base)
return INTERNAL (__strtol_l) (nptr, endptr, base, 0, _NL_CURRENT_LOCALE);
}
weak_alias (__strtol, strtol)
-libc_hidden_weak (strtol)
+libc_hidden_weak (__strtol)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index a03620e308..34ed8da0ea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -34,13 +34,13 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <wchar.h>
# define NEW(x) NEW1(x)
-# define NEW1(x) __new_##x
-long double ____new_strtold_internal (const char *, char **, int);
+# define NEW1(x) new_##x
+long double __new_strtold_internal (const char *, char **, int);
long double __new_strtold (const char *, char **);
-long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold_internal (const wchar_t *, wchar_t **, int);
long double __new_wcstold (const wchar_t *, wchar_t **);
-libc_hidden_proto (____new_strtold_internal)
-libc_hidden_proto (____new_wcstold_internal)
+libc_hidden_proto (__new_strtold_internal)
+libc_hidden_proto (__new_wcstold_internal)
libc_hidden_proto (__new_strtold)
libc_hidden_proto (__new_wcstold)
#else
@@ -63,12 +63,12 @@ libc_hidden_proto (__new_wcstold)
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
long_double_symbol (libc, __new_wcstold, wcstold);
-long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
-libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+long_double_symbol (libc, __new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (__new_wcstold_internal, __wcstold_internal)
# else
long_double_symbol (libc, __new_strtold, strtold);
-long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
-libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+long_double_symbol (libc, __new_strtold_internal, __strtold_internal);
+libc_hidden_ver (__new_strtold_internal, __strtold_internal)
# endif
#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 18dccd5924..13372e8d47 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -90,6 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if IS_IN (libc)
# define feof_unlocked(fp) __feof_unlocked (fp)
+# define strtoul __strtoul
#endif
struct gaih_service
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 461716601e..290628f5aa 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -51,7 +51,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
if (n <= 0
|| n == sizeof (uidbuf)
|| (uidbuf[n] = '\0',
- uid = strtoul (uidbuf, &endp, 10),
+ uid = __strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1ea074f0d..0c65d0e268 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -156,7 +156,7 @@ get_nprocs_cpu_online (void)
do
{
char *endp;
- unsigned long int n = strtoul (l, &endp, 10);
+ unsigned long int n = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -167,7 +167,7 @@ get_nprocs_cpu_online (void)
if (*endp == '-')
{
l = endp + 1;
- m = strtoul (l, &endp, 10);
+ m = __strtoul (l, &endp, 10);
if (l == endp)
{
result = 0;
@@ -204,7 +204,7 @@ get_nprocs_cpu (void)
if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0)
{
char *endp;
- unsigned long int nr = strtoul (d->d_name + 3, &endp, 10);
+ unsigned long int nr = __strtoul (d->d_name + 3, &endp, 10);
if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0')
++count;
}
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e8fde06fa9..3a94d7c52f 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -59,13 +59,13 @@ __readonly_area (const char *ptr, size_t size)
break;
char *p;
- uintptr_t from = strtoul (line, &p, 16);
+ uintptr_t from = __strtoul (line, &p, 16);
if (p == line || *p++ != '-')
break;
char *q;
- uintptr_t to = strtoul (p, &q, 16);
+ uintptr_t to = __strtoul (p, &q, 16);
if (q == p || *q++ != ' ')
break;
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 7706819c32..4afc00c8d0 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -111,7 +111,7 @@ __sysconf (int name)
buf[n] = '\0';
char *endp;
- long int res = strtol (buf, &endp, 10);
+ long int res = __strtol (buf, &endp, 10);
if (endp != buf && (*endp == '\0' || *endp == '\n'))
return res;
}
diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c
index a1b2374153..9ce616c89e 100644
--- a/sysdeps/wordsize-64/strtol.c
+++ b/sysdeps/wordsize-64/strtol.c
@@ -11,7 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
-libc_hidden_ver (strtol, strtoll)
+libc_hidden_ver (__strtol, __strtoll)
weak_alias (strtol, strtoq)
-libc_hidden_ver (strtol, strtoq)
weak_alias (strtol, strtoimax)
diff --git a/time/tzset.c b/time/tzset.c
index a06142bb58..ac20e1a560 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -242,7 +242,7 @@ parse_rule (const char **tzp, int whichrule)
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit (*++tz))
return false;
- unsigned long int d = strtoul (tz, &end, 10);
+ unsigned long int d = __strtoul (tz, &end, 10);
if (end == tz || d > 365)
return false;
if (tzr->type == J1 && d == 0)
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-06-09 21:15 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 18:18 [glibc/azanella/clang] Replace internal usage of strtol and wcstol for internal alias Adhemerval Zanella
-- strict thread matches above, loose matches on Subject: below --
2022-06-09 21:15 Adhemerval Zanella
2022-06-09 13:11 Adhemerval Zanella
2022-06-03 14:00 Adhemerval Zanella
2022-05-13 14:14 Adhemerval Zanella
2022-05-12 19:28 Adhemerval Zanella
2022-04-29 13:58 Adhemerval Zanella
2022-04-04 12:49 Adhemerval Zanella
2022-03-31 19:01 Adhemerval Zanella
2022-03-29 20:24 Adhemerval Zanella
2022-03-16 17:57 Adhemerval Zanella
2022-03-15 18:35 Adhemerval Zanella
2022-03-11 17:19 Adhemerval Zanella
2022-03-08 18:56 Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).