diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | elf/dl-minimal.c | 127 | ||||
-rw-r--r-- | elf/dl-runtime.c | 8 | ||||
-rw-r--r-- | elf/dlerror.c | 4 | ||||
-rw-r--r-- | libc.map | 2 | ||||
-rw-r--r-- | libio/stdio.h | 3 | ||||
-rw-r--r-- | stdio-common/asprintf.c | 5 | ||||
-rw-r--r-- | stdlib/strtod.c | 19 | ||||
-rw-r--r-- | stdlib/strtol.c | 48 | ||||
-rw-r--r-- | sysdeps/i386/dl-machine.h | 7 |
11 files changed, 196 insertions, 49 deletions
@@ -1,3 +1,21 @@ +1998-04-07 16:18 Ulrich Drepper <drepper@cygnus.com> + + * libc.map: Add __asprintf to GLIBC_2.1. + * elf/dlerror.c: Use __asprintf, not asprintf. + * libio/stdio.h: Declare __asprintf. + * stdio-common/asprintf.c: Define as __asprintf and make asprintf + a weak alias. + + * elf/dl-minimal.c: Add definition of strtol and strtoul (und friends) + to avoid inclusion from libc_pic.a. + + * elf/dl-runtime.c: Undo last patch. + + * stdlib/strtod.c: Don't use mbtowc, use btowc. + + * sysdeps/i386/dl-machine.h (dl_platform_init): Don't use "i386" + as default, use NULL. + 1998-04-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * resolv/Makefile: Include ../Makeconfig - needed for building @@ -1634,8 +1634,8 @@ if test -n "$path_binutils"; then path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'` CC="$CC -B$path_binutils" fi -AS=`$CC -print-file-name=as` -LD=`$CC -print-file-name=ld` +AS=`$CC -print-prog-name=as` +LD=`$CC -print-prog-name=ld` # Determine whether we are using GNU binutils. echo $ac_n "checking whether $AS is GNU as""... $ac_c" 1>&6 diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 6592ca0baf..4c15d83f8e 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> +#include <limits.h> #include <string.h> #include <unistd.h> #include <sys/types.h> @@ -202,3 +203,129 @@ __assert_perror_fail (int errnum, } #endif + +/* This function is only used in eval.c. */ +long int +weak_function +__strtol_internal (const char *nptr, char **endptr, int base, int group) +{ + long int result = 0; + long int sign = 1; + + while (*nptr == ' ' || *nptr == '\t') + ++nptr; + + if (*nptr == '-') + { + sign = -1; + ++nptr; + } + else if (*nptr == '+') + ++nptr; + + if (*nptr < '0' || *nptr > '9') + { + if (endptr != NULL) + *endptr = (char *) nptr; + return 0L; + } + + assert (base == 0); + if (*nptr == '0') + { + if (nptr[1] == 'x' || nptr[1] == 'X') + { + base = 16; + nptr += 2; + } + else + base = 8; + } + else + base = 10; + + while (*nptr >= '0' && *nptr <= '9') + { + long int digval = *nptr - '0'; + if (result > LONG_MAX / 10 + || (result == (sign ? LONG_MAX : LONG_MAX + 1) / 10 + && digval > (sign ? LONG_MAX : LONG_MAX + 1) % 10)) + { + errno = ERANGE; + return LONG_MAX * sign; + } + result *= 10; + result += digval; + } + + return result * sign; +} + +long int +weak_function +strtol (const char *nptr, char **endptr, int base) +{ + return __strtol_internal (nptr, endptr, base, 0); +} + +unsigned long int +weak_function +__strtoul_internal (const char *nptr, char **endptr, int base, int group) +{ + long int result = 0; + long int sign = 1; + + while (*nptr == ' ' || *nptr == '\t') + ++nptr; + + if (*nptr == '-') + { + sign = -1; + ++nptr; + } + else if (*nptr == '+') + ++nptr; + + if (*nptr < '0' || *nptr > '9') + { + if (endptr != NULL) + *endptr = (char *) nptr; + return 0UL; + } + + assert (base == 0); + if (*nptr == '0') + { + if (nptr[1] == 'x' || nptr[1] == 'X') + { + base = 16; + nptr += 2; + } + else + base = 8; + } + else + base = 10; + + while (*nptr >= '0' && *nptr <= '9') + { + long int digval = *nptr - '0'; + if (result > LONG_MAX / 10 + || (result == ULONG_MAX / 10 && digval > ULONG_MAX % 10)) + { + errno = ERANGE; + return ULONG_MAX; + } + result *= 10; + result += digval; + } + + return result * sign; +} + +unsigned long int +weak_function +strtoul (const char *nptr, char **endptr, int base) +{ + return (unsigned long int) __strtoul_internal (nptr, endptr, base, 0); +} diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 10daa98c06..53601b809f 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -128,13 +128,13 @@ fixup ( { value = _dl_lookup_versioned_symbol(strtab + sym->st_name, &sym, scope, l->l_name, - version, DL_LOOKUP_NOPLT); + version, ELF_MACHINE_JMP_SLOT); break; } } case 0: value = _dl_lookup_symbol (strtab + sym->st_name, &sym, scope, - l->l_name, DL_LOOKUP_NOPLT); + l->l_name, ELF_MACHINE_JMP_SLOT); } /* Currently value contains the base load address of the object @@ -205,13 +205,13 @@ profile_fixup ( value = _dl_lookup_versioned_symbol(strtab + sym->st_name, &sym, scope, l->l_name, version, - DL_LOOKUP_NOPLT); + ELF_MACHINE_JMP_SLOT); break; } } case 0: value = _dl_lookup_symbol (strtab + sym->st_name, &sym, scope, - l->l_name, DL_LOOKUP_NOPLT); + l->l_name, ELF_MACHINE_JMP_SLOT); } /* Currently value contains the base load address of the object diff --git a/elf/dlerror.c b/elf/dlerror.c index 00d367b0a4..ba25611bbb 100644 --- a/elf/dlerror.c +++ b/elf/dlerror.c @@ -72,8 +72,8 @@ dlerror (void) buf = result->errstring; else { - if (asprintf (&buf, "%s: %s", - result->errstring, strerror (result->errcode)) == -1) + if (__asprintf (&buf, "%s: %s", + result->errstring, strerror (result->errcode)) == -1) buf = NULL; /* We don't need the error string anymore. */ @@ -439,7 +439,7 @@ GLIBC_2.1 { __signbit; __signbitf; __signbitl; __libc_sa_len; # functions used in other libraries - _IO_fclose; _IO_fopen; _IO_fdopen; + _IO_fclose; _IO_fopen; _IO_fdopen; __asprintf; __syscall_rt_sigqueueinfo; __xstat64; __fxstat64; __lxstat64; __pread64; __pwrite64; diff --git a/libio/stdio.h b/libio/stdio.h index 4803470c81..76e4fac885 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -310,6 +310,9 @@ extern int vsnprintf __P ((char *__restrict __s, size_t __maxlen, extern int vasprintf __P ((char **__restrict __ptr, __const char *__restrict __f, _G_va_list __arg)) __attribute__ ((__format__ (__printf__, 2, 0))); +extern int __asprintf __P ((char **__restrict __ptr, + __const char *__restrict __fmt, ...)) + __attribute__ ((__format__ (__printf__, 2, 3))); extern int asprintf __P ((char **__restrict __ptr, __const char *__restrict __fmt, ...)) __attribute__ ((__format__ (__printf__, 2, 3))); diff --git a/stdio-common/asprintf.c b/stdio-common/asprintf.c index 4922427edc..bfc4d215a2 100644 --- a/stdio-common/asprintf.c +++ b/stdio-common/asprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,7 +23,7 @@ allocated with malloc and stored in *STRING_PTR. */ /* VARARGS2 */ int -asprintf (char **string_ptr, const char *format, ...) +__asprintf (char **string_ptr, const char *format, ...) { va_list arg; int done; @@ -34,3 +34,4 @@ asprintf (char **string_ptr, const char *format, ...) return done; } +weak_alias (__asprintf, asprintf) diff --git a/stdlib/strtod.c b/stdlib/strtod.c index 061cedc98a..a06239d123 100644 --- a/stdlib/strtod.c +++ b/stdlib/strtod.c @@ -88,10 +88,12 @@ # define LOCALE_PARAM_DECL #endif +#if defined _LIBC || defined HAVE_WCHAR_H +# include <wchar.h> +#endif #ifdef USE_WIDE_CHAR # include <wctype.h> -# include <wchar.h> # define STRING_TYPE wchar_t # define CHAR_TYPE wint_t # define L_(Ch) L##Ch @@ -440,7 +442,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM) /* The radix character of the current locale. */ wchar_t decimal; /* The thousands character of the current locale. */ - wchar_t thousands; + wchar_t thousands = L'\0'; /* The numeric grouping specification of the current locale, in the format described in <locale.h>. */ const char *grouping; @@ -457,18 +459,17 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM) else { /* Figure out the thousands separator character. */ - if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP), - strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0) - thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP); +#if defined _LIBC || defined _HAVE_BTOWC + thousands = btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; +#endif if (thousands == L'\0') grouping = NULL; } } else - { - grouping = NULL; - thousands = L'\0'; - } + grouping = NULL; /* Find the locale's decimal point character. */ if (mbtowc ((wchar_t *) &decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT), diff --git a/stdlib/strtol.c b/stdlib/strtol.c index 19e4a52880..e4e7b4e5a6 100644 --- a/stdlib/strtol.c +++ b/stdlib/strtol.c @@ -1,5 +1,5 @@ /* Convert string representation of a number into an integer value. - Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -167,9 +167,11 @@ extern int errno; # define LOCALE_PARAM_DECL #endif +#if defined _LIBC || defined HAVE_WCHAR_H +# include <wchar.h> +#endif #ifdef USE_WIDE_CHAR -# include <wchar.h> # include <wctype.h> # define L_(Ch) L##Ch # define UCHAR_TYPE wint_t @@ -247,7 +249,7 @@ INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM) struct locale_data *current = loc->__locales[LC_NUMERIC]; # endif /* The thousands character of the current locale. */ - wchar_t thousands; + wchar_t thousands = L'\0'; /* The numeric grouping specification of the current locale, in the format described in <locale.h>. */ const char *grouping; @@ -260,9 +262,11 @@ INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM) else { /* Figure out the thousands separator character. */ - if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP), - strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0) - thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP); +# if defined _LIBC || defined _HAVE_BTOWC + thousands = btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; +# endif if (thousands == L'\0') grouping = NULL; } @@ -299,23 +303,19 @@ INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM) else negative = 0; - if (base == 16 && s[0] == L_('0') && TOUPPER (s[1]) == L_('X')) - s += 2; - - /* If BASE is zero, figure it out ourselves. */ - if (base == 0) - if (*s == L_('0')) - { - if (TOUPPER (s[1]) == L_('X')) - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; + /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ + if (*s == L_('0')) + { + if (TOUPPER (s[1]) == L_('X')) + { + s += 2; + base = 16; + } + else if (base == 0) + base = 8; + } + else if (base == 0) + base = 10; /* Save the pointer so we can check later if anything happened. */ save = s; @@ -396,7 +396,7 @@ INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM) } /* Return the result of the appropriate sign. */ - return (negative ? -i : i); + return negative ? -i : i; noconv: /* We must handle a special case here: the base is 0 or 16 and the diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index fd463778f9..2f936e3d1e 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -274,11 +274,8 @@ extern const char *_dl_platform; static inline void __attribute__ ((unused)) dl_platform_init (void) { - if (_dl_platform == NULL) - /* We default to i386 since all instructions understood by the i386 - are also understood by later processors. */ - _dl_platform = "i386"; - else if (*_dl_platform == '\0') + if (_dl_platform != NULL && *_dl_platform == '\0') + /* Avoid an empty string which would disturb us. */ _dl_platform = NULL; } |