mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
9710f75d4a
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.
80 lines
2.7 KiB
C
80 lines
2.7 KiB
C
/* Internal function for converting integers to ASCII.
|
|
Copyright (C) 1994, 95, 96, 97, 98, 99, 2002 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
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#ifndef _ITOA_H
|
|
#define _ITOA_H
|
|
#include <sys/cdefs.h>
|
|
|
|
/* Convert VALUE into ASCII in base BASE (2..36).
|
|
Write backwards starting the character just before BUFLIM.
|
|
Return the address of the first (left-to-right) character in the number.
|
|
Use upper case letters iff UPPER_CASE is nonzero. */
|
|
|
|
extern char *_itoa (unsigned long long int value, char *buflim,
|
|
unsigned int base, int upper_case);
|
|
|
|
static inline char * __attribute__ ((unused))
|
|
_itoa_word (unsigned long value, char *buflim,
|
|
unsigned int base, int upper_case)
|
|
{
|
|
extern const char _itoa_upper_digits[], _itoa_lower_digits[];
|
|
const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
|
|
|
|
switch (base)
|
|
{
|
|
#define SPECIAL(Base) \
|
|
case Base: \
|
|
do \
|
|
*--buflim = digits[value % Base]; \
|
|
while ((value /= Base) != 0); \
|
|
break
|
|
|
|
SPECIAL (10);
|
|
SPECIAL (16);
|
|
SPECIAL (8);
|
|
default:
|
|
do
|
|
*--buflim = digits[value % base];
|
|
while ((value /= base) != 0);
|
|
}
|
|
return buflim;
|
|
}
|
|
|
|
static inline char * __attribute__ ((unused))
|
|
_fitoa_word (unsigned long value, char *buf, unsigned int base, int upper_case)
|
|
{
|
|
char tmpbuf[sizeof (value) * 4]; /* Worst case length: base 2. */
|
|
char *cp = _itoa_word (value, tmpbuf + sizeof (value) * 4, base, upper_case);
|
|
while (cp < tmpbuf + sizeof (value) * 4)
|
|
*buf++ = *cp++;
|
|
return buf;
|
|
}
|
|
|
|
static inline char * __attribute__ ((unused))
|
|
_fitoa (unsigned long long value, char *buf, unsigned int base, int upper_case)
|
|
{
|
|
char tmpbuf[sizeof (value) * 4]; /* Worst case length: base 2. */
|
|
char *cp = _itoa (value, tmpbuf + sizeof (value) * 4, base, upper_case);
|
|
while (cp < tmpbuf + sizeof (value) * 4)
|
|
*buf++ = *cp++;
|
|
return buf;
|
|
}
|
|
|
|
#endif /* itoa.h */
|