mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
2002-02-03 Andreas Schwab <schwab@suse.de> * sysdeps/posix/readv.c: Use ssize_t for bytes_read. * sysdeps/posix/writev.c: Use ssize_t for bytes_written. Fix comment. 2002-02-03 Thorsten Kukuk <kukuk@suse.de> * sysdeps/posix/writev.c: Check for ssize_t overflow, don't use alloca if the memory reqirements are too high. 2002-02-03 Ulrich Drepper <drepper@redhat.com> * elf/dl-load.c (decompose_rpath): Avoid using strstr. * elf/dl-minimal.c (_strerror_r): Use _itoa instead of _itoa_word since the former is available anyway and speed isn't important here. * elf/dl-misc.c (_dl_debug_vdprintf): Likewise. * elf/dl-version.c (match_symbol): Likewise. (_dl_check_map_versions): Likewise. * elf/rtld.c (process_envvars): Likewise. (print_statistics): Likewise. * sysdeps/generic/dl-sysdep.c (_dl_show_auxv): Likewise. * elf/dl-minimal.c (_itoa): Always define it. Make it work for all bases. Add assert to catch uses of unimplemented features. (__strsep): Add assert to catch uses of unimplemented features. * elf/dl-object.c (_dl_new_object): Don't use rawmemchr. Use strchr and avoid inline optimization. * elf/rtld.c (process_envvars): Likewise. * elf/dl-open.c: Don't include <stdio-common/_itoa.h>. * elf/dl-profile.c (_dl_start_profile): Help compiler to avoid ffs. * elf/rtld.c (dl_main): Avoid strsep inline optimization. * stdio-common/_itoa.h: Minor simplifications of the code. * stdio-common/_itoa.c: Likewise. * elf/dl-reloc.c (_dl_relocate_object): Use _dl_debug_printf instead of _dl_printf for debugging info output. * sysdeps/mips/atomicity.h (exchange_and_add): Use branch likely.
This commit is contained in:
40
ChangeLog
40
ChangeLog
@ -1,12 +1,48 @@
|
|||||||
|
2002-02-03 Andreas Schwab <schwab@suse.de>
|
||||||
|
|
||||||
|
* sysdeps/posix/readv.c: Use ssize_t for bytes_read.
|
||||||
|
* sysdeps/posix/writev.c: Use ssize_t for bytes_written. Fix comment.
|
||||||
|
|
||||||
|
2002-02-03 Thorsten Kukuk <kukuk@suse.de>
|
||||||
|
|
||||||
|
* sysdeps/posix/writev.c: Check for ssize_t overflow, don't use
|
||||||
|
alloca if the memory reqirements are too high.
|
||||||
|
|
||||||
|
2002-02-03 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-load.c (decompose_rpath): Avoid using strstr.
|
||||||
|
* elf/dl-minimal.c (_strerror_r): Use _itoa instead of _itoa_word since
|
||||||
|
the former is available anyway and speed isn't important here.
|
||||||
|
* elf/dl-misc.c (_dl_debug_vdprintf): Likewise.
|
||||||
|
* elf/dl-version.c (match_symbol): Likewise.
|
||||||
|
(_dl_check_map_versions): Likewise.
|
||||||
|
* elf/rtld.c (process_envvars): Likewise.
|
||||||
|
(print_statistics): Likewise.
|
||||||
|
* sysdeps/generic/dl-sysdep.c (_dl_show_auxv): Likewise.
|
||||||
|
* elf/dl-minimal.c (_itoa): Always define it. Make it work for all
|
||||||
|
bases. Add assert to catch uses of unimplemented features.
|
||||||
|
(__strsep): Add assert to catch uses of unimplemented features.
|
||||||
|
* elf/dl-object.c (_dl_new_object): Don't use rawmemchr. Use strchr
|
||||||
|
and avoid inline optimization.
|
||||||
|
* elf/rtld.c (process_envvars): Likewise.
|
||||||
|
* elf/dl-open.c: Don't include <stdio-common/_itoa.h>.
|
||||||
|
* elf/dl-profile.c (_dl_start_profile): Help compiler to avoid ffs.
|
||||||
|
* elf/rtld.c (dl_main): Avoid strsep inline optimization.
|
||||||
|
|
||||||
2002-02-02 Ulrich Drepper <drepper@redhat.com>
|
2002-02-02 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* stdio-common/_itoa.h: Minor simplifications of the code.
|
||||||
|
* stdio-common/_itoa.c: Likewise.
|
||||||
|
|
||||||
|
* elf/dl-reloc.c (_dl_relocate_object): Use _dl_debug_printf
|
||||||
|
instead of _dl_printf for debugging info output.
|
||||||
|
|
||||||
* manual/examples/mkfsock.c (make_named_socket): Make sure name is
|
* manual/examples/mkfsock.c (make_named_socket): Make sure name is
|
||||||
always NUL-terminated. Patch by Chris D. Sloan <cds@cs.hmc.edu>.
|
always NUL-terminated. Patch by Chris D. Sloan <cds@cs.hmc.edu>.
|
||||||
|
|
||||||
2002-02-01 H.J. Lu <hjl@gnu.org>
|
2002-02-01 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
* sysdeps/mips/atomicity.h (exchange_and_add): Use branch
|
* sysdeps/mips/atomicity.h (exchange_and_add): Use branch likely.
|
||||||
likely.
|
|
||||||
(atomic_add): Likewise.
|
(atomic_add): Likewise.
|
||||||
(compare_and_swap): Return 0 only when failed to compare. Use
|
(compare_and_swap): Return 0 only when failed to compare. Use
|
||||||
branch likely.
|
branch likely.
|
||||||
|
@ -496,12 +496,19 @@ decompose_rpath (struct r_search_path_struct *sps,
|
|||||||
if (__builtin_expect (GL(dl_inhibit_rpath) != NULL, 0)
|
if (__builtin_expect (GL(dl_inhibit_rpath) != NULL, 0)
|
||||||
&& !__libc_enable_secure)
|
&& !__libc_enable_secure)
|
||||||
{
|
{
|
||||||
const char *found = strstr (GL(dl_inhibit_rpath), where);
|
const char *inhp = GL(dl_inhibit_rpath);
|
||||||
if (found != NULL)
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
size_t len = strlen (where);
|
const char *wp = where;
|
||||||
if ((found == GL(dl_inhibit_rpath) || found[-1] == ':')
|
|
||||||
&& (found[len] == '\0' || found[len] == ':'))
|
while (*inhp == *wp && *wp != '\0')
|
||||||
|
{
|
||||||
|
++inhp;
|
||||||
|
++wp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*wp == '\0' && (*inhp == '\0' || *inhp == ':'))
|
||||||
{
|
{
|
||||||
/* This object is on the list of objects for which the
|
/* This object is on the list of objects for which the
|
||||||
RUNPATH and RPATH must not be used. */
|
RUNPATH and RPATH must not be used. */
|
||||||
@ -522,7 +529,12 @@ decompose_rpath (struct r_search_path_struct *sps,
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (*inhp != '\0')
|
||||||
|
if (*inhp++ == ':')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
while (*inhp != '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a writable copy. At the same time expand possible dynamic
|
/* Make a writable copy. At the same time expand possible dynamic
|
||||||
|
@ -171,7 +171,7 @@ __strerror_r (int errnum, char *buf, size_t buflen)
|
|||||||
/* No need to check buffer size, all calls in the dynamic linker
|
/* No need to check buffer size, all calls in the dynamic linker
|
||||||
provide enough space. */
|
provide enough space. */
|
||||||
buf[buflen - 1] = '\0';
|
buf[buflen - 1] = '\0';
|
||||||
msg = _itoa_word (errnum, buf + buflen - 1, 10, 0);
|
msg = _itoa (errnum, buf + buflen - 1, 10, 0);
|
||||||
msg = memcpy (msg - (sizeof ("Error ") - 1), "Error ",
|
msg = memcpy (msg - (sizeof ("Error ") - 1), "Error ",
|
||||||
sizeof ("Error ") - 1);
|
sizeof ("Error ") - 1);
|
||||||
break;
|
break;
|
||||||
@ -270,9 +270,9 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if HP_TIMING_AVAIL && ULONG_MAX <= 4294967295UL
|
/* We always use _itoa instead of _itoa_word in ld.so since the former
|
||||||
/* We need this function to print the cycle count. On 64-bit machines the
|
also has to be present and it is never about speed when these
|
||||||
_itoa_word function should be used. */
|
functions are used. */
|
||||||
char *
|
char *
|
||||||
_itoa (value, buflim, base, upper_case)
|
_itoa (value, buflim, base, upper_case)
|
||||||
unsigned long long int value;
|
unsigned long long int value;
|
||||||
@ -280,17 +280,16 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
unsigned int base;
|
unsigned int base;
|
||||||
int upper_case;
|
int upper_case;
|
||||||
{
|
{
|
||||||
char *bp = buflim;
|
extern const char _itoa_lower_digits[];
|
||||||
|
|
||||||
assert (base == 10);
|
assert (! upper_case);
|
||||||
|
|
||||||
do
|
do
|
||||||
*--bp = '0' + value % 10;
|
*--buflim = _itoa_lower_digits[value % base];
|
||||||
while ((value /= 10) != 0);
|
while ((value /= base) != 0);
|
||||||
|
|
||||||
return bp;
|
return buflim;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The following is not a complete strsep implementation. It cannot
|
/* The following is not a complete strsep implementation. It cannot
|
||||||
@ -303,6 +302,8 @@ __strsep (char **stringp, const char *delim)
|
|||||||
{
|
{
|
||||||
char *begin;
|
char *begin;
|
||||||
|
|
||||||
|
assert (delim[0] != '\0');
|
||||||
|
|
||||||
begin = *stringp;
|
begin = *stringp;
|
||||||
if (begin != NULL)
|
if (begin != NULL)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
|
|||||||
char *p;
|
char *p;
|
||||||
pid = __getpid ();
|
pid = __getpid ();
|
||||||
assert (pid >= 0 && pid < 100000);
|
assert (pid >= 0 && pid < 100000);
|
||||||
p = _itoa_word (pid, &pidbuf[5], 10, 0);
|
p = _itoa (pid, &pidbuf[5], 10, 0);
|
||||||
while (p > pidbuf)
|
while (p > pidbuf)
|
||||||
*--p = '0';
|
*--p = '0';
|
||||||
pidbuf[5] = ':';
|
pidbuf[5] = ':';
|
||||||
@ -185,7 +185,7 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
|
|||||||
having more than one integer formatting in a call. */
|
having more than one integer formatting in a call. */
|
||||||
char *buf = (char *) alloca (3 * sizeof (unsigned long int));
|
char *buf = (char *) alloca (3 * sizeof (unsigned long int));
|
||||||
char *endp = &buf[3 * sizeof (unsigned long int)];
|
char *endp = &buf[3 * sizeof (unsigned long int)];
|
||||||
char *cp = _itoa_word (num, endp, *fmt == 'x' ? 16 : 10, 0);
|
char *cp = _itoa (num, endp, *fmt == 'x' ? 16 : 10, 0);
|
||||||
|
|
||||||
/* Pad to the width the user specified. */
|
/* Pad to the width the user specified. */
|
||||||
if (width != -1)
|
if (width != -1)
|
||||||
|
@ -142,9 +142,10 @@ _dl_new_object (char *realname, const char *libname, int type,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the end of the path and see whether we have to add
|
/* Find the end of the path and see whether we have to add a
|
||||||
a slash. */
|
slash. We could use rawmemchr but this need not be
|
||||||
cp = __rawmemchr (origin, '\0');
|
fast. */
|
||||||
|
cp = (strchr) (origin, '\0');
|
||||||
if (cp[-1] != '/')
|
if (cp[-1] != '/')
|
||||||
*cp++ = '/';
|
*cp++ = '/';
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <bp-sym.h>
|
#include <bp-sym.h>
|
||||||
|
|
||||||
#include <dl-dst.h>
|
#include <dl-dst.h>
|
||||||
#include <stdio-common/_itoa.h>
|
|
||||||
|
|
||||||
|
|
||||||
extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
|
extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@ -217,9 +218,23 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
|
|||||||
kcountsize = textsize / HISTFRACTION;
|
kcountsize = textsize / HISTFRACTION;
|
||||||
hashfraction = HASHFRACTION;
|
hashfraction = HASHFRACTION;
|
||||||
if ((HASHFRACTION & (HASHFRACTION - 1)) == 0)
|
if ((HASHFRACTION & (HASHFRACTION - 1)) == 0)
|
||||||
|
{
|
||||||
/* If HASHFRACTION is a power of two, mcount can use shifting
|
/* If HASHFRACTION is a power of two, mcount can use shifting
|
||||||
instead of integer division. Precompute shift amount. */
|
instead of integer division. Precompute shift amount.
|
||||||
|
|
||||||
|
This is a constant but the compiler cannot compile the
|
||||||
|
expression away since the __ffs implementation is not known
|
||||||
|
to the compiler. Help the compiler by precomputing the
|
||||||
|
usual cases. */
|
||||||
|
assert (hashfraction == 2);
|
||||||
|
|
||||||
|
if (sizeof (*froms) == 8)
|
||||||
|
log_hashfraction = 4;
|
||||||
|
else if (sizeof (*froms) == 16)
|
||||||
|
log_hashfraction = 5;
|
||||||
|
else
|
||||||
log_hashfraction = __ffs (hashfraction * sizeof (*froms)) - 1;
|
log_hashfraction = __ffs (hashfraction * sizeof (*froms)) - 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
log_hashfraction = -1;
|
log_hashfraction = -1;
|
||||||
tossize = textsize / HASHFRACTION;
|
tossize = textsize / HASHFRACTION;
|
||||||
|
@ -59,7 +59,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
|||||||
lazy = 0;
|
lazy = 0;
|
||||||
|
|
||||||
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_RELOC, 0))
|
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_RELOC, 0))
|
||||||
_dl_printf ("\nrelocation processing: %s%s\n",
|
INT(_dl_debug_printf) ("\nrelocation processing: %s%s\n",
|
||||||
l->l_name[0] ? l->l_name : _dl_argv[0],
|
l->l_name[0] ? l->l_name : _dl_argv[0],
|
||||||
lazy ? " (lazy)" : "");
|
lazy ? " (lazy)" : "");
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ no version information available (required by ", name, ")");
|
|||||||
buf[sizeof (buf) - 1] = '\0';
|
buf[sizeof (buf) - 1] = '\0';
|
||||||
/* XXX We cannot translate the message. */
|
/* XXX We cannot translate the message. */
|
||||||
errstring = make_string ("unsupported version ",
|
errstring = make_string ("unsupported version ",
|
||||||
_itoa_word (def->vd_version,
|
_itoa (def->vd_version,
|
||||||
&buf[sizeof (buf) - 1], 10, 0),
|
&buf[sizeof (buf) - 1], 10, 0),
|
||||||
" of Verdef record");
|
" of Verdef record");
|
||||||
result = 1;
|
result = 1;
|
||||||
@ -210,7 +210,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode)
|
|||||||
buf[sizeof (buf) - 1] = '\0';
|
buf[sizeof (buf) - 1] = '\0';
|
||||||
/* XXX We cannot translate the message. */
|
/* XXX We cannot translate the message. */
|
||||||
errstring = make_string ("unsupported version ",
|
errstring = make_string ("unsupported version ",
|
||||||
_itoa_word (ent->vn_version,
|
_itoa (ent->vn_version,
|
||||||
&buf[sizeof (buf) - 1], 10, 0),
|
&buf[sizeof (buf) - 1], 10, 0),
|
||||||
" of Verneed record\n");
|
" of Verneed record\n");
|
||||||
call_error:
|
call_error:
|
||||||
|
16
elf/rtld.c
16
elf/rtld.c
@ -697,7 +697,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
|||||||
|
|
||||||
HP_TIMING_NOW (start);
|
HP_TIMING_NOW (start);
|
||||||
|
|
||||||
while ((p = strsep (&list, " :")) != NULL)
|
/* Prevent optimizing strsep. Speed is not important here. */
|
||||||
|
while ((p = (strsep) (&list, " :")) != NULL)
|
||||||
if (p[0] != '\0'
|
if (p[0] != '\0'
|
||||||
&& (__builtin_expect (! __libc_enable_secure, 1)
|
&& (__builtin_expect (! __libc_enable_secure, 1)
|
||||||
|| strchr (p, '/') == NULL))
|
|| strchr (p, '/') == NULL))
|
||||||
@ -1063,8 +1064,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
|||||||
{
|
{
|
||||||
ElfW(Lib) *liblist, *liblistend;
|
ElfW(Lib) *liblist, *liblistend;
|
||||||
struct link_map **r_list, **r_listend, *l;
|
struct link_map **r_list, **r_listend, *l;
|
||||||
const char *strtab = (const void *)
|
const char *strtab = (const void *) D_PTR (GL(dl_loaded),
|
||||||
D_PTR (GL(dl_loaded), l_info[DT_STRTAB]);
|
l_info[DT_STRTAB]);
|
||||||
|
|
||||||
assert (GL(dl_loaded)->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL);
|
assert (GL(dl_loaded)->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL);
|
||||||
liblist = (ElfW(Lib) *)
|
liblist = (ElfW(Lib) *)
|
||||||
@ -1550,7 +1551,8 @@ process_envvars (enum mode *modep)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsetenv (nextp);
|
unsetenv (nextp);
|
||||||
nextp = (char *) rawmemchr (nextp, '\0') + 1;
|
/* We could use rawmemchr but this need not be fast. */
|
||||||
|
nextp = (char *) (strchr) (nextp, '\0') + 1;
|
||||||
}
|
}
|
||||||
while (*nextp != '\0');
|
while (*nextp != '\0');
|
||||||
|
|
||||||
@ -1572,7 +1574,7 @@ process_envvars (enum mode *modep)
|
|||||||
char *startp;
|
char *startp;
|
||||||
|
|
||||||
buf[name_len + 11] = '\0';
|
buf[name_len + 11] = '\0';
|
||||||
startp = _itoa_word (__getpid (), &buf[name_len + 11], 10, 0);
|
startp = _itoa (__getpid (), &buf[name_len + 11], 10, 0);
|
||||||
*--startp = '.';
|
*--startp = '.';
|
||||||
startp = memcpy (startp - name_len, debug_output, name_len);
|
startp = memcpy (startp - name_len, debug_output, name_len);
|
||||||
|
|
||||||
@ -1607,7 +1609,7 @@ print_statistics (void)
|
|||||||
{
|
{
|
||||||
char pbuf[30];
|
char pbuf[30];
|
||||||
HP_TIMING_PRINT (buf, sizeof (buf), relocate_time);
|
HP_TIMING_PRINT (buf, sizeof (buf), relocate_time);
|
||||||
cp = _itoa_word ((1000ULL * relocate_time) / rtld_total_time,
|
cp = _itoa ((1000ULL * relocate_time) / rtld_total_time,
|
||||||
pbuf + sizeof (pbuf), 10, 0);
|
pbuf + sizeof (pbuf), 10, 0);
|
||||||
wp = pbuf;
|
wp = pbuf;
|
||||||
switch (pbuf + sizeof (pbuf) - cp)
|
switch (pbuf + sizeof (pbuf) - cp)
|
||||||
@ -1637,7 +1639,7 @@ print_statistics (void)
|
|||||||
{
|
{
|
||||||
char pbuf[30];
|
char pbuf[30];
|
||||||
HP_TIMING_PRINT (buf, sizeof (buf), load_time);
|
HP_TIMING_PRINT (buf, sizeof (buf), load_time);
|
||||||
cp = _itoa_word ((1000ULL * load_time) / rtld_total_time,
|
cp = _itoa ((1000ULL * load_time) / rtld_total_time,
|
||||||
pbuf + sizeof (pbuf), 10, 0);
|
pbuf + sizeof (pbuf), 10, 0);
|
||||||
wp = pbuf;
|
wp = pbuf;
|
||||||
switch (pbuf + sizeof (pbuf) - cp)
|
switch (pbuf + sizeof (pbuf) - cp)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Internal function for converting integers to ASCII.
|
/* Internal function for converting integers to ASCII.
|
||||||
Copyright (C) 1994, 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1994,1995,1996,1999,2000,2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Torbjorn Granlund <tege@matematik.su.se>
|
Contributed by Torbjorn Granlund <tege@matematik.su.se>
|
||||||
and Ulrich Drepper <drepper@gnu.org>.
|
and Ulrich Drepper <drepper@gnu.org>.
|
||||||
@ -170,7 +170,6 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
int upper_case;
|
int upper_case;
|
||||||
{
|
{
|
||||||
const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
|
const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
|
||||||
char *bp = buflim;
|
|
||||||
const struct base_table_t *brec = &_itoa_base_table[base - 2];
|
const struct base_table_t *brec = &_itoa_base_table[base - 2];
|
||||||
|
|
||||||
switch (base)
|
switch (base)
|
||||||
@ -191,7 +190,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
work_lo = value & 0xfffffffful; \
|
work_lo = value & 0xfffffffful; \
|
||||||
for (cnt = BITS_PER_MP_LIMB / BITS; cnt > 0; --cnt) \
|
for (cnt = BITS_PER_MP_LIMB / BITS; cnt > 0; --cnt) \
|
||||||
{ \
|
{ \
|
||||||
*--bp = digits[work_lo & ((1ul << BITS) - 1)]; \
|
*--buflim = digits[work_lo & ((1ul << BITS) - 1)]; \
|
||||||
work_lo >>= BITS; \
|
work_lo >>= BITS; \
|
||||||
} \
|
} \
|
||||||
if (BITS_PER_MP_LIMB % BITS != 0) \
|
if (BITS_PER_MP_LIMB % BITS != 0) \
|
||||||
@ -205,7 +204,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
if (work_hi == 0) \
|
if (work_hi == 0) \
|
||||||
work_hi = work_lo; \
|
work_hi = work_lo; \
|
||||||
else \
|
else \
|
||||||
*--bp = digits[work_lo]; \
|
*--buflim = digits[work_lo]; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
@ -213,7 +212,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
} \
|
} \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
*--bp = digits[work_hi & ((1 << BITS) - 1)]; \
|
*--buflim = digits[work_hi & ((1 << BITS) - 1)]; \
|
||||||
work_hi >>= BITS; \
|
work_hi >>= BITS; \
|
||||||
} \
|
} \
|
||||||
while (work_hi != 0); \
|
while (work_hi != 0); \
|
||||||
@ -239,7 +238,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
umul_ppmm (x, dummy, value, base_multiplier);
|
umul_ppmm (x, dummy, value, base_multiplier);
|
||||||
quo = (x + ((value - x) >> 1)) >> (brec->post_shift - 1);
|
quo = (x + ((value - x) >> 1)) >> (brec->post_shift - 1);
|
||||||
rem = value - quo * base;
|
rem = value - quo * base;
|
||||||
*--bp = digits[rem];
|
*--buflim = digits[rem];
|
||||||
value = quo;
|
value = quo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -250,7 +249,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
umul_ppmm (x, dummy, value, base_multiplier);
|
umul_ppmm (x, dummy, value, base_multiplier);
|
||||||
quo = x >> brec->post_shift;
|
quo = x >> brec->post_shift;
|
||||||
rem = value - quo * base;
|
rem = value - quo * base;
|
||||||
*--bp = digits[rem];
|
*--buflim = digits[rem];
|
||||||
value = quo;
|
value = quo;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -376,7 +375,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
umul_ppmm (x, dummy, ti, base_multiplier);
|
umul_ppmm (x, dummy, ti, base_multiplier);
|
||||||
quo = (x + ((ti - x) >> 1)) >> (brec->post_shift - 1);
|
quo = (x + ((ti - x) >> 1)) >> (brec->post_shift - 1);
|
||||||
rem = ti - quo * base;
|
rem = ti - quo * base;
|
||||||
*--bp = digits[rem];
|
*--buflim = digits[rem];
|
||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
@ -388,7 +387,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
umul_ppmm (x, dummy, ti, base_multiplier);
|
umul_ppmm (x, dummy, ti, base_multiplier);
|
||||||
quo = x >> brec->post_shift;
|
quo = x >> brec->post_shift;
|
||||||
rem = ti - quo * base;
|
rem = ti - quo * base;
|
||||||
*--bp = digits[rem];
|
*--buflim = digits[rem];
|
||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
@ -399,7 +398,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
|
|
||||||
quo = ti / base;
|
quo = ti / base;
|
||||||
rem = ti % base;
|
rem = ti % base;
|
||||||
*--bp = digits[rem];
|
*--buflim = digits[rem];
|
||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
@ -408,7 +407,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
if (n != 0)
|
if (n != 0)
|
||||||
while (ndig_for_this_limb < brec->big.ndigits)
|
while (ndig_for_this_limb < brec->big.ndigits)
|
||||||
{
|
{
|
||||||
*--bp = '0';
|
*--buflim = '0';
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,5 +417,5 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bp;
|
return buflim;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Internal function for converting integers to ASCII.
|
/* Internal function for converting integers to ASCII.
|
||||||
Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
Copyright (C) 1994, 95, 96, 97, 98, 99, 2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -35,14 +35,13 @@ _itoa_word (unsigned long value, char *buflim,
|
|||||||
{
|
{
|
||||||
extern const char _itoa_upper_digits[], _itoa_lower_digits[];
|
extern const char _itoa_upper_digits[], _itoa_lower_digits[];
|
||||||
const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
|
const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
|
||||||
char *bp = buflim;
|
|
||||||
|
|
||||||
switch (base)
|
switch (base)
|
||||||
{
|
{
|
||||||
#define SPECIAL(Base) \
|
#define SPECIAL(Base) \
|
||||||
case Base: \
|
case Base: \
|
||||||
do \
|
do \
|
||||||
*--bp = digits[value % Base]; \
|
*--buflim = digits[value % Base]; \
|
||||||
while ((value /= Base) != 0); \
|
while ((value /= Base) != 0); \
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -51,10 +50,10 @@ _itoa_word (unsigned long value, char *buflim,
|
|||||||
SPECIAL (8);
|
SPECIAL (8);
|
||||||
default:
|
default:
|
||||||
do
|
do
|
||||||
*--bp = digits[value % base];
|
*--buflim = digits[value % base];
|
||||||
while ((value /= base) != 0);
|
while ((value /= base) != 0);
|
||||||
}
|
}
|
||||||
return bp;
|
return buflim;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char * __attribute__ ((unused))
|
static inline char * __attribute__ ((unused))
|
||||||
|
@ -258,9 +258,9 @@ _dl_show_auxv (void)
|
|||||||
const char *val = av->a_un.a_ptr;
|
const char *val = av->a_un.a_ptr;
|
||||||
|
|
||||||
if (__builtin_expect (auxvars[idx].form, dec) == dec)
|
if (__builtin_expect (auxvars[idx].form, dec) == dec)
|
||||||
val = _itoa_word (av->a_un.a_val, buf + sizeof buf - 1, 10, 0);
|
val = _itoa (av->a_un.a_val, buf + sizeof buf - 1, 10, 0);
|
||||||
else if (__builtin_expect (auxvars[idx].form, hex) == hex)
|
else if (__builtin_expect (auxvars[idx].form, hex) == hex)
|
||||||
val = _itoa_word (av->a_un.a_val, buf + sizeof buf - 1, 16, 0);
|
val = _itoa (av->a_un.a_val, buf + sizeof buf - 1, 16, 0);
|
||||||
|
|
||||||
_dl_printf ("%s%s\n", auxvars[idx].label, val);
|
_dl_printf ("%s%s\n", auxvars[idx].label, val);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ __readv (fd, vector, count)
|
|||||||
char *buffer;
|
char *buffer;
|
||||||
char *buffer_start;
|
char *buffer_start;
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
int bytes_read;
|
ssize_t bytes_read;
|
||||||
int i;
|
int i;
|
||||||
bool use_malloc = false;
|
bool use_malloc = false;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1996, 1997, 2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -19,6 +19,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
/* Write data pointed by the buffers described by VECTOR, which
|
/* Write data pointed by the buffers described by VECTOR, which
|
||||||
@ -35,23 +38,46 @@ __writev (fd, vector, count)
|
|||||||
char *buffer;
|
char *buffer;
|
||||||
register char *bp;
|
register char *bp;
|
||||||
size_t bytes, to_copy;
|
size_t bytes, to_copy;
|
||||||
|
ssize_t bytes_written;
|
||||||
int i;
|
int i;
|
||||||
|
bool use_malloc = false;
|
||||||
|
|
||||||
/* Find the total number of bytes to be written. */
|
/* Find the total number of bytes to be written. */
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
/* Check for ssize_t overflow. */
|
||||||
|
if (SSIZE_MAX - bytes < vector[i].iov_len)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
bytes += vector[i].iov_len;
|
bytes += vector[i].iov_len;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate a temporary buffer to hold the data. */
|
/* Allocate a temporary buffer to hold the data. We should normally
|
||||||
|
use alloca since it's faster and does not require synchronization
|
||||||
|
with other threads. But we cannot if the amount of memory
|
||||||
|
required is too large. Use 512k as the limit. */
|
||||||
|
if (bytes < 512 * 1024)
|
||||||
buffer = (char *) __alloca (bytes);
|
buffer = (char *) __alloca (bytes);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer = (char *) malloc (bytes);
|
||||||
|
if (buffer == NULL)
|
||||||
|
/* XXX I don't know whether it is acceptable to try writing
|
||||||
|
the data in chunks. Probably not so we just fail here. */
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
use_malloc = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy the data into BUFFER. */
|
/* Copy the data into BUFFER. */
|
||||||
to_copy = bytes;
|
to_copy = bytes;
|
||||||
bp = buffer;
|
bp = buffer;
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
size_t copy = MIN (vector[i].iov_len, to_copy);
|
||||||
size_t copy = min (vector[i].iov_len, to_copy);
|
|
||||||
|
|
||||||
bp = __mempcpy ((void *) bp, (void *) vector[i].iov_base, copy);
|
bp = __mempcpy ((void *) bp, (void *) vector[i].iov_base, copy);
|
||||||
|
|
||||||
@ -60,7 +86,12 @@ __writev (fd, vector, count)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __write (fd, buffer, bytes);
|
bytes_written = __write (fd, buffer, bytes);
|
||||||
|
|
||||||
|
if (use_malloc)
|
||||||
|
free (buffer);
|
||||||
|
|
||||||
|
return bytes_written;
|
||||||
}
|
}
|
||||||
#ifndef __writev
|
#ifndef __writev
|
||||||
weak_alias (__writev, writev)
|
weak_alias (__writev, writev)
|
||||||
|
Reference in New Issue
Block a user