Update.
1998-03-27 22:46 Ulrich Drepper <drepper@cygnus.com> * Rules: Allow Makefiles to specify test-static for tests which cannot be linked dynamically. * math/Makefile: Move atest-exp, atest-sincos, atest-exp2 to tests-static. * libc.map: Add __nss_passwd_lookup, __nss_group_lookup, __nss_next. * misc/error.c: Pretty print. 1998-03-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makerules (libc_nonshared-name): Remove variable. (installed-libcs): Use libc-name instead. ($(inst_libdir)/libc.so): Likewise. Remove explicit reference to dynamic linker. * Makeconfig (link-libc): Link against libc_nonshared.a instead of libc.a. Remove explicit reference to dynamic linker. 1998-03-27 Ulrich Drepper <drepper@cygnus.com> * iconvdata/iso8859-1.c (gconv): Add cast to assignment from char to wchar_t. * iconv/iconv_prog.c: Correctly test for write failure. * iconvdata/Makefile: Add rules for EUC-KR, UHC, and JOHAB conversions. * iconvdata/gconv-modules: Likewise. * iconvdata/euckr.c: New file. * iconvdata/johab.c: New file. * iconvdata/ksc5601.c: New file. * iconvdata/ksc5601.h: New file. * iconvdata/uhc.c: New file. Contributed by Jungshik Shin <jshin@pantheon.yale.edu>. * libio/fileops.c (_IO_file_fopen): Interpret x flag to fopen. * stdio/fopen.c: Correct handling of 'x' flag. Reported by Jason M. Petry <jason@ps.ohio-state.edu>. 1998-03-27 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sunrpc/rpc/key_prot.h: Prevent warning by unknown pragma ident. * sunrpc/rpcsvc/key_prot.x: Likewise. * sunrpc/key_prot.c: Likewise. 1998-03-27 13:49 Ulrich Drepper <drepper@cygnus.com> * sysdeps/i386/bits/string.h: Correct things which never worked. * sysdeps/i386/i486/bits/string.h: Add clobber marks. Patches by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>. 1998-03-27 Ulrich Drepper <drepper@cygnus.com> * intl/textdomain.c [_LIBC]: Define strdup only if not yet defined. Reported by Thorsten Kukuk.
This commit is contained in:
parent
f38931a9f0
commit
a44d23932d
56
ChangeLog
56
ChangeLog
|
@ -1,3 +1,59 @@
|
||||||
|
1998-03-27 22:46 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* Rules: Allow Makefiles to specify test-static for tests which
|
||||||
|
cannot be linked dynamically.
|
||||||
|
* math/Makefile: Move atest-exp, atest-sincos, atest-exp2 to
|
||||||
|
tests-static.
|
||||||
|
|
||||||
|
* libc.map: Add __nss_passwd_lookup, __nss_group_lookup, __nss_next.
|
||||||
|
|
||||||
|
* misc/error.c: Pretty print.
|
||||||
|
|
||||||
|
1998-03-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||||
|
|
||||||
|
* Makerules (libc_nonshared-name): Remove variable.
|
||||||
|
(installed-libcs): Use libc-name instead.
|
||||||
|
($(inst_libdir)/libc.so): Likewise. Remove explicit reference to
|
||||||
|
dynamic linker.
|
||||||
|
|
||||||
|
* Makeconfig (link-libc): Link against libc_nonshared.a instead of
|
||||||
|
libc.a. Remove explicit reference to dynamic linker.
|
||||||
|
|
||||||
|
1998-03-27 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* iconvdata/iso8859-1.c (gconv): Add cast to assignment from char
|
||||||
|
to wchar_t.
|
||||||
|
* iconv/iconv_prog.c: Correctly test for write failure.
|
||||||
|
* iconvdata/Makefile: Add rules for EUC-KR, UHC, and JOHAB conversions.
|
||||||
|
* iconvdata/gconv-modules: Likewise.
|
||||||
|
* iconvdata/euckr.c: New file.
|
||||||
|
* iconvdata/johab.c: New file.
|
||||||
|
* iconvdata/ksc5601.c: New file.
|
||||||
|
* iconvdata/ksc5601.h: New file.
|
||||||
|
* iconvdata/uhc.c: New file.
|
||||||
|
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>.
|
||||||
|
|
||||||
|
* libio/fileops.c (_IO_file_fopen): Interpret x flag to fopen.
|
||||||
|
* stdio/fopen.c: Correct handling of 'x' flag.
|
||||||
|
Reported by Jason M. Petry <jason@ps.ohio-state.edu>.
|
||||||
|
|
||||||
|
1998-03-27 Andreas Jaeger <aj@arthur.rhein-neckar.de>
|
||||||
|
|
||||||
|
* sunrpc/rpc/key_prot.h: Prevent warning by unknown pragma ident.
|
||||||
|
* sunrpc/rpcsvc/key_prot.x: Likewise.
|
||||||
|
* sunrpc/key_prot.c: Likewise.
|
||||||
|
|
||||||
|
1998-03-27 13:49 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* sysdeps/i386/bits/string.h: Correct things which never worked.
|
||||||
|
* sysdeps/i386/i486/bits/string.h: Add clobber marks.
|
||||||
|
Patches by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>.
|
||||||
|
|
||||||
|
1998-03-27 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* intl/textdomain.c [_LIBC]: Define strdup only if not yet
|
||||||
|
defined. Reported by Thorsten Kukuk.
|
||||||
|
|
||||||
1998-03-26 18:50 Ulrich Drepper <drepper@cygnus.com>
|
1998-03-26 18:50 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/lddlibc4.c: New file.
|
* sysdeps/unix/sysv/linux/lddlibc4.c: New file.
|
||||||
|
|
|
@ -404,8 +404,7 @@ ifeq (yes,$(build-shared))
|
||||||
# run the linked programs.
|
# run the linked programs.
|
||||||
link-libc = -Wl,-rpath-link=$(rpath-link) \
|
link-libc = -Wl,-rpath-link=$(rpath-link) \
|
||||||
$(common-objpfx)libc.so$(libc.so-version) \
|
$(common-objpfx)libc.so$(libc.so-version) \
|
||||||
$(elfobjdir)/$(rtld-installed-name) \
|
$(common-objpfx)$(patsubst %,$(libtype.oS),c) $(gnulib)
|
||||||
$(common-objpfx)libc_nonshared.a $(gnulib)
|
|
||||||
# Choose the default search path for the dynamic linker based on
|
# Choose the default search path for the dynamic linker based on
|
||||||
# where we will install libraries.
|
# where we will install libraries.
|
||||||
ifneq ($(libdir),$(slibdir))
|
ifneq ($(libdir),$(slibdir))
|
||||||
|
|
18
Makerules
18
Makerules
|
@ -602,9 +602,6 @@ endef
|
||||||
ifndef libc-name
|
ifndef libc-name
|
||||||
libc-name := c
|
libc-name := c
|
||||||
endif
|
endif
|
||||||
ifndef libc_nonshared-name
|
|
||||||
libc_nonshared-name := $(libc-name)_nonshared
|
|
||||||
endif
|
|
||||||
|
|
||||||
define do-install
|
define do-install
|
||||||
$(make-target-directory)
|
$(make-target-directory)
|
||||||
|
@ -628,7 +625,7 @@ installed-libcs := $(foreach o,$(object-suffixes),\
|
||||||
installed-libcs := $(filter-out %_pic.a,$(installed-libcs))
|
installed-libcs := $(filter-out %_pic.a,$(installed-libcs))
|
||||||
ifdef libc.so-version
|
ifdef libc.so-version
|
||||||
installed-libcs += $(inst_libdir)/$(patsubst %,$(libtype.oS),\
|
installed-libcs += $(inst_libdir)/$(patsubst %,$(libtype.oS),\
|
||||||
$(libprefix)$(libc_nonshared-name))
|
$(libprefix)$(libc-name))
|
||||||
endif
|
endif
|
||||||
install: $(installed-libcs)
|
install: $(installed-libcs)
|
||||||
$(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib
|
$(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib
|
||||||
|
@ -706,17 +703,14 @@ ifndef subdir
|
||||||
# in libc.a and the dynamic linker is an extra object.
|
# in libc.a and the dynamic linker is an extra object.
|
||||||
install: $(inst_libdir)/libc.so
|
install: $(inst_libdir)/libc.so
|
||||||
$(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
|
$(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
|
||||||
$(elfobjdir)/$(rtld-installed-name) \
|
$(inst_libdir)/$(patsubst %,$(libtype.oS),\
|
||||||
$(inst_libdir)/lib$(libc_nonshared-name).a
|
$(libprefix)$(libc-name))
|
||||||
(echo '/* GNU ld script';\
|
(echo '/* GNU ld script';\
|
||||||
echo ' Use the shared library, but some functions are only in';\
|
echo ' Use the shared library, but some functions are only in';\
|
||||||
echo ' the static library, so try that secondarily.'; \
|
echo ' the static library, so try that secondarily. */';\
|
||||||
echo ' The dynamic linker defines some functions used by $(<F),';\
|
|
||||||
echo ' but ld uses definitions from libc.a before examining the';\
|
|
||||||
echo ' dependencies of $(<F) to find $(rtld-installed-name). */';\
|
|
||||||
echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
|
echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
|
||||||
'$(slibdir)/$(rtld-installed-name)' \
|
'$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
|
||||||
'$(libdir)/lib$(libc_nonshared-name).a )' \
|
')' \
|
||||||
) > $@.new
|
) > $@.new
|
||||||
mv -f $@.new $@
|
mv -f $@.new $@
|
||||||
|
|
||||||
|
|
17
Rules
17
Rules
|
@ -88,9 +88,9 @@ else
|
||||||
others: $(addprefix $(objpfx),$(extra-objs))
|
others: $(addprefix $(objpfx),$(extra-objs))
|
||||||
endif
|
endif
|
||||||
ifeq ($(cross-compiling),yes)
|
ifeq ($(cross-compiling),yes)
|
||||||
tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
|
tests: $(addprefix $(objpfx),$(tests) $(tests-static) $(test-srcs))
|
||||||
else
|
else
|
||||||
tests: $(tests:%=$(objpfx)%.out)
|
tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(build-programs),yes)
|
ifeq ($(build-programs),yes)
|
||||||
|
@ -129,6 +129,19 @@ $(objpfx)%.out: %.input $(objpfx)%
|
||||||
$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
|
$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
|
||||||
$($*-ENV) $(built-program-cmd) > $@
|
$($*-ENV) $(built-program-cmd) > $@
|
||||||
endif # tests
|
endif # tests
|
||||||
|
|
||||||
|
ifneq "$(strip $(tests-static) $(test-static-srcs))" ""
|
||||||
|
# These are the implicit rules for making test outputs
|
||||||
|
# from the test programs and whatever input files are present.
|
||||||
|
$(objpfx)%.sout: %.args $(objpfx)% %.input
|
||||||
|
$($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
|
||||||
|
$(objpfx)%.sout: %.args $(objpfx)%
|
||||||
|
$($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
|
||||||
|
$(objpfx)%.sout: %.input $(objpfx)%
|
||||||
|
$($*-ENV) $(built-program-file) < $(word 1,$^) > $@
|
||||||
|
$(objpfx)%.sout: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
|
||||||
|
$($*-ENV) $(built-program-file) > $@
|
||||||
|
endif # tests
|
||||||
|
|
||||||
.PHONY: distclean realclean subdir_distclean subdir_realclean \
|
.PHONY: distclean realclean subdir_distclean subdir_realclean \
|
||||||
subdir_clean subdir_mostlyclean
|
subdir_clean subdir_mostlyclean
|
||||||
|
|
|
@ -289,7 +289,7 @@ process_block (iconv_t cd, const char *addr, size_t len, FILE *output)
|
||||||
if (outptr != outbuf)
|
if (outptr != outbuf)
|
||||||
{
|
{
|
||||||
/* We have something to write out. */
|
/* We have something to write out. */
|
||||||
if (fwrite (outbuf, 1, outptr - outbuf, output) != 0
|
if (fwrite (outbuf, 1, outptr - outbuf, output) < outptr - outbuf
|
||||||
|| ferror (output))
|
|| ferror (output))
|
||||||
{
|
{
|
||||||
/* Error occurred while printing the result. */
|
/* Error occurred while printing the result. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 1997 Free Software Foundation, Inc.
|
# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -26,7 +26,7 @@ modules := ISO8859-1 ISO8859-2 ISO8859-3 ISO8859-4 ISO8859-5 \
|
||||||
ISO8859-6 ISO8859-7 ISO8859-8 ISO8859-9 ISO8859-10 \
|
ISO8859-6 ISO8859-7 ISO8859-8 ISO8859-9 ISO8859-10 \
|
||||||
T.61 ISO_6937 SJIS KOI-8 KOI8-R LATIN-GREEK LATIN-GREEK-1 \
|
T.61 ISO_6937 SJIS KOI-8 KOI8-R LATIN-GREEK LATIN-GREEK-1 \
|
||||||
HP-ROMAN8 EBCDIC-AT-DE EBCDIC-AT-DE-A EBCDIC-CA-FR \
|
HP-ROMAN8 EBCDIC-AT-DE EBCDIC-AT-DE-A EBCDIC-CA-FR \
|
||||||
libJIS
|
EUC-KR UHC JOHAB libJIS libKSC
|
||||||
modules.so := $(addsuffix .so, $(modules))
|
modules.so := $(addsuffix .so, $(modules))
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,11 @@ HP-ROMAN8-routines := hp-roman8
|
||||||
EBCDIC-AT-DE-routines := ebcdic-at-de
|
EBCDIC-AT-DE-routines := ebcdic-at-de
|
||||||
EBCDIC-AT-DE-A-routines := ebcdic-at-de-a
|
EBCDIC-AT-DE-A-routines := ebcdic-at-de-a
|
||||||
EBCDIC-CA-FR-routines := ebcdic-ca-fr
|
EBCDIC-CA-FR-routines := ebcdic-ca-fr
|
||||||
|
EUC-KR-routines := euckr ksc5601
|
||||||
|
JOHAB-routines := johab ksc5601
|
||||||
|
UHC-routines := uhc ksc5601
|
||||||
libJIS-routines := jis0201 jis0208 jis0212
|
libJIS-routines := jis0201 jis0208 jis0212
|
||||||
|
libKSC-routines := ksc5601
|
||||||
|
|
||||||
distribute := 8bit-generic.c 8bit-gap.c gap.pl gaptab.pl gconv-modules \
|
distribute := 8bit-generic.c 8bit-gap.c gap.pl gaptab.pl gconv-modules \
|
||||||
iso8859-1.c iso8859-2.c iso8859-3.c iso8859-4.c iso8859-5.c \
|
iso8859-1.c iso8859-2.c iso8859-3.c iso8859-4.c iso8859-5.c \
|
||||||
|
@ -62,7 +66,7 @@ distribute := 8bit-generic.c 8bit-gap.c gap.pl gaptab.pl gconv-modules \
|
||||||
koi-8.c koi8-r.c koi8-r.h hp-roman8.c latin-greek.c \
|
koi-8.c koi8-r.c koi8-r.h hp-roman8.c latin-greek.c \
|
||||||
latin-greek.h latin-greek-1.c latin-greek-1.h ebcdic-at-de.c \
|
latin-greek.h latin-greek-1.c latin-greek-1.h ebcdic-at-de.c \
|
||||||
ebcdic-at-de-a.c ebcdic-ca-fr.c jis0201.c jis0208.c jis0212.c \
|
ebcdic-at-de-a.c ebcdic-ca-fr.c jis0201.c jis0208.c jis0212.c \
|
||||||
extra-module.mk
|
extra-module.mk euckr.c johab.c uhc.c ksc5601.c ksc5601.h
|
||||||
|
|
||||||
# We build the transformation modules only when we build shared libs.
|
# We build the transformation modules only when we build shared libs.
|
||||||
ifeq (yes,$(build-shared))
|
ifeq (yes,$(build-shared))
|
||||||
|
|
|
@ -0,0 +1,318 @@
|
||||||
|
/* Mapping tables for EUC-KR handling.
|
||||||
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>, 1998.
|
||||||
|
|
||||||
|
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 <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <ksc5601.h>
|
||||||
|
|
||||||
|
/* Direction of the transformation. */
|
||||||
|
enum direction
|
||||||
|
{
|
||||||
|
illegal,
|
||||||
|
to_euckr,
|
||||||
|
from_euckr
|
||||||
|
};
|
||||||
|
|
||||||
|
struct euckr_data
|
||||||
|
{
|
||||||
|
enum direction dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
euckr_from_ucs4(wchar_t ch, unsigned char *cp)
|
||||||
|
{
|
||||||
|
if (ch > 0x7f)
|
||||||
|
{
|
||||||
|
uint16_t idx=0;
|
||||||
|
|
||||||
|
if (ucs4_to_ksc5601 (ch, &idx))
|
||||||
|
idx |= 0x8080;
|
||||||
|
|
||||||
|
*cp = (unsigned char) (idx/256);
|
||||||
|
*(cp+1) = (unsigned char) (idx & 0xff) ;
|
||||||
|
}
|
||||||
|
/* think about 0x5c ; '\' */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*cp = (unsigned char) (0x7f & ch) ;
|
||||||
|
*(cp+1) = (unsigned char) 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
gconv_init (struct gconv_step *step, struct gconv_step_data *data)
|
||||||
|
{
|
||||||
|
/* Determine which direction. */
|
||||||
|
struct euckr_data *new_data;
|
||||||
|
enum direction dir;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (strcasestr (step->from_name, "EUC-KR") != NULL)
|
||||||
|
dir = from_euckr;
|
||||||
|
else if (strcasestr (step->to_name, "EUC-KR") != NULL)
|
||||||
|
dir = to_euckr;
|
||||||
|
else
|
||||||
|
dir = illegal;
|
||||||
|
|
||||||
|
result = GCONV_NOCONV;
|
||||||
|
if (dir != illegal
|
||||||
|
&& ((new_data
|
||||||
|
= (struct euckr_data *) malloc (sizeof (struct euckr_data)))
|
||||||
|
!= NULL))
|
||||||
|
{
|
||||||
|
new_data->dir = dir;
|
||||||
|
data->data = new_data;
|
||||||
|
result = GCONV_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gconv_end (struct gconv_step_data *data)
|
||||||
|
{
|
||||||
|
free (data->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
gconv (struct gconv_step *step, struct gconv_step_data *data,
|
||||||
|
const char *inbuf, size_t *inbufsize, 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)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
enum direction dir = ((struct euckr_data *) data->data)->dir;
|
||||||
|
|
||||||
|
do_write = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result = GCONV_OK;
|
||||||
|
|
||||||
|
if (dir == from_euckr)
|
||||||
|
{
|
||||||
|
size_t inchars = *inbufsize;
|
||||||
|
size_t outwchars = data->outbufavail;
|
||||||
|
char *outbuf = data->outbuf;
|
||||||
|
size_t cnt = 0;
|
||||||
|
|
||||||
|
while (cnt < inchars
|
||||||
|
&& (outwchars + sizeof (wchar_t) <= data->outbufsize))
|
||||||
|
{
|
||||||
|
int inchar = (unsigned char) inbuf[cnt];
|
||||||
|
wchar_t ch;
|
||||||
|
|
||||||
|
/*
|
||||||
|
half-width Korean Currency WON sign
|
||||||
|
|
||||||
|
if (inchar == 0x5c)
|
||||||
|
ch = 0x20a9;
|
||||||
|
else if (inchar <= 0x7f)
|
||||||
|
ch = (wchar_t) inchar;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (inchar <= 0x7f)
|
||||||
|
ch = (wchar_t) inchar;
|
||||||
|
|
||||||
|
|
||||||
|
/* 0xfe(->0x7e : row 94) and 0xc9(->0x59 : row 41) are user-defined areas */
|
||||||
|
|
||||||
|
else if ( inchar <= 0xa0 || inchar >= 0xfe || inchar == 0xc9)
|
||||||
|
/* This is illegal. */
|
||||||
|
ch = L'\0';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Two-byte character. First test whether the next
|
||||||
|
character is also available. */
|
||||||
|
int inchar2;
|
||||||
|
|
||||||
|
if (cnt + 1 >= inchars)
|
||||||
|
{
|
||||||
|
/* The second character is not available. Store
|
||||||
|
the intermediate result. */
|
||||||
|
result = GCONV_INCOMPLETE_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
inchar2 = (unsigned char) inbuf[++cnt];
|
||||||
|
|
||||||
|
ch = ksc5601_to_ucs4 ((uint16_t) (inchar * 256 + inchar2)
|
||||||
|
& 0x7f7f);
|
||||||
|
if (ch == UNKNOWN_10646_CHAR)
|
||||||
|
ch = L'\0';
|
||||||
|
|
||||||
|
if (ch == L'\0')
|
||||||
|
--cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == L'\0' && inbuf[cnt] != '\0')
|
||||||
|
{
|
||||||
|
/* This is an illegal character. */
|
||||||
|
result = GCONV_ILLEGAL_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*((wchar_t *) (outbuf + outwchars)) = ch;
|
||||||
|
++do_write;
|
||||||
|
outwchars += sizeof (wchar_t);
|
||||||
|
++cnt;
|
||||||
|
}
|
||||||
|
*inbufsize -= cnt;
|
||||||
|
data->outbufavail = outwchars;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t inwchars = *inbufsize;
|
||||||
|
size_t outchars = data->outbufavail;
|
||||||
|
char *outbuf = data->outbuf;
|
||||||
|
size_t cnt = 0;
|
||||||
|
int extra = 0;
|
||||||
|
|
||||||
|
while (inwchars >= cnt + sizeof (wchar_t)
|
||||||
|
&& outchars < data->outbufsize)
|
||||||
|
{
|
||||||
|
wchar_t ch = *((wchar_t *) (inbuf + cnt));
|
||||||
|
unsigned char cp[2];
|
||||||
|
|
||||||
|
/* decomposing Hangul syllables not available in KS C 5601 into Jamos
|
||||||
|
should be considered either here or in euckr_from_ucs4() */
|
||||||
|
|
||||||
|
euckr_from_ucs4(ch,cp) ;
|
||||||
|
|
||||||
|
if (cp[0] == '\0' && ch != 0)
|
||||||
|
/* Illegal character. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
outbuf[outchars] = cp[0];
|
||||||
|
/* Now test for a possible second byte and write this
|
||||||
|
if possible. */
|
||||||
|
if (cp[1] != '\0')
|
||||||
|
{
|
||||||
|
if (outchars + 1 >= data->outbufsize)
|
||||||
|
{
|
||||||
|
/* The result does not fit into the buffer. */
|
||||||
|
extra = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
outbuf[++outchars] = cp[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
++do_write;
|
||||||
|
++outchars;
|
||||||
|
cnt += sizeof (wchar_t);
|
||||||
|
}
|
||||||
|
*inbufsize -= cnt;
|
||||||
|
data->outbufavail = outchars;
|
||||||
|
|
||||||
|
if (outchars + extra < data->outbufsize)
|
||||||
|
{
|
||||||
|
/* If there is still room in the output buffer something
|
||||||
|
is wrong with the input. */
|
||||||
|
if (inwchars >= cnt + sizeof (wchar_t))
|
||||||
|
{
|
||||||
|
/* An error occurred. */
|
||||||
|
result = GCONV_ILLEGAL_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (inwchars != cnt)
|
||||||
|
{
|
||||||
|
/* There are some unprocessed bytes at the end of the
|
||||||
|
input buffer. */
|
||||||
|
result = GCONV_INCOMPLETE_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != GCONV_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (data->is_last)
|
||||||
|
{
|
||||||
|
/* This is the last step. */
|
||||||
|
result = (*inbufsize > (dir == from_euckr
|
||||||
|
? 0 : sizeof (wchar_t) - 1)
|
||||||
|
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status so far. */
|
||||||
|
result = GCONV_EMPTY_INPUT;
|
||||||
|
|
||||||
|
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 && newavail > 0)
|
||||||
|
{
|
||||||
|
memmove (data->outbuf,
|
||||||
|
&data->outbuf[data->outbufavail - newavail],
|
||||||
|
newavail);
|
||||||
|
data->outbufavail = newavail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (*inbufsize > 0 && result == GCONV_EMPTY_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (written != NULL && data->is_last)
|
||||||
|
*written = do_write;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
# GNU libc iconv configuration.
|
# GNU libc iconv configuration.
|
||||||
# Copyright (C) 1997 Free Software Foundation, Inc.
|
# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
#
|
#
|
||||||
|
@ -145,9 +145,9 @@ module ISO_6937// ISO-10646/UCS4/ ISO_6937 1
|
||||||
module ISO-10646/UCS4/ ISO_6937// ISO_6937 1
|
module ISO-10646/UCS4/ ISO_6937// ISO_6937 1
|
||||||
|
|
||||||
# from to module cost
|
# from to module cost
|
||||||
alias SHIFT-JIS// SJIS
|
alias SHIFT-JIS// SJIS//
|
||||||
module SJIS// ISO-10646/UCS4/ SJIS 1
|
module SJIS// ISO-10646/UCS4/ SJIS 1
|
||||||
module ISO-10646/UCS4/ SJIS SJIS 1
|
module ISO-10646/UCS4/ SJIS// SJIS 1
|
||||||
|
|
||||||
# from to module cost
|
# from to module cost
|
||||||
module KOI-8// ISO-10646/UCS4/ KOI-8 1
|
module KOI-8// ISO-10646/UCS4/ KOI-8 1
|
||||||
|
@ -184,3 +184,18 @@ module ISO-10646/UCS4/ EBCDIC-AT-DE-A// EBCDIC-AT-DE-A 1
|
||||||
# from to module cost
|
# from to module cost
|
||||||
module EBCDIC-CA-FR// ISO-10646/UCS4/ EBCDIC-CA-FR 1
|
module EBCDIC-CA-FR// ISO-10646/UCS4/ EBCDIC-CA-FR 1
|
||||||
module ISO-10646/UCS4/ EBCDIC-CA-FR// EBCDIC-CA-FR 1
|
module ISO-10646/UCS4/ EBCDIC-CA-FR// EBCDIC-CA-FR 1
|
||||||
|
|
||||||
|
# from to module cost
|
||||||
|
alias EUCKR// EUC-KR//
|
||||||
|
module EUC-KR// ISO-10646/UCS4/ EUC-KR 1
|
||||||
|
module ISO-10646/UCS4/ EUC-KR// EUC-KR 1
|
||||||
|
|
||||||
|
# from to module cost
|
||||||
|
alias MSCP949// UHC//
|
||||||
|
module UHC// ISO-10646/UCS4/ UHC 1
|
||||||
|
module ISO-10646/UCS4/ UHC// UHC 1
|
||||||
|
|
||||||
|
# from to module cost
|
||||||
|
alias MSCP1361// JOHAB//
|
||||||
|
module JOHAB// ISO-10646/UCS4/ JOHAB 1
|
||||||
|
module ISO-10646/UCS4/ JOHAB// JOHAB 1
|
||||||
|
|
|
@ -0,0 +1,554 @@
|
||||||
|
/* Mapping tables for JOHAB handling.
|
||||||
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>, 1998.
|
||||||
|
|
||||||
|
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 <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <ksc5601.h>
|
||||||
|
|
||||||
|
/* Direction of the transformation. */
|
||||||
|
enum direction
|
||||||
|
{
|
||||||
|
illegal,
|
||||||
|
to_johab,
|
||||||
|
from_johab
|
||||||
|
};
|
||||||
|
|
||||||
|
struct johab_data
|
||||||
|
{
|
||||||
|
enum direction dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The table for Bit pattern to Hangul Jamo
|
||||||
|
5 bits each are used to encode
|
||||||
|
leading consonants(19 + 1 filler), medial vowels(21 + 1 filler)
|
||||||
|
and trailing consonants(27 + 1 filler).
|
||||||
|
|
||||||
|
KS C 5601-1992 Annex 3 Table 2
|
||||||
|
0 : Filler, -1: invalid, >= 1 : valid
|
||||||
|
|
||||||
|
*/
|
||||||
|
const int init[32] =
|
||||||
|
{
|
||||||
|
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
|
||||||
|
19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||||
|
};
|
||||||
|
const int mid[32] =
|
||||||
|
{
|
||||||
|
-1, -1, 0, 1, 2, 3, 4, 5,
|
||||||
|
-1, -1, 6, 7, 8, 9, 10, 11,
|
||||||
|
-1, -1, 12, 13, 14, 15, 16, 17,
|
||||||
|
-1, -1, 18, 19, 20, 21, -1, -1
|
||||||
|
};
|
||||||
|
const int final[32] =
|
||||||
|
{
|
||||||
|
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||||
|
-1, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hangul Jamo in Johab to Unicode 2.0 : Unicode 2.0
|
||||||
|
defines 51 Hangul Compatibility Jamos in the block [0x3131,0x314e]
|
||||||
|
|
||||||
|
It's to be considered later which Jamo block to use, Compatibility
|
||||||
|
block [0x3131,0x314e] or Hangul Conjoining Jamo block, [0x1100,0x11ff]
|
||||||
|
|
||||||
|
*/
|
||||||
|
const wchar_t init_to_ucs[19] =
|
||||||
|
{
|
||||||
|
0x3131, 0x3132, 0x3134, 0x3137, 0x3138, 0x3139, 0x3141, 0x3142,
|
||||||
|
0x3143, 0x3145, 0x3146, 0x3147, 0x3148, 0x3149, 0x314a, 0x314b,
|
||||||
|
0x314c, 0x314d, 0x314e
|
||||||
|
};
|
||||||
|
|
||||||
|
const wchar_t final_to_ucs[27] =
|
||||||
|
{
|
||||||
|
L'\0', L'\0', 0x3133, L'\0', 0x3135, 0x3136, L'\0', L'\0',
|
||||||
|
0x313a, 0x313b, 0x314c, 0x313d, 0x313e, 0x313f,
|
||||||
|
0x3140, L'\0', L'\0', 0x3144, L'\0', L'\0', L'\0',
|
||||||
|
L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The following three arrays are used to convert
|
||||||
|
precomposed Hangul syllables in [0xac00,0xd???]
|
||||||
|
to Jamo bit patterns for Johab encoding
|
||||||
|
|
||||||
|
cf. : KS C 5601-1992, Annex3 Table 2
|
||||||
|
|
||||||
|
Arrays are used to speed up things although it's possible
|
||||||
|
to get the same result arithmetically.
|
||||||
|
|
||||||
|
*/
|
||||||
|
const int init_to_bit[19] =
|
||||||
|
{
|
||||||
|
0x8800, 0x8c00, 0x9000, 0x9400, 0x9800, 0x9c00,
|
||||||
|
0xa000, 0xa400, 0xa800, 0xac00, 0xb000, 0xb400,
|
||||||
|
0xb800, 0xbc00, 0xc000, 0xc400, 0xc800, 0xcc00,
|
||||||
|
0xd000
|
||||||
|
};
|
||||||
|
|
||||||
|
const int mid_to_bit[21] =
|
||||||
|
{
|
||||||
|
0x0060, 0x0080, 0x00a0, 0x00c0, 0x00e0,
|
||||||
|
0x0140, 0x0160, 0x0180, 0x01a0, 0x01c0, 0x1e0,
|
||||||
|
0x0240, 0x0260, 0x0280, 0x02a0, 0x02c0, 0x02e0,
|
||||||
|
0x0340, 0x0360, 0x0380, 0x03a0
|
||||||
|
};
|
||||||
|
|
||||||
|
const int final_to_bit[28] =
|
||||||
|
{
|
||||||
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
|
||||||
|
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The conversion table from
|
||||||
|
UCS4 Hangul Compatibility Jamo in [0x3131,0x3163]
|
||||||
|
to Johab
|
||||||
|
|
||||||
|
cf. 1. KS C 5601-1992 Annex 3 Table 2
|
||||||
|
2. Unicode 2.0 manual
|
||||||
|
|
||||||
|
*/
|
||||||
|
const uint16_t jamo_from_ucs_table[51] =
|
||||||
|
{
|
||||||
|
0x8841, 0x8c41,
|
||||||
|
0x8444,
|
||||||
|
0x9041,
|
||||||
|
0x8446, 0x8447,
|
||||||
|
0x9441, 0x9841, 0x9c41,
|
||||||
|
0x844a, 0x844b, 0x844c, 0x844d, 0x884e, 0x884f, 0x8450,
|
||||||
|
0xa041, 0xa441, 0xa841,
|
||||||
|
0x8454,
|
||||||
|
0xac41, 0xb041, 0xb441, 0xb841, 0xbc41,
|
||||||
|
0xc041, 0xc441, 0xc841, 0xca41, 0xd041,
|
||||||
|
0x8461, 0x8481, 0x84a1, 0x84c1, 0x84e1,
|
||||||
|
0x8541, 0x8561, 0x8581, 0x85a1, 0x85c1, 0x85e1,
|
||||||
|
0x8641, 0x8661, 0x8681, 0x86a1, 0x86c1, 0x86e1,
|
||||||
|
0x8741, 0x8761, 0x8781, 0x87a1
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static inline wchar_t
|
||||||
|
johab_sym_hanja_to_ucs (int idx, int c1, int c2)
|
||||||
|
{
|
||||||
|
if (idx <= 0xdefe)
|
||||||
|
return (wchar_t) ksc5601_sym_to_ucs[(c1 - 0xd9) * 188 + c2
|
||||||
|
- (c2 > 0x90 ? 0x43 : 0x31)];
|
||||||
|
else
|
||||||
|
return (wchar_t) ksc5601_hanja_to_ucs[(c1 - 0xe0) * 188 + c2
|
||||||
|
- (c2 > 0x90 ? 0x43 : 0x31)];
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t
|
||||||
|
johab_hanja_from_ucs (wchar_t ch)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint16_t idx;
|
||||||
|
if (ucs4_to_ksc5601_hanja (ch, &idx))
|
||||||
|
{
|
||||||
|
int idx1, idx2;
|
||||||
|
/* Hanja begins at the 42th row. 42=0x2a : 0x2a + 0x20 = 0x4a. */
|
||||||
|
idx1 = idx / 256 - 0x4a;
|
||||||
|
idx2 = idx % 256 + 0x80;
|
||||||
|
|
||||||
|
return ((idx1 / 2) * 256 + 0xe000 + idx2
|
||||||
|
+ (idx1 % 2 ? 0 : (idx2 > 0xee ? 0x43 : 0x31) - 0xa1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t
|
||||||
|
johab_sym_from_ucs (wchar_t ch)
|
||||||
|
{
|
||||||
|
uint16_t idx;
|
||||||
|
if (ucs4_to_ksc5601_sym (ch, &idx))
|
||||||
|
{
|
||||||
|
int idx1, idx2;
|
||||||
|
|
||||||
|
idx1 = idx / 256 - 0x21;
|
||||||
|
idx2 = idx % 256 + 0x80;
|
||||||
|
|
||||||
|
return ((idx1 / 2) * 256 + 0xd900 + idx2
|
||||||
|
+ (idx1 % 2 ? 0 : (idx2 > 0xee ? 0x43 : 0x31) - 0xa1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
johab_from_ucs4 (wchar_t ch, unsigned char *cp)
|
||||||
|
{
|
||||||
|
if (ch >= 0x7f)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if (ch >= 0xac00 && ch <= 0xd7a3)
|
||||||
|
{
|
||||||
|
ch -= 0xac00;
|
||||||
|
idx = init_to_bit[ch / 588]; /* 21*28 = 588 */
|
||||||
|
idx += mid_to_bit[(ch / 28) % 21]; /* (ch % (21 * 28)) / 28 */
|
||||||
|
idx += final_to_bit[ch % 28]; /* (ch % (21 * 28)) % 28 */
|
||||||
|
}
|
||||||
|
/* KS C 5601-1992 Annex 3 regards 0xA4DA(Hangul Filler : U3164)
|
||||||
|
as symbol */
|
||||||
|
else if (ch >= 0x3131 && ch <= 0x3163)
|
||||||
|
idx = jamo_from_ucs_table[ch - 0x3131];
|
||||||
|
else if (ch >= 0x4e00 && ch <= 0x9fa5
|
||||||
|
|| ch >= 0xf900 && ch <= 0xfa0b)
|
||||||
|
idx = johab_hanja_from_ucs (ch);
|
||||||
|
/* Half-width Korean Currency Won Sign
|
||||||
|
else if ( ch == 0x20a9 )
|
||||||
|
idx = 0x5c00;
|
||||||
|
*/
|
||||||
|
else
|
||||||
|
idx = johab_sym_from_ucs (ch);
|
||||||
|
|
||||||
|
*cp = (char) (idx / 256);
|
||||||
|
*(cp + 1) = (char) (idx & 0xff);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*cp = (char) (0x7f & ch);
|
||||||
|
*(cp + 1) = (char) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
gconv_init (struct gconv_step *step, struct gconv_step_data *data)
|
||||||
|
{
|
||||||
|
/* Determine which direction. */
|
||||||
|
struct johab_data *new_data;
|
||||||
|
enum direction dir;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (strcasestr (step->from_name, "JOHAB") != NULL)
|
||||||
|
dir = from_johab;
|
||||||
|
else if (strcasestr (step->to_name, "JOHAB") != NULL)
|
||||||
|
dir = to_johab;
|
||||||
|
else
|
||||||
|
dir = illegal;
|
||||||
|
|
||||||
|
result = GCONV_NOCONV;
|
||||||
|
if (dir != illegal
|
||||||
|
&& ((new_data
|
||||||
|
= (struct johab_data *) malloc (sizeof (struct johab_data)))
|
||||||
|
!= NULL))
|
||||||
|
{
|
||||||
|
new_data->dir = dir;
|
||||||
|
data->data = new_data;
|
||||||
|
result = GCONV_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gconv_end (struct gconv_step_data *data)
|
||||||
|
{
|
||||||
|
free (data->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
gconv (struct gconv_step *step, struct gconv_step_data *data,
|
||||||
|
const char *inbuf, size_t *inbufsize, 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)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
enum direction dir = ((struct johab_data *) data->data)->dir;
|
||||||
|
|
||||||
|
do_write = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result = GCONV_OK;
|
||||||
|
|
||||||
|
if (dir == from_johab)
|
||||||
|
{
|
||||||
|
size_t inchars = *inbufsize;
|
||||||
|
size_t outwchars = data->outbufavail;
|
||||||
|
char *outbuf = data->outbuf;
|
||||||
|
size_t cnt = 0;
|
||||||
|
|
||||||
|
while (cnt < inchars
|
||||||
|
&& (outwchars + sizeof (wchar_t) <= data->outbufsize))
|
||||||
|
{
|
||||||
|
int inchar = (unsigned char) inbuf[cnt];
|
||||||
|
wchar_t ch;
|
||||||
|
/* half-width Korean Currency WON sign
|
||||||
|
if (inchar == 0x5c)
|
||||||
|
ch = 0x20a9;
|
||||||
|
else if (inchar < 0x7f)
|
||||||
|
ch = (wchar_t) inchar;
|
||||||
|
*/
|
||||||
|
if (inchar < 0x7f)
|
||||||
|
ch = (wchar_t) inchar;
|
||||||
|
|
||||||
|
/* Johab : 1. Hangul
|
||||||
|
1st byte : 0x84-0xd3
|
||||||
|
2nd byte : 0x41-0x7e, 0x81-0xfe
|
||||||
|
2. Hanja & Symbol :
|
||||||
|
1st byte : 0xd8-0xde, 0xe0-0xf9
|
||||||
|
2nd byte : 0x31-0x7e, 0x91-0xfe
|
||||||
|
0xd831-0xd87e and 0xd891-0xd8fe are user-defined area */
|
||||||
|
|
||||||
|
else if (inchar > 0xf9 || inchar == 0xdf
|
||||||
|
|| (inchar > 0x7e && inchar < 0x84)
|
||||||
|
|| (inchar > 0xd3 && inchar < 0xd9))
|
||||||
|
/* These are illegal. */
|
||||||
|
ch = L'\0';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Two-byte character. First test whether the next
|
||||||
|
character is also available. */
|
||||||
|
int inchar2;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if (cnt + 1 >= inchars)
|
||||||
|
{
|
||||||
|
/* The second character is not available. Store
|
||||||
|
the intermediate result. */
|
||||||
|
result = GCONV_INCOMPLETE_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
inchar2 = (unsigned char) inbuf[++cnt];
|
||||||
|
idx = inchar * 256 + inchar2;
|
||||||
|
if (inchar <= 0xd3)
|
||||||
|
{ /* Hangul */
|
||||||
|
int i, m, f;
|
||||||
|
i = init[(idx & 0x7c00) >> 10];
|
||||||
|
m = mid[(idx & 0x03e0) >> 5];
|
||||||
|
f = final[idx & 0x001f];
|
||||||
|
if (i == -1 || m == -1 || f == -1)
|
||||||
|
/* This is illegal. */
|
||||||
|
ch = L'\0';
|
||||||
|
else if (i > 0 && m > 0)
|
||||||
|
ch = ((i - 1) * 21 + (m - 1)) * 28 + f + 0xac00;
|
||||||
|
else if (i > 0 && m == 0 & f == 0)
|
||||||
|
ch = init_to_ucs[i - 1];
|
||||||
|
else if (i == 0 && m > 0 & f == 0)
|
||||||
|
ch = 0x314e + m; /* 0x314f + m - 1 */
|
||||||
|
else if (i == 0 && m == 0 & f > 0)
|
||||||
|
ch = final_to_ucs[f - 1]; /* round trip?? */
|
||||||
|
else
|
||||||
|
/* This is illegal. */
|
||||||
|
ch = L'\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (inchar2 < 0x31
|
||||||
|
|| (inchar2 > 0x7e && inchar2 < 0x91)
|
||||||
|
|| inchar2 == 0xff)
|
||||||
|
/* This is illegal. */
|
||||||
|
ch = L'\0';
|
||||||
|
else if (inchar == 0xda
|
||||||
|
&& inchar2 > 0xa0 && inchar2 < 0xd4)
|
||||||
|
/* This is illegal. */
|
||||||
|
/* Modern Hangul Jaso is defined elsewhere
|
||||||
|
in Johab */
|
||||||
|
ch = L'\0';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch = johab_sym_hanja_to_ucs (idx, inchar,
|
||||||
|
inchar2);
|
||||||
|
/* if (idx <= 0xdefe)
|
||||||
|
ch = ksc5601_sym_to_ucs[(inchar - 0xd9) * 192
|
||||||
|
+ inchar2
|
||||||
|
- (inchar2>0x90 ? 0x43 : 0x31)];
|
||||||
|
|
||||||
|
else
|
||||||
|
ch = ksc5601_hanja_to_ucs[(inchar - 0xe0) *192
|
||||||
|
+ inchar2
|
||||||
|
- (inchar2>0x90 ? 0x43 : 0x31)];
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == L'\0')
|
||||||
|
--cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == L'\0' && inbuf[cnt] != '\0')
|
||||||
|
{
|
||||||
|
/* This is an illegal character. */
|
||||||
|
result = GCONV_ILLEGAL_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*((wchar_t *) (outbuf + outwchars)) = ch;
|
||||||
|
++do_write;
|
||||||
|
outwchars += sizeof (wchar_t);
|
||||||
|
++cnt;
|
||||||
|
}
|
||||||
|
*inbufsize -= cnt;
|
||||||
|
data->outbufavail = outwchars;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t inwchars = *inbufsize;
|
||||||
|
size_t outchars = data->outbufavail;
|
||||||
|
char *outbuf = data->outbuf;
|
||||||
|
size_t cnt = 0;
|
||||||
|
int extra = 0;
|
||||||
|
|
||||||
|
while (inwchars >= cnt + sizeof (wchar_t)
|
||||||
|
&& outchars < data->outbufsize)
|
||||||
|
{
|
||||||
|
wchar_t ch = *((wchar_t *) (inbuf + cnt));
|
||||||
|
unsigned char cp[2];
|
||||||
|
/*
|
||||||
|
if (ch >= (sizeof (from_ucs4_lat1)
|
||||||
|
/ sizeof (from_ucs4_lat1[0])))
|
||||||
|
{
|
||||||
|
if (ch >= 0x0391 && ch <= 0x0451)
|
||||||
|
cp = from_ucs4_greek[ch - 0x391];
|
||||||
|
else if (ch >= 0x2010 && ch <= 0x9fa0)
|
||||||
|
cp = from_ucs4_cjk[ch - 0x02010];
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cp = from_ucs4_lat1[ch];
|
||||||
|
*/
|
||||||
|
johab_from_ucs4 (ch, cp);
|
||||||
|
|
||||||
|
if (cp[0] == '\0' && ch != 0)
|
||||||
|
/* Illegal character. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
outbuf[outchars] = cp[0];
|
||||||
|
/* Now test for a possible second byte and write this
|
||||||
|
if possible. */
|
||||||
|
if (cp[1] != '\0')
|
||||||
|
{
|
||||||
|
if (outchars + 1 >= data->outbufsize)
|
||||||
|
{
|
||||||
|
/* The result does not fit into the buffer. */
|
||||||
|
extra = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
outbuf[++outchars] = cp[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
++do_write;
|
||||||
|
++outchars;
|
||||||
|
cnt += sizeof (wchar_t);
|
||||||
|
}
|
||||||
|
*inbufsize -= cnt;
|
||||||
|
data->outbufavail = outchars;
|
||||||
|
|
||||||
|
if (outchars + extra < data->outbufsize)
|
||||||
|
{
|
||||||
|
/* If there is still room in the output buffer something
|
||||||
|
is wrong with the input. */
|
||||||
|
if (inwchars >= cnt + sizeof (wchar_t))
|
||||||
|
{
|
||||||
|
/* An error occurred. */
|
||||||
|
result = GCONV_ILLEGAL_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (inwchars != cnt)
|
||||||
|
{
|
||||||
|
/* There are some unprocessed bytes at the end of the
|
||||||
|
input buffer. */
|
||||||
|
result = GCONV_INCOMPLETE_INPUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != GCONV_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (data->is_last)
|
||||||
|
{
|
||||||
|
/* This is the last step. */
|
||||||
|
result = (*inbufsize > (dir == from_johab
|
||||||
|
? 0 : sizeof (wchar_t) - 1)
|
||||||
|
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status so far. */
|
||||||
|
result = GCONV_EMPTY_INPUT;
|
||||||
|
|
||||||
|
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 && newavail > 0)
|
||||||
|
{
|
||||||
|
memmove (data->outbuf,
|
||||||
|
&data->outbuf[data->outbufavail - newavail],
|
||||||
|
newavail);
|
||||||
|
data->outbufavail = newavail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (*inbufsize > 0 && result == GCONV_EMPTY_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (written != NULL && data->is_last)
|
||||||
|
*written = do_write;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,161 @@
|
||||||
|
/* Access functions for KS C 5601-1992 based encoding conversion.
|
||||||
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
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 _KSC5601_H
|
||||||
|
#define _KSC5601_H 1
|
||||||
|
|
||||||
|
#define KSC5601_HANGUL 2350
|
||||||
|
#define KSC5601_HANJA 4888
|
||||||
|
#define KSC5601_SYMBOL 986
|
||||||
|
|
||||||
|
#include <gconv.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
/* Conversion table. */
|
||||||
|
extern const uint16_t ksc5601_hangul_to_ucs[KSC5601_HANGUL];
|
||||||
|
extern const uint16_t ksc5601_sym_to_ucs[];
|
||||||
|
extern const uint16_t ksc5601_sym_from_ucs[KSC5601_SYMBOL][2];
|
||||||
|
extern const uint16_t ksc5601_hanja_to_ucs[KSC5601_HANJA];
|
||||||
|
extern const uint16_t ksc5601_hanja_from_ucs[KSC5601_HANJA][2];
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
static inline wchar_t
|
||||||
|
ksc5601_to_ucs4 (char **s, size_t avail)
|
||||||
|
*/
|
||||||
|
static inline wchar_t
|
||||||
|
ksc5601_to_ucs4 (uint16_t s)
|
||||||
|
{
|
||||||
|
unsigned char ch = s / 256;
|
||||||
|
unsigned char ch2;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
/* row 94(0x7e) and row 41(0x49) are user-defined area in KS C 5601 */
|
||||||
|
|
||||||
|
if (ch <= 0x20 || ch >= 0x7e || ch == 0x49)
|
||||||
|
return UNKNOWN_10646_CHAR;
|
||||||
|
|
||||||
|
ch2 = s % 256;
|
||||||
|
if (ch2 <= 0x20 || ch2 >= 0x7f)
|
||||||
|
return UNKNOWN_10646_CHAR;
|
||||||
|
|
||||||
|
idx = (ch - 0x21) * 94 + (ch2 - 0x21);
|
||||||
|
|
||||||
|
/* 1410 = 15 * 94 , 3760 = 40 * 94
|
||||||
|
Hangul in KS C 5601 : row 16 - row 40 */
|
||||||
|
|
||||||
|
if (idx >= 1410 && idx < 3760)
|
||||||
|
return ksc5601_hangul_to_ucs[idx-1410];
|
||||||
|
else if (idx > 3854)
|
||||||
|
/* Hanja : row 42 - row 93 : 3854 = 94 * (42-1) */
|
||||||
|
return ksc5601_hanja_to_ucs[idx-3854];
|
||||||
|
else
|
||||||
|
return ksc5601_sym_to_ucs[idx] ?: UNKNOWN_10646_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t
|
||||||
|
ucs4_to_ksc5601_hangul (wchar_t wch, uint16_t *s)
|
||||||
|
{
|
||||||
|
int l=0,m,u=KSC5601_HANGUL-1;
|
||||||
|
wchar_t try;
|
||||||
|
|
||||||
|
while (l <= u)
|
||||||
|
{
|
||||||
|
try = (wchar_t) ksc5601_hangul_to_ucs[m=(l+u)/2];
|
||||||
|
if (try > wch)
|
||||||
|
u = m - 1;
|
||||||
|
else if (try < wch)
|
||||||
|
l= m + 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*s = (uint16_t) ((m / 94) * 256 + m % 94 + 0x3021) ;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline size_t
|
||||||
|
ucs4_to_ksc5601_hanja (wchar_t wch, uint16_t *s)
|
||||||
|
{
|
||||||
|
int l=0,m,u=KSC5601_HANJA-1;
|
||||||
|
wchar_t try;
|
||||||
|
|
||||||
|
while (l <= u)
|
||||||
|
{
|
||||||
|
try = (wchar_t) ksc5601_hanja_from_ucs[m=(l+u)/2][0];
|
||||||
|
if (try > wch)
|
||||||
|
u=m-1;
|
||||||
|
else if (try < wch)
|
||||||
|
l = m + 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*s = ksc5601_hanja_from_ucs[m][1];
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t
|
||||||
|
ucs4_to_ksc5601_sym (wchar_t wch, uint16_t *s)
|
||||||
|
{
|
||||||
|
int l = 0;
|
||||||
|
int m;
|
||||||
|
int u = KSC5601_SYMBOL - 1;
|
||||||
|
wchar_t try;
|
||||||
|
|
||||||
|
while (l <= u)
|
||||||
|
{
|
||||||
|
m = (l + u) / 2;
|
||||||
|
try = ksc5601_sym_from_ucs[m][0];
|
||||||
|
if (try > wch)
|
||||||
|
u = m - 1;
|
||||||
|
else if (try < wch)
|
||||||
|
l = m + 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*s = ksc5601_sym_from_ucs[m][1];
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
static inline size_t
|
||||||
|
ucs4_to_ksc5601 (wchar_t wch, char **s, size_t avail)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline size_t
|
||||||
|
ucs4_to_ksc5601 (wchar_t ch, uint16_t *s)
|
||||||
|
{
|
||||||
|
*s = (uint16_t) UNKNOWN_10646_CHAR; /* FIXIT */
|
||||||
|
|
||||||
|
if (ch >= 0xac00 && ch <= 0xd7a3)
|
||||||
|
return ucs4_to_ksc5601_hangul (ch, s);
|
||||||
|
else if (ch >= 0x4e00 && ch <= 0x9fff || ch >= 0xf900 && ch <= 0xfa0b)
|
||||||
|
return ucs4_to_ksc5601_hanja (ch, s);
|
||||||
|
else
|
||||||
|
return ucs4_to_ksc5601_sym (ch, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ksc5601.h */
|
File diff suppressed because it is too large
Load Diff
1
libc.map
1
libc.map
|
@ -71,6 +71,7 @@ GLIBC_2.0 {
|
||||||
|
|
||||||
# functions used in other libraries
|
# functions used in other libraries
|
||||||
__printf_fp; __stpncpy; __stpcpy; __strdup; __mempcpy;
|
__printf_fp; __stpncpy; __stpcpy; __strdup; __mempcpy;
|
||||||
|
__nss_passwd_lookup; __nss_group_lookup; __nss_next;
|
||||||
_nss_files_parse_grent; _nss_files_parse_pwent; _nss_files_parse_spent;
|
_nss_files_parse_grent; _nss_files_parse_pwent; _nss_files_parse_spent;
|
||||||
__nss_database_lookup; __internal_endnetgrent; __internal_getnetgrent_r;
|
__nss_database_lookup; __internal_endnetgrent; __internal_getnetgrent_r;
|
||||||
__internal_setnetgrent; __gmtime_r; __secure_getenv;
|
__internal_setnetgrent; __gmtime_r; __secure_getenv;
|
||||||
|
|
|
@ -77,8 +77,8 @@ distribute += $(long-c-yes:=.c)
|
||||||
|
|
||||||
# Rules for the test suite.
|
# Rules for the test suite.
|
||||||
tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
|
tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
|
||||||
test-ifloat test-idouble test-matherr test-fenv \
|
test-ifloat test-idouble test-matherr test-fenv
|
||||||
atest-exp atest-sincos atest-exp2
|
tests-static = atest-exp atest-sincos atest-exp2
|
||||||
# We do the `long double' tests only if this data type is available and
|
# We do the `long double' tests only if this data type is available and
|
||||||
# distinct from `double'.
|
# distinct from `double'.
|
||||||
test-longdouble-yes = test-ldouble test-ildoubl
|
test-longdouble-yes = test-ldouble test-ildoubl
|
||||||
|
|
14
misc/error.c
14
misc/error.c
|
@ -1,5 +1,5 @@
|
||||||
/* Error handler for noninteractive utilities
|
/* Error handler for noninteractive utilities
|
||||||
Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc.
|
Copyright (C) 1990,91,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
This file is part of the GNU C Library. Its master source is NOT part of
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
the C library, however. The master source lives in /gd/gnu/lib.
|
||||||
|
@ -76,13 +76,15 @@ unsigned int error_message_count;
|
||||||
# define error __error
|
# define error __error
|
||||||
# define error_at_line __error_at_line
|
# define error_at_line __error_at_line
|
||||||
|
|
||||||
#else
|
#else /* not _LIBC */
|
||||||
|
|
||||||
/* The calling program should define program_name and set it to the
|
/* The calling program should define program_name and set it to the
|
||||||
name of the executing program. */
|
name of the executing program. */
|
||||||
extern char *program_name;
|
extern char *program_name;
|
||||||
|
|
||||||
#ifndef HAVE_STRERROR_R
|
# ifdef HAVE_STRERROR_R
|
||||||
|
# define __strerror_r strerror_r
|
||||||
|
# else
|
||||||
# if HAVE_STRERROR
|
# if HAVE_STRERROR
|
||||||
# ifndef strerror /* On some systems, strerror is a macro */
|
# ifndef strerror /* On some systems, strerror is a macro */
|
||||||
char *strerror ();
|
char *strerror ();
|
||||||
|
@ -102,7 +104,7 @@ private_strerror (errnum)
|
||||||
# define strerror private_strerror
|
# define strerror private_strerror
|
||||||
# endif /* HAVE_STRERROR */
|
# endif /* HAVE_STRERROR */
|
||||||
# endif /* HAVE_STRERROR_R */
|
# endif /* HAVE_STRERROR_R */
|
||||||
#endif /* _LIBC */
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||||
format string with optional args.
|
format string with optional args.
|
||||||
|
@ -111,7 +113,7 @@ private_strerror (errnum)
|
||||||
/* VARARGS */
|
/* VARARGS */
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined(VA_START) && __STDC__
|
#if defined VA_START && __STDC__
|
||||||
error (int status, int errnum, const char *message, ...)
|
error (int status, int errnum, const char *message, ...)
|
||||||
#else
|
#else
|
||||||
error (status, errnum, message, va_alist)
|
error (status, errnum, message, va_alist)
|
||||||
|
@ -166,7 +168,7 @@ error (status, errnum, message, va_alist)
|
||||||
int error_one_per_line;
|
int error_one_per_line;
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined(VA_START) && __STDC__
|
#if defined VA_START && __STDC__
|
||||||
error_at_line (int status, int errnum, const char *file_name,
|
error_at_line (int status, int errnum, const char *file_name,
|
||||||
unsigned int line_number, const char *message, ...)
|
unsigned int line_number, const char *message, ...)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -51,27 +51,28 @@ __getmode (const char *mode, __io_mode *mptr)
|
||||||
badmode ();
|
badmode ();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < 3; ++i)
|
for (i = 1; i < 4; ++i)
|
||||||
{
|
{
|
||||||
++mode;
|
switch (*++mode)
|
||||||
if (*mode == '\0')
|
{
|
||||||
|
case '\0':
|
||||||
break;
|
break;
|
||||||
switch (*mode)
|
|
||||||
{
|
|
||||||
case '+':
|
case '+':
|
||||||
mptr->__read = mptr->__write = 1;
|
mptr->__read = mptr->__write = 1;
|
||||||
break;
|
continue;
|
||||||
case 'b':
|
case 'b':
|
||||||
mptr->__binary = 1;
|
mptr->__binary = 1;
|
||||||
break;
|
continue;
|
||||||
|
case 'x':
|
||||||
|
mptr->__exclusive = 1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mptr->__read && !mptr->__write)
|
if (!mptr->__read && !mptr->__write)
|
||||||
badmode ();
|
badmode ();
|
||||||
|
|
||||||
mptr->__exclusive = *mode == 'x';
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* Mountain View, California 94043
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@
|
||||||
* 2550 Garcia Avenue
|
* 2550 Garcia Avenue
|
||||||
* Mountain View, California 94043
|
* Mountain View, California 94043
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
||||||
|
#endif
|
||||||
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -43,7 +43,9 @@
|
||||||
* requirements.
|
* requirements.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
%#if 0
|
||||||
%#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
%#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
|
||||||
|
%#endif
|
||||||
%
|
%
|
||||||
%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
|
||||||
%
|
%
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memcpy_c (void *__dest, __const void *__src, size_t __n)
|
__memcpy_c (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
switch (__n)
|
switch (__n)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -138,7 +138,7 @@ __memcpy_c (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
memmove (void *__dest, __const void *__src, size_t __n)
|
memmove (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
if (__dest < __src)
|
if (__dest < __src)
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -173,7 +173,7 @@ memmove (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_cc (void *__s, unsigned long int __pattern, size_t __n)
|
__memset_cc (void *__s, unsigned long int __pattern, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1;
|
register unsigned long int __d0, __d1;
|
||||||
switch (__n)
|
switch (__n)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -222,7 +222,7 @@ __memset_cc (void *__s, unsigned long int __pattern, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_cg (void *__s, unsigned long __c, size_t __n)
|
__memset_cg (void *__s, unsigned long __c, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1;
|
register unsigned long int __d0, __d1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"rep; stosl\n\t"
|
"rep; stosl\n\t"
|
||||||
|
@ -243,7 +243,7 @@ __memset_cg (void *__s, unsigned long __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_gg (void *__s, char __c, size_t __n)
|
__memset_gg (void *__s, char __c, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1;
|
register unsigned long int __d0, __d1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"rep; stosb"
|
"rep; stosb"
|
||||||
|
@ -261,14 +261,13 @@ __memset_gg (void *__s, char __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
memchr (__const void *__s, int __c, size_t __n)
|
memchr (__const void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0;
|
register unsigned long int __d0;
|
||||||
register void *__res;
|
register void *__res;
|
||||||
if (count == 0)
|
if (__n == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"repne\n\t"
|
"repne; scasb\n\t"
|
||||||
"scasb\n\t"
|
|
||||||
"je 1f\n\t"
|
"je 1f\n\t"
|
||||||
"movl $1,%0\n"
|
"movl $1,%0\n"
|
||||||
"1:"
|
"1:"
|
||||||
|
@ -283,7 +282,7 @@ memchr (__const void *__s, int __c, size_t __n)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
strlen (__const char *__str)
|
strlen (__const char *__str)
|
||||||
{
|
{
|
||||||
unsigned long int __d0;
|
register unsigned long int __d0;
|
||||||
register size_t __res;
|
register size_t __res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -301,7 +300,7 @@ strlen (__const char *__str)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strcpy (char *__dest, __const char *__src)
|
strcpy (char *__dest, __const char *__src)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1;
|
register unsigned long int __d0, __d1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
|
@ -321,7 +320,7 @@ strcpy (char *__dest, __const char *__src)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strncpy (char *__dest, __const char *__src, size_t __n)
|
strncpy (char *__dest, __const char *__src, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
|
@ -345,7 +344,7 @@ strncpy (char *__dest, __const char *__src, size_t __n)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strcat (char *__dest, __const char *__src)
|
strcat (char *__dest, __const char *__src)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
|
@ -367,7 +366,7 @@ strcat (char *__dest, __const char *__src)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strncat (char *__dest, __const char *__src, size_t __n)
|
strncat (char *__dest, __const char *__src, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
|
@ -395,7 +394,7 @@ strncat (char *__dest, __const char *__src, size_t __n)
|
||||||
__STRING_INLINE int
|
__STRING_INLINE int
|
||||||
strcmp (__const char *__s1, __const char *__s2)
|
strcmp (__const char *__s1, __const char *__s2)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1;
|
register unsigned long int __d0, __d1;
|
||||||
register int __res;
|
register int __res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -423,7 +422,7 @@ strcmp (__const char *__s1, __const char *__s2)
|
||||||
__STRING_INLINE int
|
__STRING_INLINE int
|
||||||
strncmp (__const char *__s1, __const char *__s2, size_t __n)
|
strncmp (__const char *__s1, __const char *__s2, size_t __n)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register int __res;
|
register int __res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -459,7 +458,7 @@ strncmp (__const char *__s1, __const char *__s2, size_t __n)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strchr_g (__const char *__s, int __c)
|
__strchr_g (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
unsigned long int __d0;
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -482,7 +481,7 @@ __strchr_g (__const char *__s, int __c)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strchr_c (__const char *__s, int __c)
|
__strchr_c (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
unsigned long int __d0;
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -509,7 +508,7 @@ __strchr_c (__const char *__s, int __c)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
strcspn (__const char *__s, __const char *__reject)
|
strcspn (__const char *__s, __const char *__reject)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("pushl %%ebx\n\t"
|
("pushl %%ebx\n\t"
|
||||||
|
@ -538,7 +537,7 @@ strcspn (__const char *__s, __const char *__reject)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
strcspn (__const char *__s, __const char *__reject)
|
strcspn (__const char *__s, __const char *__reject)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -571,7 +570,7 @@ strcspn (__const char *__s, __const char *__reject)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
strspn (__const char *__s, __const char *__accept)
|
strspn (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2;
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("pushl %%ebx\n\t"
|
("pushl %%ebx\n\t"
|
||||||
|
@ -600,7 +599,7 @@ strspn (__const char *__s, __const char *__accept)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
strspn (__const char *__s, __const char *__accept)
|
strspn (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -665,7 +664,7 @@ strpbrk (__const char *__s, __const char *__accept)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strpbrk (__const char *__s, __const char *__accept)
|
strpbrk (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -701,7 +700,7 @@ strpbrk (__const char *__s, __const char *__accept)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strstr (__const char *__haystack, __const char *__needle)
|
strstr (__const char *__haystack, __const char *__needle)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("pushl %%ebx\n\t"
|
("pushl %%ebx\n\t"
|
||||||
|
@ -733,7 +732,7 @@ strstr (__const char *__haystack, __const char *__needle)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
strstr (__const char *__haystack, __const char *__needle)
|
strstr (__const char *__haystack, __const char *__needle)
|
||||||
{
|
{
|
||||||
unsigned long int __d0, __d1, __d2, __d3;
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t" \
|
("cld\n\t" \
|
||||||
|
|
|
@ -62,8 +62,8 @@
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memcpy_by4 (void *__dest, __const void *__src, size_t __n)
|
__memcpy_by4 (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register void *__tmp = __dest;
|
register void *__tmp = __dest;
|
||||||
register int __dummy1, __dummy2;
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
"movl (%2),%0\n\t"
|
"movl (%2),%0\n\t"
|
||||||
|
@ -72,7 +72,7 @@ __memcpy_by4 (void *__dest, __const void *__src, size_t __n)
|
||||||
"leal 4(%1),%1\n\t"
|
"leal 4(%1),%1\n\t"
|
||||||
"decl %3\n\t"
|
"decl %3\n\t"
|
||||||
"jnz 1b"
|
"jnz 1b"
|
||||||
: "=r" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&r" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__n / 4)
|
: "1" (__tmp), "2" (__src), "3" (__n / 4)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
|
@ -81,8 +81,8 @@ __memcpy_by4 (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memcpy_by2 (void *__dest, __const void *__src, size_t __n)
|
__memcpy_by2 (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register void *__tmp = __dest;
|
register void *__tmp = __dest;
|
||||||
register int __dummy1, __dummy2;
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("shrl $1,%3\n\t"
|
("shrl $1,%3\n\t"
|
||||||
"jz 2f\n" /* only a word */
|
"jz 2f\n" /* only a word */
|
||||||
|
@ -96,7 +96,7 @@ __memcpy_by2 (void *__dest, __const void *__src, size_t __n)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movw (%2),%w0\n\t"
|
"movw (%2),%w0\n\t"
|
||||||
"movw %w0,(%1)"
|
"movw %w0,(%1)"
|
||||||
: "=q" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&q" (__d0), "=&r" (__tmp), "=&r" (__src), "=&r" (__d1)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__n / 2)
|
: "1" (__tmp), "2" (__src), "3" (__n / 2)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
|
@ -105,6 +105,7 @@ __memcpy_by2 (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memcpy_g (void *__dest, __const void *__src, size_t __n)
|
__memcpy_g (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register void *__tmp = __dest;
|
register void *__tmp = __dest;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -117,9 +118,9 @@ __memcpy_g (void *__dest, __const void *__src, size_t __n)
|
||||||
"movsw\n"
|
"movsw\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"rep; movsl"
|
"rep; movsl"
|
||||||
: /* no output */
|
: "=&c" (__d0), "=&D" (__d1), "=&S" (__d2)
|
||||||
: "c" (__n), "D" (__tmp),"S" (__src)
|
: "0" (__n), "1" (__tmp), "2" (__src)
|
||||||
: "cx", "di", "si", "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,23 +130,24 @@ __memcpy_g (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
memmove (void *__dest, __const void *__src, size_t __n)
|
memmove (void *__dest, __const void *__src, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register void *__tmp = __dest;
|
register void *__tmp = __dest;
|
||||||
if (__dest < __src)
|
if (__dest < __src)
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"rep; movsb"
|
"rep; movsb"
|
||||||
: /* no output */
|
: "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
|
||||||
: "c" (__n), "S" (__src), "D" (__tmp)
|
: "0" (__n), "1" (__src), "2" (__tmp)
|
||||||
: "cx", "si", "di");
|
: "memory");
|
||||||
else
|
else
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("std\n\t"
|
("std\n\t"
|
||||||
"rep; movsb\n\t"
|
"rep; movsb\n\t"
|
||||||
"cld"
|
"cld"
|
||||||
: /* no output */
|
: "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
|
||||||
: "c" (__n), "S" (__n - 1 + (__const char *) __src),
|
: "0" (__n), "1" (__n - 1 + (__const char *) __src),
|
||||||
"D" (__n - 1 + (char *) __tmp)
|
"2" (__n - 1 + (char *) __tmp)
|
||||||
: "cx", "si", "di", "memory");
|
: "memory");
|
||||||
return __dest;
|
return __dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +159,7 @@ memmove (void *__dest, __const void *__src, size_t __n)
|
||||||
__STRING_INLINE int
|
__STRING_INLINE int
|
||||||
memcmp (__const void *__s1, __const void *__s2, size_t __n)
|
memcmp (__const void *__s1, __const void *__s2, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register int __res;
|
register int __res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -165,9 +168,9 @@ memcmp (__const void *__s1, __const void *__s2, size_t __n)
|
||||||
"sbbl %0,%0\n\t"
|
"sbbl %0,%0\n\t"
|
||||||
"orb $1,%b0\n"
|
"orb $1,%b0\n"
|
||||||
"1:"
|
"1:"
|
||||||
: "=a" (__res)
|
: "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
|
||||||
: "0" (0), "S" (__s1), "D" (__s2), "c" (__n)
|
: "0" (0), "1" (__s1), "2" (__s2), "3" (__n)
|
||||||
: "si", "di", "cx", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -203,15 +206,15 @@ memcmp (__const void *__s1, __const void *__s2, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_cc_by4 (void *__s, int __c, size_t __n)
|
__memset_cc_by4 (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register char *__tmp = __s;
|
register char *__tmp = __s;
|
||||||
register int __dummy;
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
"movl %2,(%0)\n\t"
|
"movl %2,(%0)\n\t"
|
||||||
"leal 4(%0),%0\n\t"
|
"leal 4(%0),%0\n\t"
|
||||||
"decl %1\n\t"
|
"decl %1\n\t"
|
||||||
"jnz 1b"
|
"jnz 1b"
|
||||||
: "=r" (__tmp), "=r" (__dummy)
|
: "=&r" (__tmp), "=&r" (__d0)
|
||||||
: "q" (0x01010101UL * (unsigned char) __c), "0" (__tmp), "1" (__n / 4)
|
: "q" (0x01010101UL * (unsigned char) __c), "0" (__tmp), "1" (__n / 4)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
|
@ -220,8 +223,8 @@ __memset_cc_by4 (void *__s, int __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_cc_by2 (void *__s, int __c, size_t __n)
|
__memset_cc_by2 (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register void *__tmp = __s;
|
register void *__tmp = __s;
|
||||||
register int __dummy;
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("shrl $1,%1\n\t" /* may be divisible also by 4 */
|
("shrl $1,%1\n\t" /* may be divisible also by 4 */
|
||||||
"jz 2f\n"
|
"jz 2f\n"
|
||||||
|
@ -232,7 +235,7 @@ __memset_cc_by2 (void *__s, int __c, size_t __n)
|
||||||
"jnz 1b\n"
|
"jnz 1b\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movw %w2,(%0)"
|
"movw %w2,(%0)"
|
||||||
: "=r" (__tmp), "=r" (__dummy)
|
: "=&r" (__tmp), "=&r" (__dummy)
|
||||||
: "q" (0x01010101UL * (unsigned char) __c), "0" (__tmp), "1" (__n / 2)
|
: "q" (0x01010101UL * (unsigned char) __c), "0" (__tmp), "1" (__n / 2)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
|
@ -242,7 +245,7 @@ __STRING_INLINE void *
|
||||||
__memset_gc_by4 (void *__s, int __c, size_t __n)
|
__memset_gc_by4 (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
register void *__tmp = __s;
|
register void *__tmp = __s;
|
||||||
register int __dummy;
|
register unsigned long int __d0;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %b0,%h0\n"
|
("movb %b0,%h0\n"
|
||||||
"pushw %w0\n\t"
|
"pushw %w0\n\t"
|
||||||
|
@ -253,7 +256,7 @@ __memset_gc_by4 (void *__s, int __c, size_t __n)
|
||||||
"addl $4,%1\n\t"
|
"addl $4,%1\n\t"
|
||||||
"decl %2\n\t"
|
"decl %2\n\t"
|
||||||
"jnz 1b\n"
|
"jnz 1b\n"
|
||||||
: "=q" (__c), "=r" (__tmp), "=r" (__dummy)
|
: "=&q" (__c), "=&r" (__tmp), "=&r" (__d0)
|
||||||
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
|
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
|
@ -262,8 +265,8 @@ __memset_gc_by4 (void *__s, int __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_gc_by2 (void *__s, int __c, size_t __n)
|
__memset_gc_by2 (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register void *__tmp = __s;
|
register void *__tmp = __s;
|
||||||
register int __dummy1, __dummy2;
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %b0,%h0\n\t"
|
("movb %b0,%h0\n\t"
|
||||||
"shrl $1,%2\n\t" /* may be divisible also by 4 */
|
"shrl $1,%2\n\t" /* may be divisible also by 4 */
|
||||||
|
@ -278,7 +281,7 @@ __memset_gc_by2 (void *__s, int __c, size_t __n)
|
||||||
"jnz 1b\n"
|
"jnz 1b\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movw %w0,(%1)"
|
"movw %w0,(%1)"
|
||||||
: "=q" (__dummy1), "=r" (__tmp), "=r" (__dummy2)
|
: "=&q" (__d0), "=&r" (__tmp), "=&r" (__d1)
|
||||||
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 2)
|
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 2)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
|
@ -287,6 +290,7 @@ __memset_gc_by2 (void *__s, int __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_cg (void *__s, int __c, size_t __n)
|
__memset_cg (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long __d0, __d1;
|
||||||
register void *__tmp = __s;
|
register void *__tmp = __s;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("shrl $1,%%ecx\n\t"
|
("shrl $1,%%ecx\n\t"
|
||||||
|
@ -294,15 +298,16 @@ __memset_cg (void *__s, int __c, size_t __n)
|
||||||
"jnc 1f\n\t"
|
"jnc 1f\n\t"
|
||||||
"movb %%al,(%%edi)\n"
|
"movb %%al,(%%edi)\n"
|
||||||
"1:"
|
"1:"
|
||||||
: /* no output */
|
: "=&c" (__d0), "=&D" (__d1)
|
||||||
: "c" (__n),"D" (__tmp), "a" (0x0101U * (unsigned char) __c)
|
: "0" (__n), "1" (__tmp), "a" (0x0101U * (unsigned char) __c)
|
||||||
: "cx", "di", "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
__memset_gg (void *__s, int __c, size_t __n)
|
__memset_gg (void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register void *__tmp = __s;
|
register void *__tmp = __s;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %%al,%%ah\n\t"
|
("movb %%al,%%ah\n\t"
|
||||||
|
@ -311,9 +316,9 @@ __memset_gg (void *__s, int __c, size_t __n)
|
||||||
"jnc 1f\n\t"
|
"jnc 1f\n\t"
|
||||||
"movb %%al,(%%edi)\n"
|
"movb %%al,(%%edi)\n"
|
||||||
"1:"
|
"1:"
|
||||||
: /* no output */
|
: "=&c" (__d0), "=&D" (__d1)
|
||||||
: "c" (__n), "D" (__tmp), "a" (__c)
|
: "0" (__n), "1" (__tmp), "a" (__c)
|
||||||
: "cx", "di", "memory", "cc");
|
: "memory", "cc");
|
||||||
return __s;
|
return __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,20 +328,31 @@ __memset_gg (void *__s, int __c, size_t __n)
|
||||||
__STRING_INLINE void *
|
__STRING_INLINE void *
|
||||||
memchr (__const void *__s, int __c, size_t __n)
|
memchr (__const void *__s, int __c, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register void *__res;
|
register void *__res;
|
||||||
if (__n == 0)
|
if (__n == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#ifdef __i686__
|
||||||
|
__asm__ __volatile__
|
||||||
|
("movl $1, %%edx\n\t"
|
||||||
|
"cld\n\t"
|
||||||
|
"repne; scasb\n\t"
|
||||||
|
"cmovne %%edx,%0"
|
||||||
|
: "=D" (__res), "=&c" (__d0)
|
||||||
|
: "a" (__c), "0" (__s), "1" (__n)
|
||||||
|
: "dx", "cc");
|
||||||
|
#else
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"je 1f\n\t"
|
"je 1f\n\t"
|
||||||
"movl $1,%0\n"
|
"movl $1,%0\n"
|
||||||
"1:\n\t"
|
"1:"
|
||||||
"decl %0"
|
: "=D" (__res), "=&c" (__d0)
|
||||||
: "=D" (__res)
|
: "a" (__c), "0" (__s), "1" (__n)
|
||||||
: "a" (__c), "D" (__s), "c" (__n)
|
: "cc");
|
||||||
: "cx", "cc");
|
#endif
|
||||||
return __res;
|
return __res - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -357,7 +373,7 @@ __strlen_g (__const char *__str)
|
||||||
"leal 1(%0),%0\n\t"
|
"leal 1(%0),%0\n\t"
|
||||||
"testb %b1,%b1\n\t"
|
"testb %b1,%b1\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=r" (__tmp), "=q" (__dummy)
|
: "=r" (__tmp), "=&q" (__dummy)
|
||||||
: "0" (__str)
|
: "0" (__str)
|
||||||
: "memory", "cc" );
|
: "memory", "cc" );
|
||||||
return __tmp - __str - 1;
|
return __tmp - __str - 1;
|
||||||
|
@ -434,7 +450,7 @@ __strcpy_g (char *__dest, __const char *__src)
|
||||||
"leal 1(%1),%1\n\t"
|
"leal 1(%1),%1\n\t"
|
||||||
"testb %b2,%b2\n\t"
|
"testb %b2,%b2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=r" (__src), "=r" (__tmp), "=q" (__dummy)
|
: "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy)
|
||||||
: "0" (__src), "1" (__tmp)
|
: "0" (__src), "1" (__tmp)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
|
@ -516,7 +532,7 @@ __STRING_INLINE char *
|
||||||
__mempcpy_by4 (char *__dest, __const char *__src, size_t __srclen)
|
__mempcpy_by4 (char *__dest, __const char *__src, size_t __srclen)
|
||||||
{
|
{
|
||||||
register char *__tmp = __dest;
|
register char *__tmp = __dest;
|
||||||
register int __dummy1, __dummy2;
|
register unsigned long int __d0, __d1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
"movl (%2),%0\n\t"
|
"movl (%2),%0\n\t"
|
||||||
|
@ -525,7 +541,7 @@ __mempcpy_by4 (char *__dest, __const char *__src, size_t __srclen)
|
||||||
"leal 4(%1),%1\n\t"
|
"leal 4(%1),%1\n\t"
|
||||||
"decl %3\n\t"
|
"decl %3\n\t"
|
||||||
"jnz 1b"
|
"jnz 1b"
|
||||||
: "=r" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&r" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__srclen / 4)
|
: "1" (__tmp), "2" (__src), "3" (__srclen / 4)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __tmp;
|
return __tmp;
|
||||||
|
@ -535,7 +551,7 @@ __STRING_INLINE char *
|
||||||
__mempcpy_by2 (char *__dest, __const char *__src, size_t __srclen)
|
__mempcpy_by2 (char *__dest, __const char *__src, size_t __srclen)
|
||||||
{
|
{
|
||||||
register char *__tmp = __dest;
|
register char *__tmp = __dest;
|
||||||
register int __dummy1, __dummy2;
|
register unsigned long int __d0, __d1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("shrl $1,%3\n\t"
|
("shrl $1,%3\n\t"
|
||||||
"jz 2f\n" /* only a word */
|
"jz 2f\n" /* only a word */
|
||||||
|
@ -549,7 +565,7 @@ __mempcpy_by2 (char *__dest, __const char *__src, size_t __srclen)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movw (%2),%w0\n\t"
|
"movw (%2),%w0\n\t"
|
||||||
"movw %w0,(%1)"
|
"movw %w0,(%1)"
|
||||||
: "=q" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&q" (__d0), "=r" (__tmp), "=&r" (__src), "=&r" (__d1)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__srclen / 2)
|
: "1" (__tmp), "2" (__src), "3" (__srclen / 2)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __tmp + 2;
|
return __tmp + 2;
|
||||||
|
@ -558,6 +574,7 @@ __mempcpy_by2 (char *__dest, __const char *__src, size_t __srclen)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__mempcpy_byn (char *__dest, __const char *__src, size_t __srclen)
|
__mempcpy_byn (char *__dest, __const char *__src, size_t __srclen)
|
||||||
{
|
{
|
||||||
|
register unsigned long __d0, __d1;
|
||||||
register char *__tmp = __dest;
|
register char *__tmp = __dest;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -570,9 +587,9 @@ __mempcpy_byn (char *__dest, __const char *__src, size_t __srclen)
|
||||||
"movsw\n"
|
"movsw\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"rep; movsl"
|
"rep; movsl"
|
||||||
: "=D" (__tmp)
|
: "=D" (__tmp), "=&c" (__d0), "=&S" (__d1)
|
||||||
: "c" (__srclen), "0" (__tmp),"S" (__src)
|
: "0" (__tmp), "1" (__srclen), "2" (__src)
|
||||||
: "cx", "di", "si", "memory", "cc");
|
: "memory", "cc");
|
||||||
return __tmp;
|
return __tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +607,7 @@ __stpcpy_g (char *__dest, __const char *__src)
|
||||||
"leal 1(%1),%1\n\t"
|
"leal 1(%1),%1\n\t"
|
||||||
"testb %b2,%b2\n\t"
|
"testb %b2,%b2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=r" (__src), "=r" (__tmp), "=q" (__dummy)
|
: "=&r" (__src), "=r" (__tmp), "=&q" (__dummy)
|
||||||
: "0" (__src), "1" (__tmp)
|
: "0" (__src), "1" (__tmp)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __tmp - 1;
|
return __tmp - 1;
|
||||||
|
@ -626,7 +643,7 @@ __strncpy_by4 (char *__dest, __const char __src[], size_t __srclen, size_t __n)
|
||||||
"leal 4(%1),%1\n\t"
|
"leal 4(%1),%1\n\t"
|
||||||
"decl %3\n\t"
|
"decl %3\n\t"
|
||||||
"jnz 1b"
|
"jnz 1b"
|
||||||
: "=r" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&r" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__srclen / 4)
|
: "1" (__tmp), "2" (__src), "3" (__srclen / 4)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
(void) memset (__tmp, '\0', __n - __srclen);
|
(void) memset (__tmp, '\0', __n - __srclen);
|
||||||
|
@ -651,7 +668,7 @@ __strncpy_by2 (char *__dest, __const char __src[], size_t __srclen, size_t __n)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movw (%2),%w0\n\t"
|
"movw (%2),%w0\n\t"
|
||||||
"movw %w0,(%1)\n\t"
|
"movw %w0,(%1)\n\t"
|
||||||
: "=q" (__dummy1), "=r" (__tmp), "=r" (__src), "=r" (__dummy2)
|
: "=&q" (__dummy1), "=r" (__tmp), "=&r" (__src), "=&r" (__dummy2)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__srclen / 2)
|
: "1" (__tmp), "2" (__src), "3" (__srclen / 2)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
(void) memset (__tmp + 2, '\0', __n - __srclen);
|
(void) memset (__tmp + 2, '\0', __n - __srclen);
|
||||||
|
@ -661,21 +678,22 @@ __strncpy_by2 (char *__dest, __const char __src[], size_t __srclen, size_t __n)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strncpy_byn (char *__dest, __const char __src[], size_t __srclen, size_t __n)
|
__strncpy_byn (char *__dest, __const char __src[], size_t __srclen, size_t __n)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register char *__tmp = __dest;
|
register char *__tmp = __dest;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
"shrl $1,%%ecx\n\t"
|
"shrl $1,%1\n\t"
|
||||||
"jnc 1f\n\t"
|
"jnc 1f\n\t"
|
||||||
"movsb\n"
|
"movsb\n"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"shrl $1,%%ecx\n\t"
|
"shrl $1,%1\n\t"
|
||||||
"jnc 2f\n\t"
|
"jnc 2f\n\t"
|
||||||
"movsw\n"
|
"movsw\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"rep; movsl"
|
"rep; movsl"
|
||||||
: "=D" (__tmp)
|
: "=D" (__tmp), "=&c" (__d0), "=&S" (__d1)
|
||||||
: "c" (__srclen), "0" (__tmp),"S" (__src)
|
: "1" (__srclen), "0" (__tmp),"2" (__src)
|
||||||
: "cx", "di", "si", "memory", "cc");
|
: "memory", "cc");
|
||||||
(void) memset (__tmp, '\0', __n - __srclen);
|
(void) memset (__tmp, '\0', __n - __srclen);
|
||||||
return __dest;
|
return __dest;
|
||||||
}
|
}
|
||||||
|
@ -702,7 +720,7 @@ __strncpy_gg (char *__dest, __const char *__src, size_t __n)
|
||||||
"decl %3\n\t"
|
"decl %3\n\t"
|
||||||
"jne 2b\n\t"
|
"jne 2b\n\t"
|
||||||
"3:"
|
"3:"
|
||||||
: "=r" (__src), "=r" (__tmp), "=q" (__dummy), "=r" (__n)
|
: "=&r" (__src), "=&r" (__tmp), "=&q" (__dummy), "=&r" (__n)
|
||||||
: "0" (__src), "1" (__tmp), "3" (__n)
|
: "0" (__src), "1" (__tmp), "3" (__n)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
|
|
||||||
|
@ -720,6 +738,15 @@ __strncpy_gg (char *__dest, __const char *__src, size_t __n)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strcat_c (char *__dest, __const char __src[], size_t __srclen)
|
__strcat_c (char *__dest, __const char __src[], size_t __srclen)
|
||||||
{
|
{
|
||||||
|
#ifdef __i686__
|
||||||
|
register unsigned long int __d0;
|
||||||
|
register char *__tmp;
|
||||||
|
__asm__ __volatile__
|
||||||
|
("repne; cmpsb"
|
||||||
|
: "=S" (__tmp), "=&c" (__d0)
|
||||||
|
: "0" (__dest), "1" (0xffffffff), "a" (0)
|
||||||
|
: "cc");
|
||||||
|
#else
|
||||||
register char *__tmp = __dest - 1;
|
register char *__tmp = __dest - 1;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
|
@ -729,6 +756,7 @@ __strcat_c (char *__dest, __const char __src[], size_t __srclen)
|
||||||
: "=r" (__tmp)
|
: "=r" (__tmp)
|
||||||
: "0" (__tmp)
|
: "0" (__tmp)
|
||||||
: "cc");
|
: "cc");
|
||||||
|
#endif
|
||||||
(void) memcpy (__tmp, __src, __srclen);
|
(void) memcpy (__tmp, __src, __srclen);
|
||||||
return __dest;
|
return __dest;
|
||||||
}
|
}
|
||||||
|
@ -750,7 +778,7 @@ __strcat_g (char *__dest, __const char *__src)
|
||||||
"incl %1\n\t"
|
"incl %1\n\t"
|
||||||
"testb %b0,%b0\n\t"
|
"testb %b0,%b0\n\t"
|
||||||
"jne 2b\n"
|
"jne 2b\n"
|
||||||
: "=q" (__dummy), "=r" (__tmp), "=r" (__src)
|
: "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src)
|
||||||
: "1" (__tmp), "2" (__src)
|
: "1" (__tmp), "2" (__src)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
|
@ -789,7 +817,7 @@ __strncat_g (char *__dest, __const char __src[], size_t __n)
|
||||||
"decl %1\n"
|
"decl %1\n"
|
||||||
"3:\n\t"
|
"3:\n\t"
|
||||||
"movb $0,(%1)\n\t"
|
"movb $0,(%1)\n\t"
|
||||||
: "=q" (__dummy), "=r" (__tmp), "=r" (__src), "=r" (__n)
|
: "=&q" (__dummy), "=&r" (__tmp), "=&r" (__src), "=&r" (__n)
|
||||||
: "1" (__tmp), "2" (__src), "3" (__n)
|
: "1" (__tmp), "2" (__src), "3" (__n)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
return __dest;
|
return __dest;
|
||||||
|
@ -884,7 +912,7 @@ __strcmp_gg (__const char *__s1, __const char *__s2)
|
||||||
"jb 3f\n\t"
|
"jb 3f\n\t"
|
||||||
"negl %0\n"
|
"negl %0\n"
|
||||||
"3:"
|
"3:"
|
||||||
: "=q" (__res), "=r" (__s1), "=r" (__s2)
|
: "=q" (__res), "=&r" (__s1), "=&r" (__s2)
|
||||||
: "1" (__s1), "2" (__s2)
|
: "1" (__s1), "2" (__s2)
|
||||||
: "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
|
@ -923,7 +951,7 @@ __strncmp_g (__const char *__s1, __const char *__s2, size_t __n)
|
||||||
"jb 4f\n\t"
|
"jb 4f\n\t"
|
||||||
"negl %0\n"
|
"negl %0\n"
|
||||||
"4:"
|
"4:"
|
||||||
: "=q" (__res), "=r" (__s1), "=r" (__s2), "=r" (__n)
|
: "=q" (__res), "=&r" (__s1), "=&r" (__s2), "=&r" (__n)
|
||||||
: "1" (__s1), "2" (__s2), "3" (__n)
|
: "1" (__s1), "2" (__s2), "3" (__n)
|
||||||
: "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
|
@ -940,6 +968,7 @@ __strncmp_g (__const char *__s1, __const char *__s2, size_t __n)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strchr_c (__const char *__s, int __c)
|
__strchr_c (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
|
@ -951,15 +980,16 @@ __strchr_c (__const char *__s, int __c)
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"xorl %0,%0\n"
|
"xorl %0,%0\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=r" (__res)
|
: "=r" (__res), "=&a" (__d0)
|
||||||
: "a" (__c), "0" (__s)
|
: "0" (__s), "1" (__c)
|
||||||
: "ax", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strchr_g (__const char *__s, int __c)
|
__strchr_g (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %%al,%%ah\n"
|
("movb %%al,%%ah\n"
|
||||||
|
@ -972,9 +1002,9 @@ __strchr_g (__const char *__s, int __c)
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"xorl %0,%0\n"
|
"xorl %0,%0\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=r" (__res)
|
: "=r" (__res), "=&a" (__d0)
|
||||||
: "a" (__c), "0" (__s)
|
: "0" (__s), "1" (__c)
|
||||||
: "ax", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,43 +1030,46 @@ __strchr_g (__const char *__s, int __c)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strrchr_c (__const char *__s, int __c)
|
__strrchr_c (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"cmpb %%ah,%%al\n\t"
|
"cmpb %h2,%b2\n\t"
|
||||||
"cmove %%esi,%0\n\t"
|
"cmove %1,%0\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %b2,%b2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=d" (__res)
|
: "=d" (__res), "=&S" (__d0), "=&a" (__d1)
|
||||||
: "0" (1), "S" (__s), "a" (__c)
|
: "0" (1), "1" (__s), "2" (__c)
|
||||||
: "ax", "si", "cc");
|
: "cc");
|
||||||
return __res - 1;
|
return __res - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strrchr_g (__const char *__s, int __c)
|
__strrchr_g (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %%al,%%ah\n"
|
("movb %b2,%h2\n"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"cmpb %%ah,%%al\n\t"
|
"cmpb %h2,%b2\n\t"
|
||||||
"cmove %%esi,%0\n\t"
|
"cmove %1,%0\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %b2,%b2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=r" (__res)
|
: "=d" (__res), "=&S" (__d0), "=&a" (__d1)
|
||||||
: "0" (1), "S" (__s), "a" (__c)
|
: "0" (1), "1" (__s), "2" (__c)
|
||||||
: "ax", "si", "cc");
|
: "cc");
|
||||||
return __res - 1;
|
return __res - 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strrchr_c (__const char *__s, int __c)
|
__strrchr_c (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -1048,15 +1081,16 @@ __strrchr_c (__const char *__s, int __c)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=d" (__res)
|
: "=d" (__res), "=&S" (__d0), "=&a" (__d1)
|
||||||
: "0" (0), "S" (__s),"a" (__c)
|
: "0" (0), "1" (__s), "2" (__c)
|
||||||
: "ax", "si", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strrchr_g (__const char *__s, int __c)
|
__strrchr_g (__const char *__s, int __c)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movb %%al,%%ah\n"
|
("movb %%al,%%ah\n"
|
||||||
|
@ -1069,9 +1103,9 @@ __strrchr_g (__const char *__s, int __c)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=r" (__res)
|
: "=r" (__res), "=&S" (__d0), "=&a" (__d1)
|
||||||
: "0" (0), "S" (__s),"a" (__c)
|
: "0" (0), "1" (__s), "2" (__c)
|
||||||
: "ax", "si", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1102,6 +1136,7 @@ __strrchr_g (__const char *__s, int __c)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strcspn_c1 (__const char *__s, int __reject)
|
__strcspn_c1 (__const char *__s, int __reject)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
|
@ -1112,15 +1147,16 @@ __strcspn_c1 (__const char *__s, int __reject)
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"jne 1b\n"
|
"jne 1b\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=r" (__res)
|
: "=r" (__res), "=&a" (__d0)
|
||||||
: "a" (__reject), "0" (__s)
|
: "0" (__s), "1" (__reject)
|
||||||
: "ax", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strcspn_cg (__const char *__s, __const char __reject[], size_t __reject_len)
|
__strcspn_cg (__const char *__s, __const char __reject[], size_t __reject_len)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -1128,14 +1164,14 @@ __strcspn_cg (__const char *__s, __const char __reject[], size_t __reject_len)
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"je 2f\n\t"
|
"je 2f\n\t"
|
||||||
"movl %2,%%edi\n\t"
|
"movl %5,%%edi\n\t"
|
||||||
"movl %3,%%ecx\n\t"
|
"movl %6,%%ecx\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"jne 1b\n"
|
"jne 1b\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "0" (__s), "d" (__reject), "g" (__reject_len)
|
: "0" (__s), "d" (__reject), "g" (__reject_len)
|
||||||
: "ax", "cx", "di", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1143,11 +1179,12 @@ __strcspn_cg (__const char *__s, __const char __reject[], size_t __reject_len)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strcspn_g (__const char *__s, __const char *__reject)
|
__strcspn_g (__const char *__s, __const char *__reject)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
int __mem;
|
int __mem;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %%ebx,%1\n\t"
|
("pushl %%ebx\n\t"
|
||||||
"movl %5,%%edi\n\t"
|
"movl %4,%%edi\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"notl %%ecx\n\t"
|
"notl %%ecx\n\t"
|
||||||
|
@ -1156,21 +1193,22 @@ __strcspn_g (__const char *__s, __const char *__reject)
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"je 2f\n\t"
|
"je 2f\n\t"
|
||||||
"movl %5,%%edi\n\t"
|
"movl %4,%%edi\n\t"
|
||||||
"movl %%ebx,%%ecx\n\t"
|
"movl %%ebx,%%ecx\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"jne 1b\n"
|
"jne 1b\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movl %1,%%ebx"
|
"popl %%ebx"
|
||||||
: "=S" (__res), "=&m" (__mem)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "r" (__reject), "1" (__mem)
|
: "r" (__reject), "0" (__s), "1" (0), "2" (0xffffffff)
|
||||||
: "ax", "cx", "di", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strcspn_g (__const char *__s, __const char *__reject)
|
__strcspn_g (__const char *__s, __const char *__reject)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -1186,9 +1224,9 @@ __strcspn_g (__const char *__s, __const char *__reject)
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"jne 1b\n"
|
"jne 1b\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "b" (__reject), "D" (__reject)
|
: "0" (__s), "1" (0), "2" (0xffffffff), "3" (__reject), "b" (__reject)
|
||||||
: "ax", "cx", "dx", "di", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1209,23 +1247,25 @@ __strcspn_g (__const char *__s, __const char *__reject)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strspn_c1 (__const char *__s, int __accept)
|
__strspn_c1 (__const char *__s, int __accept)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
/* Please note that __accept never can be '\0'. */
|
/* Please note that __accept never can be '\0'. */
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("1:\n\t"
|
("1:\n\t"
|
||||||
"movb (%0),%%al\n\t"
|
"movb (%0),%b1\n\t"
|
||||||
"leal 1(%0),%0\n\t"
|
"leal 1(%0),%0\n\t"
|
||||||
"cmpb %%ah,%%al\n\t"
|
"cmpb %h1,%b1\n\t"
|
||||||
"je 1b"
|
"je 1b"
|
||||||
: "=r" (__res)
|
: "=r" (__res), "=&q" (__d0)
|
||||||
: "a" (__accept), "0" (__s)
|
: "0" (__s), "1" (__accept)
|
||||||
: "ax", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strspn_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
__strspn_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -1233,14 +1273,14 @@ __strspn_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"je 2f\n\t"
|
"je 2f\n\t"
|
||||||
"movl %2,%%edi\n\t"
|
"movl %1,%%edi\n\t"
|
||||||
"movl %3,%%ecx\n\t"
|
"movl %6,%%ecx\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"je 1b\n"
|
"je 1b\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&d" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "0" (__s), "d" (__accept), "g" (__accept_len)
|
: "0" (__s), "1" (__accept), "g" (__accept_len)
|
||||||
: "ax", "cx", "di", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,10 +1288,11 @@ __strspn_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strspn_g (__const char *__s, __const char *__accept)
|
__strspn_g (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
int __mem;
|
int __mem;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %%ebx,%1\n\t"
|
("pushl %%ebx\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"notl %%ecx\n\t"
|
"notl %%ecx\n\t"
|
||||||
|
@ -1265,17 +1306,17 @@ __strspn_g (__const char *__s, __const char *__accept)
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"je 1b\n"
|
"je 1b\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movl %1,%%ebx"
|
"popl %%ebx"
|
||||||
: "=S" (__res), "=m" (__mem)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "d" (__accept), "1" (__mem),
|
: "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept)
|
||||||
"D" (__accept)
|
: "cc");
|
||||||
: "ax", "cx", "di", "cc");
|
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
__STRING_INLINE size_t
|
__STRING_INLINE size_t
|
||||||
__strspn_g (__const char *__s, __const char *__accept)
|
__strspn_g (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register __const char *__res;
|
register __const char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n\t"
|
("cld\n\t"
|
||||||
|
@ -1291,9 +1332,9 @@ __strspn_g (__const char *__s, __const char *__accept)
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"je 1b\n"
|
"je 1b\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2), "=&d" (__d3)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "b" (__accept), "D" (__accept)
|
: "0" (__s), "1" (0), "2" (0xffffffff), "3" (__accept), "b" (__accept)
|
||||||
: "ax", "cx", "dx", "di", "cc");
|
: "cc");
|
||||||
return (__res - 1) - __s;
|
return (__res - 1) - __s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1313,6 +1354,7 @@ __strspn_g (__const char *__s, __const char *__accept)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
__strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n"
|
("cld\n"
|
||||||
|
@ -1320,8 +1362,8 @@ __strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
"lodsb\n\t"
|
"lodsb\n\t"
|
||||||
"testb %%al,%%al\n\t"
|
"testb %%al,%%al\n\t"
|
||||||
"je 2f\n\t"
|
"je 2f\n\t"
|
||||||
"movl %2,%%edi\n\t"
|
"movl %5,%%edi\n\t"
|
||||||
"movl %3,%%ecx\n\t"
|
"movl %6,%%ecx\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"decl %0\n\t"
|
"decl %0\n\t"
|
||||||
|
@ -1329,9 +1371,9 @@ __strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"xorl %0,%0\n"
|
"xorl %0,%0\n"
|
||||||
"3:"
|
"3:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "0" (__s), "d" (__accept), "g" (__accept_len)
|
: "0" (__s), "d" (__accept), "g" (__accept_len)
|
||||||
: "ax", "cx", "di", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1339,10 +1381,11 @@ __strpbrk_cg (__const char *__s, __const char __accept[], size_t __accept_len)
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strpbrk_g (__const char *__s, __const char *__accept)
|
__strpbrk_g (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
int __mem;
|
int __mem;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %%ebx,%1\n\t"
|
("pushl %%ebx\n\t"
|
||||||
"movl %%edx,%%edi\n\t"
|
"movl %%edx,%%edi\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
|
@ -1361,16 +1404,17 @@ __strpbrk_g (__const char *__s, __const char *__accept)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"xorl %0,%0\n"
|
"xorl %0,%0\n"
|
||||||
"3:\n\t"
|
"3:\n\t"
|
||||||
"movl %1,%%ebx"
|
"popl %%ebx"
|
||||||
: "=S" (__res), "=m" (__mem)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "d" (__accept), "1" (__mem)
|
: "d" (__accept), "0" (__s), "1" (0), "2" (0xffffffff)
|
||||||
: "ax", "cx", "di", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strpbrk_g (__const char *__s, __const char *__accept)
|
__strpbrk_g (__const char *__s, __const char *__accept)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2, __d3;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %%ebx,%%edi\n\t"
|
("movl %%ebx,%%edi\n\t"
|
||||||
|
@ -1391,9 +1435,9 @@ __strpbrk_g (__const char *__s, __const char *__accept)
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"xorl %0,%0\n"
|
"xorl %0,%0\n"
|
||||||
"3:"
|
"3:"
|
||||||
: "=S" (__res)
|
: "=S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3)
|
||||||
: "a" (0), "c" (0xffffffff), "0" (__s), "b" (__accept)
|
: "0" (__s), "1" (0), "2" (0xffffffff), "b" (__accept)
|
||||||
: "ax", "cx", "dx", "di", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1416,42 +1460,39 @@ __STRING_INLINE char *
|
||||||
__strstr_cg (__const char *__haystack, __const char __needle[],
|
__strstr_cg (__const char *__haystack, __const char __needle[],
|
||||||
size_t __needle_len)
|
size_t __needle_len)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("cld\n" \
|
("cld\n" \
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"movl %3,%%edi\n\t"
|
"movl %6,%%edi\n\t"
|
||||||
"movl %2,%%eax\n\t"
|
"movl %5,%%eax\n\t"
|
||||||
"movl %1,%%ecx\n\t"
|
"movl %4,%%ecx\n\t"
|
||||||
"repe; cmpsb\n\t"
|
"repe; cmpsb\n\t"
|
||||||
"je 2f\n\t"
|
"je 2f\n\t"
|
||||||
"cmpb $0,-1(%%esi)\n\t"
|
"cmpb $0,-1(%%esi)\n\t"
|
||||||
"leal 1(%%eax),%2\n\t"
|
"leal 1(%%eax),%5\n\t"
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"xorl %%eax,%%eax\n"
|
"xorl %%eax,%%eax\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=a" (__res)
|
: "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2)
|
||||||
: "g" (__needle_len), "S" (__haystack), "d" (__needle)
|
: "g" (__needle_len), "1" (__haystack), "d" (__needle)
|
||||||
: "cx", "di", "si", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __PIC__
|
#ifdef __PIC__
|
||||||
# if 1
|
|
||||||
/* For now this does not always works due to spilling problems. */
|
|
||||||
# define __strstr_g(haystack, needle) strstr (haystack, needle)
|
|
||||||
# else
|
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strstr_g (__const char *__haystack, __const char *__needle)
|
__strstr_g (__const char *__haystack, __const char *__needle)
|
||||||
{
|
{
|
||||||
|
register unsigned long int __d0, __d1, __d2;
|
||||||
register char *__res;
|
register char *__res;
|
||||||
int __mem;
|
int __mem;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %2,%%edi\n\t"
|
("cld\n\t"
|
||||||
"cld\n\t"
|
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"notl %%ecx\n\t"
|
"notl %%ecx\n\t"
|
||||||
"movl %%ebx,%1\n\t"
|
"pushl %%ebx\n\t"
|
||||||
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
|
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
|
||||||
"movl %%ecx,%%ebx\n"
|
"movl %%ecx,%%ebx\n"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
|
@ -1465,21 +1506,19 @@ __strstr_g (__const char *__haystack, __const char *__needle)
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"xorl %%eax,%%eax\n"
|
"xorl %%eax,%%eax\n"
|
||||||
"2:\n\t"
|
"2:\n\t"
|
||||||
"movl %1,%%ebx"
|
"popl %%ebx"
|
||||||
: "=a" (__res), "=&m" (__mem)
|
: "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
|
||||||
: "0" (0), "c" (0xffffffff), "S" (__haystack), "d" (__needle), "1" (__mem)
|
: "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (0), "d" (__needle)
|
||||||
: "cx", "di", "si", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
__strstr_g (__const char *__haystack, __const char *__needle)
|
__strstr_g (__const char *__haystack, __const char *__needle)
|
||||||
{
|
{
|
||||||
register char *__res;
|
register char *__res;
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("movl %1,%%edi\n\t"
|
("cld\n\t"
|
||||||
"cld\n\t"
|
|
||||||
"repne; scasb\n\t"
|
"repne; scasb\n\t"
|
||||||
"notl %%ecx\n\t"
|
"notl %%ecx\n\t"
|
||||||
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
|
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
|
||||||
|
@ -1495,9 +1534,9 @@ __strstr_g (__const char *__haystack, __const char *__needle)
|
||||||
"jne 1b\n\t"
|
"jne 1b\n\t"
|
||||||
"xorl %%eax,%%eax\n"
|
"xorl %%eax,%%eax\n"
|
||||||
"2:"
|
"2:"
|
||||||
: "=a" (__res)
|
: "=a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2), "=&d" (__d3)
|
||||||
: "0" (0), "c" (0xffffffff), "S" (__haystack), "b" (__needle)
|
: "0" (0), "1" (0xffffffff), "2" (__haystack), "3" (0), "b" (__needle)
|
||||||
: "cx", "dx", "di", "si", "cc");
|
: "cc");
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue