1997-11-18 02:31  Ulrich Drepper  <drepper@cygnus.com>

	* iconv/Makefile: New file.
	* iconv/gconv.c: New file.
	* iconv/gconv.h: New file.
	* iconv/gconv_builtin.c: New file.
	* iconv/gconv_builtin.h: New file.
	* iconv/gconv_close.c: New file.
	* iconv/gconv_conf.c: New file.
	* iconv/gconv_db.c: New file.
	* iconv/gconv_dl.c: New file.
	* iconv/gconv_open.c: New file.
	* iconv/gconv_simple.c: New file.
	* iconv/iconv.c: New file.
	* iconv/iconv.h: New file.
	* iconv/iconv_close.c: New file.
	* iconv/iconv_open.c: New file.
	* include/gconv.h: New file.

	* Makeconfig: Define gconvdir.
	* Makefile (subdirs): Add iconv.

	* string/bits/string2.h: Add optimization for strtok_r.

	* sysdeps/generic/_G_config.h: Define __need_NULL to get definition
	for NULL.
	Reported by H.J. Lu <hjl@gnu.ai.mit.edu>.
	* configure.in: Correct test for bash2.
	* locale/Makefile (CFLAGS-charmap.c): Add -Wno-char-subscripts.
	(CFLAGS-locfile.c): Likewise.
	Suggested by Zack Weinberg <zack@rabi.phys.columbia.edu>.
	* misc/hsearch_r.c (hsearch_r): Avoid undefinitely search for
	non-existing entry if the table is full.
	* posix/regex.h: Pretty print.
	* stdio-common/printf_fp.c: Don't define NDEBUG if already defined.
	* sysdeps/posix/ctermid.c: Simplify a bit.
	* sysdeps/unix/sysv/linux/net/if.h: Pretty print.
1997-11-17  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* sysdeps/unix/sysv/linux/sys/quota.h: Add include for
	<sys/types.h> instead of <asm/types.h>.
1997-11-16  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* math/libm-test.c (asin_test): Add epsilon for asin (0.5).
1997-11-16 17:09  H.J. Lu  <hjl@gnu.ai.mit.edu>
	* libc.map (_IO_stdin_, _IO_stdout_, _IO_stderr_, _IO_fopen,
	fopen, freopen, _IO_fclose, fclose): Added to GLIBC_2.0.
	(_IO_stdin_, _IO_stdout_, _IO_stderr_): Removed from GLIBC_2.1.
	(_IO_2_1_stdin_, _IO_2_1_stdout_, _IO_2_1_stderr_, _IO_fclose,
	fclose): Added to GLIBC_2.1.
	* libio/Makefile (routines, shared-only-routines): Add
	oldiofclose.  Remove oldfreopen.
	* libio/freopen.c (freopen): When PIC is defined, call
	_IO_old_freopen () for old stdio.
	* libio/iofclose.c (_IO_new_fclose): Renamed from _IO_fclose.
	(_IO_fclose, fclose): Use _IO_new_fclose as default version
	for GLIBC_2.1.
	* libio/iolibio.h (_IO_old_freopen): Use _IO_old_file_close_it
	instead of _IO_file_close_it.
	* libio/libio.h (_IO_stdin_, _IO_stdout_, _IO_stderr_): Changed
	to _IO_2_1_stdxxx_.
	(_IO_stdin, _IO_stdout, _IO_stderr): Declare as extern if _LIBC
	* libio/libioP.h (_IO_old_do_flush): New.
	* libio/oldfileops.c (_IO_old_file_close_it,
	_IO_old_file_finish, _IO_old_file_overflow, _IO_old_file_sync):
	Call _IO_old_do_flush () instead of _IO_do_flush ().
	(_IO_old_file_xsputn): Call _IO_old_do_write () instead of
	_IO_do_write ().
	* libio/oldiofopen.c (_IO_old_fopen): Call _IO_old_file_init ()
	instead of _IO_file_init ().
	Bind old symbols to version GLIBC_2.0.
	* libio/oldstdfiles.c (DEF_STDFILE): Don't use symbol_version.
	(_IO_old_stdin_, _IO_old_stdout_, _IO_old_stderr_): Changed to
	_IO_stdxxx_.
	(_IO_check_libio): New function in .init.
	* libio/oldiofclose.c: New file.
	* libio/stdfiles.c (_IO_new_stdin_, _IO_new_stdout_,
	_IO_new_stderr_): Changed to _IO_2_1_stdxxx_.
	(DEF_STDFILE): Don't use default_symbol_version.
	* libio/stdio.c (stdin, stdout, stderr): Set to
	_IO_2_1_stdxxx_._
	(_IO_stdin, _IO_stdout, _IO_stderr): New, strong alias of
	stdxxx.
	* csu/Makefile (distribute): Add init.c.
	(extra-objs): Add init.o for ELF.
	(start-installed-name): Add $(objpfx)init.o.
	* csu/init.c: New file.
1997-11-12 08:02  H.J. Lu  <hjl@gnu.ai.mit.edu>
	* elf/dl-lookup.c (do_lookup): Don't use the hidden base
	definition as the default.
1997-08-27  Klaus Espenlaub  <kespenla@hydra.informatik.uni-ulm.de>
	* erand48_r.c (__erand48_r): Implement for 32 bit short int.
1997-11-15  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* elf/genrtldtbl.awk: Replace gensub for compatibility with gawk2
	(PR 351).
1997-11-16 21:01  Philip Blundell  <Philip.Blundell@pobox.com>
	* sysdeps/arm/sysdep.h: Use __APCS_32__ to decide whether or not
	to preserve condition codes on function call.
1997-11-13  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* sysdeps/generic/s_exp2l.c: Change exp2l to __ieee754_exp2l.
1997-11-14  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* math/libm-test.c (asin_test): Add epsilon for float.
	(tan_test): Add epsilon for float.
	(log1p_test): Add epsilon for float.
	(inverse_functions): Add epsilons.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers) [socket]: Add
	net/if_packet.h.
	* sysdeps/unix/sysv/linux/Dist: Add net/if_packet.h.
1997-11-10  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* md5-crypt/Makefile (extra-objs): Make recursively expanded
	variable, since $(object-suffixes) is not defined yet.
1997-11-11  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* db2/Makefile (distribute): db185/db185_int.src ->
	db185/db185_int.h.
1997-11-11  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* misc/tst-fdset.c: Don't require the value of FD_ISSET to be
	exactly one.
1997-11-11  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* sysdeps/generic/e_acoshl.c: Fix stub_warning: use the user level
	* sysdeps/generic/e_acosl.c: Likewise.
	* sysdeps/generic/e_asinl.c: Likewise.
	* sysdeps/generic/e_atan2l.c: Likewise.
	* sysdeps/generic/e_expl.c: Likewise.
	* sysdeps/generic/e_fmodl.c: Likewise.
	* sysdeps/generic/e_j0l.c: Likewise.
	* sysdeps/generic/e_j1l.c: Likewise.
	* sysdeps/generic/e_jnl.c: Likewise.
	* sysdeps/generic/e_lgammal_r.c: Likewise.
	* sysdeps/generic/e_log10l.c: Likewise.
	* sysdeps/generic/e_logl.c: Likewise.
	* sysdeps/generic/e_powl.c: Likewise.
	* sysdeps/generic/e_sqrtl.c: Likewise.
	* sysdeps/generic/e_exp2l.c: Likewise.

1997-11-11  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* Make-dist (+sysdep-names): Remove extra paren.
	* Makefile (distribute): Add stub-tag.h.
	* elf/Makefile (distribute): Add atomicity.h.
	* stdlib/Makefile (headers): Add ucontext.h and sys/ucontext.h.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers)
	[$(subdir)=socket]: Add net/if_packet.h.
	* sysdeps/alpha/Dist: Remove setjmp_aux.c.
	* sysdeps/unix/sysv/linux/Dist: Add s_pread64.c, s_pwrite64.c,
	net/if_packet.h, scsi/sg.h.
1997-11-13  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* Makefile (install): Quote $(CC) expansion.
1997-11-14  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Added caching of
	working /proc cwd and no restrictions on path length.  Following
	some ideas from Andi Kleen <ak@muc.de> (PR 350).
1997-11-14 19:14  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>
	* nis/nss_compat/compat-grp.c: Remove buggy assert call.
1997-11-14 22:23  Ulrich Drepper  <drepper@cygnus.com>
	* sysdeps/libm-i387/s_fdim.S: New file.
	* sysdeps/libm-i387/s_fdimf.S: New file.
	* sysdeps/libm-i387/s_fdiml.S: New file.
	* sysdeps/libm-i387/i686/s_fdim.S: New file.
	* sysdeps/libm-i387/i686/s_fdimf.S: New file.
	* sysdeps/libm-i387/i686/s_fdiml.S: New file.
1997-11-12  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	* string/bits/string2.h (strstr): Avoid warning if HAYSTACK is a
	pointer to unsigned char.
1997-11-13  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* sysdeps/libm-ieee754/s_llrintf.c (__llrintf): Fix function.
	* sysdeps/libm-ieee754/s_lrintf.c (__lrintf): Fix function.
	* sysdeps/libm-ieee754/s_lrint.c (__lrint): Fix function.
1997-11-12  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
	* sysdeps/libm-ieee754/s_ilogbf.c: Correct return values for
	ilogb(0/NaN).
	* sysdeps/libm-ieee754/s_ilogbl.c: Likewise.
	* sysdeps/libm-ieee754/s_ilogb.c: Likewise.

1997-11-14 05:44  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/libm-i387/s_fmin.S: New file.
	* sysdeps/libm-i387/s_fminf.S: New file.
	* sysdeps/libm-i387/s_fminl.S: New file.
	* sysdeps/libm-i387/s_fmax.S: New file.
	* sysdeps/libm-i387/s_fmaxf.S: New file.
	* sysdeps/libm-i387/s_fmaxl.S: New file.
	* sysdeps/libm-i387/i686/s_fmin.S: New file.
	* sysdeps/libm-i387/i686/s_fminf.S: New file.
	* sysdeps/libm-i387/i686/s_fminl.S: New file.
	* sysdeps/libm-i387/i686/s_fmax.S: New file.
	* sysdeps/libm-i387/i686/s_fmaxf.S: New file.
	* sysdeps/libm-i387/i686/s_fmaxl.S: New file.

1997-11-14 03:06  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/accept.S: Add __libc_accept as alias.
	* sysdeps/unix/sysv/linux/send.S: Likewise.
	* sysdeps/unix/sysv/linux/recv.S: Likewise.
	* sysdeps/unix/sysv/linux/connect.S: Likewise.
	Reported by Christopher Wiles <wileyc@ai.cs.fujitsu.co.jp>.
See ChangeLog.7 for earlier changes.
This commit is contained in:
Ulrich Drepper 1997-11-18 02:50:07 +00:00
parent fe0ec73edb
commit 6973fc0127
116 changed files with 18259 additions and 14801 deletions

14792
ChangeLog

File diff suppressed because it is too large Load Diff

14580
ChangeLog.7 Normal file

File diff suppressed because it is too large Load Diff

28
FAQ
View File

@ -104,6 +104,11 @@ please let me know.
[Q29] ``I don't include any kernel header myself but still the
compiler complains about type redeclarations of types in the
kernel headers.''
[Q30] ``When I start the program XXX after upgrading the library
I get
XXX: Symbol `_sys_errlist' has different size in shared object, consider re-linking
Why? What to do?''
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[Q1] ``What systems does the GNU C Library run on?''
@ -776,6 +781,29 @@ There might be some more problems left but 2.1.61 fixes some of the known
ones. See the BUGS file for other known problems.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
[Q30] ``When I start the program XXX after upgrading the library
I get
XXX: Symbol `_sys_errlist' has different size in shared object, consider re-linking
Why? What to do?''
[A30] {UD} As the message says, relink the binary. The problem is that
very few symbols from the library can change in size and there is no way
to avoid this. _sys_errlist is a good example. Occasionally there are
new error numbers added to the kernel and this must be reflected at user
level.
But this does not mean all programs are doomed once such a change is
necessary. Such symbols should normally not be used at all. There are
mechanisms to avoid using them. In the case of _sys_errlist, there is the
strerror() function which should _always_ be used instead. So the correct
fix is to rewrite that part of the application.
In some situations (especially when testing a new library release) it might
be possible that such a symbol size change slipped in though it must not
happen. So in case of doubt report such a warning message as a problem.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Answers were given by:

View File

@ -96,7 +96,7 @@ foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
foo:=$(shell echo 'generic +sysdeps=$(+sysdeps)'>&2)
+sysdep-names := $(sort $(patsubst $(..)sysdeps/generic/%,%,\
$(patsubst $(..)sysdeps/libm-ieee754/%,%,\
$(+sysdeps)))))
$(+sysdeps))))
foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
ifdef subdir-dirs

View File

@ -217,6 +217,12 @@ i18ndir = $(datadir)/i18n
endif
inst_i18ndir = $(install_root)$(i18ndir)
# Where to install the shared object for charset transformation.
ifndef gconvdir
gconvdir = $(libdir)/gconv
endif
inst_gconvdir = $(install_root)$(gconvdir)
# Where to install programs.
ifndef bindir

View File

@ -53,7 +53,7 @@ endif
# These are the subdirectories containing the library source.
subdirs = csu assert ctype db2 locale intl catgets math setjmp signal stdlib \
stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd \
posix io termios resource misc socket sysvipc gmon gnulib \
posix io termios resource misc socket sysvipc gmon gnulib iconv \
wctype manual shadow md5-crypt po argp $(add-ons) nss \
$(sysdep-subdirs) $(binfmt-subdir)
export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
@ -117,7 +117,7 @@ include Makerules
# Install from subdirectories too.
install: subdir_install
# Create linkfs for shared libraries using the `ldconfig' program is possible.
# Create links for shared libraries using the `ldconfig' program is possible.
# Ignore the error if we cannot update /etc/ld.so.cache.
ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
@ -127,7 +127,7 @@ install:
ifneq (no,$(PERL))
ifeq (/usr,$(prefix))
ifeq (,$(install_root))
CC=$(CC) $(PERL) test-installation.pl $(common-objpfx)
CC="$(CC)" $(PERL) test-installation.pl $(common-objpfx)
endif
endif
endif
@ -312,7 +312,8 @@ distribute := README INSTALL FAQ NOTES NEWS PROJECTS BUGS \
config.h.in config.make.in config-name.in Makefile.in \
autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags
rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags \
stub-tag.h
distribute := $(strip $(distribute))
generated := $(generated) stubs.h version-info.h

83
configure vendored
View File

@ -1636,7 +1636,8 @@ else
fi
if test "$BASH" != no &&
$BASH -c 'test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
$BASH -c 'test "$BASH_VERSINFO"
&& test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
libc_cv_have_bash2=yes
else
libc_cv_have_bash2=no
@ -1647,7 +1648,7 @@ if test "$BASH" = no; then
# Extract the first word of "ksh", so it can be a program name with args.
set dummy ksh; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1651: checking for $ac_word" >&5
echo "configure:1652: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_KSH'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1693,7 +1694,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1697: checking for $ac_word" >&5
echo "configure:1698: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1728,7 +1729,7 @@ test -n "$PERL" || PERL="no"
echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6
echo "configure:1732: checking for signed size_t type" >&5
echo "configure:1733: checking for signed size_t type" >&5
if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1752,12 +1753,12 @@ EOF
fi
echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6
echo "configure:1756: checking for libc-friendly stddef.h" >&5
echo "configure:1757: checking for libc-friendly stddef.h" >&5
if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1761 "configure"
#line 1762 "configure"
#include "confdefs.h"
#define __need_size_t
#define __need_wchar_t
@ -1772,7 +1773,7 @@ size_t size; wchar_t wchar;
if (&size == NULL || &wchar == NULL) abort ();
; return 0; }
EOF
if { (eval echo configure:1776: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_friendly_stddef=yes
else
@ -1791,7 +1792,7 @@ override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
fi
echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6
echo "configure:1795: checking whether we need to use -P to assemble .S files" >&5
echo "configure:1796: checking whether we need to use -P to assemble .S files" >&5
if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1822,7 +1823,7 @@ if test $ac_cv_prog_gcc = yes; then
# We must check this even if -pipe is not given here, because the user
# might do `make CFLAGS=-pipe'.
echo $ac_n "checking for gcc 2.7.x -pipe bug""... $ac_c" 1>&6
echo "configure:1826: checking for gcc 2.7.x -pipe bug" >&5
echo "configure:1827: checking for gcc 2.7.x -pipe bug" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_pipe_bug'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1851,7 +1852,7 @@ else
fi
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6
echo "configure:1855: checking for assembler global-symbol directive" >&5
echo "configure:1856: checking for assembler global-symbol directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1881,7 +1882,7 @@ EOF
fi
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6
echo "configure:1885: checking for .set assembler directive" >&5
echo "configure:1886: checking for .set assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1915,7 +1916,7 @@ EOF
fi
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6
echo "configure:1919: checking for .symver assembler directive" >&5
echo "configure:1920: checking for .symver assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1934,7 +1935,7 @@ fi
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6
echo "configure:1938: checking for ld --version-script" >&5
echo "configure:1939: checking for ld --version-script" >&5
if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1953,7 +1954,7 @@ EOF
if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o
-nostartfiles -nostdlib
-Wl,--version-script,conftest.map
1>&5'; { (eval echo configure:1957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
1>&5'; { (eval echo configure:1958: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_ld_version_script_option=yes
else
@ -1984,7 +1985,7 @@ fi
if test $elf = yes; then
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6
echo "configure:1988: checking for .previous assembler directive" >&5
echo "configure:1989: checking for .previous assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1992,7 +1993,7 @@ else
.section foo_section
.previous
EOF
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1996: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1997: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_previous_directive=yes
else
libc_cv_asm_previous_directive=no
@ -2008,7 +2009,7 @@ EOF
else
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6
echo "configure:2012: checking for .popsection assembler directive" >&5
echo "configure:2013: checking for .popsection assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2016,7 +2017,7 @@ else
.pushsection foo_section
.popsection
EOF
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2020: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2021: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_popsection_directive=yes
else
libc_cv_asm_popsection_directive=no
@ -2036,12 +2037,12 @@ fi
if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
echo "configure:2040: checking for .init and .fini sections" >&5
echo "configure:2041: checking for .init and .fini sections" >&5
if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2045 "configure"
#line 2046 "configure"
#include "confdefs.h"
int main() {
@ -2050,7 +2051,7 @@ asm (".section .init");
asm (".text");
; return 0; }
EOF
if { (eval echo configure:2054: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2055: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_have_initfini=yes
else
@ -2078,19 +2079,19 @@ if test $elf = yes; then
else
if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
echo "configure:2082: checking for _ prefix on C symbol names" >&5
echo "configure:2083: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2087 "configure"
#line 2088 "configure"
#include "confdefs.h"
asm ("_glibc_foobar:");
int main() {
glibc_foobar ();
; return 0; }
EOF
if { (eval echo configure:2094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:2095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
libc_cv_asm_underscores=yes
else
@ -2105,17 +2106,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
echo "configure:2109: checking for _ prefix on C symbol names" >&5
echo "configure:2110: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2114 "configure"
#line 2115 "configure"
#include "confdefs.h"
void underscore_test(void) {
return; }
EOF
if { (eval echo configure:2119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2120: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if grep _underscore_test conftest* >/dev/null; then
rm -f conftest*
libc_cv_asm_underscores=yes
@ -2148,7 +2149,7 @@ if test $elf = yes; then
libc_cv_asm_weakext_directive=no
else
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
echo "configure:2152: checking for assembler .weak directive" >&5
echo "configure:2153: checking for assembler .weak directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2171,7 +2172,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
echo "configure:2175: checking for assembler .weakext directive" >&5
echo "configure:2176: checking for assembler .weakext directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2208,7 +2209,7 @@ EOF
fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
echo "configure:2212: checking for ld --no-whole-archive" >&5
echo "configure:2213: checking for ld --no-whole-archive" >&5
if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2219,7 +2220,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive
-o conftest conftest.c 1>&5'; { (eval echo configure:2223: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
-o conftest conftest.c 1>&5'; { (eval echo configure:2224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ld_no_whole_archive=yes
else
libc_cv_ld_no_whole_archive=no
@ -2230,7 +2231,7 @@ fi
echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6
echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6
echo "configure:2234: checking for gcc -fno-exceptions" >&5
echo "configure:2235: checking for gcc -fno-exceptions" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2241,7 +2242,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fno-exceptions
-o conftest conftest.c 1>&5'; { (eval echo configure:2245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
-o conftest conftest.c 1>&5'; { (eval echo configure:2246: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_no_exceptions=yes
else
libc_cv_gcc_no_exceptions=no
@ -2252,12 +2253,12 @@ fi
echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6
echo "configure:2256: checking for DWARF2 unwind info support" >&5
echo "configure:2257: checking for DWARF2 unwind info support" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
#line 2261 "configure"
#line 2262 "configure"
static char __EH_FRAME_BEGIN__;
_start ()
{
@ -2278,7 +2279,7 @@ __bzero () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:2282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:2283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=yes
else
libc_cv_gcc_dwarf2_unwind_info=no
@ -2336,7 +2337,7 @@ if test "$uname" = "sysdeps/generic"; then
fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
echo "configure:2340: checking OS release for uname" >&5
echo "configure:2341: checking OS release for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2358,7 +2359,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
echo "configure:2362: checking OS version for uname" >&5
echo "configure:2363: checking OS version for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2380,7 +2381,7 @@ else
fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6
echo "configure:2384: checking stdio selection" >&5
echo "configure:2385: checking stdio selection" >&5
case $stdio in
libio) cat >> confdefs.h <<\EOF
@ -2392,7 +2393,7 @@ esac
echo "$ac_t""$stdio" 1>&6
echo $ac_n "checking ldap selection""... $ac_c" 1>&6
echo "configure:2396: checking ldap selection" >&5
echo "configure:2397: checking ldap selection" >&5
case $add_ons in
*ldap*)
@ -2442,7 +2443,7 @@ if test $shared = default; then
fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
echo "configure:2446: checking whether -fPIC is default" >&5
echo "configure:2447: checking whether -fPIC is default" >&5
if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else

View File

@ -422,7 +422,8 @@ AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_PATH_PROG(BASH, bash, no)
if test "$BASH" != no &&
$BASH -c 'test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
$BASH -c 'test "$BASH_VERSINFO"
&& test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
libc_cv_have_bash2=yes
else
libc_cv_have_bash2=no

View File

@ -36,7 +36,7 @@ omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
$(csu-dummies))
install-lib = $(start-installed-name) g$(start-installed-name) \
$(csu-dummies)
distribute = initfini.c gmon-start.c start.c defs.awk abi-note.S
distribute = initfini.c gmon-start.c start.c defs.awk abi-note.S init.c
all: # Make this the default target; it will be defined in Rules.
@ -89,7 +89,7 @@ $(objpfx)defs.h: $(objpfx)initfini.s
endif
ifeq (yes,$(elf))
extra-objs += abi-note.o
extra-objs += abi-note.o init.o
asm-CPPFLAGS += -I$(objpfx).
endif
@ -103,7 +103,8 @@ ifndef start-installed-name-rule
ifeq (yes,$(elf))
# We link the ELF startfile along with a SHT_NOTE section indicating
# the the kernel ABI the binaries linked with this library will require.
$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o
$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
$(objpfx)init.o
$(link-relocatable)
else
# The startfile is installed under different names, so we just call our

37
csu/init.c Normal file
View File

@ -0,0 +1,37 @@
/* Special startup support.
Copyright (C) 1997 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 Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Library General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The Library General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#if defined __GNUC__ && __GNUC__ >= 2
#undef _LIBC
#include <libio.h>
/* This records which stdio is linked against in the application. */
const void *const _IO_stdin_used = _IO_stdin;
#endif

View File

@ -33,7 +33,7 @@ subdir-dirs = btree common db db185 dbm hash lock log mp mutex os txn \
headers = db.h db_185.h
distribute = db_int.h config.h compat.h clib/getlong.c btree/btree.src \
db/db.src db185/db185_int.src hash/hash.src log/log.src \
db/db.src db185/db185_int.h hash/hash.src log/log.src \
txn/txn.src \
$(addprefix include/,btree.h btree_auto.h btree_ext.h \
clib_ext.h common_ext.h cxx_int.h \

View File

@ -37,7 +37,7 @@ elide-routines.os = $(dl-routines) dl-support enbl-secure
rtld-routines := rtld $(dl-routines) dl-sysdep dl-minimal
distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c \
genrtldtbl.awk
genrtldtbl.awk atomicity.h
extra-libs = libdl
extra-libs-others = $(extra-libs)

View File

@ -155,11 +155,12 @@ do_lookup (const char *undef_name, unsigned long int hash,
else
{
/* We can match the version information or use the
default one. */
default one if it is not hidden. */
ElfW(Half) ndx = verstab[symidx] & 0x7fff;
if ((map->l_versions[ndx].hash != version->hash
|| strcmp (map->l_versions[ndx].name, version->name))
&& (version->hidden || map->l_versions[ndx].hash))
&& (version->hidden || map->l_versions[ndx].hash
|| (verstab[symidx] & 0x8000)))
/* It's not the version we want. */
continue;
}

View File

@ -5,7 +5,8 @@ BEGIN {
}
{
for (i = 1; i <= NF; ++i) {
dir[count++] = gensub(/((.*)[^/])?[/]*/, "\\1", "", $i);
gsub (/\/*$/, "", $i);
dir[count++] = $i;
}
}
END {

32
iconv/Makefile Normal file
View File

@ -0,0 +1,32 @@
# Copyright (C) 1997 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 Library General Public License as
# published by the Free Software Foundation; either version 2 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
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Makefile for iconv.
#
subdir := iconv
headers = iconv.h gconv.h
routines = iconv_open iconv iconv_close \
gconv_open gconv gconv_close gconv_db gconv_conf \
gconv_dl gconv_builtin gconv_simple
distribute = gconv_builtin.h
CFLAGS-gconv_conf.c = -DGCONV_PATH='"$(gconvdir)"'
include ../Rules

46
iconv/gconv.c Normal file
View File

@ -0,0 +1,46 @@
/* Convert characters in input buffer using conversion descriptor to
output buffer.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <gconv.h>
int
__gconv (gconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
size_t *outbytesleft, size_t *converted)
{
size_t last_step = cd->nsteps - 1;
int result;
cd->data[last_step].outbuf = *outbuf;
cd->data[last_step].outbufavail = 0;
cd->data[last_step].outbufsize = *outbytesleft;
if (converted != NULL)
*converted = 0;
result = (*cd->steps->fct) (cd->steps, cd->data, inbuf, inbytesleft,
converted, inbuf == NULL || *inbuf == NULL);
*outbuf += cd->data[last_step].outbufavail;
*outbytesleft -= cd->data[last_step].outbufavail;
return result;
}

205
iconv/gconv.h Normal file
View File

@ -0,0 +1,205 @@
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _GCONV_H
#define _GCONV_H 1
#include <features.h>
#include <sys/types.h>
#include <regex.h>
/* Error codes for gconv functions. */
enum
{
GCONV_OK = 0,
GCONV_NOCONV,
GCONV_NODB,
GCONV_NOMEM,
GCONV_EMPTY_INPUT,
GCONV_FULL_OUTPUT,
GCONV_ILLEGAL_INPUT,
GCONV_ILLEGAL_DESCRIPTOR,
GCONV_INTERNAL_ERROR
};
/* Structure for alias definition. Simply to strings. */
struct gconv_alias
{
__const char *fromname;
__const char *toname;
};
/* Default size of intermediate buffers. */
#define GCONV_DEFAULT_BUFSIZE 8160
/* Forward declarations. */
struct gconv_step;
struct gconv_step_data;
/* Type of a conversion function. */
typedef int (*gconv_fct) __P ((struct gconv_step *,
struct gconv_step_data *,
__const char *, size_t *, size_t *, int));
/* Constructor and destructor for local data for conversion step. */
typedef int (*gconv_init_fct) __P ((struct gconv_step *,
struct gconv_step_data *));
typedef void (*gconv_end_fct) __P ((struct gconv_step_data *));
/* Description of a conversion step. */
struct gconv_step
{
void *shlib_handle;
__const char *from_name;
__const char *to_name;
gconv_fct fct;
gconv_init_fct init_fct;
gconv_end_fct end_fct;
};
/* Additional data for steps in use of conversion descriptor. This is
allocated by the `init' function. */
struct gconv_step_data
{
char *outbuf; /* Output buffer for this step. */
size_t outbufavail; /* Bytes already available in output buffer. */
size_t outbufsize; /* Size of output buffer. */
int is_last;
void *data; /* Pointer to step-local data. */
};
/* Combine conversion step description with data. */
typedef struct gconv_info
{
size_t nsteps;
struct gconv_step *steps;
struct gconv_step_data *data;
} *gconv_t;
/* Description for an available conversion module. */
struct gconv_module
{
__const char *from_pattern;
__const char *from_constpfx;
size_t from_constpfx_len;
__const regex_t *from_regex;
__const char *to_string;
int cost;
__const char *module_name;
};
/* Global variables. */
/* Database of alias names. */
extern void *__gconv_alias_db;
/* Array with available modules. */
extern size_t __gconv_nmodules;
extern struct gconv_module **__gconv_modules_db;
/* Return in *HANDLE decriptor for transformation from FROMSET to TOSET. */
extern int __gconv_open __P ((__const char *__toset, __const char *__fromset,
gconv_t *__handle));
/* Free resources associated with transformation descriptor CD. */
extern int __gconv_close __P ((gconv_t cd));
/* Transform at most *INBYTESLEFT bytes from buffer starting at *INBUF
according to rules described by CD and place up to *OUTBYTESLEFT
bytes in buffer starting at *OUTBUF. Return number of written
characters in *CONVERTED if this pointer is not null. */
extern int __gconv __P ((gconv_t __cd,
__const char **__inbuf, size_t *__inbytesleft,
char **__outbuf, size_t *__outbytesleft,
size_t *__converted));
/* Return in *HANDLE a pointer to an array with *NSTEPS elements describing
the single steps necessary for transformation from FROMSET to TOSET. */
extern int __gconv_find_transform __P ((__const char *__toset,
__const char *__fromset,
struct gconv_step **__handle,
size_t *__nsteps));
/* Read all the configuration data and cache it. */
extern void __gconv_read_conf __P ((void));
/* Comparison function to search alias. */
extern int __gconv_alias_compare __P ((__const void *__p1,
__const void *__p2));
/* Clear reference to transformation step implementations which might
cause the code to be unloaded. */
extern int __gconv_close_transform __P ((struct gconv_step *__steps,
size_t __nsteps));
/* Find in the shared object associated with HANDLE for a function with
name NAME. Return function pointer or NULL. */
extern void *__gconv_find_func __P ((void *__handle, __const char *__name));
/* Load shared object named by NAME. If already loaded increment reference
count. */
extern void *__gconv_find_shlib __P ((__const char *__name));
/* Release shared object. If no further reference is available unload
the object. */
extern int __gconv_release_shlib __P ((void *__handle));
/* Fill STEP with information about builtin module with NAME. */
extern void __gconv_get_builtin_trans __P ((__const char *__name,
struct gconv_step *__step));
/* Builtin transformations. */
#ifdef _LIBC
# define __BUILTIN_TRANS(Name) \
extern int Name __P ((struct gconv_step *__step, \
struct gconv_step_data *__data, __const char *__inbuf,\
size_t *__inlen, size_t *__written, int __do_flush))
__BUILTIN_TRANS (__gconv_transform_dummy);
__BUILTIN_TRANS (__gconv_transform_ucs4_utf8);
__BUILTIN_TRANS (__gconv_transform_utf8_ucs4);
# undef __BUITLIN_TRANS
extern int __gconv_transform_init_rstate __P ((struct gconv_step *__step,
struct gconv_step_data *__data));
extern void __gconv_transform_end_rstate __P ((struct gconv_step_data *__data));
#endif
#endif /* gconv.h */

64
iconv/gconv_builtin.c Normal file
View File

@ -0,0 +1,64 @@
/* Table for builtin transformation mapping.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <gconv.h>
#include <string.h>
#include <assert.h>
static struct builtin_map
{
const char *name;
gconv_fct fct;
gconv_init_fct init;
gconv_end_fct end;
} map[] =
{
#define BUILTIN_TRANSFORMATION(From, ConstPfx, ConstLen, To, Cost, Name, \
Fct, Init, End) \
{ \
name: Name, \
fct: Fct, \
init: Init, \
end: End, \
},
#include <gconv_builtin.h>
};
void
__gconv_get_builtin_trans (const char *name, struct gconv_step *step)
{
size_t cnt;
for (cnt = 0; cnt < sizeof (map) / sizeof (map[0]); ++cnt)
if (strcmp (name, map[cnt].name) == 0)
break;
assert (cnt < sizeof (map) / sizeof (map[0]));
step->fct = map[cnt].fct;
step->init_fct = map[cnt].init;
step->end_fct = map[cnt].end;
step->shlib_handle = NULL;
}

34
iconv/gconv_builtin.h Normal file
View File

@ -0,0 +1,34 @@
/* Builtin transformations.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
BUILTIN_TRANSFORMATION ("\\([^/]+\\)/UCS4/\\([^/]*\\)", NULL, 0,
"\\1/UTF8/\\2", 1, "=ucs4->utf8",
__gconv_transform_ucs4_utf8,
__gconv_transform_init_rstate,
__gconv_transform_end_rstate)
BUILTIN_TRANSFORMATION ("\\([^/]+\\)/UTF8/\\([^/]*\\)", NULL, 0,
"\\1/UCS4/\\2", 1, "=utf8->ucs4",
__gconv_transform_utf8_ucs4,
__gconv_transform_init_rstate,
__gconv_transform_end_rstate)
BUILTIN_TRANSFORMATION ("\\(.*\\)", NULL, 0, "\\1", 1, "=dummy",
__gconv_transform_dummy, NULL, NULL)

64
iconv/gconv_close.c Normal file
View File

@ -0,0 +1,64 @@
/* Release any resource associated with given conversion descriptor.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <gconv.h>
#include <stdlib.h>
int
__gconv_close (gconv_t cd)
{
struct gconv_step *srunp;
struct gconv_step_data *drunp;
size_t nsteps;
/* Free all resources by calling destructor functions and release
the implementations. */
srunp = cd->steps;
nsteps = cd->nsteps;
drunp = cd->data;
do
{
/* Call destructor. */
if (srunp->end_fct != NULL)
(*srunp->end_fct) (drunp);
else
{
free (drunp->outbuf);
if (drunp->data != NULL)
free (drunp->data);
}
/* Next step. */
++srunp;
++drunp;
}
while (!drunp->is_last);
/* Save the pointer, we need it below. */
srunp = cd->steps;
/* Free the data allocated for the descriptor. */
free (cd->data);
free (cd);
/* Close the participating modules. */
return __gconv_close_transform (srunp, nsteps);
}

420
iconv/gconv_conf.c Normal file
View File

@ -0,0 +1,420 @@
/* Handle configuration data.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <ctype.h>
#include <gconv.h>
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
/* This is the default path where we look for module lists. */
static const char default_gconv_path[] = GCONV_PATH;
/* Name of the file containing the module information in the directories
along the path. */
static const char gconv_conf_filename[] = "gconv-modules";
/* We have a few builtin transformations. */
static struct gconv_module builtin_modules[] =
{
#define BUILTIN_TRANSFORMATION(From, ConstPfx, ConstLen, To, Cost, Name, \
Fct, Init, End) \
{ \
from_pattern: From, \
from_constpfx: ConstPfx, \
from_constpfx_len: ConstLen, \
from_regex: NULL, \
to_string: To, \
cost: Cost, \
module_name: Name \
},
#include "gconv_builtin.h"
};
/* Function for searching module. */
static int
module_compare (const void *p1, const void *p2)
{
struct gconv_module *s1 = (struct gconv_module *) p1;
struct gconv_module *s2 = (struct gconv_module *) p2;
int result;
if (s1->from_pattern == NULL)
{
if (s2->from_pattern == NULL)
result = strcmp (s1->from_constpfx, s2->from_constpfx);
else
result = -1;
}
else if (s2->from_pattern == NULL)
result = 1;
else
result = strcmp (s1->from_pattern, s2->from_pattern);
if (result == 0)
result = strcmp (s1->to_string, s2->to_string);
return result;
}
/* Add new alias. */
static inline void
add_alias (char *rp)
{
/* We now expect two more string. The strings are normalized
(converted to UPPER case) and strored in the alias database. */
struct gconv_alias *new_alias;
char *from, *to, *wp;
while (isspace (*rp))
++rp;
from = wp = rp;
while (*rp != '\0' && !isspace (*rp))
++rp;
if (*rp == '\0')
/* There is no `to' string on the line. Ignore it. */
return;
*rp++ = '\0';
to = wp = rp;
while (isspace (*rp))
++rp;
while (*rp != '\0' && !isspace (*rp))
*wp++ = *rp++;
if (to == wp)
/* No `to' string, ignore the line. */
return;
*wp++ = '\0';
new_alias = (struct gconv_alias *)
malloc (sizeof (struct gconv_alias) + (wp - from));
new_alias->fromname = memcpy ((char *) new_alias
+ sizeof (struct gconv_alias),
from, to - from);
new_alias->toname = memcpy ((char *) new_alias + sizeof (struct gconv_alias)
+ (to - from), to, wp - to);
if (__tsearch (new_alias, &__gconv_alias_db, __gconv_alias_compare) == NULL)
/* Something went wrong, free this entry. */
free (new_alias);
}
/* Add new module. */
static inline void
add_module (char *rp, const char *directory, size_t dir_len, void **modules,
size_t *nmodules)
{
/* We expect now
1. `from' name
2. `to' name
3. filename of the module
4. an optional cost value
*/
struct gconv_module *new_module;
char *from, *to, *module, *wp;
size_t const_len;
int from_is_regex;
int cost;
while (isspace (*rp))
++rp;
from = rp;
from_is_regex = 0;
while (*rp != '\0' && !isspace (*rp))
{
if (!isalnum (*rp) && *rp != '-' && *rp != '/' && *rp != '.'
&& *rp != '_')
from_is_regex = 1;
++rp;
}
if (*rp == '\0')
return;
*rp++ = '\0';
to = wp = rp;
while (isspace (*rp))
++rp;
while (*rp != '\0' && !isspace (*rp))
*wp++ = *rp++;
if (*rp == '\0')
return;
*wp++ = '\0';
do
++rp;
while (isspace (*rp));
module = wp;
while (*rp != '\0' && !isspace (*rp))
*wp++ = *rp++;
if (*rp == '\0')
{
/* There is no cost, use one by default. */
*wp++ = '\0';
cost = 1;
}
else
{
/* There might be a cost value. */
char *endp;
*wp++ = '\0';
cost = strtol (rp, &endp, 10);
if (rp == endp)
/* No useful information. */
cost = 1;
}
if (module[0] == '\0')
/* No module name given. */
return;
if (module[0] == '/')
dir_len = 0;
else
/* Increment by one for the slash. */
++dir_len;
/* We've collected all the information, now create an entry. */
const_len = 0;
if (from_is_regex)
do
++const_len;
while (isalnum (from[const_len]) || from[const_len] == '-'
|| from[const_len] == '/' || from[const_len] == '.'
|| from[const_len] == '_');
new_module = (struct gconv_module *) malloc (sizeof (struct gconv_module)
+ (wp - from) + const_len
+ dir_len);
if (new_module != NULL)
{
if (from_is_regex)
{
new_module->from_pattern = memcpy ((char *) new_module
+ sizeof (struct gconv_module),
from, to - from);
new_module->from_constpfx = memcpy ((char *) new_module->from_pattern
+ (to - from),
from, const_len);
((char *) new_module->from_constpfx)[const_len] = '\0';
new_module->from_constpfx_len = const_len;
++const_len;
}
else
{
new_module->from_pattern = NULL;
new_module->from_constpfx = memcpy ((char *) new_module
+ sizeof (struct gconv_module),
from, to - from);
new_module->from_constpfx_len = to - from - 1;
const_len = to - from;
}
new_module->from_regex = NULL;
new_module->to_string = memcpy ((char *) new_module->from_constpfx
+ const_len + 1, to, module - to);
new_module->cost = cost;
if (dir_len == 0)
new_module->module_name = memcpy ((char *) new_module->to_string
+ (module - to),
module, wp - module);
else
{
char *tmp;
new_module->module_name = ((char *) new_module->to_string
+ (module - to));
tmp = __mempcpy ((char *) new_module->module_name,
directory, dir_len - 1);
*tmp++ = '/';
memcpy (tmp, module, wp - module);
}
if (__tfind (new_module, *modules, module_compare) != NULL)
if (__tsearch (new_module, modules, module_compare) == NULL)
/* Something went wrong while inserting the new module. */
free (new_module);
else
++*nmodules;
}
}
static void
insert_module (const void *nodep, VISIT value, int level)
{
if (value == preorder || value == leaf)
__gconv_modules_db[__gconv_nmodules++] = (struct gconv_module *) nodep;
}
static void
nothing (void *unused __attribute__ ((unused)))
{
}
/* Read the next configuration file. */
static void
internal_function
read_conf_file (const char *filename, const char *directory, size_t dir_len,
void **modules, size_t *nmodules)
{
FILE *fp = fopen (filename, "r");
char *line = NULL;
size_t line_len = 0;
/* Don't complain if a file is not present or readable, simply silently
ignore it. */
if (fp == NULL)
return;
/* Process the known entries of the file. Comments start with `#' and
end with the end of the line. Empty lines are ignored. */
while (!feof (fp))
{
char *rp, *endp, *word;
ssize_t n = __getdelim (&line, &line_len, '\n', fp);
if (n < 0)
/* An error occurred. */
break;
rp = line;
while (isspace (*rp))
++rp;
/* Terminate the line (excluding comments or newline) by an NUL byte
to simplify the following code. */
endp = strchr (rp, '#');
if (endp != NULL)
*endp = '\0';
else
{
endp = strchr (rp, '\n');
if (endp != NULL)
*endp = '\0';
}
/* If this is an empty line go on with the next one. */
if (rp == endp)
continue;
word = rp;
while (*rp != '\0' && !isspace (*rp))
++rp;
if (rp - word == sizeof ("alias") - 1
&& memcpy (word, "alias", sizeof ("alias") - 1) == 0)
add_alias (rp);
else if (rp - word == sizeof ("module") - 1
&& memcpy (word, "module", sizeof ("module") - 1) == 0)
add_module (rp, directory, dir_len, modules, nmodules);
/* else */
/* Otherwise ignore the line. */
}
if (line != NULL)
free (line);
fclose (fp);
}
/* Read all configuration files found in the user-specified and the default
path. */
void
__gconv_read_conf (void)
{
const char *user_path = __secure_getenv ("GCONV_PATH");
char *gconv_path, *elem;
void *modules = NULL;
size_t nmodules = 0;
if (user_path == NULL)
/* No user-defined path. Make a modifiable copy of the default path. */
gconv_path = strdupa (default_gconv_path);
else
{
/* Append the default path to the user-defined path. */
size_t user_len = strlen (user_path);
char *tmp;
gconv_path = alloca (user_len + 1 + sizeof (default_gconv_path));
tmp = __mempcpy (gconv_path, user_path, user_len);
*tmp++ = ':';
__mempcpy (tmp, default_gconv_path, sizeof (default_gconv_path));
}
elem = strtok_r (gconv_path, ":", &gconv_path);
while (elem != NULL)
{
char real_elem[MAXPATHLEN];
if (realpath (elem, real_elem) != NULL)
{
size_t elem_len = strlen (real_elem);
char *filename, *tmp;
filename = alloca (elem_len + 1 + sizeof (gconv_conf_filename));
tmp = __mempcpy (filename, real_elem, elem_len);
*tmp++ = '/';
__mempcpy (tmp, gconv_conf_filename, sizeof (gconv_conf_filename));
/* Read the next configuration file. */
read_conf_file (filename, real_elem, elem_len, &modules, &nmodules);
}
/* Get next element in the path. */
elem = strtok_r (NULL, ":", &gconv_path);
}
/* If the configuration files do not contain any valid module specification
remember this by setting the pointer to the module array to NULL. */
nmodules = sizeof (builtin_modules) / sizeof (struct gconv_module);
if (nmodules == 0)
{
__gconv_modules_db = NULL;
return;
}
__gconv_modules_db =
(struct gconv_module **) malloc (nmodules * sizeof (struct gconv_module));
if (__gconv_modules_db == NULL)
/* We cannot do anything. */
return;
/* First insert the builtin transformations. */
while (__gconv_nmodules < (sizeof (builtin_modules)
/ sizeof (struct gconv_module)))
{
__gconv_modules_db[__gconv_nmodules] =
&builtin_modules[__gconv_nmodules];
++__gconv_nmodules;
}
/* Insert all module entries into the array. */
__twalk (modules, insert_module);
/* No remove the tree data structure. */
__tdestroy (modules, nothing);
}

538
iconv/gconv_db.c Normal file
View File

@ -0,0 +1,538 @@
/* Provide access to the collection of available transformation modules.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <gconv.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <bits/libc-lock.h>
/* Simple data structure for alias mapping. We have two names, `from'
and `to'. */
void *__gconv_alias_db;
/* Array with available modules. */
size_t __gconv_nmodules;
struct gconv_module **__gconv_modules_db;
/* Function for searching alias. */
int
__gconv_alias_compare (const void *p1, const void *p2)
{
struct gconv_alias *s1 = (struct gconv_alias *) p1;
struct gconv_alias *s2 = (struct gconv_alias *) p2;
return __strcasecmp (s1->fromname, s2->fromname);
}
/* To search for a derivation we create a list of intermediate steps.
Each element contains a pointer to the element which precedes it
in the derivation order. */
struct derivation_step
{
const char *result_set;
struct gconv_module *code;
struct derivation_step *last;
struct derivation_step *next;
};
#define NEW_STEP(result, module, last_mod) \
({ struct derivation_step *newp = alloca (sizeof (struct derivation_step)); \
newp->result_set = result; \
newp->code = module; \
newp->last = last_mod; \
newp->next = NULL; \
newp; })
/* If a specific transformation is used more than once we should not need
to start looking for it again. Instead cache each successful result. */
struct known_derivation
{
const char *from;
const char *to;
struct gconv_step *steps;
size_t nsteps;
};
/* Compare function for database of found derivations. */
static int
derivation_compare (const void *p1, const void *p2)
{
struct known_derivation *s1 = (struct known_derivation *) p1;
struct known_derivation *s2 = (struct known_derivation *) p2;
int result;
result = strcmp (s1->from, s2->from);
if (result == 0)
result = strcmp (s1->to, s2->to);
return result;
}
/* The search tree for known derivations. */
static void *known_derivations;
/* Look up whether given transformation was already requested before. */
static int
derivation_lookup (const char *fromset, const char *toset,
struct gconv_step **handle, size_t *nsteps)
{
struct known_derivation key = { fromset, toset, NULL, 0 };
struct known_derivation *result;
result = __tfind (&key, known_derivations, derivation_compare);
if (result == NULL)
return GCONV_NOCONV;
*handle = result->steps;
*nsteps = result->nsteps;
/* Please note that we return GCONV_OK even if the last search for
this transformation was unsuccessful. */
return GCONV_OK;
}
/* Add new derivation to list of known ones. */
static void
add_derivation (const char *fromset, const char *toset,
struct gconv_step *handle, size_t nsteps)
{
struct known_derivation *new_deriv;
size_t fromset_len = strlen (fromset) + 1;
size_t toset_len = strlen (toset) + 1;
new_deriv = (struct known_derivation *)
malloc (sizeof (struct known_derivation) + fromset_len + toset_len);
if (new_deriv != NULL)
{
new_deriv->from = memcpy ((char *) new_deriv
+ sizeof (struct known_derivation),
fromset, fromset_len);
new_deriv->to = memcpy ((char *) new_deriv->from + fromset_len,
toset, toset_len);
new_deriv->steps = handle;
new_deriv->nsteps = nsteps;
__tsearch (new_deriv, &known_derivations, derivation_compare);
}
/* Please note that we don't complain if the allocation failed. This
is not tragically but in case we use the memory debugging facilities
not all memory will be freed. */
}
static void
free_derivation (void *p)
{
struct known_derivation *deriv = (struct known_derivation *) p;
free ((struct gconv_step *) deriv->steps);
free (deriv);
}
static int
internal_function
gen_steps (struct derivation_step *best, const char *toset,
const char *fromset, struct gconv_step **handle, size_t *nsteps)
{
size_t step_cnt = 0;
struct gconv_step *result;
struct derivation_step *current;
int status = GCONV_NOMEM;
/* First determine number of steps. */
for (current = best; current->last != NULL; current = current->last)
++step_cnt;
result = (struct gconv_step *) malloc (sizeof (struct gconv_step)
* step_cnt);
if (result != NULL)
{
current = best;
while (step_cnt-- > 0)
{
result[step_cnt].from_name = current->last->result_set;
result[step_cnt].to_name = current->result_set;
if (current->code->module_name[0] == '/')
{
/* Load the module, return handle for it. */
void *shlib_handle =
__gconv_find_shlib (current->code->module_name);
if (shlib_handle == NULL)
break;
result[step_cnt].shlib_handle = shlib_handle;
result[step_cnt].fct = __gconv_find_func (shlib_handle, "gconv");
if (result[step_cnt].fct == NULL)
{
/* Argh, no conversion function. There is something
wrong here. */
__gconv_release_shlib (result[step_cnt].shlib_handle);
break;
}
result[step_cnt].init_fct = __gconv_find_func (shlib_handle,
"gconv_init");
result[step_cnt].end_fct = __gconv_find_func (shlib_handle,
"gconv_end");
}
else
/* It's a builtin transformation. */
__gconv_get_builtin_trans (current->code->module_name,
&result[step_cnt]);
current = current->last;
}
if (step_cnt != 0)
{
/* Something went wrong while initializing the modules. */
while (step_cnt-- > 0)
__gconv_release_shlib (result[step_cnt].shlib_handle);
free (result);
status = GCONV_NOCONV;
}
else
{
*handle = result;
*nsteps = step_cnt;
status = GCONV_OK;
}
}
return status;
}
/* The main function: find a possible derivation from the `fromset' (either
the given name or the alias) to the `toset' (again with alias). */
static int
find_derivation (const char *toset, const char *toset_expand,
const char *fromset, const char *fromset_expand,
struct gconv_step **handle, size_t *nsteps)
{
__libc_lock_define_initialized (static, lock)
struct derivation_step *current, **lastp, *best = NULL;
int best_cost = 0;
int result;
result = derivation_lookup (fromset_expand ?: fromset, toset_expand ?: toset,
handle, nsteps);
if (result == GCONV_OK)
return result;
__libc_lock_lock (lock);
/* There is a small chance that this derivation is meanwhile found. This
can happen if in `find_derivation' we look for this derivation, didn't
find it but at the same time another thread looked for this derivation. */
result = derivation_lookup (fromset_expand ?: fromset, toset_expand ?: toset,
handle, nsteps);
if (result == GCONV_OK)
return result;
/* ### TODO
For now we use a simple algorithm with quadratic runtime behaviour.
The task is to match the `toset' with any of the available. */
if (fromset_expand != NULL)
{
current = NEW_STEP (fromset_expand, NULL, NULL);
current->next = NEW_STEP (fromset, NULL, NULL);
lastp = &current->next->next;
}
else
{
current = NEW_STEP (fromset, NULL, NULL);
lastp = &current->next;
}
while (current != NULL)
{
/* Now match all the available module specifications against the
current charset name. If any of them matches check whether
we already have a derivation for this charset. If yes, use the
one with the lower costs. Otherwise add the new charset at the
end. */
size_t cnt;
for (cnt = 0; cnt < __gconv_nmodules; ++cnt)
{
const char *result_set = NULL;
if (__gconv_modules_db[cnt]->from_pattern == NULL)
{
if (__strcasecmp (current->result_set,
__gconv_modules_db[cnt]->from_constpfx) == 0)
{
if (strcmp (__gconv_modules_db[cnt]->to_string, "-") == 0)
result_set = toset_expand ?: toset;
else
result_set = __gconv_modules_db[cnt]->to_string;
}
}
else
/* We have a regular expression. First see if the prefix
matches. */
if (__strncasecmp (current->result_set,
__gconv_modules_db[cnt]->from_constpfx,
__gconv_modules_db[cnt]->from_constpfx_len)
== 0)
{
/* First compile the regex if not already done. */
if (__gconv_modules_db[cnt]->from_regex == NULL)
{
regex_t *newp = (regex_t *) malloc (sizeof (regex_t));
if (regcomp (newp, __gconv_modules_db[cnt]->from_pattern,
REG_EXTENDED | REG_ICASE) != 0)
{
/* Something is wrong. Remember this. */
free (newp);
__gconv_modules_db[cnt]->from_regex = (regex_t *) -1L;
}
else
__gconv_modules_db[cnt]->from_regex = newp;
}
if (__gconv_modules_db[cnt]->from_regex != (regex_t *) -1L)
{
/* Try to match the from name. */
regmatch_t match[4];
if (regexec (__gconv_modules_db[cnt]->from_regex,
current->result_set, 4, match, 0) == 0
&& match[0].rm_so == 0
&& current->result_set[match[0].rm_eo] == '\0')
{
/* At least the whole <from> string is matched.
We must now match sed-like possible
subexpressions from the match to the
toset expression. */
#define ENSURE_LEN(LEN) \
if (wp + (LEN) >= constr + len - 1) \
{ \
char *newp = alloca (len += 128); \
memcpy (newp, constr, wp - constr); \
wp = newp + (wp - constr); \
constr = newp; \
}
size_t len = 128;
char *constr = alloca (len);
char *wp = constr;
const char *cp = __gconv_modules_db[cnt]->to_string;
while (*cp != '\0')
{
if (*cp != '\\')
{
ENSURE_LEN (1);
*wp++ = *cp++;
}
else if (cp[1] == '\0')
/* Backslash at end of string. */
break;
else
{
++cp;
if (*cp == '\\')
{
*wp++ = *cp++;
ENSURE_LEN (1);
}
else if (*cp < '1' || *cp > '3')
break;
else
{
int idx = *cp - '0';
if (match[idx].rm_so == -1)
/* No match. */
break;
ENSURE_LEN (match[idx].rm_eo
- match[idx].rm_so);
wp = __mempcpy (wp,
&current->result_set[match[idx].rm_so],
match[idx].rm_eo
- match[idx].rm_so);
++cp;
}
}
}
if (*cp == '\0' && wp != constr)
{
/* Terminate the constructed string. */
*wp = '\0';
result_set = constr;
}
}
}
}
if (result_set != NULL)
{
/* We managed to find a derivation. First see whether
this is what we are looking for. */
if (__strcasecmp (result_set, toset) == 0
|| (toset_expand != NULL
&& __strcasecmp (result_set, toset_expand) == 0))
{
/* Determine the costs. If they are lower than the
previous solution (or this is the first solution)
remember this solution. */
int cost = __gconv_modules_db[cnt]->cost;
struct derivation_step *runp = current;
while (runp->code != NULL)
{
cost += runp->code->cost;
runp = runp->last;
}
if (best == NULL || cost < best_cost)
{
best = NEW_STEP (result_set, __gconv_modules_db[cnt],
current);
best_cost = cost;
}
}
else
{
/* Append at the end. */
*lastp = NEW_STEP (result_set, __gconv_modules_db[cnt],
current);
lastp = &(*lastp)->next;
}
}
}
}
if (best != NULL)
/* We really found a way to do the transformation. Now build a data
structure describing the transformation steps.*/
result = gen_steps (best, toset_expand ?: toset, fromset_expand ?: fromset,
handle, nsteps);
else
{
/* We haven't found a transformation. Clear the result values. */
*handle = NULL;
*nsteps = 0;
}
/* Add result in any case to list of known derivations. */
add_derivation (fromset_expand ?: fromset, toset_expand ?: toset,
*handle, *nsteps);
__libc_lock_unlock (lock);
return result;
}
int
__gconv_find_transform (const char *toset, const char *fromset,
struct gconv_step **handle, size_t *nsteps)
{
__libc_once_define (static, once);
const char *fromset_expand = NULL;
const char *toset_expand = NULL;
int result;
/* Ensure that the configuration data is read. */
__libc_once (once, __gconv_read_conf);
/* If we don't have a module database return with an error. */
if (__gconv_modules_db == NULL)
return GCONV_NOCONV;
/* See whether the names are aliases. */
if (__gconv_alias_db != NULL)
{
struct gconv_alias key;
struct gconv_alias *found;
key.fromname = fromset;
found = __tfind (&key, __gconv_alias_db, __gconv_alias_compare);
fromset_expand = found != NULL ? found->toname : NULL;
key.fromname = toset;
found = __tfind (&key, __gconv_alias_db, __gconv_alias_compare);
toset_expand = found != NULL ? found->toname : NULL;
}
result = find_derivation (toset, toset_expand, fromset, fromset_expand,
handle, nsteps);
/* The following code is necessary since `find_derivation' will return
GCONV_OK even when no derivation was found but the same request
was processed before. I.e., negative results will also be cached. */
return (result == GCONV_OK
? (*handle == NULL ? GCONV_NOCONV : GCONV_OK)
: result);
}
/* Release the entries of the modules list. */
int
__gconv_close_transform (struct gconv_step *steps, size_t nsteps)
{
int result = GCONV_OK;
while (nsteps-- > 0)
if (steps[nsteps].shlib_handle != NULL)
{
result = __gconv_release_shlib (steps[nsteps].shlib_handle);
if (result != GCONV_OK)
break;
}
return result;
}
/* Free all resources if necessary. */
static void __attribute__ ((unused))
free_mem (void)
{
size_t cnt;
if (__gconv_alias_db != NULL)
__tdestroy (__gconv_alias_db, free);
for (cnt = 0; cnt < __gconv_nmodules; ++cnt)
{
if (__gconv_modules_db[cnt]->from_regex != NULL)
regfree ((regex_t *) __gconv_modules_db[cnt]->from_regex);
/* Modules which names do not start with a slash are builtin
transformations and the memory is not allocated dynamically. */
if (__gconv_modules_db[cnt]->module_name[0] == '/')
free (__gconv_modules_db[cnt]);
}
if (known_derivations != NULL)
__tdestroy (known_derivations, free_derivation);
}
text_set_element (__libc_subfreeres, free_mem);

254
iconv/gconv_dl.c Normal file
View File

@ -0,0 +1,254 @@
/* Handle loading/unloading of shared object for transformation.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <dlfcn.h>
#include <gconv.h>
#include <inttypes.h>
#include <link.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <bits/libc-lock.h>
#include <sys/param.h>
/* This is a tuning parameter. If a transformation module is not used
anymore it gets not immediately unloaded. Instead we wait a certain
number of load attempts for further modules. If none of the
subsequent load attempts name the same object it finally gets unloaded.
Otherwise it is still available which hopefully is the frequent case.
The following number is the number of unloading attempts we wait
before unloading. */
#define TRIES_BEFORE_UNLOAD 2
/* Structure describing one loaded shared object. This normally are
objects to perform conversation but as a special case the db shared
object is also handled. */
struct loaded_object
{
/* Name of the object. */
const char *name;
/* Reference counter for the db functionality. If no conversion is
needed we unload the db library. */
int counter;
/* The handle for the shared object. */
void *handle;
};
/* Array of loaded objects. This is shared by all threads so we have
to use semaphores to access it. */
static void *loaded;
__libc_lock_define_initialized (static, lock)
/* Comparison function for searching `loaded_object' tree. */
static int
known_compare (const void *p1, const void *p2)
{
const struct loaded_object *s1 = (const struct loaded_object *) p1;
const struct loaded_object *s2 = (const struct loaded_object *) p2;
return (intptr_t) s1->handle - (intptr_t) s2->handle;
}
static void
do_open (void *a)
{
struct loaded_object *args = (struct loaded_object *) a;
/* Open and relocate the shared object. */
args->handle = _dl_open (args->name, RTLD_LAZY);
}
static int
dlerror_run (void (*operate) (void *), void *args)
{
char *last_errstring = NULL;
const char *last_object_name = NULL;
int result;
(void) _dl_catch_error (&last_errstring, &last_object_name, operate, args);
result = last_errstring != NULL;
if (result)
free (last_errstring);
return result;
}
struct get_sym_args
{
/* Arguments to get_sym. */
struct link_map *map;
const char *name;
/* Return values of get_sym. */
ElfW(Addr) loadbase;
const ElfW(Sym) *ref;
};
static void
get_sym (void *a)
{
struct get_sym_args *args = (struct get_sym_args *) a;
struct link_map *scope[2] = { args->map, NULL };
args->ref = NULL;
args->loadbase = _dl_lookup_symbol (args->name, &args->ref,
scope, args->map->l_name, 0);
}
void *
__gconv_find_func (void *handle, const char *name)
{
struct get_sym_args args;
args.map = handle;
args.name = name;
return (dlerror_run (get_sym, &args) ? NULL
: (void *) (args.loadbase + args.ref->st_value));
}
/* Open the gconv database if necessary. A non-negative return value
means success. */
void *
__gconv_find_shlib (const char *name)
{
void *result = NULL;
struct loaded_object *found;
/* Acquire the lock. */
__libc_lock_lock (lock);
/* Search the tree of shared objects previously requested. Data in
the tree are `loaded_object' structures, whose first member is a
`const char *', the lookup key. The search returns a pointer to
the tree node structure; the first member of the is a pointer to
our structure (i.e. what will be a `loaded_object'); since the
first member of that is the lookup key string, &FCT_NAME is close
enough to a pointer to our structure to use as a lookup key that
will be passed to `known_compare' (above). */
found = __tfind (&name, loaded, known_compare);
if (found == NULL)
{
/* This name was not known before. */
found = malloc (sizeof (struct loaded_object));
if (found != NULL)
{
/* Point the tree node at this new structure. */
found->name = name;
found->counter = -TRIES_BEFORE_UNLOAD - 1;
found->handle = NULL;
if (__tsearch (found, &loaded, known_compare) == NULL)
{
/* Something went wrong while inserting the entry. */
free (found);
found = NULL;
}
}
}
/* Try to load the shared object if the usage count is 0. This
implies that if the shared object is not loadable, the handle is
NULL and the usage count > 0. */
if (found != NULL)
{
if (found->counter < -TRIES_BEFORE_UNLOAD)
{
if (dlerror_run (do_open, found) == 0)
found->counter = 1;
}
else if (found->handle != NULL)
found->counter = MAX (found->counter + 1, 1);
result = found->handle;
}
/* Release the lock. */
__libc_lock_unlock (lock);
return result;
}
/* This is very ugly but the tsearch functions provide no way to pass
information to the walker function. So we use a global variable.
It is MT safe since we use a lock. */
static void *release_handle;
static void
do_release_shlib (const void *nodep, VISIT value, int level)
{
struct loaded_object *obj = (struct loaded_object *) nodep;
if (value != preorder && value != leaf)
return;
if (obj->handle == release_handle)
/* This is the object we want to unload. Now set the release
counter to zero. */
obj->counter = 0;
else if (obj->counter <= 0)
{
if (--obj->counter < -TRIES_BEFORE_UNLOAD && obj->handle != NULL)
{
/* Unload the shared object. We don't use the trick to
catch errors since in the case an error is signalled
something is really wrong. */
_dl_close ((struct link_map *) obj->handle);
obj->handle = NULL;
}
}
}
/* Notify system that a shared object is not longer needed. */
int
__gconv_release_shlib (void *handle)
{
/* Acquire the lock. */
__libc_lock_lock (lock);
/* Urgh, this is ugly but we have no other possibility. */
release_handle = handle;
/* Process all entries. Please note that we also visit entries
with release counts <= 0. This way we can finally unload them
if necessary. */
__twalk (loaded, do_release_shlib);
/* Release the lock. */
__libc_lock_unlock (lock);
return GCONV_OK;
}

123
iconv/gconv_open.c Normal file
View File

@ -0,0 +1,123 @@
/* Find matching transformation algorithms and initialize steps.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <gconv.h>
#include <stdlib.h>
int
__gconv_open (const char *toset, const char *fromset, gconv_t *handle)
{
struct gconv_step *steps;
size_t nsteps;
gconv_t result = NULL;
size_t cnt = 0;
int res;
res = __gconv_find_transform (toset, fromset, &steps, &nsteps);
if (res == GCONV_OK)
{
/* Allocate room for handle. */
result = (gconv_t) malloc (sizeof (struct gconv_info));
if (result == NULL)
res = GCONV_NOMEM;
else
{
/* Remember the list of steps. */
result->steps = steps;
result->nsteps = nsteps;
/* Allocate array for the step data. */
result->data = (struct gconv_step_data *)
calloc (nsteps, sizeof (struct gconv_step_data));
if (result->data == NULL)
res = GCONV_NOMEM;
else
{
/* Call all initialization functions for the transformation
step implemenations. */
struct gconv_step_data *data = result->data;
for (cnt = 0; cnt < nsteps; ++cnt)
{
/* If this is the last step we must not allocate an output
buffer. Signal this to the initializer. */
data[cnt].is_last = cnt == nsteps - 1;
if (steps[cnt].init_fct != NULL)
{
res = (steps[cnt].init_fct) (&steps[cnt], &data[cnt]);
if (res != GCONV_OK)
break;
}
else
if (!data[cnt].is_last)
{
data[cnt].outbufsize = GCONV_DEFAULT_BUFSIZE;
data[cnt].outbuf =
(char *) malloc (data[cnt].outbufsize);
if (data[cnt].outbuf == NULL)
{
res = GCONV_NOMEM;
break;
}
data[cnt].outbufavail = 0;
}
}
}
}
}
if (res != GCONV_OK)
{
/* Something went wrong. Free all the resources. */
int serrno = errno;
if (result != NULL)
{
if (result->data != NULL)
{
while (cnt-- > 0)
if (steps[cnt].end_fct != NULL)
(*steps[cnt].end_fct) (&result->data[cnt]);
else
{
free (result->data[cnt].outbuf);
if (result->data[cnt].data != NULL)
free (result->data[cnt].data);
}
free (result->data);
}
free (result);
result = NULL;
}
__gconv_close_transform (steps, nsteps);
__set_errno (serrno);
}
*handle = result;
return res;
}

240
iconv/gconv_simple.c Normal file
View File

@ -0,0 +1,240 @@
/* Simple transformations functions.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <gconv.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <sys/param.h>
int
__gconv_transform_dummy (struct gconv_step *step, struct gconv_step_data *data,
const char *inbuf, size_t *inlen, size_t *written,
int do_flush)
{
size_t do_write;
/* We have no stateful encoding. So we don't have to do anything
special. */
if (do_flush)
do_write = 0;
else
{
do_write = MIN (*inlen, data->outbufsize - data->outbufavail);
memcpy (data->outbuf, inbuf, do_write);
*inlen -= do_write;
data->outbufavail += do_write;
}
/* ### TODO Actually, this number must be devided according to the
size of the input charset. I.e., if the input is in UCS4 the
number of copied bytes must be divided by 4. */
if (written != NULL)
*written = do_write;
return GCONV_OK;
}
int
__gconv_transform_init_rstate (struct gconv_step *step,
struct gconv_step_data *data)
{
/* We have to provide the transformation function an correctly initialized
object of type `mbstate_t'. This must be dynamically allocated. */
data->data = calloc (1, sizeof (mbstate_t));
return data->data == NULL ? GCONV_NOMEM : GCONV_OK;
}
void
__gconv_transform_end_rstate (struct gconv_step_data *data)
{
if (data->data != NULL)
free (data->data);
}
int
__gconv_transform_ucs4_utf8 (struct gconv_step *step,
struct gconv_step_data *data, const char *inbuf,
size_t *inlen, size_t *written, int do_flush)
{
struct gconv_step *next_step = step + 1;
struct gconv_step_data *next_data = data + 1;
gconv_fct fct = next_step->fct;
size_t do_write;
int result;
/* If the function is called with no input this means we have to reset
to the initial state. The possibly partly converted input is
dropped. */
if (do_flush)
{
/* Clear the state. */
memset (data->data, '\0', sizeof (mbstate_t));
do_write = 0;
/* Call the steps down the chain if there are any. */
if (data->is_last)
result = GCONV_OK;
else
{
struct gconv_step *next_step = step + 1;
struct gconv_step_data *next_data = data + 1;
result = (*fct) (next_step, next_data, NULL, 0, written, 1);
/* Clear output buffer. */
data->outbufavail = 0;
}
}
else
{
do_write = 0;
do
{
const char *newinbuf = inbuf;
size_t actually = __wcsnrtombs (&data->outbuf[data->outbufavail],
(const wchar_t **) &newinbuf,
*inlen / sizeof (wchar_t),
data->outbufsize - data->outbufavail,
(mbstate_t *) data->data);
/* Status so far. */
result = GCONV_EMPTY_INPUT;
/* Remember how much we converted. */
do_write += newinbuf - inbuf;
*inlen -= (newinbuf - inbuf) * sizeof (wchar_t);
data->outbufavail += actually;
if (data->outbufavail > 0)
{
/* Call the functions below in the chain. */
size_t newavail = data->outbufavail;
result = (*fct) (next_step, next_data, data->outbuf, &newavail,
written, 0);
/* Correct the output buffer. */
if (newavail != data->outbufavail)
{
memmove (data->outbuf,
&data->outbuf[data->outbufavail - newavail],
newavail);
data->outbufavail = newavail;
}
}
}
while (*inlen > 0 && result == GCONV_EMPTY_INPUT);
}
if (written != NULL && data->is_last)
*written = do_write / sizeof (wchar_t);
return result;
}
int
__gconv_transform_utf8_ucs4 (struct gconv_step *step,
struct gconv_step_data *data, const char *inbuf,
size_t *inlen, size_t *written, int do_flush)
{
struct gconv_step *next_step = step + 1;
struct gconv_step_data *next_data = data + 1;
gconv_fct fct = next_step->fct;
size_t do_write;
int result;
/* If the function is called with no input this means we have to reset
to the initial state. The possibly partly converted input is
dropped. */
if (do_flush)
{
/* Clear the state. */
memset (data->data, '\0', sizeof (mbstate_t));
do_write = 0;
/* Call the steps down the chain if there are any. */
if (data->is_last)
result = GCONV_OK;
else
{
struct gconv_step *next_step = step + 1;
struct gconv_step_data *next_data = data + 1;
result = (*fct) (next_step, next_data, NULL, 0, written, 1);
}
}
else
{
do_write = 0;
do
{
const char *newinbuf = inbuf;
size_t actually = __mbsnrtowcs ((wchar_t *) &data->outbuf[data->outbufavail],
&newinbuf, *inlen,
((data->outbufsize
- data->outbufavail)
/ sizeof (wchar_t)),
(mbstate_t *) data->data);
/* Status so far. */
result = GCONV_EMPTY_INPUT;
/* Remember how much we converted. */
do_write += actually;
*inlen -= newinbuf - inbuf;
data->outbufavail += actually * sizeof (wchar_t);
if (data->outbufavail > 0)
{
/* Call the functions below in the chain. */
size_t newavail = data->outbufavail;
result = (*fct) (next_step, next_data, data->outbuf, &newavail,
written, 0);
/* Correct the output buffer. */
if (newavail != data->outbufavail)
{
memmove (data->outbuf,
&data->outbuf[data->outbufavail - newavail],
newavail);
data->outbufavail = newavail;
}
}
}
while (*inlen > 0 && result == GCONV_EMPTY_INPUT);
}
if (written != NULL && data->is_last)
*written = do_write;
return GCONV_OK;
}

38
iconv/iconv.c Normal file
View File

@ -0,0 +1,38 @@
/* Convert characters in input buffer using conversion descriptor to
output buffer.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <iconv.h>
#include <gconv.h>
size_t
iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
size_t *outbytesleft)
{
gconv_t gcd = (gconv_t) cd;
size_t converted;
if (__gconv (gcd, inbuf, inbytesleft, outbuf, outbytesleft, &converted)
!= GCONV_OK)
return (size_t) -1;
return converted;
}

50
iconv/iconv.h Normal file
View File

@ -0,0 +1,50 @@
/* Copyright (C) 1997 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 Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _ICONV_H
#define _ICONV_H 1
#include <features.h>
#define __need_size_t
#include <stddef.h>
__BEGIN_DECLS
/* Identifier for conversion method from one codeset to another. */
typedef void *iconv_t;
/* Allocate descriptor for code conversion from codeset FROMCODE to
codeset TOCODE. */
extern iconv_t iconv_open __P ((__const char *__tocode,
__const char *__fromcode));
/* Convert at most *INBYTESLEFT bytes from *INBUF according to the
code conversion algorithm specified by CD and place up to
*OUTBYTESLEFT bytes in buffer at *OUTBUF. */
extern size_t iconv __P ((iconv_t cd,
__const char **__inbuf, size_t *__inbytesleft,
char **__outbuf, size_t *__outbytesleft));
/* Free resources allocated for descriptor CD for code conversion. */
extern int iconv_close __P ((iconv_t __cd));
__END_DECLS
#endif /* iconv.h */

30
iconv/iconv_close.c Normal file
View File

@ -0,0 +1,30 @@
/* Release any resource associated with given conversion descriptor.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <iconv.h>
#include <gconv.h>
int
iconv_close (iconv_t cd)
{
return __gconv_close ((gconv_t) cd) ? -1 : 0;
}

45
iconv/iconv_open.c Normal file
View File

@ -0,0 +1,45 @@
/* Get descriptor for character set conversion.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <iconv.h>
#include <gconv.h>
iconv_t
iconv_open (const char *tocode, const char *fromcode)
{
gconv_t cd;
int res;
res = __gconv_open (tocode, fromcode, &cd);
if (res != GCONV_OK)
{
/* We must set the error number according to the specs. */
if (res == GCONV_NOCONV || res == GCONV_NODB)
__set_errno (EINVAL);
return (iconv_t) -1;
}
return (iconv_t) cd;
}

1
include/gconv.h Normal file
View File

@ -0,0 +1 @@
#include <iconv/gconv.h>

View File

@ -415,12 +415,15 @@ GLIBC_2.0 {
_IO_list_all;
_IO_stdin_; _IO_stdout_; _IO_stderr_;
_IO_fopen; fopen; freopen; _IO_fclose; fclose;
local:
*;
};
GLIBC_2.1 {
global:
_IO_fopen; fopen; _IO_stdin_; _IO_stdout_; _IO_stderr_;
freopen;
_IO_fopen; fopen; _IO_fclose; fclose;
_IO_2_1_stdin_; _IO_2_1_stdout_; _IO_2_1_stderr_;
} GLIBC_2.0;

View File

@ -43,7 +43,7 @@ all: # Make this the default target; it will be defined in Rules.
include ../Makeconfig
ifeq ($(versioning),yes)
routines += oldiofopen oldfreopen
routines += oldiofopen oldiofclose
endif
CPPFLAGS-.o += -DIO_DEBUG
@ -62,7 +62,7 @@ ifeq ($(versioning),yes)
aux += oldfileops oldstdfiles
endif
shared-only-routines = oldiofopen oldfreopen oldfileops oldstdfiles
shared-only-routines = oldiofopen oldiofclose oldfileops oldstdfiles
distribute := iolibio.h libioP.h strfile.h Banner

View File

@ -26,8 +26,13 @@
#include "libioP.h"
#include "stdio.h"
#ifdef PIC
extern void *_IO_stdin_used;
weak_extern (_IO_stdin_used);
#endif
FILE*
__new_freopen (filename, mode, fp)
freopen (filename, mode, fp)
const char* filename;
const char* mode;
FILE* fp;
@ -38,9 +43,17 @@ __new_freopen (filename, mode, fp)
return NULL;
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_freopen (filename, mode, fp);
#ifdef PIC
if (&_IO_stdin_used == NULL)
/* If the shared C library is used by the application binary which
was linked against the older version of libio, we just use the
older one even for internal use to avoid trouble since a pointer
to the old libio may be passed into shared C library and wind
up here. */
result = _IO_old_freopen (filename, mode, fp);
else
#endif
result = _IO_freopen (filename, mode, fp);
_IO_cleanup_region_end (1);
return result;
}
default_symbol_version (__new_freopen, freopen, GLIBC_2.1);

View File

@ -29,7 +29,7 @@
#endif
int
_IO_fclose (fp)
_IO_new_fclose (fp)
_IO_FILE *fp;
{
int status;
@ -53,6 +53,13 @@ _IO_fclose (fp)
return status;
}
#ifdef weak_alias
weak_alias (_IO_fclose, fclose)
#ifdef DO_VERSIONING
strong_alias (_IO_new_fclose, __new_fclose)
default_symbol_version (_IO_new_fclose, _IO_fclose, GLIBC_2.1);
default_symbol_version (__new_fclose, fclose, GLIBC_2.1);
#else
# ifdef weak_alias
weak_alias (_IO_new_fclose, _IO_fclose)
weak_alias (_IO_new_fclose, fclose)
# endif
#endif

View File

@ -53,7 +53,7 @@ extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
#define _IO_freopen(FILENAME, MODE, FP) \
(_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 0))
#define _IO_old_freopen(FILENAME, MODE, FP) \
(_IO_file_close_it(FP), _IO_old_file_fopen(FP, FILENAME, MODE))
(_IO_old_file_close_it (FP), _IO_old_file_fopen(FP, FILENAME, MODE))
#define _IO_freopen64(FILENAME, MODE, FP) \
(_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 1))
#define _IO_fileno(FP) ((FP)->_fileno)

View File

@ -225,10 +225,18 @@ typedef struct _IO_FILE _IO_FILE;
#endif
struct _IO_FILE_complete;
extern struct _IO_FILE_complete _IO_stdin_, _IO_stdout_, _IO_stderr_;
#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
extern struct _IO_FILE_complete _IO_2_1_stdin_;
extern struct _IO_FILE_complete _IO_2_1_stdout_;
extern struct _IO_FILE_complete _IO_2_1_stderr_;
#ifndef _LIBC
#define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))
#define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))
#define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))
#else
extern _IO_FILE *_IO_stdin;
extern _IO_FILE *_IO_stdout;
extern _IO_FILE *_IO_stderr;
#endif
/* Define the user-visible type, with user-friendly member names. */

View File

@ -346,6 +346,9 @@ extern void _IO_flush_all_linebuffered __P ((void));
#define _IO_do_flush(_f) \
_IO_do_write(_f, (_f)->_IO_write_base, \
(_f)->_IO_write_ptr-(_f)->_IO_write_base)
#define _IO_old_do_flush(_f) \
_IO_old_do_write(_f, (_f)->_IO_write_base, \
(_f)->_IO_write_ptr-(_f)->_IO_write_base)
#define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
#define _IO_mask_flags(fp, f, mask) \
((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))

View File

@ -130,7 +130,7 @@ _IO_old_file_close_it (fp)
if (!_IO_file_is_open (fp))
return EOF;
write_status = _IO_do_flush (fp);
write_status = _IO_old_do_flush (fp);
_IO_unsave_markers(fp);
@ -156,7 +156,7 @@ _IO_old_file_finish (fp, dummy)
{
if (_IO_file_is_open (fp))
{
_IO_do_flush (fp);
_IO_old_do_flush (fp);
if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
_IO_SYSCLOSE (fp);
}
@ -378,14 +378,14 @@ _IO_old_file_overflow (f, ch)
f->_flags |= _IO_CURRENTLY_PUTTING;
}
if (ch == EOF)
return _IO_do_flush (f);
return _IO_old_do_flush (f);
if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
if (_IO_do_flush (f) == EOF)
if (_IO_old_do_flush (f) == EOF)
return EOF;
*f->_IO_write_ptr++ = ch;
if ((f->_flags & _IO_UNBUFFERED)
|| ((f->_flags & _IO_LINE_BUF) && ch == '\n'))
if (_IO_do_flush (f) == EOF)
if (_IO_old_do_flush (f) == EOF)
return EOF;
return (unsigned char) ch;
}
@ -401,7 +401,7 @@ _IO_old_file_sync (fp)
_IO_flockfile (fp);
/* char* ptr = cur_ptr(); */
if (fp->_IO_write_ptr > fp->_IO_write_base)
if (_IO_do_flush(fp)) return EOF;
if (_IO_old_do_flush(fp)) return EOF;
delta = fp->_IO_read_ptr - fp->_IO_read_end;
if (delta != 0)
{
@ -679,7 +679,7 @@ _IO_old_file_xsputn (f, data, n)
dont_write = block_size >= 128 ? to_do % block_size : 0;
count = to_do - dont_write;
if (_IO_do_write (f, s, count) == EOF)
if (_IO_old_do_write (f, s, count) == EOF)
return n - to_do;
to_do = dont_write;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
This file is part of the GNU IO Library.
This library is free software; you can redistribute it and/or
@ -24,23 +24,35 @@
General Public License. */
#include "libioP.h"
#include "stdio.h"
#ifdef __STDC__
#include <stdlib.h>
#endif
FILE*
__old_freopen (filename, mode, fp)
const char* filename;
const char* mode;
FILE* fp;
int
_IO_old_fclose (fp)
_IO_FILE *fp;
{
FILE *result;
CHECK_FILE (fp, NULL);
if (!(fp->_flags & _IO_IS_FILEBUF))
return NULL;
int status;
CHECK_FILE(fp, EOF);
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_old_freopen (filename, mode, fp);
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
status = _IO_old_file_close_it (fp);
else
status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
_IO_FINISH (fp);
_IO_cleanup_region_end (1);
return result;
if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
{
fp->_IO_file_flags = 0;
free(fp);
}
return status;
}
symbol_version (__old_freopen, freopen,);
strong_alias (_IO_old_fclose, __old_fclose)
symbol_version (_IO_old_fclose, _IO_fclose, GLIBC_2.0);
symbol_version (__old_fclose, fclose, GLIBC_2.0);

View File

@ -49,7 +49,7 @@ _IO_old_fopen (filename, mode)
#endif
_IO_init (&new_f->fp.file, 0);
_IO_JUMPS (&new_f->fp.file) = &_IO_old_file_jumps;
_IO_file_init (&new_f->fp.file);
_IO_old_file_init (&new_f->fp.file);
#if !_IO_UNIFIED_JUMPTABLES
new_f->fp.vtable = NULL;
#endif
@ -61,5 +61,5 @@ _IO_old_fopen (filename, mode)
}
strong_alias (_IO_old_fopen, __old_fopen)
symbol_version (_IO_old_fopen, _IO_fopen,);
symbol_version (__old_fopen, fopen,);
symbol_version (_IO_old_fopen, _IO_fopen, GLIBC_2.0);
symbol_version (__old_fopen, fopen, GLIBC_2.0);

View File

@ -36,22 +36,52 @@
#define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \
static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
struct _IO_FILE_plus INAME \
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; \
symbol_version (INAME, NAME,)
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps};
#else
#define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \
struct _IO_FILE_plus INAME \
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; \
symbol_version (INAME, NAME,)
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps};
#endif
DEF_STDFILE(_IO_old_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES);
DEF_STDFILE(_IO_old_stdout_, _IO_stdout_, 1, &_IO_stdin_.plus.file,
DEF_STDFILE(_IO_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES);
DEF_STDFILE(_IO_stdout_, _IO_stdout_, 1, &_IO_stdin_.file,
_IO_NO_READS);
DEF_STDFILE(_IO_old_stderr_, _IO_stderr_, 2, &_IO_stdout_.plus.file,
DEF_STDFILE(_IO_stderr_, _IO_stderr_, 2, &_IO_stdout_.file,
_IO_NO_READS+_IO_UNBUFFERED);
#if 0
_IO_FILE *_IO_old_list_all = &_IO_stderr_.plus.file;
symbol_version (_IO_old_list_all, _IO_list_all,);
#if defined __GNUC__ && __GNUC__ >= 2
#include <stdio.h>
extern void * _IO_stdin_used;
weak_extern (_IO_stdin_used);
#undef stdin
#undef stdout
#undef stderr
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
extern FILE *_IO_list_all;
static void _IO_check_libio __P ((void)) __attribute__ ((constructor));
/* This function determines which shared C library the application
was linked against. We then set up the stdin/stdout/stderr and
_IO_list_all accordingly. */
static void
_IO_check_libio ()
{
if (&_IO_stdin_used == NULL)
{
/* We are using the old one. */
stdin = &_IO_stdin_.file;
stdout = &_IO_stdout_.file;
stderr = _IO_list_all = &_IO_stderr_.file;
}
}
#endif

View File

@ -36,22 +36,17 @@
#define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \
static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
struct _IO_FILE_complete INAME \
= {{FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps},}; \
default_symbol_version (INAME, NAME, GLIBC_2.1)
= {{FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps},};
#else
#define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \
struct _IO_FILE_complete INAME \
= {{FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps},}; \
default_symbol_version (INAME, NAME, GLIBC_2.1)
= {{FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps},};
#endif
DEF_STDFILE(_IO_new_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES);
DEF_STDFILE(_IO_new_stdout_, _IO_stdout_, 1, &_IO_stdin_.plus.file,
DEF_STDFILE(_IO_2_1_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES);
DEF_STDFILE(_IO_2_1_stdout_, _IO_stdout_, 1, &_IO_2_1_stdin_.plus.file,
_IO_NO_READS);
DEF_STDFILE(_IO_new_stderr_, _IO_stderr_, 2, &_IO_stdout_.plus.file,
DEF_STDFILE(_IO_2_1_stderr_, _IO_stderr_, 2, &_IO_2_1_stdout_.plus.file,
_IO_NO_READS+_IO_UNBUFFERED);
_IO_FILE *_IO_list_all = &_IO_stderr_.plus.file;
#if 0
default_symbol_version (_IO_new_list_all, _IO_list_all, GLIBC_2.1);
#endif
_IO_FILE *_IO_list_all = &_IO_2_1_stderr_.plus.file;

View File

@ -29,6 +29,13 @@
#undef stdin
#undef stdout
#undef stderr
FILE *stdin = &_IO_stdin_.plus.file;
FILE *stdout = &_IO_stdout_.plus.file;
FILE *stderr = &_IO_stderr_.plus.file;
FILE *stdin = &_IO_2_1_stdin_.plus.file;
FILE *stdout = &_IO_2_1_stdout_.plus.file;
FILE *stderr = &_IO_2_1_stderr_.plus.file;
#undef _IO_stdin
#undef _IO_stdout
#undef _IO_stderr
strong_alias (stdin, _IO_stdin);
strong_alias (stdout, _IO_stdout);
strong_alias (stderr, _IO_stderr);

View File

@ -80,8 +80,8 @@ CPPFLAGS := -DLOCALE_PATH='$(localepath)' \
-DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
-Iprograms $(CPPFLAGS)
CFLAGS-charmap.c = -Wno-write-strings
CFLAGS-locfile.c = -Wno-write-strings
CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts
CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by

View File

@ -1,5 +1,5 @@
@c We need some definitions here.
@ifclear cdor
@ifclear cdot
@ifhtml
@set cdot ·
@end ifhtml
@ -140,6 +140,7 @@ from real values:
@smallexample
3.0 - _Complex_I * 4.0
@end smallexample
@end deftypevr
@noindent
Without an optimizing compiler this is more expensive than the use of
@ -150,6 +151,7 @@ problem.
@deftypevr Macro {const float imaginary} _Imaginary_I
This macro is a representation of the value ``@math{1i}''. I.e., it is
the value for which
@end deftypevr
@smallexample
_Imaginary_I * _Imaginary_I = -1
@ -166,7 +168,6 @@ One can use it to easily construct complex number like in
@noindent
which results in the complex number with a real part of 3.0 and a
imaginary part -4.0.
@end deftypevr
@noindent
A more intuitive approach is to use the following macro.

View File

@ -856,7 +856,8 @@ asin_test (void)
#endif
check ("asin (0) == 0", FUNC(asin) (0), 0);
check ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6);
check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6,
CHOOSE(3.5e-18, 0, 2e-7));
check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2);
}
@ -1508,7 +1509,7 @@ log1p_test (void)
check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
CHOOSE (1e-18L, 0, 0));
CHOOSE (1e-18L, 0, 6e-8));
}
@ -1779,7 +1780,7 @@ tan_test (void)
FUNC(tan) (minus_infty), INVALID_EXCEPTION);
check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
CHOOSE (2e-18L, 1e-15L, 0));
CHOOSE (2e-18L, 1e-15L, 2e-7));
}
@ -4880,26 +4881,31 @@ static void
inverse_functions (void)
{
inverse_func_pair_test ("asin(sin(x)) == x",
FUNC(sin), FUNC(asin), 1.0, CHOOSE (2e-18L, 0, 3e-7L));
FUNC(sin), FUNC(asin), 1.0,
CHOOSE (2e-18L, 0, 3e-7L));
inverse_func_pair_test ("sin(asin(x)) == x",
FUNC(asin), FUNC(sin), 1.0, 0.0);
inverse_func_pair_test ("acos(cos(x)) == x",
FUNC(cos), FUNC(acos), 1.0, CHOOSE (4e-18L, 1e-15L, 0));
FUNC(cos), FUNC(acos), 1.0,
CHOOSE (4e-18L, 1e-15L, 0));
inverse_func_pair_test ("cos(acos(x)) == x",
FUNC(acos), FUNC(cos), 1.0, 0.0);
inverse_func_pair_test ("atan(tan(x)) == x",
FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
inverse_func_pair_test ("tan(atan(x)) == x",
FUNC(atan), FUNC(tan), 1.0, CHOOSE (2e-18L, 1e-15L, 0));
FUNC(atan), FUNC(tan), 1.0,
CHOOSE (2e-18L, 1e-15L, 2e-7));
inverse_func_pair_test ("asinh(sinh(x)) == x",
FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
inverse_func_pair_test ("sinh(asinh(x)) == x",
FUNC(asinh), FUNC(sinh), 1.0, CHOOSE (2e-18L, 0, 0));
FUNC(asinh), FUNC(sinh), 1.0,
CHOOSE (2e-18L, 2e-16L, 2e-7));
inverse_func_pair_test ("acosh(cosh(x)) == x",
FUNC(cosh), FUNC(acosh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
FUNC(cosh), FUNC(acosh), 1.0,
CHOOSE (1e-18L, 1e-15L, 6e-8));
inverse_func_pair_test ("cosh(acosh(x)) == x",
FUNC(acosh), FUNC(cosh), 1.0, 0.0);

View File

@ -36,7 +36,7 @@ libcrypt-map := libcrypt.map
onlymd5-routines := onlymd5-entry md5-crypt md5
distribute += onlymd5-entry.c
extra-objs := $(patsubst %,onlymd5-entry%,$(object-suffixes))
extra-objs = $(patsubst %,onlymd5-entry%,$(object-suffixes))
include ../Makeconfig

View File

@ -187,6 +187,10 @@ hsearch_r (item, action, retval, htab)
else
idx -= hval2;
/* If we visited all entries leave the loop unsuccessfully. */
if (idx == hval)
break;
/* If entry is found use it. */
if (htab->table[idx].used == hval
&& strcmp (item.key, htab->table[idx].entry.key) == 0)

View File

@ -42,7 +42,7 @@ main (void)
fputs (", set", stdout);
FD_SET (i, &set);
fputs (", check:", stdout);
if (FD_ISSET (i, &set) == 1)
if (FD_ISSET (i, &set))
fputs ("ok", stdout);
else
{

View File

@ -29,10 +29,6 @@
#include <rpcsvc/nis.h>
#include <nsswitch.h>
/* Comment out the following line for the production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "nss-nisplus.h"
#include "nisplus-parser.h"
@ -101,10 +97,6 @@ _nss_first_init (void)
key, sizeof (key) - 1),
local_dir, len_local_dir + 1)
- grptable) - 1;
/* *Maybe* (I'm no NIS expert) we have to duplicate the `local_dir'
value since it might change during our work. So add a test here. */
assert (grptablelen == sizeof (key) + len_local_dir);
}
return NSS_STATUS_SUCCESS;
@ -705,7 +697,7 @@ getgrgid_plusgroup (gid_t gid, struct group *result, char *buffer,
if (use_nisplus) /* Do the NIS+ query here */
{
nis_result *res;
char buf[1024 + grptablelen];
char buf[24 + grptablelen];
sprintf(buf, "[gid=%d],%s", gid, grptable);
res = nis_list(buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
@ -727,7 +719,7 @@ getgrgid_plusgroup (gid_t gid, struct group *result, char *buffer,
}
else /* Use NIS */
{
char buf[1024];
char buf[24];
char *domain, *outval, *p;
int outvallen;

View File

@ -30,10 +30,6 @@
#include <rpcsvc/nis.h>
#include <nsswitch.h>
/* Comment out the following line for the production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "netgroup.h"
#include "nss-nisplus.h"
#include "nisplus-parser.h"
@ -227,10 +223,6 @@ internal_setpwent (ent_t *ent)
key, sizeof (key) - 1),
local_dir, len_local_dir + 1)
- pwdtable) - 1;
/* *Maybe* (I'm no NIS expert) we have to duplicate the `local_dir'
value since it might change during our work. So add a test here. */
assert (pwdtablelen == sizeof (key) + len_local_dir);
}
ent->blacklist.current = 0;

View File

@ -30,10 +30,6 @@
#include <rpcsvc/nis.h>
#include <nsswitch.h>
/* Comment out the following line for the production version. */
/* #define NDEBUG 1 */
#include <assert.h>
#include "netgroup.h"
#include "nss-nisplus.h"
#include "nisplus-parser.h"
@ -179,10 +175,6 @@ internal_setspent (ent_t *ent)
key, sizeof (key) - 1),
local_dir, len_local_dir + 1)
- pwdtable) - 1;
/* *Maybe* (I'm no NIS expert) we have to duplicate the `local_dir'
value since it might change during our work. So add a test here. */
assert (pwdtablelen == sizeof (key) + len_local_dir);
}
ent->blacklist.current = 0;

View File

@ -31,10 +31,10 @@ extern "C" {
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#if !defined (_POSIX_C_SOURCE) && !defined (_POSIX_SOURCE) && defined (VMS)
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
#include <stddef.h>
# include <stddef.h>
#endif
/* The following two types have to be signed and unsigned integer type
@ -239,7 +239,7 @@ extern reg_syntax_t re_syntax_options;
(erroneously) define this in other header files, but we want our
value, so remove any previous define. */
#ifdef RE_DUP_MAX
#undef RE_DUP_MAX
# undef RE_DUP_MAX
#endif
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
#define RE_DUP_MAX (0x7fff)
@ -313,7 +313,7 @@ typedef enum
private to the regex routines. */
#ifndef RE_TRANSLATE_TYPE
#define RE_TRANSLATE_TYPE char *
# define RE_TRANSLATE_TYPE char *
#endif
struct re_pattern_buffer
@ -404,7 +404,7 @@ struct re_registers
`re_match_2' returns information about at least this many registers
the first time a `regs' structure is passed. */
#ifndef RE_NREGS
#define RE_NREGS 30
# define RE_NREGS 30
#endif
@ -427,11 +427,11 @@ typedef struct
#if __STDC__
#define _RE_ARGS(args) args
# define _RE_ARGS(args) args
#else /* not __STDC__ */
#define _RE_ARGS(args) ()
# define _RE_ARGS(args) ()
#endif /* not __STDC__ */
@ -502,11 +502,11 @@ extern void re_set_registers
unsigned num_regs, regoff_t *starts, regoff_t *ends));
#ifdef _REGEX_RE_COMP
#ifndef _CRAY
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp _RE_ARGS ((const char *));
extern int re_exec _RE_ARGS ((const char *));
#endif
# endif
#endif
/* POSIX compatibility. */

View File

@ -42,7 +42,9 @@
#include <unistd.h>
#include <stdlib.h>
#define NDEBUG /* Undefine this for debugging assertions. */
#ifndef NDEBUG
# define NDEBUG /* Undefine this for debugging assertions. */
#endif
#include <assert.h>
/* This defines make it possible to use the same code for GNU C library and

View File

@ -21,7 +21,7 @@
#
subdir := stdlib
headers := stdlib.h alloca.h monetary.h fmtmsg.h
headers := stdlib.h alloca.h monetary.h fmtmsg.h ucontext.h sys/ucontext.h
routines := \
atof atoi atol atoll \

View File

@ -42,12 +42,18 @@ __erand48_r (xsubi, buffer, result)
temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
/* Please note the lower 4 bits of mantissa1 are always 0. */
*result = temp.d - 1.0;
#elif USHRT_MAX == 2147483647
temp.ieee.negative = 0;
temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
temp.ieee.mantissa0 = (xsubi[1] << 4) | (xsubi[0] >> 28);
temp.ieee.mantissa1 = ((xsubi[0] & 0xfffffff) << 4);
#else
# error Unsupported size of short int
#endif
/* Please note the lower 4 bits of mantissa1 are always 0. */
*result = temp.d - 1.0;
return 0;
}
weak_alias (__erand48_r, erand48_r)

View File

@ -583,7 +583,7 @@ __strspn_c1 (__const char *__s, char __accept)
# define strstr(haystack, needle) \
(__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \
? (((__const unsigned char *) (needle))[0] == '\0' \
? haystack \
? (char *) (haystack) \
: (((__const unsigned char *) (needle))[1] == '\0' \
? strchr (haystack, \
((__const unsigned char *) (needle))[0]) \
@ -605,6 +605,47 @@ strnlen (__const char *__string, size_t __maxlen)
#endif
#if defined __USE_POSIX || defined __USE_MISC
# ifndef _HAVE_STRING_ARCH_strtok_r
# define strtok_r(s, sep, nextp) \
(__extension__ (__builtin_constant_p (sep) && __string2_1bptr_p (sep) \
? (((__const unsigned char *) (sep))[0] != '\0' \
&& ((__const unsigned char *) (sep))[1] == '\0' \
? __strtok_r_1c (s, ((__const unsigned char *) (sep))[0],\
nextp) \
: strtok_r (s, sep, nextp)) \
: strtok_r (s, sep, nextp)))
__STRING_INLINE char *__strtok_r_1c (char *__s, char __sep, char **__nextp);
__STRING_INLINE char *
__strtok_r_1c (char *__s, char __sep, char **__nextp)
{
char *__result;
if (__s == NULL)
__s = *__nextp;
while (*__s == __sep)
++__s;
if (*__s == '\0')
__result = NULL;
else
{
__result = __s;
while (*__s != '\0' && *__s != __sep)
++__s;
if (*__s == '\0')
*__nextp = __s;
else
{
*__s = '\0';
*__nextp = __s + 1;
}
}
return __result;
}
# endif
#endif
#ifdef __USE_BSD
# ifndef _HAVE_STRING_ARCH_strsep

View File

@ -1,4 +1,3 @@
setjmp_aux.c
divrem.h
divl.S divq.S reml.S remq.S
_mcount.S

View File

@ -43,13 +43,13 @@
#endif
/* ARM 6 needs slightly different handling */
#ifdef __arm6__
/* APCS-32 doesn't preserve the condition codes across function call. */
#ifdef __APCS_32__
#define LOADREGS(cond, base, reglist...)\
ldm##cond base,reglist
#define RETINSTR(instr, regs...)\
instr regs
#else /* arm 3 */
#else /* APCS-26 */
#define LOADREGS(cond, base, reglist...)\
ldm##cond base,reglist^
#define RETINSTR(instr, regs...)\

View File

@ -9,6 +9,7 @@
#include <bits/types.h>
#define __need_size_t
#define __need_wint_t
#define __need_NULL
#include <stddef.h>
#ifndef _WINT_T
/* Integral type unchanged by default argument promotions that can

View File

@ -10,5 +10,5 @@ __ieee754_acoshl (long double x)
return 0.0;
}
stub_warning (__ieee754_acoshl)
stub_warning (acoshl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_acosl (long double x)
return 0.0;
}
stub_warning (__ieee754_acosl)
stub_warning (acosl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_asinl (long double x)
return 0.0;
}
stub_warning (__ieee754_asinl)
stub_warning (asinl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_atan2l (long double x, long double y)
return 0.0;
}
stub_warning (__ieee754_atan2l)
stub_warning (atan2l)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_expl (long double x)
return 0.0;
}
stub_warning (__ieee754_expl)
stub_warning (expl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_fmodl (long double x, long double y)
return 0.0;
}
stub_warning (__ieee754_fmodl)
stub_warning (fmodl)
#include <stub-tag.h>

View File

@ -10,7 +10,7 @@ __ieee754_j0l (long double x)
return 0.0;
}
stub_warning (__ieee754_j0l)
stub_warning (j0l)
long double
__ieee754_y0l (long double x)
@ -20,5 +20,5 @@ __ieee754_y0l (long double x)
return 0.0;
}
stub_warning (__ieee754_y0l)
stub_warning (y0l)
#include <stub-tag.h>

View File

@ -10,7 +10,7 @@ __ieee754_j1l (long double x)
return 0.0;
}
stub_warning (__ieee754_j1l)
stub_warning (j1l)
long double
__ieee754_y1l (long double x)
@ -20,5 +20,5 @@ __ieee754_y1l (long double x)
return 0.0;
}
stub_warning (__ieee754_y1l)
stub_warning (y1l)
#include <stub-tag.h>

View File

@ -10,7 +10,7 @@ __ieee754_jnl (int n, long double x)
return 0.0;
}
stub_warning (__ieee754_jnl)
stub_warning (jnl)
long double
__ieee754_ynl (int n, long double x)
@ -20,5 +20,5 @@ __ieee754_ynl (int n, long double x)
return 0.0;
}
stub_warning (__ieee754_ynl)
stub_warning (ynl)
#include <stub-tag.h>

View File

@ -10,5 +10,6 @@ __ieee754_lgammal_r (long double x, int *signgamp)
return 0.0;
}
stub_warning (__ieee754_lgammal_r)
stub_warning (lgammal)
stub_warning (lgammal_r)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_log10l (long double x)
return 0.0;
}
stub_warning (__ieee754_log10l)
stub_warning (log10l)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_logl (long double x)
return 0.0;
}
stub_warning (__ieee754_logl)
stub_warning (logl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_powl (long double x, long double y)
return 0.0;
}
stub_warning (__ieee754_powl)
stub_warning (powl)
#include <stub-tag.h>

View File

@ -10,5 +10,5 @@ __ieee754_sqrtl (long double x)
return 0.0;
}
stub_warning (__ieee754_sqrtl)
stub_warning (sqrtl)
#include <stub-tag.h>

View File

@ -3,13 +3,12 @@
#include <errno.h>
long double
__exp2l (long double x)
__ieee754_exp2l (long double x)
{
fputs ("__exp2l not implemented\n", stderr);
fputs ("__ieee754_exp2l not implemented\n", stderr);
__set_errno (ENOSYS);
return 0.0;
}
weak_alias (__exp2l, exp2l)
stub_warning (exp2l)
#include <stub-tag.h>

View File

@ -0,0 +1,41 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdim)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fucomi %st(1), %st
jp 1f
fsubp %st(1), %st
fldz
fcmovnb %st(1), %st
jmp 2f
1: fucomi %st(0), %st
fcmovu %st, %st(1)
2: fstp %st(1)
ret
END(__fdim)
weak_alias (__fdim, fdim)

View File

@ -0,0 +1,41 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdimf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fucomi %st(1), %st
jp 1f
fsubp %st(1), %st
fldz
fcmovnb %st(1), %st
jmp 2f
1: fucomi %st(0), %st
fcmovu %st, %st(1)
2: fstp %st(1)
ret
END(__fdimf)
weak_alias (__fdimf, fdimf)

View File

@ -0,0 +1,41 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdiml)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fucomi %st(1), %st
jp 1f
fsubp %st(1), %st
fldz
fcmovnb %st(1), %st
jmp 2f
1: fucomi %st(0), %st
fcmovu %st, %st(1)
2: fstp %st(1)
ret
END(__fdiml)
weak_alias (__fdiml, fdiml)

View File

@ -0,0 +1,40 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmax)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fxch
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fmax)
weak_alias (__fmax, fmax)

View File

@ -0,0 +1,40 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmaxf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fxch
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fmaxf)
weak_alias (__fmaxf, fmaxf)

View File

@ -0,0 +1,40 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmaxl)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fxch
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fmaxl)
weak_alias (__fmaxl, fmaxl)

View File

@ -0,0 +1,38 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmin)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fmin)
weak_alias (__fmin, fmin)

View File

@ -0,0 +1,38 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fminf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fminf)
weak_alias (__fminf, fminf)

View File

@ -0,0 +1,38 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fminl)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fucomi %st(0), %st
fcmovu %st(1), %st // now %st contains y if not NaN, x otherwise
fucomi %st(1), %st
fcmovb %st(1), %st
fstp %st(1)
ret
END(__fminl)
weak_alias (__fminl, fminl)

View File

@ -0,0 +1,51 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdim)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fucom %st(1)
fnstsw
sahf
jp 1f
fsubp %st(1), %st
jc 2f
fstp %st(0)
fldz
jmp 2f
1: fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 3f
fxch
3: fstp %st(1)
2: ret
END(__fdim)
weak_alias (__fdim, fdim)

View File

@ -0,0 +1,51 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdimf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fucom %st(1)
fnstsw
sahf
jp 1f
fsubp %st(1), %st
jc 2f
fstp %st(0)
fldz
jmp 2f
1: fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 3f
fxch
3: fstp %st(1)
2: ret
END(__fdimf)
weak_alias (__fdimf, fdimf)

View File

@ -0,0 +1,51 @@
/* Compute positive difference.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fdiml)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fucom %st(1)
fnstsw
sahf
jp 1f
fsubp %st(1), %st
jc 2f
fstp %st(0)
fldz
jmp 2f
1: fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 3f
fxch
3: fstp %st(1)
2: ret
END(__fdiml)
weak_alias (__fdiml, fdiml)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmax)
fldl 12(%esp) // y
fxam
fnstsw
fldl 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmax)
weak_alias (__fmax, fmax)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmaxf)
flds 8(%esp) // y
fxam
fnstsw
flds 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmaxf)
weak_alias (__fmaxf, fmaxf)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmaxl)
fldt 16(%esp) // y
fxam
fnstsw
fldt 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmaxl)
weak_alias (__fmaxl, fmaxl)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fmin)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fmin)
weak_alias (__fmin, fmin)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fminf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fminf)
weak_alias (__fminf, fminf)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
.text
ENTRY(__fminl)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fminl)
weak_alias (__fminl, fminl)

View File

@ -37,7 +37,7 @@ static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $";
if(hx<0x00100000) {
GET_LOW_WORD(lx,x);
if((hx|lx)==0)
return 0x80000001; /* ilogb(0) = 0x80000001 */
return FP_ILOGB0; /* ilogb(0) = FP_ILOGB0 */
else /* subnormal x */
if(hx==0) {
for (ix = -1043; lx>0; lx<<=1) ix -=1;
@ -47,7 +47,7 @@ static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $";
return ix;
}
else if (hx<0x7ff00000) return (hx>>20)-1023;
else return 0x7fffffff;
else return FP_ILOGBNAN;
}
weak_alias (__ilogb, ilogb)
#ifdef NO_LONG_DOUBLE

View File

@ -33,12 +33,12 @@ static char rcsid[] = "$NetBSD: s_ilogbf.c,v 1.4 1995/05/10 20:47:31 jtc Exp $";
hx &= 0x7fffffff;
if(hx<0x00800000) {
if(hx==0)
return 0x80000001; /* ilogb(0) = 0x80000001 */
return FP_ILOGB0; /* ilogb(0) = FP_ILOGB0 */
else /* subnormal x */
for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1;
return ix;
}
else if (hx<0x7f800000) return (hx>>23)-127;
else return 0x7fffffff;
else return FP_ILOGBNAN;
}
weak_alias (__ilogbf, ilogbf)

View File

@ -41,7 +41,7 @@ static char rcsid[] = "$NetBSD: $";
if(es==0) {
GET_LDOUBLE_WORDS(es,hx,lx,x);
if((hx|lx)==0)
return 0x80000001; /* ilogbl(0) = 0x80000001 */
return FP_ILOGB0; /* ilogbl(0) = FP_ILOGB0 */
else /* subnormal x */
if(hx==0) {
for (ix = -16415; lx>0; lx<<=1) ix -=1;
@ -51,6 +51,6 @@ static char rcsid[] = "$NetBSD: $";
return ix;
}
else if (es<0x7fff) return es-0x3fff;
else return 0x7fffffff;
else return FP_ILOGBNAN;
}
weak_alias (__ilogbl, ilogbl)

View File

@ -34,17 +34,17 @@ long long int
__llrintf (float x)
{
int32_t j0;
u_int32_t i, i0;
u_int32_t i0;
volatile float w;
float t;
long long int result;
int sx;
GET_FLOAT_WORD (i, x);
GET_FLOAT_WORD (i0, x);
sx = i0 >> 31;
j0 = ((i0 >> 23) & 0xff) - 0x7f;
i0 = i & 0x7fffff;
i0 &= 0x7fffff;
i0 |= 0x800000;
if (j0 < (int32_t) (sizeof (long long int) * 8) - 1)
@ -57,10 +57,10 @@ __llrintf (float x)
{
w = two23[sx] + x;
t = w - two23[sx];
GET_FLOAT_WORD (i, t);
i0 = i & 0x7fffff;
i0 |= 0x800000;
GET_FLOAT_WORD (i0, t);
j0 = ((i0 >> 23) & 0xff) - 0x7f;
i0 &= 0x7fffff;
i0 |= 0x800000;
result = i0 >> (23 - j0);
}

View File

@ -34,7 +34,7 @@ long int
__lrint (double x)
{
int32_t j0;
u_int32_t i0,i1,i;
u_int32_t i0,i1;
volatile double w;
double t;
long int result;
@ -55,9 +55,9 @@ __lrint (double x)
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
i0 = i & 0xfffff;
i0 |= 0x100000;
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
result = i0 >> (20 - j0);
}
@ -71,9 +71,9 @@ __lrint (double x)
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
i0 = i & 0xfffff;
i0 |= 0x100000;
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0));
}

View File

@ -34,17 +34,17 @@ long int
__lrintf (float x)
{
int32_t j0;
u_int32_t i, i0;
u_int32_t i0;
volatile float w;
float t;
long int result;
int sx;
GET_FLOAT_WORD (i, x);
GET_FLOAT_WORD (i0, x);
sx = i0 >> 31;
j0 = ((i0 >> 23) & 0xff) - 0x7f;
i0 = i & 0x7fffff;
i0 &= 0x7fffff;
i0 |= 0x800000;
if (j0 < (int32_t) (sizeof (long int) * 8) - 1)
@ -57,10 +57,10 @@ __lrintf (float x)
{
w = two23[sx] + x;
t = w - two23[sx];
GET_FLOAT_WORD (i, t);
i0 = i & 0x7fffff;
i0 |= 0x800000;
GET_FLOAT_WORD (i0, t);
j0 = ((i0 >> 23) & 0xff) - 0x7f;
i0 &= 0x7fffff;
i0 |= 0x800000;
result = i0 >> (23 - j0);
}

View File

@ -35,6 +35,6 @@ __nanf (const char *tagp)
return strtof (buf, NULL);
}
return NANF;
return NAN;
}
weak_alias (__nanf, nanf)

Some files were not shown because too many files have changed in this diff Show More