mirror of
git://sourceware.org/git/glibc.git
synced 2025-04-06 14:10:30 +08:00
Updated to fedora-glibc-20060130T0922
This commit is contained in:
parent
06f313e361
commit
3e543bc563
1
Makefile
1
Makefile
@ -163,6 +163,7 @@ else
|
||||
installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
|
||||
|
||||
$(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
|
||||
$(make-target-directory)
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
install-others-nosubdir: $(installed-stubs)
|
||||
|
42
Makerules
42
Makerules
@ -257,6 +257,10 @@ $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
|
||||
\$$(compile-command.S)"; \
|
||||
echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
|
||||
\$$(compile-command.s)"; \
|
||||
echo "\$$(objpfx)m_%$$o: $$dir/s_%.S \$$(before-compile); \
|
||||
\$$(compile-command.S)"; \
|
||||
echo "\$$(objpfx)m_%$$o: $$dir/s_%.s \$$(before-compile); \
|
||||
\$$(compile-command.s)"; \
|
||||
$(close-check-inhibit-asm) \
|
||||
echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
|
||||
\$$(compile-command.c)"; \
|
||||
@ -264,11 +268,12 @@ $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
|
||||
\$$(compile-command.c)"; \
|
||||
echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
|
||||
\$$(compile-command.c)"; \
|
||||
echo "\$$(objpfx)m_%$$o: $$dir/s_%.c \$$(before-compile); \
|
||||
\$$(compile-command.c)"; \
|
||||
done; \
|
||||
echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \
|
||||
echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \
|
||||
echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force); \
|
||||
\$$(do-install)"; \
|
||||
done; \
|
||||
echo "\$$(objpfx)m_%.c: s_%.c; \$$(+make-include-of-dep)"; \
|
||||
echo 'sysd-rules-done = t') > $@T
|
||||
mv -f $@T $@
|
||||
|
||||
@ -277,17 +282,6 @@ ifndef sysd-rules-done
|
||||
no_deps=t
|
||||
endif
|
||||
|
||||
# This is used by the m_%.[Sc] pattern rules in sysd-rules.
|
||||
define +make-include-of-dep
|
||||
echo '#include <$<>' > $@T
|
||||
mv -f $@T $@
|
||||
endef
|
||||
|
||||
# It matters that this set of rules, for compiling from sources in
|
||||
# the current directory (the $srcdir/$subdir) come before the
|
||||
# generated sysdep rules in included from sysd-rules below. When
|
||||
# compiling in the source tree, generated sources go into the current
|
||||
# directory, and those should be chosen before any sources in sysdeps.
|
||||
define o-iterator-doit
|
||||
$(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
|
||||
endef
|
||||
@ -572,6 +566,11 @@ define build-module
|
||||
$(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
|
||||
$(csu-objpfx)abi-note.o $(build-module-objlist)
|
||||
endef
|
||||
define build-module-asneeded
|
||||
$(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
|
||||
$(csu-objpfx)abi-note.o \
|
||||
-Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
|
||||
endef
|
||||
else
|
||||
ifneq (,$(findstring aix,$(config-os)))
|
||||
define build-module
|
||||
@ -1121,8 +1120,21 @@ $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
|
||||
endif
|
||||
headers := $(strip $(headers))
|
||||
ifdef headers
|
||||
$(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
|
||||
# This implicit rule installs headers from the source directory.
|
||||
# It may be ignored in preference to rules from sysd-rules to find
|
||||
# headers in the sysdeps tree.
|
||||
$(inst_includedir)/%.h: $(objpfx)%.h $(+force)
|
||||
$(do-install)
|
||||
$(inst_includedir)/%.h: %.h $(+force)
|
||||
$(do-install)
|
||||
$(inst_includedir)/%.h: $(..)include/%.h $(+force)
|
||||
$(do-install)
|
||||
headers-nonh := $(filter-out %.h,$(headers))
|
||||
ifdef headers-nonh
|
||||
$(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
|
||||
% $(+force)
|
||||
$(do-install)
|
||||
endif # headers-nonh
|
||||
endif # headers
|
||||
|
||||
.PHONY: install-bin-nosubdir install-bin-script-nosubdir \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
/* Write formatted output to FP from the format string FORMAT. */
|
||||
int
|
||||
__fprintf_chk (FILE *fp, int flag, const char *format, ...)
|
||||
___fprintf_chk (FILE *fp, int flag, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int done;
|
||||
@ -43,3 +43,4 @@ __fprintf_chk (FILE *fp, int flag, const char *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (___fprintf_chk, __fprintf_chk)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
/* Write formatted output to stdout from the format string FORMAT. */
|
||||
int
|
||||
__printf_chk (int flag, const char *format, ...)
|
||||
___printf_chk (int flag, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int done;
|
||||
@ -43,3 +43,4 @@ __printf_chk (int flag, const char *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (___printf_chk, __printf_chk)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991, 1995, 1997, 1998, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1997, 1998, 2004, 2006
|
||||
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
|
||||
@ -16,6 +17,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -24,8 +26,8 @@
|
||||
string FORMAT, writing no more than MAXLEN characters. */
|
||||
/* VARARGS5 */
|
||||
int
|
||||
__snprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
const char *format, ...)
|
||||
___snprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -36,3 +38,4 @@ __snprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (___snprintf_chk, __snprintf_chk)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991,1995,1997,1998,2002,2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1997, 1998, 2002, 2004, 2006
|
||||
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
|
||||
@ -16,13 +17,14 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Write formatted output into S, according to the format string FORMAT. */
|
||||
/* VARARGS4 */
|
||||
int
|
||||
__sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
|
||||
___sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -33,3 +35,4 @@ __sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (___sprintf_chk, __sprintf_chk)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2005
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
/* Write formatted output to FP from the format string FORMAT. */
|
||||
int
|
||||
__vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
|
||||
___vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
|
||||
{
|
||||
int done;
|
||||
|
||||
@ -40,4 +40,5 @@ __vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
|
||||
|
||||
return done;
|
||||
}
|
||||
libc_hidden_def (__vfprintf_chk)
|
||||
ldbl_hidden_def (___vfprintf_chk, __vfprintf_chk)
|
||||
ldbl_strong_alias (___vfprintf_chk, __vfprintf_chk)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2005
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -40,3 +40,4 @@ __vfwprintf_chk (FILE *fp, int flag, const wchar_t *format, va_list ap)
|
||||
|
||||
return done;
|
||||
}
|
||||
libc_hidden_def (__vfwprintf_chk)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
/* Write formatted output to stdout from the format string FORMAT. */
|
||||
int
|
||||
__vprintf_chk (int flag, const char *format, va_list ap)
|
||||
___vprintf_chk (int flag, const char *format, va_list ap)
|
||||
{
|
||||
int done;
|
||||
|
||||
@ -40,3 +40,4 @@ __vprintf_chk (int flag, const char *format, va_list ap)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (___vprintf_chk, __vprintf_chk)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991, 1995, 1997, 1998, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1997, 1998, 2004, 2006
|
||||
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
|
||||
@ -27,8 +28,8 @@ extern const struct _IO_jump_t _IO_strn_jumps attribute_hidden;
|
||||
string FORMAT, writing no more than MAXLEN characters. */
|
||||
/* VARARGS5 */
|
||||
int
|
||||
__vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
const char *format, va_list args)
|
||||
___vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
const char *format, va_list args)
|
||||
{
|
||||
/* XXX Maybe for less strict version do not fail immediately.
|
||||
Though, maxlen is supposed to be the size of buffer pointed
|
||||
@ -67,4 +68,5 @@ __vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
|
||||
*sf.f._sbf._f._IO_write_ptr = '\0';
|
||||
return ret;
|
||||
}
|
||||
libc_hidden_def (__vsnprintf_chk)
|
||||
ldbl_hidden_def (___vsnprintf_chk, __vsnprintf_chk)
|
||||
ldbl_strong_alias (___vsnprintf_chk, __vsnprintf_chk)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1994, 1997, 1999-2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994, 1997, 1999-2003, 2004, 2006
|
||||
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
|
||||
@ -61,8 +62,8 @@ static const struct _IO_jump_t _IO_str_chk_jumps =
|
||||
|
||||
|
||||
int
|
||||
__vsprintf_chk (char *s, int flags, size_t slen, const char *format,
|
||||
va_list args)
|
||||
___vsprintf_chk (char *s, int flags, size_t slen, const char *format,
|
||||
va_list args)
|
||||
{
|
||||
_IO_strfile f;
|
||||
int ret;
|
||||
@ -88,4 +89,5 @@ __vsprintf_chk (char *s, int flags, size_t slen, const char *format,
|
||||
*f._sbf._f._IO_write_ptr = '\0';
|
||||
return ret;
|
||||
}
|
||||
libc_hidden_def (__vsprintf_chk)
|
||||
ldbl_hidden_def (___vsprintf_chk, __vsprintf_chk)
|
||||
ldbl_strong_alias (___vsprintf_chk, __vsprintf_chk)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 1991-2000, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991-2000,2002,2003,2005,2006 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
|
||||
@ -28,7 +28,8 @@ routines := opendir closedir readdir readdir_r rewinddir \
|
||||
alphasort64 versionsort64 fdopendir
|
||||
distribute := dirstream.h
|
||||
|
||||
tests := list tst-seekdir opendir-tst1 bug-readdir1 tst-fdopendir
|
||||
tests := list tst-seekdir opendir-tst1 bug-readdir1 tst-fdopendir \
|
||||
tst-fdopendir2
|
||||
|
||||
CFLAGS-scandir.c = $(uses-callbacks)
|
||||
CFLAGS-scandir64.c = $(uses-callbacks)
|
||||
|
41
dirent/tst-fdopendir2.c
Normal file
41
dirent/tst-fdopendir2.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
char tmpl[] = "/tmp/tst-fdopendir2-XXXXXX";
|
||||
int fd = mkstemp (tmpl);
|
||||
if (fd == -1)
|
||||
{
|
||||
puts ("cannot open temp file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
DIR *d = fdopendir (fd);
|
||||
|
||||
int e = errno;
|
||||
|
||||
close (fd);
|
||||
unlink (tmpl);
|
||||
|
||||
if (d != NULL)
|
||||
{
|
||||
puts ("fdopendir with normal file descriptor did not fail");
|
||||
return 1;
|
||||
}
|
||||
if (e != ENOTDIR)
|
||||
{
|
||||
printf ("fdopendir set errno to %d, not %d as expected\n", e, ENOTDIR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
30
elf/Makefile
30
elf/Makefile
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-2004, 2005, 2006 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
|
||||
@ -647,7 +647,7 @@ $(objpfx)dblunload: $(libdl)
|
||||
$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
|
||||
|
||||
$(objpfx)reldep5: $(libdl)
|
||||
$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod5.so
|
||||
$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod6.so
|
||||
|
||||
$(objpfx)reldep6: $(libdl)
|
||||
$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
|
||||
@ -806,6 +806,10 @@ check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
|
||||
$(objpfx)check-textrel: check-textrel.c
|
||||
$(native-compile)
|
||||
|
||||
check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99
|
||||
$(objpfx)check-localplt: check-localplt.c
|
||||
$(native-compile)
|
||||
|
||||
ifeq (yes,$(build-shared))
|
||||
tests: $(objpfx)check-textrel.out
|
||||
|
||||
@ -818,6 +822,28 @@ generated += check-textrel check-textrel.out
|
||||
$(objpfx)tst-dlmodcount: $(libdl)
|
||||
$(objpfx)tst-dlmodcount.out: $(test-modules)
|
||||
|
||||
check-data := $(firstword $(wildcard \
|
||||
$(foreach M,$(config-machine) $(base-machine),\
|
||||
../scripts/data/localplt-$M-$(config-os).data)))
|
||||
ifneq (,$(check-data))
|
||||
tests: $(objpfx)check-localplt.out
|
||||
|
||||
ifeq ($(have-thread-library),yes)
|
||||
thread-dso := $(filter-out %_nonshared.a, $(shared-thread-library))
|
||||
endif
|
||||
|
||||
$(objpfx)check-localplt.out: $(objpfx)check-localplt $(common-objpfx)libc.so \
|
||||
$(common-objpfx)math/libm.so $(thread-dso) \
|
||||
$(common-objpfx)rt/librt.so \
|
||||
$(common-objpfx)dlfcn/libdl.so \
|
||||
$(check-data)
|
||||
$(objpfx)check-localplt $(common-objpfx)libc.so \
|
||||
$(common-objpfx)math/libm.so $(thread-dso) \
|
||||
$(common-objpfx)rt/librt.so \
|
||||
$(common-objpfx)dlfcn/libdl.so | \
|
||||
LC_ALL=C sort | \
|
||||
diff -u $(check-data) - > $@
|
||||
endif
|
||||
endif
|
||||
|
||||
$(objpfx)tst-dlopenrpathmod.so: $(libdl)
|
||||
|
299
elf/check-localplt.c
Normal file
299
elf/check-localplt.c
Normal file
@ -0,0 +1,299 @@
|
||||
/* Show local PLT use in DSOs.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contribute by Ulrich Drepper <drepper@redhat.com>. 2006.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <elf.h>
|
||||
#include <endian.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#ifdef BITS
|
||||
|
||||
# define AB(name) _AB (name, BITS)
|
||||
# define _AB(name, bits) __AB (name, bits)
|
||||
# define __AB(name, bits) name##bits
|
||||
# define E(name) _E (name, BITS)
|
||||
# define _E(name, bits) __E (name, bits)
|
||||
# define __E(name, bits) Elf##bits##_##name
|
||||
# define EE(name) _EE (name, BITS)
|
||||
# define _EE(name, bits) __EE (name, bits)
|
||||
# define __EE(name, bits) ELF##bits##_##name
|
||||
# define SWAP(val) \
|
||||
({ __typeof (val) __res; \
|
||||
if (((ehdr.e_ident[EI_DATA] == ELFDATA2MSB \
|
||||
&& BYTE_ORDER == LITTLE_ENDIAN) \
|
||||
|| (ehdr.e_ident[EI_DATA] == ELFDATA2LSB \
|
||||
&& BYTE_ORDER == BIG_ENDIAN)) \
|
||||
&& sizeof (val) != 1) \
|
||||
{ \
|
||||
if (sizeof (val) == 2) \
|
||||
__res = bswap_16 (val); \
|
||||
else if (sizeof (val) == 4) \
|
||||
__res = bswap_32 (val); \
|
||||
else \
|
||||
__res = bswap_64 (val); \
|
||||
} \
|
||||
else \
|
||||
__res = (val); \
|
||||
__res; })
|
||||
|
||||
|
||||
static int
|
||||
AB(handle_file) (const char *fname, int fd)
|
||||
{
|
||||
E(Ehdr) ehdr;
|
||||
|
||||
if (pread (fd, &ehdr, sizeof (ehdr), 0) != sizeof (ehdr))
|
||||
{
|
||||
read_error:
|
||||
printf ("%s: read error: %m\n", fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const size_t phnum = SWAP (ehdr.e_phnum);
|
||||
const size_t phentsize = SWAP (ehdr.e_phentsize);
|
||||
|
||||
/* Read the program header. */
|
||||
E(Phdr) *phdr = alloca (phentsize * phnum);
|
||||
if (pread (fd, phdr, phentsize * phnum, SWAP (ehdr.e_phoff))
|
||||
!= phentsize * phnum)
|
||||
goto read_error;
|
||||
|
||||
/* Search for the PT_DYNAMIC entry. */
|
||||
size_t cnt;
|
||||
E(Phdr) *dynphdr = NULL;
|
||||
for (cnt = 0; cnt < phnum; ++cnt)
|
||||
if (SWAP (phdr[cnt].p_type) == PT_DYNAMIC)
|
||||
{
|
||||
dynphdr = &phdr[cnt];
|
||||
break;
|
||||
}
|
||||
|
||||
if (dynphdr == NULL)
|
||||
{
|
||||
printf ("%s: no DYNAMIC segment found\n", fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the dynamic segment. */
|
||||
size_t pmemsz = SWAP(dynphdr->p_memsz);
|
||||
E(Dyn) *dyn = alloca (pmemsz);
|
||||
if (pread64 (fd, dyn, pmemsz, SWAP(dynphdr->p_offset)) != pmemsz)
|
||||
goto read_error;
|
||||
|
||||
/* Search for an DT_PLTREL, DT_JMPREL, DT_PLTRELSZ, DT_STRTAB,
|
||||
DT_STRSZ, and DT_SYMTAB entries. */
|
||||
size_t pltrel_idx = SIZE_MAX;
|
||||
size_t jmprel_idx = SIZE_MAX;
|
||||
size_t pltrelsz_idx = SIZE_MAX;
|
||||
size_t strtab_idx = SIZE_MAX;
|
||||
size_t strsz_idx = SIZE_MAX;
|
||||
size_t symtab_idx = SIZE_MAX;
|
||||
for (cnt = 0; (cnt + 1) * sizeof (E(Dyn)) - 1 < pmemsz; ++cnt)
|
||||
{
|
||||
unsigned int tag = SWAP (dyn[cnt].d_tag);
|
||||
|
||||
if (tag == DT_NULL)
|
||||
/* We reached the end. */
|
||||
break;
|
||||
|
||||
if (tag == DT_PLTREL)
|
||||
pltrel_idx = cnt;
|
||||
else if (tag == DT_JMPREL)
|
||||
jmprel_idx = cnt;
|
||||
else if (tag == DT_PLTRELSZ)
|
||||
pltrelsz_idx = cnt;
|
||||
else if (tag == DT_STRTAB)
|
||||
strtab_idx = cnt;
|
||||
else if (tag == DT_STRSZ)
|
||||
strsz_idx = cnt;
|
||||
else if (tag == DT_SYMTAB)
|
||||
symtab_idx = cnt;
|
||||
}
|
||||
|
||||
if (pltrel_idx == SIZE_MAX || jmprel_idx == SIZE_MAX
|
||||
|| pltrelsz_idx == SIZE_MAX || strtab_idx == SIZE_MAX
|
||||
|| strsz_idx == SIZE_MAX || symtab_idx == SIZE_MAX)
|
||||
{
|
||||
puts ("not all PLT information found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
E(Xword) relsz = SWAP (dyn[pltrelsz_idx].d_un.d_val);
|
||||
|
||||
void *relmem = NULL;
|
||||
char *strtab = NULL;
|
||||
E(Xword) symtab_offset = 0;
|
||||
|
||||
/* Find the offset of DT_JMPREL and load the data. */
|
||||
for (cnt = 0; cnt < phnum; ++cnt)
|
||||
if (SWAP (phdr[cnt].p_type) == PT_LOAD)
|
||||
{
|
||||
E(Addr) vaddr = SWAP (phdr[cnt].p_vaddr);
|
||||
E(Xword) memsz = SWAP (phdr[cnt].p_memsz);
|
||||
|
||||
if (vaddr <= SWAP (dyn[jmprel_idx].d_un.d_val)
|
||||
&& vaddr + memsz >= SWAP (dyn[jmprel_idx].d_un.d_val) + relsz)
|
||||
{
|
||||
relmem = alloca (SWAP (dyn[pltrelsz_idx].d_un.d_val));
|
||||
if (pread64 (fd, relmem, relsz,
|
||||
SWAP (phdr[cnt].p_offset)
|
||||
+ SWAP (dyn[jmprel_idx].d_un.d_val) - vaddr)
|
||||
!= relsz)
|
||||
{
|
||||
puts ("cannot read JMPREL");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (vaddr <= SWAP (dyn[symtab_idx].d_un.d_val)
|
||||
&& vaddr + memsz > SWAP (dyn[symtab_idx].d_un.d_val))
|
||||
symtab_offset = (SWAP (phdr[cnt].p_offset)
|
||||
+ SWAP (dyn[symtab_idx].d_un.d_val) - vaddr);
|
||||
|
||||
if (vaddr <= SWAP (dyn[strtab_idx].d_un.d_val)
|
||||
&& vaddr + memsz >= (SWAP (dyn[strtab_idx].d_un.d_val)
|
||||
+ SWAP(dyn[strsz_idx].d_un.d_val)))
|
||||
{
|
||||
strtab = alloca (SWAP(dyn[strsz_idx].d_un.d_val));
|
||||
if (pread64 (fd, strtab, SWAP(dyn[strsz_idx].d_un.d_val),
|
||||
SWAP (phdr[cnt].p_offset)
|
||||
+ SWAP (dyn[strtab_idx].d_un.d_val) - vaddr)
|
||||
!= SWAP(dyn[strsz_idx].d_un.d_val))
|
||||
{
|
||||
puts ("cannot read STRTAB");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (relmem == NULL || strtab == NULL || symtab_offset == 0)
|
||||
{
|
||||
puts ("couldn't load PLT data");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SWAP (dyn[pltrel_idx].d_un.d_val) == DT_RELA)
|
||||
for (E(Rela) *rela = relmem; (char *) rela - (char *) relmem < relsz;
|
||||
++rela)
|
||||
{
|
||||
E(Sym) sym;
|
||||
|
||||
if (pread64 (fd, &sym, sizeof (sym),
|
||||
symtab_offset
|
||||
+ EE(R_SYM) (SWAP (rela->r_info)) * sizeof (sym))
|
||||
!= sizeof (sym))
|
||||
{
|
||||
puts ("cannot read symbol");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sym.st_value != 0)
|
||||
/* This symbol is locally defined. */
|
||||
printf ("%s: %s\n", basename (fname), strtab + SWAP (sym.st_name));
|
||||
}
|
||||
else
|
||||
for (E(Rel) *rel = relmem; (char *) rel - (char *) relmem < relsz; ++rel)
|
||||
{
|
||||
E(Sym) sym;
|
||||
|
||||
if (pread64 (fd, &sym, sizeof (sym),
|
||||
symtab_offset
|
||||
+ EE(R_SYM) (SWAP (rel->r_info)) * sizeof (sym))
|
||||
!= sizeof (sym))
|
||||
{
|
||||
puts ("cannot read symbol");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sym.st_value != 0)
|
||||
/* This symbol is locally defined. */
|
||||
printf ("%s: %s\n", basename (fname), strtab + SWAP (sym.st_name));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# undef BITS
|
||||
#else
|
||||
|
||||
# define BITS 32
|
||||
# include "check-localplt.c"
|
||||
|
||||
# define BITS 64
|
||||
# include "check-localplt.c"
|
||||
|
||||
|
||||
static int
|
||||
handle_file (const char *fname)
|
||||
{
|
||||
int fd = open (fname, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
printf ("cannot open %s: %m\n", fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read was is supposed to be the ELF header. Read the initial
|
||||
bytes to determine whether this is a 32 or 64 bit file. */
|
||||
char ident[EI_NIDENT];
|
||||
if (read (fd, ident, EI_NIDENT) != EI_NIDENT)
|
||||
{
|
||||
printf ("%s: read error: %m\n", fname);
|
||||
close (fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (memcmp (&ident[EI_MAG0], ELFMAG, SELFMAG) != 0)
|
||||
{
|
||||
printf ("%s: not an ELF file\n", fname);
|
||||
close (fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result;
|
||||
if (ident[EI_CLASS] == ELFCLASS64)
|
||||
result = handle_file64 (fname, fd);
|
||||
else
|
||||
result = handle_file32 (fname, fd);
|
||||
|
||||
close (fd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int cnt;
|
||||
int result = 0;
|
||||
|
||||
for (cnt = 1; cnt < argc; ++cnt)
|
||||
result |= handle_file (argv[cnt]);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/* Check for text relocations in DSOs.
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contribute by Ulrich Drepper <drepper@redhat.com>. 2002.
|
||||
|
||||
@ -79,20 +79,28 @@ AB(handle_file) (const char *fname, int fd)
|
||||
|
||||
/* Search for the PT_DYNAMIC entry. */
|
||||
size_t cnt;
|
||||
E(Phdr) *dynphdr = NULL;
|
||||
for (cnt = 0; cnt < phnum; ++cnt)
|
||||
if (SWAP (phdr[cnt].p_type) == PT_DYNAMIC)
|
||||
break;
|
||||
dynphdr = &phdr[cnt];
|
||||
else if (SWAP (phdr[cnt].p_type) == PT_LOAD
|
||||
&& (SWAP (phdr[cnt].p_flags) & (PF_X | PF_W)) == (PF_X | PF_W))
|
||||
{
|
||||
printf ("%s: segment %zu is executable and writable\n",
|
||||
fname, cnt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cnt == phnum)
|
||||
if (dynphdr == NULL)
|
||||
{
|
||||
printf ("%s: no DYNAMIC segment found\n", fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the dynamic segment. */
|
||||
size_t pmemsz = SWAP(phdr[cnt].p_memsz);
|
||||
size_t pmemsz = SWAP(dynphdr->p_memsz);
|
||||
E(Dyn) *dyn = alloca (pmemsz);
|
||||
if (pread (fd, dyn, pmemsz, SWAP(phdr[cnt].p_offset)) != pmemsz)
|
||||
if (pread (fd, dyn, pmemsz, SWAP(dynphdr->p_offset)) != pmemsz)
|
||||
goto read_error;
|
||||
|
||||
/* Search for an DT_TEXTREL entry of DT_FLAGS with the DF_TEXTREL
|
||||
|
@ -247,6 +247,7 @@ _dl_map_object_deps (struct link_map *map,
|
||||
if (__builtin_expect (errstring != NULL, 0))
|
||||
{
|
||||
char *new_errstring = strdupa (errstring);
|
||||
objname = strdupa (objname);
|
||||
if (malloced)
|
||||
free ((char *) errstring);
|
||||
errstring = new_errstring;
|
||||
@ -337,6 +338,7 @@ _dl_map_object_deps (struct link_map *map,
|
||||
if (__builtin_expect (errstring != NULL, 0))
|
||||
{
|
||||
char *new_errstring = strdupa (errstring);
|
||||
objname = strdupa (objname);
|
||||
if (malloced)
|
||||
free ((char *) errstring);
|
||||
errstring = new_errstring;
|
||||
|
@ -3,5 +3,5 @@ glibc-branch := fedora
|
||||
glibc-base := HEAD
|
||||
DIST_BRANCH := devel
|
||||
COLLECTION := dist-fc4
|
||||
fedora-sync-date := 2006-01-09 21:52 UTC
|
||||
fedora-sync-tag := fedora-glibc-20060109T2152
|
||||
fedora-sync-date := 2006-01-30 09:22 UTC
|
||||
fedora-sync-tag := fedora-glibc-20060130T0922
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* longjmp cleanup function for unwinding past signal handlers.
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995,1996,1997,1998,2005,2006 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
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
#include <hurd.h>
|
||||
#include <thread_state.h>
|
||||
#include <setjmp.h>
|
||||
#include <jmpbuf-unwind.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -467,7 +467,7 @@ libc_freeres_fn (free_mem)
|
||||
if (cache_malloced)
|
||||
free (gconv_cache);
|
||||
#ifdef _POSIX_MAPPED_FILES
|
||||
else
|
||||
else if (gconv_cache != NULL)
|
||||
__munmap (gconv_cache, cache_size);
|
||||
#endif
|
||||
}
|
||||
|
@ -5,12 +5,14 @@ extra-objs := $(extra-objs) $(patsubst %,%.os,$($(mod)-routines))
|
||||
|
||||
$(objpfx)$(mod).so: $(addprefix $(objpfx),$(addsuffix .os,$($(mod)-routines)))\
|
||||
$(common-objpfx)shlib.lds
|
||||
$(build-module)
|
||||
$(build-module-asneeded)
|
||||
|
||||
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
|
||||
# This ensures they will load libc.so for needed symbols if loaded by
|
||||
# a statically-linked program that hasn't already loaded it.
|
||||
$(objpfx)$(mod).so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
|
||||
$(objpfx)$(mod).so: $(common-objpfx)libc.so \
|
||||
$(common-objpfx)/elf/ld.so \
|
||||
$(common-objpfx)libc_nonshared.a
|
||||
|
||||
ifneq (,$(extra-modules-left))
|
||||
include extra-module.mk
|
||||
|
@ -25,4 +25,8 @@ extern void __atfct_seterrno_2 (int errval, int fd1, const char *buf1,
|
||||
int fd2, const char *buf2)
|
||||
attribute_hidden;
|
||||
|
||||
|
||||
/* Flag determining whether the *at system calls are available. */
|
||||
extern int __have_atfcts attribute_hidden;
|
||||
|
||||
#endif
|
||||
|
@ -10,6 +10,7 @@ extern int __sched_setscheduler (__pid_t __pid, int __policy,
|
||||
libc_hidden_proto (__sched_setscheduler)
|
||||
extern int __sched_getscheduler (__pid_t __pid);
|
||||
extern int __sched_yield (void);
|
||||
libc_hidden_proto (__sched_yield)
|
||||
extern int __sched_get_priority_max (int __algorithm);
|
||||
extern int __sched_get_priority_min (int __algorithm);
|
||||
extern int __sched_rr_get_interval (__pid_t __pid, struct timespec *__t);
|
||||
|
@ -25,10 +25,6 @@ libc_hidden_proto (abort)
|
||||
libc_hidden_proto (getenv)
|
||||
libc_hidden_proto (bsearch)
|
||||
libc_hidden_proto (qsort)
|
||||
libc_hidden_proto (ecvt_r)
|
||||
libc_hidden_proto (fcvt_r)
|
||||
libc_hidden_proto (qecvt_r)
|
||||
libc_hidden_proto (qfcvt_r)
|
||||
libc_hidden_proto (lrand48_r)
|
||||
libc_hidden_proto (wctomb)
|
||||
libc_hidden_proto (__secure_getenv)
|
||||
@ -186,6 +182,28 @@ __NTH (__strtoull_l (__const char * __restrict __nptr,
|
||||
return ____strtoull_l_internal (__nptr, __endptr, __base, 0, __loc);
|
||||
}
|
||||
|
||||
extern char *__ecvt (double __value, int __ndigit, int *__restrict __decpt,
|
||||
int *__restrict __sign);
|
||||
extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt,
|
||||
int *__restrict __sign);
|
||||
extern char *__gcvt (double __value, int __ndigit, char *__buf);
|
||||
extern int __ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
|
||||
int *__restrict __sign, char *__restrict __buf,
|
||||
size_t __len);
|
||||
extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
|
||||
int *__restrict __sign, char *__restrict __buf,
|
||||
size_t __len);
|
||||
extern char *__qecvt (long double __value, int __ndigit,
|
||||
int *__restrict __decpt, int *__restrict __sign);
|
||||
extern char *__qfcvt (long double __value, int __ndigit,
|
||||
int *__restrict __decpt, int *__restrict __sign);
|
||||
extern char *__qgcvt (long double __value, int __ndigit, char *__buf);
|
||||
extern int __qecvt_r (long double __value, int __ndigit,
|
||||
int *__restrict __decpt, int *__restrict __sign,
|
||||
char *__restrict __buf, size_t __len);
|
||||
extern int __qfcvt_r (long double __value, int __ndigit,
|
||||
int *__restrict __decpt, int *__restrict __sign,
|
||||
char *__restrict __buf, size_t __len);
|
||||
|
||||
# ifndef NOT_IN_libc
|
||||
# undef MB_CUR_MAX
|
||||
|
@ -31,6 +31,8 @@ extern __inline__ int __mknod (__const char *__path, __mode_t __mode,
|
||||
}
|
||||
libc_hidden_proto (__xmknodat)
|
||||
|
||||
libc_hidden_proto (__fxstatat64)
|
||||
|
||||
|
||||
/* The `stat', `fstat', `lstat' functions have to be handled special since
|
||||
even while not compiling the library with optimization calls to these
|
||||
|
@ -92,7 +92,7 @@ extern int __getclktck (void);
|
||||
/* strptime support. */
|
||||
/* Status of lookup: do we use the locale data or the raw data? */
|
||||
#ifndef __cplusplus
|
||||
// C++ cannot deal with using 'not'.
|
||||
/* C++ cannot deal with using 'not'. */
|
||||
enum ptime_locale_status { not, loc, raw };
|
||||
|
||||
extern char * __strptime_internal (const char *rp, const char *fmt,
|
||||
|
@ -107,18 +107,21 @@ extern int __vswprintf (wchar_t *__restrict __s, size_t __n,
|
||||
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
|
||||
extern int __fwprintf (__FILE *__restrict __s,
|
||||
__const wchar_t *__restrict __format, ...)
|
||||
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
|
||||
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
|
||||
extern int __vfwprintf (__FILE *__restrict __s,
|
||||
__const wchar_t *__restrict __format,
|
||||
__gnuc_va_list __arg)
|
||||
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
|
||||
extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
|
||||
const wchar_t *__restrict __format,
|
||||
__gnuc_va_list __arg)
|
||||
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
|
||||
|
||||
|
||||
extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
|
||||
int __flag, size_t __s_len,
|
||||
__const wchar_t *__restrict __format,
|
||||
__gnuc_va_list __arg)
|
||||
/* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
|
||||
libc_hidden_proto (__vfwprintf_chk)
|
||||
libc_hidden_proto (__vswprintf_chk)
|
||||
|
||||
/* Internal functions. */
|
||||
|
@ -48,7 +48,7 @@ routines := \
|
||||
ttyname ttyname_r isatty \
|
||||
link linkat symlink symlinkat readlink readlinkat \
|
||||
unlink unlinkat rmdir \
|
||||
ftw ftw64 fts poll \
|
||||
ftw ftw64 fts poll ppoll \
|
||||
posix_fadvise posix_fadvise64 \
|
||||
posix_fallocate posix_fallocate64 \
|
||||
sendfile sendfile64
|
||||
@ -64,7 +64,9 @@ test-srcs := ftwtest
|
||||
tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \
|
||||
tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
|
||||
tst-openat tst-unlinkat tst-fstatat tst-futimesat \
|
||||
tst-renameat tst-fchownat tst-fchmodat tst-faccessat
|
||||
tst-renameat tst-fchownat tst-fchmodat tst-faccessat \
|
||||
tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \
|
||||
tst-mknodat tst-mkfifoat
|
||||
|
||||
distribute := ftwtest-sh
|
||||
|
||||
@ -72,6 +74,7 @@ include ../Rules
|
||||
|
||||
CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
|
||||
CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
|
||||
CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables
|
||||
CFLAGS-lockf.c = -fexceptions
|
||||
CFLAGS-statfs.c = -fexceptions
|
||||
CFLAGS-fstatfs.c = -fexceptions
|
||||
|
@ -110,5 +110,7 @@ libc {
|
||||
readlinkat;
|
||||
symlinkat;
|
||||
unlinkat;
|
||||
|
||||
ppoll;
|
||||
}
|
||||
}
|
||||
|
76
io/ppoll.c
Normal file
76
io/ppoll.c
Normal file
@ -0,0 +1,76 @@
|
||||
/* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h> /* For NULL. */
|
||||
#include <sys/poll.h>
|
||||
#include <sysdep-cancel.h>
|
||||
|
||||
|
||||
int
|
||||
ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
|
||||
const sigset_t *sigmask)
|
||||
{
|
||||
int tval = -1;
|
||||
|
||||
/* poll uses a simple millisecond value. Convert it. */
|
||||
if (timeout != NULL)
|
||||
{
|
||||
if (timeout->tv_sec < 0
|
||||
|| timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (timeout->tv_sec > INT_MAX / 1000
|
||||
|| (timeout->tv_sec == INT_MAX / 1000
|
||||
&& ((timeout->tv_nsec + 999999) / 1000000 > INT_MAX % 1000)))
|
||||
/* We cannot represent the timeout in an int value. Wait
|
||||
forever. */
|
||||
tval = -1;
|
||||
else
|
||||
tval = (timeout->tv_sec * 1000
|
||||
+ (timeout->tv_nsec + 999999) / 1000000);
|
||||
}
|
||||
|
||||
/* The setting and restoring of the signal mask and the select call
|
||||
should be an atomic operation. This can't be done without kernel
|
||||
help. */
|
||||
sigset_t savemask;
|
||||
if (sigmask != NULL)
|
||||
__sigprocmask (SIG_SETMASK, sigmask, &savemask);
|
||||
|
||||
/* Note the ppoll() is a cancellation point. But since we call
|
||||
poll() which itself is a cancellation point we do not have
|
||||
to do anything here. */
|
||||
int retval = __poll (fds, nfds, tval);
|
||||
|
||||
if (sigmask != NULL)
|
||||
__sigprocmask (SIG_SETMASK, &savemask, NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#ifndef ppoll
|
||||
/* __poll handles cancellation. */
|
||||
LIBC_CANCEL_HANDLED ();
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/* Compatibility definitions for System V `poll' interface.
|
||||
Copyright (C) 1994,1996-2001,2004,2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994,1996-2001,2004,2005,2006 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
|
||||
@ -24,6 +24,13 @@
|
||||
|
||||
/* Get the platform dependent bits of `poll'. */
|
||||
#include <bits/poll.h>
|
||||
#ifdef __USE_GNU
|
||||
/* Get the __sigset_t definition. */
|
||||
# include <bits/sigset.h>
|
||||
/* Get the timespec definition. */
|
||||
# define __need_timespec
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Type used for the number of file descriptors. */
|
||||
@ -50,6 +57,18 @@ __BEGIN_DECLS
|
||||
__THROW. */
|
||||
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
/* Like poll, but before waiting the threads signal mask is replaced
|
||||
with that specified in the fourth parameter. For better usability,
|
||||
the timeout value is specified using a TIMESPEC object.
|
||||
|
||||
This function is a cancellation point and therefore not marked with
|
||||
__THROW. */
|
||||
extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
|
||||
__const struct timespec *__timeout,
|
||||
__const __sigset_t *__ss);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* sys/poll.h */
|
||||
|
@ -98,6 +98,20 @@ do_test (void)
|
||||
write (fd, "hello", 5);
|
||||
puts ("file created");
|
||||
|
||||
/* Before closing the file, try using this file descriptor to open
|
||||
another file. This must fail. */
|
||||
if (faccessat (fd, "should-not-work", F_OK, AT_EACCESS) != -1)
|
||||
{
|
||||
puts ("faccessat using descriptor for normal file worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("\
|
||||
error for faccessat using descriptor for normal file not ENOTDIR ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
int result = 0;
|
||||
@ -135,12 +149,45 @@ do_test (void)
|
||||
|
||||
errno = 0;
|
||||
if (faccessat (dir_fd, "some-file", W_OK, AT_EACCESS) == 0
|
||||
|| errno != EACCES)
|
||||
? (geteuid () != 0) : (errno != EACCES))
|
||||
{
|
||||
printf ("faccessat W_OK on unwritable file: %m\n");
|
||||
result = 1;
|
||||
}
|
||||
|
||||
/* Create a file descriptor which is closed again right away. */
|
||||
int dir_fd2 = dup (dir_fd);
|
||||
if (dir_fd2 == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
close (dir_fd2);
|
||||
|
||||
/* With the file descriptor closed the next call must fail. */
|
||||
if (faccessat (dir_fd2, "some-file", F_OK, AT_EACCESS) != -1)
|
||||
{
|
||||
puts ("faccessat using closed descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("faccessat using closed descriptor did not set EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Same with a non-existing file. */
|
||||
if (faccessat (dir_fd2, "non-existing-file", F_OK, AT_EACCESS) != -1)
|
||||
{
|
||||
puts ("2nd faccessat using closed descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("2nd faccessat using closed descriptor did not set EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "some-file", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
@ -149,5 +196,17 @@ do_test (void)
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
fd = faccessat (-1, "some-file", F_OK, AT_EACCESS);
|
||||
if (fd != -1)
|
||||
{
|
||||
puts ("faccessat using -1 descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("faccessat using -1 descriptor did not set EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -107,6 +107,20 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Before closing the file, try using this file descriptor to open
|
||||
another file. This must fail. */
|
||||
if (fchmodat (fd, "some-file", 0400, 0) != -1)
|
||||
{
|
||||
puts ("fchmodat using descriptor for normal file worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("\
|
||||
error for fchmodat using descriptor for normal file not ENOTDIR ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if ((st1.st_mode & 0777) != 0644)
|
||||
@ -140,7 +154,38 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a file descriptor which is closed again right away. */
|
||||
int dir_fd2 = dup (dir_fd);
|
||||
if (dir_fd2 == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
close (dir_fd2);
|
||||
|
||||
if (fchmodat (dir_fd2, "some-file", 0400, 0) != -1)
|
||||
{
|
||||
puts ("fchmodat using closed descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fchmodat using closed descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
if (fchmodat (-1, "some-file", 0400, 0) != -1)
|
||||
{
|
||||
puts ("fchmodat using invalid descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fchmodat using invalid descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -112,6 +112,20 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Before closing the file, try using this file descriptor to open
|
||||
another file. This must fail. */
|
||||
if (fchownat (fd, "some-file", 1, 1, 0) != -1)
|
||||
{
|
||||
puts ("fchownat using descriptor for normal file worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("\
|
||||
error for fchownat using descriptor for normal file not ENOTDIR ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if (fchownat (dir_fd, "some-file", st1.st_uid + 1, st1.st_gid + 1, 0) != 0)
|
||||
@ -139,7 +153,38 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a file descriptor which is closed again right away. */
|
||||
int dir_fd2 = dup (dir_fd);
|
||||
if (dir_fd2 == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
close (dir_fd2);
|
||||
|
||||
if (fchownat (dir_fd2, "some-file", 1, 1, 0) != -1)
|
||||
{
|
||||
puts ("fchownat using closed descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fchownat using closed descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
if (fchownat (-1, "some-file", 1, 1, 0) != -1)
|
||||
{
|
||||
puts ("fchownat using invalid descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fchownat using invalid descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -97,6 +97,20 @@ do_test (void)
|
||||
puts ("file created");
|
||||
|
||||
struct stat64 st1;
|
||||
|
||||
/* Before closing the file, try using this file descriptor to open
|
||||
another file. This must fail. */
|
||||
if (fstatat64 (fd, "some-file", &st1, 0) != -1)
|
||||
{
|
||||
puts ("fstatatat using descriptor for normal file worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("error for fstatat using descriptor for normal file not ENOTDIR ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstat64 (fd, &st1) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
@ -137,7 +151,38 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a file descriptor which is closed again right away. */
|
||||
int dir_fd2 = dup (dir_fd);
|
||||
if (dir_fd2 == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
close (dir_fd2);
|
||||
|
||||
if (fstatat64 (dir_fd2, "some-file", &st1, 0) != -1)
|
||||
{
|
||||
puts ("fstatat64 using closed descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fstatat using closed descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
if (fstatat64 (-1, "some-file", &st1, 0) != -1)
|
||||
{
|
||||
puts ("fstatat64 using invalid descriptor worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for fstatat using invalid descriptor not EBADF ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
171
io/tst-linkat.c
Normal file
171
io/tst-linkat.c
Normal file
@ -0,0 +1,171 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-linkat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
/* Try to create a file. */
|
||||
int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666);
|
||||
if (fd == -1)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
puts ("*at functions not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts ("file creation failed");
|
||||
return 1;
|
||||
}
|
||||
write (fd, "hello", 5);
|
||||
puts ("file created");
|
||||
|
||||
struct stat64 st1;
|
||||
if (fstat64 (fd, &st1) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if (linkat (dir_fd, "some-file", dir_fd, "another-file") != 0)
|
||||
{
|
||||
puts ("symlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st2;
|
||||
if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
|
||||
{
|
||||
puts ("fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
|
||||
{
|
||||
puts ("file changed after symlinkat");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
{
|
||||
puts ("2nd fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (S_ISLNK (st2.st_mode))
|
||||
{
|
||||
puts ("2nd fstatat64 shows file is a symlink");
|
||||
return 1;
|
||||
}
|
||||
if (st1.st_dev != st2.st_dev
|
||||
|| st1.st_ino != st2.st_ino
|
||||
|| st1.st_size != st2.st_size)
|
||||
{
|
||||
puts ("stat results for linked file do not match");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstatat64 (dir_fd, "another-file", &st2, 0) != 0)
|
||||
{
|
||||
puts ("3rd fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (st1.st_dev != st2.st_dev
|
||||
|| st1.st_ino != st2.st_ino
|
||||
|| st1.st_size != st2.st_size)
|
||||
{
|
||||
puts ("stat results do not match");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "another-file", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
if (unlinkat (dir_fd, "some-file", 0) != 0)
|
||||
{
|
||||
puts ("2nd unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
162
io/tst-mkdirat.c
Normal file
162
io/tst-mkdirat.c
Normal file
@ -0,0 +1,162 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-mkdirat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
/* Create a new directory. */
|
||||
int e = mkdirat (dir_fd, "some-dir", 0777);
|
||||
if (e == -1)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
puts ("*at functions not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts ("directory creation failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st1;
|
||||
if (fstatat64 (dir_fd, "some-dir", &st1, 0) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (!S_ISDIR (st1.st_mode))
|
||||
{
|
||||
puts ("mkdirat did not create a directory");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("2nd fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
bool has_some_dir = false;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, "some-dir") == 0)
|
||||
{
|
||||
has_some_dir = true;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if (d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
|
||||
{
|
||||
puts ("d_type for some-dir wrong");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
if (!has_some_dir)
|
||||
{
|
||||
puts ("some-dir not in directory list");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "some-dir", AT_REMOVEDIR) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
162
io/tst-mkfifoat.c
Normal file
162
io/tst-mkfifoat.c
Normal file
@ -0,0 +1,162 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-mkfifoat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
/* Create a new directory. */
|
||||
int e = mkfifoat (dir_fd, "some-fifo", 0777);
|
||||
if (e == -1)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
puts ("*at functions not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts ("fifo creation failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st1;
|
||||
if (fstatat64 (dir_fd, "some-fifo", &st1, 0) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (!S_ISFIFO (st1.st_mode))
|
||||
{
|
||||
puts ("mkfifoat did not create FIFO");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("2nd fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
bool has_some_fifo = false;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, "some-fifo") == 0)
|
||||
{
|
||||
has_some_fifo = true;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if (d->d_type != DT_UNKNOWN && d->d_type != DT_FIFO)
|
||||
{
|
||||
puts ("d_type for some-fifo wrong");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
if (!has_some_fifo)
|
||||
{
|
||||
puts ("some-fifo not in directory list");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "some-fifo", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
162
io/tst-mknodat.c
Normal file
162
io/tst-mknodat.c
Normal file
@ -0,0 +1,162 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-mknodat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
/* Create a new directory. */
|
||||
int e = mknodat (dir_fd, "some-sock", 0777 | S_IFSOCK, 0);
|
||||
if (e == -1)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
puts ("*at functions not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts ("socket creation failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st1;
|
||||
if (fstatat64 (dir_fd, "some-sock", &st1, 0) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (!S_ISSOCK (st1.st_mode))
|
||||
{
|
||||
puts ("mknodat did not create a Unix domain socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("2nd fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
bool has_some_sock = false;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, "some-sock") == 0)
|
||||
{
|
||||
has_some_sock = true;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if (d->d_type != DT_UNKNOWN && d->d_type != DT_SOCK)
|
||||
{
|
||||
puts ("d_type for some-sock wrong");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
if (!has_some_sock)
|
||||
{
|
||||
puts ("some-sock not in directory list");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "some-sock", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
@ -94,6 +94,21 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
write (fd, "hello", 5);
|
||||
|
||||
/* Before closing the file, try using this file descriptor to open
|
||||
another file. This must fail. */
|
||||
int fd2 = openat (fd, "should-not-work", O_CREAT|O_RDWR, 0666);
|
||||
if (fd2 != -1)
|
||||
{
|
||||
puts ("openat using descriptor for normal file worked");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("error for openat using descriptor for normal file not ENOTDIR ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
puts ("file created");
|
||||
|
||||
@ -165,5 +180,30 @@ do_test (void)
|
||||
close (dir_fd);
|
||||
close (cwdfd);
|
||||
|
||||
/* With the file descriptor closed the next call must fail. */
|
||||
fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666);
|
||||
if (fd != -1)
|
||||
{
|
||||
puts ("openat using closed descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("openat using closed descriptor did not set EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = openat (-1, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666);
|
||||
if (fd != -1)
|
||||
{
|
||||
puts ("openat using -1 descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("openat using -1 descriptor did not set EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
136
io/tst-readlinkat.c
Normal file
136
io/tst-readlinkat.c
Normal file
@ -0,0 +1,136 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-symlinkat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
static const char symlinkcontent[] = "some-file";
|
||||
if (symlinkat (symlinkcontent, dir_fd, "another-file") != 0)
|
||||
{
|
||||
puts ("symlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st2;
|
||||
if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
{
|
||||
puts ("fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (!S_ISLNK (st2.st_mode))
|
||||
{
|
||||
puts ("2nd fstatat64 does not show file is a symlink");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstatat64 (dir_fd, symlinkcontent, &st2, AT_SYMLINK_NOFOLLOW) == 0)
|
||||
{
|
||||
puts ("2nd fstatat64 succeeded");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buf[100];
|
||||
int n = readlinkat (dir_fd, "another-file", buf, sizeof (buf));
|
||||
if (n == -1)
|
||||
{
|
||||
puts ("readlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
if (n != sizeof (symlinkcontent) - 1)
|
||||
{
|
||||
printf ("readlinkat returned %d, expected %zu\n",
|
||||
n, sizeof (symlinkcontent) - 1);
|
||||
return 1;
|
||||
}
|
||||
if (strncmp (buf, symlinkcontent, n) != 0)
|
||||
{
|
||||
puts ("readlinkat retrieved wrong link content");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "another-file", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
@ -103,6 +103,29 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Using a descriptor for a normal file must fail. */
|
||||
if (renameat (fd, "some-file", dir_fd, "another-file") == 0)
|
||||
{
|
||||
puts ("renameat with normal file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("error for renameat with normal file descriptor not ENOTDIR");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (renameat (dir_fd, "some-file", fd, "another-file") == 0)
|
||||
{
|
||||
puts ("2nd renameat with normal file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENOTDIR)
|
||||
{
|
||||
puts ("error for 2nd renameat with normal file descriptor not ENOTDIR");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if (renameat (dir_fd, "some-file", dir_fd, "another-file") != 0)
|
||||
@ -137,12 +160,65 @@ do_test (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a file descriptor which is closed again right away. */
|
||||
int dir_fd2 = dup (dir_fd);
|
||||
if (dir_fd2 == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
close (dir_fd2);
|
||||
|
||||
if (renameat (dir_fd2, "another-file", dir_fd, "some-file") == 0)
|
||||
{
|
||||
puts ("renameat with closed file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for renameat with closed file descriptor not EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (renameat (dir_fd, "another-file", dir_fd2, "some-file") == 0)
|
||||
{
|
||||
puts ("2nd renameat with closed file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for 2nd renameat with closed file descriptor not EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "another-file", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (renameat (-1, "another-file", dir_fd, "some-file") == 0)
|
||||
{
|
||||
puts ("renameat with invalid file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for renameat with invalid file descriptor not EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (renameat (dir_fd, "another-file", -1, "some-file") == 0)
|
||||
{
|
||||
puts ("2nd renameat with invalid file descriptor succeeded");
|
||||
return 1;
|
||||
}
|
||||
if (errno != EBADF)
|
||||
{
|
||||
puts ("error for 2nd renameat with invalid file descriptor not EBADF");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
|
164
io/tst-symlinkat.c
Normal file
164
io/tst-symlinkat.c
Normal file
@ -0,0 +1,164 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ()
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
static int dir_fd;
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
size_t test_dir_len = strlen (test_dir);
|
||||
static const char dir_name[] = "/tst-symlinkat.XXXXXX";
|
||||
|
||||
size_t dirbuflen = test_dir_len + sizeof (dir_name);
|
||||
char *dirbuf = malloc (dirbuflen);
|
||||
if (dirbuf == NULL)
|
||||
{
|
||||
puts ("out of memory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);
|
||||
if (mkdtemp (dirbuf) == NULL)
|
||||
{
|
||||
puts ("cannot create temporary directory");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
add_temp_file (dirbuf);
|
||||
|
||||
dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY);
|
||||
if (dir_fd == -1)
|
||||
{
|
||||
puts ("cannot open directory");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
/* fdopendir takes over the descriptor, make a copy. */
|
||||
int dupfd = dup (dir_fd);
|
||||
if (dupfd == -1)
|
||||
{
|
||||
puts ("dup failed");
|
||||
return 1;
|
||||
}
|
||||
if (lseek (dupfd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
puts ("1st lseek failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The directory should be empty safe the . and .. files. */
|
||||
DIR *dir = fdopendir (dupfd);
|
||||
if (dir == NULL)
|
||||
{
|
||||
puts ("fdopendir failed");
|
||||
return 1;
|
||||
}
|
||||
struct dirent64 *d;
|
||||
while ((d = readdir64 (dir)) != NULL)
|
||||
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
|
||||
{
|
||||
printf ("temp directory contains file \"%s\"\n", d->d_name);
|
||||
return 1;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
/* Try to create a file. */
|
||||
int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666);
|
||||
if (fd == -1)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
puts ("*at functions not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts ("file creation failed");
|
||||
return 1;
|
||||
}
|
||||
write (fd, "hello", 5);
|
||||
puts ("file created");
|
||||
|
||||
struct stat64 st1;
|
||||
if (fstat64 (fd, &st1) != 0)
|
||||
{
|
||||
puts ("fstat64 failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if (symlinkat ("some-file", dir_fd, "another-file") != 0)
|
||||
{
|
||||
puts ("symlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat64 st2;
|
||||
if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
|
||||
{
|
||||
puts ("fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
|
||||
{
|
||||
puts ("file changed after symlinkat");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
{
|
||||
puts ("2nd fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (!S_ISLNK (st2.st_mode))
|
||||
{
|
||||
puts ("2nd fstatat64 does not show file is a symlink");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstatat64 (dir_fd, "another-file", &st2, 0) != 0)
|
||||
{
|
||||
puts ("3rd fstatat64 failed");
|
||||
return 1;
|
||||
}
|
||||
if (st1.st_dev != st2.st_dev
|
||||
|| st1.st_ino != st2.st_ino
|
||||
|| st1.st_size != st2.st_size)
|
||||
{
|
||||
puts ("stat results do not match");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlinkat (dir_fd, "another-file", 0) != 0)
|
||||
{
|
||||
puts ("unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
if (unlinkat (dir_fd, "some-file", 0) != 0)
|
||||
{
|
||||
puts ("2nd unlinkat failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close (dir_fd);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1995-2002,2003,2004,2006 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
|
||||
@ -22,7 +22,7 @@
|
||||
subdir := libio
|
||||
|
||||
headers := stdio.h libio.h _G_config.h bits/stdio.h bits/stdio-lock.h \
|
||||
bits/sys_errlist.h bits/stdio2.h
|
||||
bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h
|
||||
|
||||
routines := \
|
||||
filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
|
||||
@ -35,7 +35,7 @@ routines := \
|
||||
iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \
|
||||
putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \
|
||||
wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \
|
||||
wstrops wfileops iofwide fwide \
|
||||
wstrops wfileops iofwide fwide wmemstream \
|
||||
\
|
||||
clearerr feof ferror fileno fputc freopen fseek getc getchar \
|
||||
memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
|
||||
@ -54,7 +54,9 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
|
||||
tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
|
||||
tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
|
||||
tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \
|
||||
bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4
|
||||
bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \
|
||||
tst-memstream1 tst-memstream2 \
|
||||
tst-wmemstream1 tst-wmemstream2
|
||||
test-srcs = test-freopen
|
||||
|
||||
all: # Make this the default target; it will be defined in Rules.
|
||||
|
@ -145,6 +145,9 @@ libc {
|
||||
# w*
|
||||
wprintf; wscanf;
|
||||
}
|
||||
GLIBC_2.4 {
|
||||
open_wmemstream;
|
||||
}
|
||||
GLIBC_PRIVATE {
|
||||
# Used by NPTL and librt
|
||||
__libc_fatal;
|
||||
|
27
libio/bits/libio-ldbl.h
Normal file
27
libio/bits/libio-ldbl.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* -mlong-double-64 compatibility mode for libio functions.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _IO_STDIO_H
|
||||
# error "Never include <bits/libio-ldbl.h> directly; use <libio.h> instead."
|
||||
#endif
|
||||
|
||||
__LDBL_REDIR_DECL (_IO_vfscanf)
|
||||
__LDBL_REDIR_DECL (_IO_vfprintf)
|
||||
__LDBL_REDIR_DECL (_IO_vfwscanf)
|
||||
__LDBL_REDIR_DECL (_IO_vfwprintf)
|
74
libio/bits/stdio-ldbl.h
Normal file
74
libio/bits/stdio-ldbl.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* -mlong-double-64 compatibility mode for stdio functions.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _STDIO_H
|
||||
# error "Never include <bits/stdio-ldbl.h> directly; use <stdio.h> instead."
|
||||
#endif
|
||||
|
||||
__BEGIN_NAMESPACE_STD
|
||||
__LDBL_REDIR_DECL (fprintf)
|
||||
__LDBL_REDIR_DECL (printf)
|
||||
__LDBL_REDIR_DECL (sprintf)
|
||||
__LDBL_REDIR_DECL (vfprintf)
|
||||
__LDBL_REDIR_DECL (vprintf)
|
||||
__LDBL_REDIR_DECL (vsprintf)
|
||||
__LDBL_REDIR_DECL (fscanf)
|
||||
__LDBL_REDIR_DECL (scanf)
|
||||
__LDBL_REDIR_DECL (sscanf)
|
||||
__END_NAMESPACE_STD
|
||||
|
||||
#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
|
||||
__BEGIN_NAMESPACE_C99
|
||||
__LDBL_REDIR_DECL (snprintf)
|
||||
__LDBL_REDIR_DECL (vsnprintf)
|
||||
__END_NAMESPACE_C99
|
||||
#endif
|
||||
|
||||
#ifdef __USE_ISOC99
|
||||
__BEGIN_NAMESPACE_C99
|
||||
__LDBL_REDIR_DECL (vfscanf)
|
||||
__LDBL_REDIR_DECL (vsscanf)
|
||||
__LDBL_REDIR_DECL (vscanf)
|
||||
__END_NAMESPACE_C99
|
||||
#endif
|
||||
|
||||
#ifdef __USE_GNU
|
||||
__LDBL_REDIR_DECL (vdprintf)
|
||||
__LDBL_REDIR_DECL (dprintf)
|
||||
__LDBL_REDIR_DECL (vasprintf)
|
||||
__LDBL_REDIR_DECL (__asprintf)
|
||||
__LDBL_REDIR_DECL (asprintf)
|
||||
__LDBL_REDIR_DECL (obstack_printf)
|
||||
__LDBL_REDIR_DECL (obstack_vprintf)
|
||||
#endif
|
||||
|
||||
#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
|
||||
__LDBL_REDIR_DECL (__sprintf_chk)
|
||||
__LDBL_REDIR_DECL (__vsprintf_chk)
|
||||
# if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
|
||||
__LDBL_REDIR_DECL (__snprintf_chk)
|
||||
__LDBL_REDIR_DECL (__vsnprintf_chk)
|
||||
# endif
|
||||
# if __USE_FORTIFY_LEVEL > 1
|
||||
__LDBL_REDIR_DECL (__fprintf_chk)
|
||||
__LDBL_REDIR_DECL (__printf_chk)
|
||||
__LDBL_REDIR_DECL (__vfprintf_chk)
|
||||
__LDBL_REDIR_DECL (__vprintf_chk)
|
||||
# endif
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1995, 1997-2004, 2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1995, 1997-2005, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Per Bothner <bothner@cygnus.com>.
|
||||
|
||||
@ -399,6 +399,9 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
|
||||
/* And now the transliteration. */
|
||||
cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
|
||||
|
||||
/* From now on use the wide character callback functions. */
|
||||
((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable;
|
||||
|
||||
/* Set the mode now. */
|
||||
result->_mode = 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993,1996,1997,1998,1999,2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993,1996,1997,1998,1999,2003, 2006 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
|
||||
@ -33,7 +33,7 @@ fputwc (wc, fp)
|
||||
wchar_t wc;
|
||||
_IO_FILE *fp;
|
||||
{
|
||||
int result;
|
||||
wint_t result;
|
||||
CHECK_FILE (fp, EOF);
|
||||
_IO_acquire_lock (fp);
|
||||
if (_IO_fwide (fp, 1) < 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1996, 1997, 1999, 2006 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
|
||||
@ -35,7 +35,7 @@ fputwc_unlocked (wc, fp)
|
||||
wchar_t wc;
|
||||
_IO_FILE *fp;
|
||||
{
|
||||
CHECK_FILE (fp, EOF);
|
||||
CHECK_FILE (fp, WEOF);
|
||||
if (_IO_fwide (fp, 1) < 0)
|
||||
return WEOF;
|
||||
return _IO_putwc_unlocked (wc, fp);
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1997, 1999, 2000, 2001, 2006
|
||||
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
|
||||
@ -16,6 +17,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@ -35,4 +37,4 @@ __fwprintf (FILE *stream, const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
weak_alias (__fwprintf, fwprintf)
|
||||
ldbl_weak_alias (__fwprintf, fwprintf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1997, 1999, 2000, 2006 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
|
||||
@ -16,6 +16,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@ -23,7 +24,7 @@
|
||||
/* Read formatted input from STREAM according to the format string FORMAT. */
|
||||
/* VARARGS2 */
|
||||
int
|
||||
fwscanf (FILE *stream, const wchar_t *format, ...)
|
||||
__fwscanf (FILE *stream, const wchar_t *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -34,3 +35,4 @@ fwscanf (FILE *stream, const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (__fwscanf, fwscanf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1993,1995,1997-2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993,1995,1997-2002, 2003, 2004, 2006
|
||||
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
|
||||
@ -657,6 +658,7 @@ _IO_no_init (fp, flags, orientation, wd, jmp)
|
||||
fp->_wide_data->_wide_vtable = jmp;
|
||||
}
|
||||
#endif
|
||||
fp->_freeres_list = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@ -914,10 +916,27 @@ INTDEF(_IO_flush_all_linebuffered)
|
||||
weak_alias (_IO_flush_all_linebuffered, _flushlbf)
|
||||
#endif
|
||||
|
||||
|
||||
/* The following is a bit tricky. In general, we want to unbuffer the
|
||||
streams so that all output which follows is seen. If we are not
|
||||
looking for memory leaks it does not make much sense to free the
|
||||
actual buffer because this will happen anyway once the program
|
||||
terminated. If we do want to look for memory leaks we have to free
|
||||
the buffers. Whether something is freed is determined by the
|
||||
function sin the libc_freeres section. Those are called as part of
|
||||
the atexit routine, just like _IO_cleanup. The problem is we do
|
||||
not know whether the freeres code is called first or _IO_cleanup.
|
||||
if the former is the case, we set the DEALLOC_BUFFER variable to
|
||||
true and _IO_unbuffer_write will take care of the rest. If
|
||||
_IO_unbuffer_write is called first we add the streams to a list
|
||||
which the freeres function later can walk through. */
|
||||
static void _IO_unbuffer_write (void);
|
||||
|
||||
static bool dealloc_buffers;
|
||||
static _IO_FILE *freeres_list;
|
||||
|
||||
static void
|
||||
_IO_unbuffer_write ()
|
||||
_IO_unbuffer_write (void)
|
||||
{
|
||||
struct _IO_FILE *fp;
|
||||
for (fp = (_IO_FILE *) INTUSE(_IO_list_all); fp; fp = fp->_chain)
|
||||
@ -927,7 +946,32 @@ _IO_unbuffer_write ()
|
||||
|| (fp->_flags & _IO_IS_APPENDING))
|
||||
/* Iff stream is un-orientated, it wasn't used. */
|
||||
&& fp->_mode != 0)
|
||||
_IO_SETBUF (fp, NULL, 0);
|
||||
{
|
||||
int cnt;
|
||||
#define MAXTRIES 2
|
||||
for (cnt = 0; cnt < MAXTRIES; ++cnt)
|
||||
if (_IO_lock_trylock (*fp->_lock) == 0)
|
||||
break;
|
||||
else
|
||||
/* Give the other thread time to finish up its use of the
|
||||
stream. */
|
||||
__sched_yield ();
|
||||
|
||||
if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
|
||||
{
|
||||
fp->_flags |= _IO_USER_BUF;
|
||||
|
||||
fp->_freeres_list = freeres_list;
|
||||
freeres_list = fp;
|
||||
fp->_freeres_buf = fp->_IO_buf_base;
|
||||
fp->_freeres_size = _IO_blen (fp);
|
||||
}
|
||||
|
||||
_IO_SETBUF (fp, NULL, 0);
|
||||
|
||||
if (cnt < MAXTRIES)
|
||||
_IO_lock_unlock (*fp->_lock);
|
||||
}
|
||||
|
||||
/* Make sure that never again the wide char functions can be
|
||||
used. */
|
||||
@ -935,11 +979,25 @@ _IO_unbuffer_write ()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
libc_freeres_fn (buffer_free)
|
||||
{
|
||||
dealloc_buffers = true;
|
||||
|
||||
while (freeres_list != NULL)
|
||||
{
|
||||
FREE_BUF (freeres_list->_freeres_buf, freeres_list->_freeres_size);
|
||||
|
||||
freeres_list = freeres_list->_freeres_list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_IO_cleanup ()
|
||||
{
|
||||
/* We do *not* want locking. Some threads might use streams but
|
||||
that is there problem, we flush them underneath them. */
|
||||
that is their problem, we flush them underneath them. */
|
||||
int result = _IO_flush_all_lockp (0);
|
||||
|
||||
/* We currently don't have a reliable mechanism for making sure that
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993,1995,1996,1997,1999,2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993,1995,1996,1997,1999,2000, 2006 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
|
||||
@ -33,7 +33,7 @@
|
||||
wint_t
|
||||
__getwc_unlocked (FILE *fp)
|
||||
{
|
||||
CHECK_FILE (fp, EOF);
|
||||
CHECK_FILE (fp, WEOF);
|
||||
return _IO_getwc_unlocked (fp);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003
|
||||
/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -34,7 +34,7 @@ ungetwc (c, fp)
|
||||
wint_t c;
|
||||
_IO_FILE *fp;
|
||||
{
|
||||
int result;
|
||||
wint_t result;
|
||||
CHECK_FILE (fp, WEOF);
|
||||
_IO_acquire_lock (fp);
|
||||
_IO_fwide (fp, 1);
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1995,1997-2000,2001,2002,2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 1997-2000, 2001, 2002, 2003, 2006
|
||||
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
|
||||
@ -25,7 +26,7 @@
|
||||
This exception applies to code released by its copyright holders
|
||||
in files containing the exception. */
|
||||
|
||||
#include "libioP.h"
|
||||
#include <libioP.h>
|
||||
#include <stdio_ext.h>
|
||||
|
||||
int
|
||||
@ -63,7 +64,4 @@ _IO_vdprintf (d, format, arg)
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vdprintf, vdprintf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vdprintf, vdprintf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1997-2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997-2003, 2006 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
|
||||
@ -29,10 +29,7 @@
|
||||
#include "strfile.h"
|
||||
|
||||
int
|
||||
_IO_vsprintf (string, format, args)
|
||||
char *string;
|
||||
const char *format;
|
||||
_IO_va_list args;
|
||||
__IO_vsprintf (char *string, const char *format, _IO_va_list args)
|
||||
{
|
||||
_IO_strfile sf;
|
||||
int ret;
|
||||
@ -47,8 +44,7 @@ _IO_vsprintf (string, format, args)
|
||||
_IO_putc_unlocked ('\0', (_IO_FILE *) &sf._sbf);
|
||||
return ret;
|
||||
}
|
||||
INTDEF(_IO_vsprintf)
|
||||
INTDEF2(__IO_vsprintf, _IO_vsprintf)
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vsprintf, vsprintf)
|
||||
#endif
|
||||
ldbl_strong_alias (__IO_vsprintf, _IO_vsprintf)
|
||||
ldbl_weak_alias (__IO_vsprintf, vsprintf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1997-2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997-2003, 2006 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
|
||||
@ -45,8 +45,5 @@ _IO_vsscanf (string, format, args)
|
||||
ret = INTUSE(_IO_vfscanf) ((_IO_FILE *) &sf._sbf, format, args, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vsscanf, __vsscanf)
|
||||
weak_alias (_IO_vsscanf, vsscanf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vsscanf, __vsscanf)
|
||||
ldbl_weak_alias (_IO_vsscanf, vsscanf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997-2000, 2001, 2002, 2006
|
||||
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
|
||||
@ -30,10 +31,7 @@
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
vswscanf (string, format, args)
|
||||
const wchar_t *string;
|
||||
const wchar_t *format;
|
||||
_IO_va_list args;
|
||||
__vswscanf (const wchar_t *string, const wchar_t *format, _IO_va_list args)
|
||||
{
|
||||
int ret;
|
||||
_IO_strfile sf;
|
||||
@ -47,4 +45,5 @@ vswscanf (string, format, args)
|
||||
ret = _IO_vfwscanf ((_IO_FILE *) &sf._sbf, format, args, NULL);
|
||||
return ret;
|
||||
}
|
||||
libc_hidden_def (vswscanf)
|
||||
ldbl_hidden_def (__vswscanf, vswscanf)
|
||||
ldbl_strong_alias (__vswscanf, vswscanf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991-1995,1997-2003,2004,2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991-1995,1997-2005,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Per Bothner <bothner@cygnus.com>.
|
||||
|
||||
@ -317,13 +317,19 @@ struct _IO_FILE_complete
|
||||
/* Wide character stream stuff. */
|
||||
struct _IO_codecvt *_codecvt;
|
||||
struct _IO_wide_data *_wide_data;
|
||||
struct _IO_FILE *_freeres_list;
|
||||
void *_freeres_buf;
|
||||
size_t _freeres_size;
|
||||
# else
|
||||
void *__pad1;
|
||||
void *__pad2;
|
||||
void *__pad3;
|
||||
void *__pad4;
|
||||
size_t __pad5;
|
||||
# endif
|
||||
int _mode;
|
||||
/* Make sure we don't get into trouble again. */
|
||||
char _unused2[15 * sizeof (int) - 2 * sizeof (void *)];
|
||||
char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -472,9 +478,9 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
|
||||
#endif /* !_IO_MTSAFE_IO */
|
||||
|
||||
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
|
||||
_IO_va_list, int *__restrict) __THROW;
|
||||
_IO_va_list, int *__restrict);
|
||||
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
|
||||
_IO_va_list) __THROW;
|
||||
_IO_va_list);
|
||||
extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t) __THROW;
|
||||
extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t) __THROW;
|
||||
|
||||
@ -521,13 +527,17 @@ weak_extern (_IO_stdin_used);
|
||||
# endif
|
||||
|
||||
extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
|
||||
_IO_va_list, int *__restrict) __THROW;
|
||||
_IO_va_list, int *__restrict);
|
||||
extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict,
|
||||
_IO_va_list) __THROW;
|
||||
_IO_va_list);
|
||||
extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW;
|
||||
extern void _IO_free_wbackup_area (_IO_FILE *) __THROW;
|
||||
#endif
|
||||
|
||||
#ifdef __LDBL_COMPAT
|
||||
# include <bits/libio-ldbl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1993, 1997-2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997-2003,2004,2005,2006
|
||||
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
|
||||
@ -35,6 +36,8 @@
|
||||
/*# include <comthread.h>*/
|
||||
#endif
|
||||
|
||||
#include <math_ldbl_opt.h>
|
||||
|
||||
#include "iolibio.h"
|
||||
|
||||
/* Control of exported symbols. Used in glibc. By default we don't
|
||||
@ -649,7 +652,7 @@ extern void _IO_wstr_finish (_IO_FILE *, int) __THROW;
|
||||
|
||||
extern int _IO_vasprintf (char **result_ptr, __const char *format,
|
||||
_IO_va_list args) __THROW;
|
||||
extern int _IO_vdprintf (int d, __const char *format, _IO_va_list arg) __THROW;
|
||||
extern int _IO_vdprintf (int d, __const char *format, _IO_va_list arg);
|
||||
extern int _IO_vsnprintf (char *string, _IO_size_t maxlen,
|
||||
__const char *format, _IO_va_list args) __THROW;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1995-97,99,2000,2002,2003,2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995-97,99,2000,2002-2004,2006 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
|
||||
@ -106,11 +106,6 @@ _IO_mem_sync (fp)
|
||||
_IO_FILE* fp;
|
||||
{
|
||||
struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp;
|
||||
int res;
|
||||
|
||||
res = _IO_default_sync (fp);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
if (fp->_IO_write_ptr == fp->_IO_write_end)
|
||||
{
|
||||
@ -140,9 +135,9 @@ _IO_mem_finish (fp, dummy)
|
||||
{
|
||||
(*mp->bufloc)[fp->_IO_write_ptr - fp->_IO_write_base] = '\0';
|
||||
*mp->sizeloc = fp->_IO_write_ptr - fp->_IO_write_base;
|
||||
|
||||
fp->_IO_buf_base = NULL;
|
||||
}
|
||||
|
||||
fp->_IO_buf_base = NULL;
|
||||
|
||||
INTUSE(_IO_default_finish) (fp, 0);
|
||||
_IO_str_finish (fp, 0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Print output of stream to given obstack.
|
||||
Copyright (C) 1996,1997,1999,2000,2001,2002,2003,2004,2005
|
||||
Copyright (C) 1996,1997,1999,2000,2001,2002,2003,2004,2005,2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
@ -176,9 +176,7 @@ _IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
|
||||
|
||||
return result;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_obstack_vprintf, obstack_vprintf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_obstack_vprintf, obstack_vprintf)
|
||||
|
||||
|
||||
int
|
||||
@ -191,6 +189,4 @@ _IO_obstack_printf (struct obstack *obstack, const char *format, ...)
|
||||
va_end (ap);
|
||||
return result;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_obstack_printf, obstack_printf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_obstack_printf, obstack_printf)
|
||||
|
@ -295,6 +295,11 @@ extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
|
||||
and the number of characters written on fflush or fclose. */
|
||||
extern FILE *open_memstream (char **__restrict __bufloc,
|
||||
size_t *__restrict __sizeloc) __THROW;
|
||||
|
||||
/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
|
||||
a wide character string. */
|
||||
extern FILE *open_wmemstream (wchar_t **__restrict __bufloc,
|
||||
size_t *__restrict __sizeloc) __THROW;
|
||||
#endif
|
||||
|
||||
|
||||
@ -838,6 +843,9 @@ extern void funlockfile (FILE *__stream) __THROW;
|
||||
#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
|
||||
# include <bits/stdio2.h>
|
||||
#endif
|
||||
#ifdef __LDBL_COMPAT
|
||||
# include <bits/stdio-ldbl.h>
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991,1995,1997,1998,1999,2000,2003
|
||||
/* Copyright (C) 1991,1995,1997,1998,1999,2000,2003,2004,2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -17,13 +17,14 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
/* Write formatted output into S, according to the format string FORMAT. */
|
||||
/* VARARGS3 */
|
||||
int
|
||||
swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
|
||||
__swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -34,3 +35,4 @@ swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (__swprintf, swprintf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991,1995,1996,1998,1999,2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1996, 1998, 1999, 2003, 2006
|
||||
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
|
||||
@ -16,13 +17,14 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
/* Read formatted input from S, according to the format string FORMAT. */
|
||||
/* VARARGS2 */
|
||||
int
|
||||
swscanf (const wchar_t *s, const wchar_t *format, ...)
|
||||
__swscanf (const wchar_t *s, const wchar_t *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -33,3 +35,4 @@ swscanf (const wchar_t *s, const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (__swscanf, swscanf)
|
||||
|
116
libio/tst-fopenloc2.c
Normal file
116
libio/tst-fopenloc2.c
Normal file
@ -0,0 +1,116 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *enc;
|
||||
const char *data;
|
||||
size_t datalen;
|
||||
const wchar_t *expected;
|
||||
size_t expectedlen;
|
||||
} tests[] =
|
||||
{
|
||||
{ "UCS-4LE", "a\0\0\0b\0\0\0", 8, L"ab", 2 },
|
||||
{ "UCS-4BE", "\0\0\0a\0\0\0b", 8, L"ab", 2 },
|
||||
};
|
||||
#define ntests (sizeof (tests) / sizeof (tests[0]))
|
||||
|
||||
|
||||
static int do_test (void);
|
||||
#define TEST_FUNCTION do_test ()
|
||||
|
||||
static void prepare (void);
|
||||
#define PREPARE(argc, argv) prepare ();
|
||||
|
||||
#include "../test-skeleton.c"
|
||||
|
||||
|
||||
static int fd;
|
||||
static char *tmpname;
|
||||
|
||||
|
||||
static void
|
||||
prepare (void)
|
||||
{
|
||||
fd = create_temp_file ("tst-fopenloc2", &tmpname);
|
||||
if (fd == -1)
|
||||
{
|
||||
puts ("cannot open temp file");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
for (int i = 0; i < ntests; ++i)
|
||||
{
|
||||
if (ftruncate (fd, 0) != 0)
|
||||
{
|
||||
printf ("ftruncate in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (TEMP_FAILURE_RETRY (write (fd, tests[i].data, tests[i].datalen))
|
||||
!= tests[i].datalen)
|
||||
{
|
||||
printf ("write in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lseek (fd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
printf ("lseek in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *ccs;
|
||||
if (asprintf (&ccs, "r,ccs=%s", tests[i].enc) == -1)
|
||||
{
|
||||
printf ("asprintf in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *fp = fopen (tmpname, ccs);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf ("fopen in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LINELEN 100
|
||||
wchar_t line[LINELEN];
|
||||
if (fgetws (line, LINELEN, fp) != line)
|
||||
{
|
||||
printf ("fgetws in round %d failed\n", i + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wcslen (line) != tests[i].expectedlen)
|
||||
{
|
||||
printf ("round %d: expected length %zu, got length %zu\n",
|
||||
i + 1, tests[i].expectedlen, wcslen (line));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wcscmp (tests[i].expected, line) != 0)
|
||||
{
|
||||
printf ("round %d: expected L\"%ls\", got L\"%ls\"\n",
|
||||
i + 1, tests[i].expected, line);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
free (ccs);
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
return 0;
|
||||
}
|
89
libio/tst-memstream1.c
Normal file
89
libio/tst-memstream1.c
Normal file
@ -0,0 +1,89 @@
|
||||
#include <mcheck.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef CHAR_T
|
||||
# define CHAR_T char
|
||||
# define W(o) o
|
||||
# define OPEN_MEMSTREAM open_memstream
|
||||
#endif
|
||||
|
||||
#define S(s) S1 (s)
|
||||
#define S1(s) #s
|
||||
|
||||
|
||||
static void
|
||||
mcheck_abort (enum mcheck_status ev)
|
||||
{
|
||||
printf ("mecheck failed with status %d\n", (int) ev);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
mcheck_pedantic (mcheck_abort);
|
||||
|
||||
CHAR_T *buf = (CHAR_T *) 1l;
|
||||
size_t len = 12345;
|
||||
FILE *fp = OPEN_MEMSTREAM (&buf, &len);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf ("%s failed\n", S(OPEN_MEMSTREAM));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fflush (fp) != 0)
|
||||
{
|
||||
puts ("fflush failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
puts ("string after no write not empty");
|
||||
return 1;
|
||||
}
|
||||
if (buf == (CHAR_T *) 1l)
|
||||
{
|
||||
puts ("buf not updated");
|
||||
return 1;
|
||||
}
|
||||
if (buf[0] != W('\0'))
|
||||
{
|
||||
puts ("buf[0] != 0");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf = (CHAR_T *) 1l;
|
||||
len = 12345;
|
||||
if (fclose (fp) != 0)
|
||||
{
|
||||
puts ("fclose failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
puts ("string after close with no write not empty");
|
||||
return 1;
|
||||
}
|
||||
if (buf == (CHAR_T *) 1l)
|
||||
{
|
||||
puts ("buf not updated");
|
||||
return 1;
|
||||
}
|
||||
if (buf[0] != W('\0'))
|
||||
{
|
||||
puts ("buf[0] != 0");
|
||||
return 1;
|
||||
}
|
||||
|
||||
free (buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
104
libio/tst-memstream2.c
Normal file
104
libio/tst-memstream2.c
Normal file
@ -0,0 +1,104 @@
|
||||
#include <mcheck.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef CHAR_T
|
||||
# define CHAR_T char
|
||||
# define W(o) o
|
||||
# define OPEN_MEMSTREAM open_memstream
|
||||
#endif
|
||||
|
||||
#define S(s) S1 (s)
|
||||
#define S1(s) #s
|
||||
|
||||
|
||||
static void
|
||||
mcheck_abort (enum mcheck_status ev)
|
||||
{
|
||||
printf ("mecheck failed with status %d\n", (int) ev);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
mcheck_pedantic (mcheck_abort);
|
||||
|
||||
CHAR_T *buf = (CHAR_T *) 1l;
|
||||
size_t len = 12345;
|
||||
FILE *fp = OPEN_MEMSTREAM (&buf, &len);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf ("%s failed\n", S(OPEN_MEMSTREAM));
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int outer = 0; outer < 800; ++outer)
|
||||
{
|
||||
for (int inner = 0; inner < 100; ++inner)
|
||||
if (fputc (W('a') + (outer * 100 + inner) % 26, fp) == EOF)
|
||||
{
|
||||
printf ("fputc at %d:%d failed\n", outer, inner);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fflush (fp) != 0)
|
||||
{
|
||||
puts ("fflush failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != (outer + 1) * 100)
|
||||
{
|
||||
printf ("string in round %d not %d bytest long\n",
|
||||
outer + 1, (outer + 1) * 100);
|
||||
return 1;
|
||||
}
|
||||
if (buf == (CHAR_T *) 1l)
|
||||
{
|
||||
printf ("round %d: buf not updated\n", outer + 1);
|
||||
return 1;
|
||||
}
|
||||
for (int inner = 0; inner < (outer + 1) * 100; ++inner)
|
||||
if (buf[inner] != W('a') + inner % 26)
|
||||
{
|
||||
printf ("round %d: buf[%d] != '%c'\n", outer + 1, inner,
|
||||
(char) (W('a') + inner % 26));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
buf = (CHAR_T *) 1l;
|
||||
len = 12345;
|
||||
if (fclose (fp) != 0)
|
||||
{
|
||||
puts ("fclose failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != 800 * 100)
|
||||
{
|
||||
puts ("string after close not 80000 bytes long");
|
||||
return 1;
|
||||
}
|
||||
if (buf == (CHAR_T *) 1l)
|
||||
{
|
||||
puts ("buf not updated");
|
||||
return 1;
|
||||
}
|
||||
for (int inner = 0; inner < 800 * 100; ++inner)
|
||||
if (buf[inner] != W('a') + inner % 26)
|
||||
{
|
||||
printf ("after close: buf[%d] != %c\n", inner,
|
||||
(char) (W('a') + inner % 26));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free (buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
5
libio/tst-wmemstream1.c
Normal file
5
libio/tst-wmemstream1.c
Normal file
@ -0,0 +1,5 @@
|
||||
#define CHAR_T wchar_t
|
||||
#define W(o) L##o
|
||||
#define OPEN_MEMSTREAM open_wmemstream
|
||||
|
||||
#include "tst-memstream1.c"
|
5
libio/tst-wmemstream2.c
Normal file
5
libio/tst-wmemstream2.c
Normal file
@ -0,0 +1,5 @@
|
||||
#define CHAR_T wchar_t
|
||||
#define W(o) L##o
|
||||
#define OPEN_MEMSTREAM open_wmemstream
|
||||
|
||||
#include "tst-memstream2.c"
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1995,1997,1999-2002,2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995,1997,1999-2002,2004,2006 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
|
||||
@ -87,7 +87,4 @@ _IO_vasprintf (result_ptr, format, args)
|
||||
(*result_ptr)[needed - 1] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vasprintf, vasprintf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vasprintf, vasprintf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997, 2002, 2006 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
|
||||
@ -37,7 +37,4 @@ _IO_vscanf (format, args)
|
||||
{
|
||||
return INTUSE(_IO_vfscanf) (_IO_stdin, format, args, NULL);
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vscanf, vscanf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vscanf, vscanf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1994,1997,1999-2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994,1997,1999-2003, 2004, 2006 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
|
||||
@ -123,8 +123,5 @@ _IO_vsnprintf (string, maxlen, format, args)
|
||||
*sf.f._sbf._f._IO_write_ptr = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vsnprintf, __vsnprintf)
|
||||
weak_alias (_IO_vsnprintf, vsnprintf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vsnprintf, __vsnprintf)
|
||||
ldbl_weak_alias (_IO_vsnprintf, vsnprintf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1994,1997,1999-2002,2004,2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994, 1997, 1999-2002, 2004, 2005, 2006
|
||||
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
|
||||
@ -126,8 +127,5 @@ _IO_vswprintf (string, maxlen, format, args)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (_IO_vswprintf, __vswprintf)
|
||||
weak_alias (_IO_vswprintf, vswprintf)
|
||||
#endif
|
||||
ldbl_weak_alias (_IO_vswprintf, vswprintf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991,1993,1995,1997,1999,2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1993, 1995, 1997, 1999, 2001, 2006
|
||||
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
|
||||
@ -16,6 +17,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@ -23,9 +25,8 @@
|
||||
/* Write formatted output to stdout according to the
|
||||
format string FORMAT, using the argument list in ARG. */
|
||||
int
|
||||
vwprintf (format, arg)
|
||||
const wchar_t *format;
|
||||
__gnuc_va_list arg;
|
||||
__vwprintf (const wchar_t *format, __gnuc_va_list arg)
|
||||
{
|
||||
return __vfwprintf (stdout, format, arg);
|
||||
}
|
||||
ldbl_strong_alias (__vwprintf, vwprintf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993, 1997, 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993, 1997, 1999, 2006 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
|
||||
@ -29,9 +29,8 @@
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
vwscanf (format, args)
|
||||
const wchar_t *format;
|
||||
_IO_va_list args;
|
||||
__vwscanf (const wchar_t *format, _IO_va_list args)
|
||||
{
|
||||
return _IO_vfwscanf (_IO_stdin, format, args, NULL);
|
||||
}
|
||||
ldbl_strong_alias (__vwscanf, vwscanf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1993,1995,1997-2003,2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993,1995,1997-2003,2004, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Ulrich Drepper <drepper@cygnus.com>.
|
||||
Based on the single byte version by Per Bothner <bothner@cygnus.com>.
|
||||
@ -69,7 +69,7 @@ _IO_wdo_write (fp, data, to_do)
|
||||
{
|
||||
if (_IO_new_do_write (fp, fp->_IO_write_base,
|
||||
fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
|
||||
return EOF;
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
do
|
||||
|
149
libio/wmemstream.c
Normal file
149
libio/wmemstream.c
Normal file
@ -0,0 +1,149 @@
|
||||
/* Copyright (C) 1995-97,99,2000,2002-2004,2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include "libioP.h"
|
||||
#include "strfile.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
struct _IO_FILE_wmemstream
|
||||
{
|
||||
_IO_strfile _sf;
|
||||
wchar_t **bufloc;
|
||||
_IO_size_t *sizeloc;
|
||||
};
|
||||
|
||||
|
||||
static int _IO_wmem_sync (_IO_FILE* fp) __THROW;
|
||||
static void _IO_wmem_finish (_IO_FILE* fp, int) __THROW;
|
||||
|
||||
|
||||
static const struct _IO_jump_t _IO_wmem_jumps =
|
||||
{
|
||||
JUMP_INIT_DUMMY,
|
||||
JUMP_INIT (finish, _IO_wmem_finish),
|
||||
JUMP_INIT (overflow, (_IO_overflow_t) _IO_wstr_overflow),
|
||||
JUMP_INIT (underflow, (_IO_underflow_t) _IO_wstr_underflow),
|
||||
JUMP_INIT (uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
|
||||
JUMP_INIT (pbackfail, (_IO_pbackfail_t) _IO_wstr_pbackfail),
|
||||
JUMP_INIT (xsputn, INTUSE(_IO_wdefault_xsputn)),
|
||||
JUMP_INIT (xsgetn, INTUSE(_IO_wdefault_xsgetn)),
|
||||
JUMP_INIT (seekoff, _IO_wstr_seekoff),
|
||||
JUMP_INIT (seekpos, _IO_default_seekpos),
|
||||
JUMP_INIT (setbuf, _IO_default_setbuf),
|
||||
JUMP_INIT (sync, _IO_wmem_sync),
|
||||
JUMP_INIT (doallocate, INTUSE(_IO_wdefault_doallocate)),
|
||||
JUMP_INIT (read, _IO_default_read),
|
||||
JUMP_INIT (write, _IO_default_write),
|
||||
JUMP_INIT (seek, _IO_default_seek),
|
||||
JUMP_INIT (close, _IO_default_close),
|
||||
JUMP_INIT (stat, _IO_default_stat),
|
||||
JUMP_INIT (showmanyc, _IO_default_showmanyc),
|
||||
JUMP_INIT (imbue, _IO_default_imbue)
|
||||
};
|
||||
|
||||
/* Open a stream that writes into a malloc'd buffer that is expanded as
|
||||
necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
|
||||
and the number of characters written on fflush or fclose. */
|
||||
_IO_FILE *
|
||||
open_wmemstream (bufloc, sizeloc)
|
||||
wchar_t **bufloc;
|
||||
_IO_size_t *sizeloc;
|
||||
{
|
||||
struct locked_FILE
|
||||
{
|
||||
struct _IO_FILE_wmemstream fp;
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
_IO_lock_t lock;
|
||||
#endif
|
||||
struct _IO_wide_data wd;
|
||||
} *new_f;
|
||||
wchar_t *buf;
|
||||
|
||||
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
|
||||
if (new_f == NULL)
|
||||
return NULL;
|
||||
#ifdef _IO_MTSAFE_IO
|
||||
new_f->fp._sf._sbf._f._lock = &new_f->lock;
|
||||
#endif
|
||||
|
||||
buf = malloc (_IO_BUFSIZ);
|
||||
if (buf == NULL)
|
||||
return NULL;
|
||||
|
||||
_IO_no_init (&new_f->fp._sf._sbf._f, 0, 0, &new_f->wd, &_IO_wmem_jumps);
|
||||
_IO_fwide (&new_f->fp._sf._sbf._f, 1);
|
||||
_IO_wstr_init_static (&new_f->fp._sf._sbf._f, buf,
|
||||
_IO_BUFSIZ / sizeof (wchar_t), buf);
|
||||
new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF;
|
||||
new_f->fp._sf._s._allocate_buffer = (_IO_alloc_type) malloc;
|
||||
new_f->fp._sf._s._free_buffer = (_IO_free_type) free;
|
||||
|
||||
new_f->fp.bufloc = bufloc;
|
||||
new_f->fp.sizeloc = sizeloc;
|
||||
|
||||
return (_IO_FILE *) &new_f->fp._sf._sbf;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_IO_wmem_sync (fp)
|
||||
_IO_FILE* fp;
|
||||
{
|
||||
struct _IO_FILE_wmemstream *mp = (struct _IO_FILE_wmemstream *) fp;
|
||||
|
||||
if (fp->_wide_data->_IO_write_ptr == fp->_wide_data->_IO_write_end)
|
||||
{
|
||||
_IO_wstr_overflow (fp, '\0');
|
||||
--fp->_wide_data->_IO_write_ptr;
|
||||
}
|
||||
else
|
||||
*fp->_wide_data->_IO_write_ptr = '\0';
|
||||
|
||||
*mp->bufloc = fp->_wide_data->_IO_write_base;
|
||||
*mp->sizeloc = (fp->_wide_data->_IO_write_ptr
|
||||
- fp->_wide_data->_IO_write_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_IO_wmem_finish (fp, dummy)
|
||||
_IO_FILE* fp;
|
||||
int dummy;
|
||||
{
|
||||
struct _IO_FILE_wmemstream *mp = (struct _IO_FILE_wmemstream *) fp;
|
||||
|
||||
*mp->bufloc = (wchar_t *) realloc (fp->_wide_data->_IO_write_base,
|
||||
(fp->_wide_data->_IO_write_ptr
|
||||
- fp->_wide_data->_IO_write_base + 1)
|
||||
* sizeof (wchar_t));
|
||||
if (*mp->bufloc != NULL)
|
||||
{
|
||||
size_t len = (fp->_wide_data->_IO_write_ptr
|
||||
- fp->_wide_data->_IO_write_base);
|
||||
(*mp->bufloc)[len] = '\0';
|
||||
*mp->sizeloc = len;
|
||||
|
||||
fp->_wide_data->_IO_buf_base = NULL;
|
||||
}
|
||||
|
||||
_IO_wstr_finish (fp, 0);
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991,1995,1996,1997,1999,2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 1999, 2001, 2006
|
||||
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
|
||||
@ -16,6 +17,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@ -23,7 +25,7 @@
|
||||
/* Write formatted output to stdout from the format string FORMAT. */
|
||||
/* VARARGS1 */
|
||||
int
|
||||
wprintf (const wchar_t *format, ...)
|
||||
__wprintf (const wchar_t *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -34,3 +36,4 @@ wprintf (const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (__wprintf, wprintf)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1995, 1996, 1997, 1999, 2006
|
||||
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
|
||||
@ -16,6 +17,7 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <libioP.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@ -24,7 +26,7 @@
|
||||
/* Read formatted input from stdin according to the format string FORMAT. */
|
||||
/* VARARGS1 */
|
||||
int
|
||||
wscanf (const wchar_t *format, ...)
|
||||
__wscanf (const wchar_t *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
int done;
|
||||
@ -35,3 +37,4 @@ wscanf (const wchar_t *format, ...)
|
||||
|
||||
return done;
|
||||
}
|
||||
ldbl_strong_alias (__wscanf, wscanf)
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
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.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@ -16,8 +15,9 @@
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
@ -52,22 +52,38 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
# if HAVE_STDINT_H || defined _LIBC
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
|
||||
/* Determine default alignment. */
|
||||
struct fooalign {char x; double d;};
|
||||
# define DEFAULT_ALIGNMENT \
|
||||
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
||||
union fooround
|
||||
{
|
||||
uintmax_t i;
|
||||
long double d;
|
||||
void *p;
|
||||
};
|
||||
struct fooalign
|
||||
{
|
||||
char c;
|
||||
union fooround u;
|
||||
};
|
||||
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
||||
But in fact it might be less smart and round addresses to as much as
|
||||
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
||||
union fooround {long x; double d;};
|
||||
# define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||
enum
|
||||
{
|
||||
DEFAULT_ALIGNMENT = offsetof (struct fooalign, u),
|
||||
DEFAULT_ROUNDING = sizeof (union fooround)
|
||||
};
|
||||
|
||||
/* When we copy a long block of data, this is the unit to do it with.
|
||||
On some machines, copying successive ints does not work;
|
||||
@ -143,7 +159,7 @@ _obstack_begin (struct obstack *h,
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
alignment = DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
@ -170,7 +186,8 @@ _obstack_begin (struct obstack *h,
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
|
||||
alignment - 1);
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
@ -189,7 +206,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
alignment = DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
@ -217,7 +234,8 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
|
||||
alignment - 1);
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
@ -259,8 +277,7 @@ _obstack_newchunk (struct obstack *h, int length)
|
||||
|
||||
/* Compute an aligned object_base in the new chunk */
|
||||
object_base =
|
||||
__INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask)
|
||||
& ~ (h->alignment_mask));
|
||||
__PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask);
|
||||
|
||||
/* Move the existing object to the new chunk.
|
||||
Word at a time is fast and is safe if the object
|
||||
@ -285,7 +302,10 @@ _obstack_newchunk (struct obstack *h, int length)
|
||||
/* If the object just copied was the only data in OLD_CHUNK,
|
||||
free that chunk and remove it from the chain.
|
||||
But not if that chunk might contain an empty object. */
|
||||
if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
|
||||
if (! h->maybe_empty_object
|
||||
&& (h->object_base
|
||||
== __PTR_ALIGN ((char *) old_chunk, old_chunk->contents,
|
||||
h->alignment_mask)))
|
||||
{
|
||||
new_chunk->prev = old_chunk->prev;
|
||||
CALL_FREEFUN (h, old_chunk);
|
||||
@ -410,7 +430,11 @@ print_and_abort (void)
|
||||
happen because the "memory exhausted" message appears in other places
|
||||
like this and the translation should be reused instead of creating
|
||||
a very similar string which requires a separate translation. */
|
||||
# ifdef _LIBC
|
||||
(void) __fxprintf (NULL, "%s\n", _("memory exhausted"));
|
||||
# else
|
||||
fprintf (stderr, "%s\n", _("memory exhausted"));
|
||||
# endif
|
||||
exit (obstack_exit_failure);
|
||||
}
|
||||
|
||||
|
109
malloc/obstack.h
109
malloc/obstack.h
@ -1,8 +1,7 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988-1994,1996-1999,2003,2004,2005
|
||||
Free Software Foundation, Inc.
|
||||
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.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@ -16,8 +15,8 @@
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Summary:
|
||||
|
||||
@ -111,19 +110,7 @@ Summary:
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* We use subtraction of (char *) 0 instead of casting to int
|
||||
because on word-addressable machines a simple cast to int
|
||||
may ignore the byte-within-word field of the pointer. */
|
||||
|
||||
#ifndef __PTR_TO_INT
|
||||
# define __PTR_TO_INT(P) ((P) - (char *) 0)
|
||||
#endif
|
||||
|
||||
#ifndef __INT_TO_PTR
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
#endif
|
||||
|
||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||
/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is
|
||||
defined, as with GNU C, use that; that way we don't pollute the
|
||||
namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h>
|
||||
and use ptrdiff_t. */
|
||||
@ -135,6 +122,23 @@ extern "C" {
|
||||
# define PTR_INT_TYPE ptrdiff_t
|
||||
#endif
|
||||
|
||||
/* If B is the base of an object addressed by P, return the result of
|
||||
aligning P to the next multiple of A + 1. B and P must be of type
|
||||
char *. A + 1 must be a power of 2. */
|
||||
|
||||
#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
|
||||
|
||||
/* Similiar to _BPTR_ALIGN (B, P, A), except optimize the common case
|
||||
where pointers can be converted to integers, aligned as integers,
|
||||
and converted back again. If PTR_INT_TYPE is narrower than a
|
||||
pointer (e.g., the AS/400), play it safe and compute the alignment
|
||||
relative to B. Otherwise, use the faster strategy of computing the
|
||||
alignment relative to 0. */
|
||||
|
||||
#define __PTR_ALIGN(B, P, A) \
|
||||
__BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
|
||||
P, A)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct _obstack_chunk /* Lives at front of each chunk. */
|
||||
@ -151,7 +155,11 @@ struct obstack /* control current object in current chunk */
|
||||
char *object_base; /* address of object we are building */
|
||||
char *next_free; /* where to add next char to current object */
|
||||
char *chunk_limit; /* address of char after current chunk */
|
||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||
union
|
||||
{
|
||||
PTR_INT_TYPE tempint;
|
||||
void *tempptr;
|
||||
} temp; /* Temporary for some macros. */
|
||||
int alignment_mask; /* Mask of alignment for each object. */
|
||||
/* These prototypes vary based on `use_extra_arg', and we use
|
||||
casts to the prototypeless function type in all assignments,
|
||||
@ -276,7 +284,10 @@ __extension__ \
|
||||
# define obstack_empty_p(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack const *__o = (OBSTACK); \
|
||||
(__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
|
||||
(__o->chunk->prev == 0 \
|
||||
&& __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
|
||||
__o->chunk->contents, \
|
||||
__o->alignment_mask)); })
|
||||
|
||||
# define obstack_grow(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
@ -375,8 +386,8 @@ __extension__ \
|
||||
if (__o1->next_free == __value) \
|
||||
__o1->maybe_empty_object = 1; \
|
||||
__o1->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
|
||||
& ~ (__o1->alignment_mask)); \
|
||||
= __PTR_ALIGN (__o1->object_base, __o1->next_free, \
|
||||
__o1->alignment_mask); \
|
||||
if (__o1->next_free - (char *)__o1->chunk \
|
||||
> __o1->chunk_limit - (char *)__o1->chunk) \
|
||||
__o1->next_free = __o1->chunk_limit; \
|
||||
@ -400,7 +411,10 @@ __extension__ \
|
||||
(unsigned) ((h)->chunk_limit - (h)->next_free)
|
||||
|
||||
# define obstack_empty_p(h) \
|
||||
((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
|
||||
((h)->chunk->prev == 0 \
|
||||
&& (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
|
||||
(h)->chunk->contents, \
|
||||
(h)->alignment_mask))
|
||||
|
||||
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
|
||||
so that we can avoid having void expressions
|
||||
@ -409,23 +423,23 @@ __extension__ \
|
||||
but some compilers won't accept it. */
|
||||
|
||||
# define obstack_make_room(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
|
||||
( (h)->temp.tempint = (length), \
|
||||
(((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0))
|
||||
|
||||
# define obstack_grow(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
memcpy ((h)->next_free, where, (h)->temp), \
|
||||
(h)->next_free += (h)->temp)
|
||||
( (h)->temp.tempint = (length), \
|
||||
(((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
|
||||
memcpy ((h)->next_free, where, (h)->temp.tempint), \
|
||||
(h)->next_free += (h)->temp.tempint)
|
||||
|
||||
# define obstack_grow0(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
|
||||
memcpy ((h)->next_free, where, (h)->temp), \
|
||||
(h)->next_free += (h)->temp, \
|
||||
( (h)->temp.tempint = (length), \
|
||||
(((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \
|
||||
memcpy ((h)->next_free, where, (h)->temp.tempint), \
|
||||
(h)->next_free += (h)->temp.tempint, \
|
||||
*((h)->next_free)++ = 0)
|
||||
|
||||
# define obstack_1grow(h,datum) \
|
||||
@ -450,10 +464,10 @@ __extension__ \
|
||||
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
|
||||
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
obstack_blank_fast (h, (h)->temp))
|
||||
( (h)->temp.tempint = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \
|
||||
? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
|
||||
obstack_blank_fast (h, (h)->temp.tempint))
|
||||
|
||||
# define obstack_alloc(h,length) \
|
||||
(obstack_blank ((h), (length)), obstack_finish ((h)))
|
||||
@ -468,22 +482,23 @@ __extension__ \
|
||||
( ((h)->next_free == (h)->object_base \
|
||||
? (((h)->maybe_empty_object = 1), 0) \
|
||||
: 0), \
|
||||
(h)->temp = __PTR_TO_INT ((h)->object_base), \
|
||||
(h)->temp.tempptr = (h)->object_base, \
|
||||
(h)->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
|
||||
& ~ ((h)->alignment_mask)), \
|
||||
= __PTR_ALIGN ((h)->object_base, (h)->next_free, \
|
||||
(h)->alignment_mask), \
|
||||
(((h)->next_free - (char *) (h)->chunk \
|
||||
> (h)->chunk_limit - (char *) (h)->chunk) \
|
||||
? ((h)->next_free = (h)->chunk_limit) : 0), \
|
||||
(h)->object_base = (h)->next_free, \
|
||||
(void *) __INT_TO_PTR ((h)->temp))
|
||||
(h)->temp.tempptr)
|
||||
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
|
||||
((((h)->temp.tempint > 0 \
|
||||
&& (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
|
||||
= (h)->temp.tempint + (char *) (h)->chunk) \
|
||||
: (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
|
||||
|
||||
#endif /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Copyright (C) 1996-2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2001,2002,2003,2004,2005,2006
|
||||
# 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
|
||||
@ -149,6 +150,15 @@ distribute += ieee-math.c
|
||||
include ../Rules
|
||||
|
||||
|
||||
# The generated sysd-rules file defines rules like this for sources
|
||||
# coming from sysdeps/ directories. These rules find the generic sources.
|
||||
define o-iterator-doit
|
||||
$(objpfx)m_%$o: s_%.c $(before-compile); $$(compile-command.c)
|
||||
endef
|
||||
object-suffixes-left := $(all-object-suffixes)
|
||||
include $(o-iterator)
|
||||
|
||||
|
||||
# This file defines the default _LIB_VERSION variable that controls
|
||||
# the error return conventions for the math functions.
|
||||
CPPFLAGS-s_lib_version.c := -D_POSIX_MODE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Prototype declarations for math functions; helper file for <math.h>.
|
||||
Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-2002, 2003, 2006 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
|
||||
@ -281,7 +281,7 @@ __MATHCALL (rint,, (_Mdouble_ __x));
|
||||
|
||||
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
|
||||
__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
|
||||
# ifdef __USE_ISOC99
|
||||
# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
|
||||
__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
|
||||
# endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997, 1998, 1999, 2000, 2006 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
|
||||
@ -84,7 +84,14 @@ __BEGIN_DECLS
|
||||
|
||||
/* And the long double versions. It is non-critical to define them
|
||||
here unconditionally since `long double' is required in ISO C99. */
|
||||
#if __STDC__ - 0 || __GNUC__ - 0 && !defined __NO_LONG_DOUBLE_MATH
|
||||
#if (__STDC__ - 0 || __GNUC__ - 0) \
|
||||
&& (!defined __NO_LONG_DOUBLE_MATH || defined __LDBL_COMPAT)
|
||||
# ifdef __LDBL_COMPAT
|
||||
# undef __MATHDECL_1
|
||||
# define __MATHDECL_1(type, function, args) \
|
||||
extern type __REDIRECT(__MATH_PRECNAME(function), args, function) __THROW
|
||||
# endif
|
||||
|
||||
# ifndef _Mlong_double_
|
||||
# define _Mlong_double_ long double
|
||||
# endif
|
||||
|
@ -1,14 +1,10 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "math_private.h"
|
||||
|
||||
long double
|
||||
__ieee754_exp2l (long double x)
|
||||
{
|
||||
fputs ("__ieee754_exp2l not implemented\n", stderr);
|
||||
__set_errno (ENOSYS);
|
||||
return 0.0;
|
||||
/* This is a very stupid and inprecise implementation. It'll get
|
||||
replaced sometime (soon?). */
|
||||
return __ieee754_expl (M_LN2l * x);
|
||||
}
|
||||
|
||||
stub_warning (exp2l)
|
||||
#include <stub-tag.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1997-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Andreas Jaeger <aj@suse.de>, 1997.
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
This file is processed by a perl script. The resulting file has to
|
||||
be included by a master file that defines:
|
||||
|
||||
Makros:
|
||||
Macros:
|
||||
FUNC(function): converts general function name (like cos) to
|
||||
name with correct suffix (e.g. cosl or cosf)
|
||||
MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
|
||||
@ -498,7 +498,7 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
|
||||
&& computed == 0.0 && expected == 0.0
|
||||
&& signbit(computed) != signbit (expected))
|
||||
ok = 0;
|
||||
else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp))
|
||||
else if (ulp <= 0.5 || (ulp <= max_ulp && !ignore_max_ulp))
|
||||
ok = 1;
|
||||
else
|
||||
{
|
||||
@ -1116,7 +1116,7 @@ cacosh_test (void)
|
||||
TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
|
||||
|
||||
TEST_c_c (cacosh, 0.75L, 1.25L, 1.13239363160530819522266333696834467L, 1.11752014915610270578240049553777969L);
|
||||
TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
|
||||
TEST_c_c (cacosh, -2, -3, 1.9833870299165354323470769028940395L, -2.1414491111159960199416055713254211L);
|
||||
|
||||
END (cacosh, complex);
|
||||
}
|
||||
@ -1631,6 +1631,51 @@ ceil_test (void)
|
||||
TEST_f_f (ceil, 0.25, 1.0);
|
||||
TEST_f_f (ceil, -0.25, minus_zero);
|
||||
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
TEST_f_f (ceil, 4503599627370495.5L, 4503599627370496.0L);
|
||||
TEST_f_f (ceil, 4503599627370496.25L, 4503599627370497.0L);
|
||||
TEST_f_f (ceil, 4503599627370496.5L, 4503599627370497.0L);
|
||||
TEST_f_f (ceil, 4503599627370496.75L, 4503599627370497.0L);
|
||||
TEST_f_f (ceil, 4503599627370497.5L, 4503599627370498.0L);
|
||||
|
||||
TEST_f_f (ceil, -4503599627370495.5L, -4503599627370495.0L);
|
||||
TEST_f_f (ceil, -4503599627370496.25L, -4503599627370496.0L);
|
||||
TEST_f_f (ceil, -4503599627370496.5L, -4503599627370496.0L);
|
||||
TEST_f_f (ceil, -4503599627370496.75L, -4503599627370496.0L);
|
||||
TEST_f_f (ceil, -4503599627370497.5L, -4503599627370497.0L);
|
||||
|
||||
TEST_f_f (ceil, 9007199254740991.5L, 9007199254740992.0L);
|
||||
TEST_f_f (ceil, 9007199254740992.25L, 9007199254740993.0L);
|
||||
TEST_f_f (ceil, 9007199254740992.5L, 9007199254740993.0L);
|
||||
TEST_f_f (ceil, 9007199254740992.75L, 9007199254740993.0L);
|
||||
TEST_f_f (ceil, 9007199254740993.5L, 9007199254740994.0L);
|
||||
|
||||
TEST_f_f (ceil, -9007199254740991.5L, -9007199254740991.0L);
|
||||
TEST_f_f (ceil, -9007199254740992.25L, -9007199254740992.0L);
|
||||
TEST_f_f (ceil, -9007199254740992.5L, -9007199254740992.0L);
|
||||
TEST_f_f (ceil, -9007199254740992.75L, -9007199254740992.0L);
|
||||
TEST_f_f (ceil, -9007199254740993.5L, -9007199254740993.0L);
|
||||
|
||||
TEST_f_f (ceil, 72057594037927935.5L, 72057594037927936.0L);
|
||||
TEST_f_f (ceil, 72057594037927936.25L, 72057594037927937.0L);
|
||||
TEST_f_f (ceil, 72057594037927936.5L, 72057594037927937.0L);
|
||||
TEST_f_f (ceil, 72057594037927936.75L, 72057594037927937.0L);
|
||||
TEST_f_f (ceil, 72057594037927937.5L, 72057594037927938.0L);
|
||||
|
||||
TEST_f_f (ceil, -72057594037927935.5L, -72057594037927935.0L);
|
||||
TEST_f_f (ceil, -72057594037927936.25L, -72057594037927936.0L);
|
||||
TEST_f_f (ceil, -72057594037927936.5L, -72057594037927936.0L);
|
||||
TEST_f_f (ceil, -72057594037927936.75L, -72057594037927936.0L);
|
||||
TEST_f_f (ceil, -72057594037927937.5L, -72057594037927937.0L);
|
||||
|
||||
TEST_f_f (ceil, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (ceil, 10141204801825835211973625643008.25L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (ceil, 10141204801825835211973625643008.5L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (ceil, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (ceil, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L);
|
||||
#endif
|
||||
|
||||
END (ceil);
|
||||
}
|
||||
|
||||
@ -2389,7 +2434,9 @@ erfc_test (void)
|
||||
TEST_f_f (erfc, 4.125L, 0.542340079956506600531223408575531062e-8L);
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
# if LDBL_MIN_10_EXP < -319
|
||||
TEST_f_f (erfc, 27.0L, 0.523704892378925568501606768284954709e-318L);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
END (erfc);
|
||||
@ -2584,6 +2631,52 @@ floor_test (void)
|
||||
TEST_f_f (floor, 0.25, 0.0);
|
||||
TEST_f_f (floor, -0.25, -1.0);
|
||||
|
||||
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
TEST_f_f (floor, 4503599627370495.5L, 4503599627370495.0L);
|
||||
TEST_f_f (floor, 4503599627370496.25L, 4503599627370496.0L);
|
||||
TEST_f_f (floor, 4503599627370496.5L, 4503599627370496.0L);
|
||||
TEST_f_f (floor, 4503599627370496.75L, 4503599627370496.0L);
|
||||
TEST_f_f (floor, 4503599627370497.5L, 4503599627370497.0L);
|
||||
|
||||
TEST_f_f (floor, -4503599627370495.5L, -4503599627370496.0L);
|
||||
TEST_f_f (floor, -4503599627370496.25L, -4503599627370497.0L);
|
||||
TEST_f_f (floor, -4503599627370496.5L, -4503599627370497.0L);
|
||||
TEST_f_f (floor, -4503599627370496.75L, -4503599627370497.0L);
|
||||
TEST_f_f (floor, -4503599627370497.5L, -4503599627370498.0L);
|
||||
|
||||
TEST_f_f (floor, 9007199254740991.5L, 9007199254740991.0L);
|
||||
TEST_f_f (floor, 9007199254740992.25L, 9007199254740992.0L);
|
||||
TEST_f_f (floor, 9007199254740992.5L, 9007199254740992.0L);
|
||||
TEST_f_f (floor, 9007199254740992.75L, 9007199254740992.0L);
|
||||
TEST_f_f (floor, 9007199254740993.5L, 9007199254740993.0L);
|
||||
|
||||
TEST_f_f (floor, -9007199254740991.5L, -9007199254740992.0L);
|
||||
TEST_f_f (floor, -9007199254740992.25L, -9007199254740993.0L);
|
||||
TEST_f_f (floor, -9007199254740992.5L, -9007199254740993.0L);
|
||||
TEST_f_f (floor, -9007199254740992.75L, -9007199254740993.0L);
|
||||
TEST_f_f (floor, -9007199254740993.5L, -9007199254740994.0L);
|
||||
|
||||
TEST_f_f (floor, 72057594037927935.5L, 72057594037927935.0L);
|
||||
TEST_f_f (floor, 72057594037927936.25L, 72057594037927936.0L);
|
||||
TEST_f_f (floor, 72057594037927936.5L, 72057594037927936.0L);
|
||||
TEST_f_f (floor, 72057594037927936.75L, 72057594037927936.0L);
|
||||
TEST_f_f (floor, 72057594037927937.5L, 72057594037927937.0L);
|
||||
|
||||
TEST_f_f (floor, -72057594037927935.5L, -72057594037927936.0L);
|
||||
TEST_f_f (floor, -72057594037927936.25L, -72057594037927937.0L);
|
||||
TEST_f_f (floor, -72057594037927936.5L, -72057594037927937.0L);
|
||||
TEST_f_f (floor, -72057594037927936.75L, -72057594037927937.0L);
|
||||
TEST_f_f (floor, -72057594037927937.5L, -72057594037927938.0L);
|
||||
|
||||
TEST_f_f (floor, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L);
|
||||
TEST_f_f (floor, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (floor, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (floor, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (floor, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L);
|
||||
#endif
|
||||
|
||||
END (floor);
|
||||
}
|
||||
|
||||
@ -3164,6 +3257,44 @@ llrint_test (void)
|
||||
TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL);
|
||||
/* 0x100000000000000 */
|
||||
TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL);
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The input can only be represented in long double. */
|
||||
TEST_f_L (llrint, 4503599627370495.5L, 4503599627370496LL);
|
||||
TEST_f_L (llrint, 4503599627370496.25L, 4503599627370496LL);
|
||||
TEST_f_L (llrint, 4503599627370496.5L, 4503599627370496LL);
|
||||
TEST_f_L (llrint, 4503599627370496.75L, 4503599627370497LL);
|
||||
TEST_f_L (llrint, 4503599627370497.5L, 4503599627370498LL);
|
||||
|
||||
TEST_f_L (llrint, -4503599627370495.5L, -4503599627370496LL);
|
||||
TEST_f_L (llrint, -4503599627370496.25L, -4503599627370496LL);
|
||||
TEST_f_L (llrint, -4503599627370496.5L, -4503599627370496LL);
|
||||
TEST_f_L (llrint, -4503599627370496.75L, -4503599627370497LL);
|
||||
TEST_f_L (llrint, -4503599627370497.5L, -4503599627370498LL);
|
||||
|
||||
TEST_f_L (llrint, 9007199254740991.5L, 9007199254740992LL);
|
||||
TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL);
|
||||
TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL);
|
||||
TEST_f_L (llrint, 9007199254740992.75L, 9007199254740993LL);
|
||||
TEST_f_L (llrint, 9007199254740993.5L, 9007199254740994LL);
|
||||
|
||||
TEST_f_L (llrint, -9007199254740991.5L, -9007199254740992LL);
|
||||
TEST_f_L (llrint, -9007199254740992.25L, -9007199254740992LL);
|
||||
TEST_f_L (llrint, -9007199254740992.5L, -9007199254740992LL);
|
||||
TEST_f_L (llrint, -9007199254740992.75L, -9007199254740993LL);
|
||||
TEST_f_L (llrint, -9007199254740993.5L, -9007199254740994LL);
|
||||
|
||||
TEST_f_L (llrint, 72057594037927935.5L, 72057594037927936LL);
|
||||
TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL);
|
||||
TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL);
|
||||
TEST_f_L (llrint, 72057594037927936.75L, 72057594037927937LL);
|
||||
TEST_f_L (llrint, 72057594037927937.5L, 72057594037927938LL);
|
||||
|
||||
TEST_f_L (llrint, -72057594037927935.5L, -72057594037927936LL);
|
||||
TEST_f_L (llrint, -72057594037927936.25L, -72057594037927936LL);
|
||||
TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL);
|
||||
TEST_f_L (llrint, -72057594037927936.75L, -72057594037927937LL);
|
||||
TEST_f_L (llrint, -72057594037927937.5L, -72057594037927938LL);
|
||||
#endif
|
||||
|
||||
END (llrint);
|
||||
}
|
||||
@ -3398,6 +3529,52 @@ llround_test (void)
|
||||
TEST_f_L (llround, 8589934591.5, 8589934592LL);
|
||||
#endif
|
||||
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The input can only be represented in long double. */
|
||||
TEST_f_L (llround, 4503599627370495.5L, 4503599627370496LL);
|
||||
TEST_f_L (llround, 4503599627370496.25L, 4503599627370496LL);
|
||||
TEST_f_L (llround, 4503599627370496.5L, 4503599627370497LL);
|
||||
TEST_f_L (llround, 4503599627370496.75L, 4503599627370497LL);
|
||||
TEST_f_L (llround, 4503599627370497.5L, 4503599627370498LL);
|
||||
|
||||
TEST_f_L (llround, -4503599627370495.5L, -4503599627370496LL);
|
||||
TEST_f_L (llround, -4503599627370496.25L, -4503599627370496LL);
|
||||
TEST_f_L (llround, -4503599627370496.5L, -4503599627370497LL);
|
||||
TEST_f_L (llround, -4503599627370496.75L, -4503599627370497LL);
|
||||
TEST_f_L (llround, -4503599627370497.5L, -4503599627370498LL);
|
||||
|
||||
TEST_f_L (llround, 9007199254740991.5L, 9007199254740992LL);
|
||||
TEST_f_L (llround, 9007199254740992.25L, 9007199254740992LL);
|
||||
TEST_f_L (llround, 9007199254740992.5L, 9007199254740993LL);
|
||||
TEST_f_L (llround, 9007199254740992.75L, 9007199254740993LL);
|
||||
TEST_f_L (llround, 9007199254740993.5L, 9007199254740994LL);
|
||||
|
||||
TEST_f_L (llround, -9007199254740991.5L, -9007199254740992LL);
|
||||
TEST_f_L (llround, -9007199254740992.25L, -9007199254740992LL);
|
||||
TEST_f_L (llround, -9007199254740992.5L, -9007199254740993LL);
|
||||
TEST_f_L (llround, -9007199254740992.75L, -9007199254740993LL);
|
||||
TEST_f_L (llround, -9007199254740993.5L, -9007199254740994LL);
|
||||
|
||||
TEST_f_L (llround, 72057594037927935.5L, 72057594037927936LL);
|
||||
TEST_f_L (llround, 72057594037927936.25L, 72057594037927936LL);
|
||||
TEST_f_L (llround, 72057594037927936.5L, 72057594037927937LL);
|
||||
TEST_f_L (llround, 72057594037927936.75L, 72057594037927937LL);
|
||||
TEST_f_L (llround, 72057594037927937.5L, 72057594037927938LL);
|
||||
|
||||
TEST_f_L (llround, -72057594037927935.5L, -72057594037927936LL);
|
||||
TEST_f_L (llround, -72057594037927936.25L, -72057594037927936LL);
|
||||
TEST_f_L (llround, -72057594037927936.5L, -72057594037927937LL);
|
||||
TEST_f_L (llround, -72057594037927936.75L, -72057594037927937LL);
|
||||
TEST_f_L (llround, -72057594037927937.5L, -72057594037927938LL);
|
||||
|
||||
TEST_f_L (llround, 9223372036854775806.25L, 9223372036854775806LL);
|
||||
TEST_f_L (llround, -9223372036854775806.25L, -9223372036854775806LL);
|
||||
TEST_f_L (llround, 9223372036854775806.5L, 9223372036854775807LL);
|
||||
TEST_f_L (llround, -9223372036854775806.5L, -9223372036854775807LL);
|
||||
TEST_f_L (llround, 9223372036854775807.0L, 9223372036854775807LL);
|
||||
TEST_f_L (llround, -9223372036854775807.0L, -9223372036854775807LL);
|
||||
#endif
|
||||
|
||||
END (llround);
|
||||
}
|
||||
|
||||
@ -3794,6 +3971,50 @@ rint_test (void)
|
||||
TEST_f_f (rint, -2.5, -2.0);
|
||||
TEST_f_f (rint, -3.5, -4.0);
|
||||
TEST_f_f (rint, -4.5, -4.0);
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L);
|
||||
TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L);
|
||||
TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L);
|
||||
TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L);
|
||||
TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L);
|
||||
|
||||
TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L);
|
||||
TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L);
|
||||
TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L);
|
||||
TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L);
|
||||
TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L);
|
||||
|
||||
TEST_f_f (rint, 9007199254740991.5L, 9007199254740992.0L);
|
||||
TEST_f_f (rint, 9007199254740992.25L, 9007199254740992.0L);
|
||||
TEST_f_f (rint, 9007199254740992.5L, 9007199254740992.0L);
|
||||
TEST_f_f (rint, 9007199254740992.75L, 9007199254740993.0L);
|
||||
TEST_f_f (rint, 9007199254740993.5L, 9007199254740994.0L);
|
||||
|
||||
TEST_f_f (rint, -9007199254740991.5L, -9007199254740992.0L);
|
||||
TEST_f_f (rint, -9007199254740992.25L, -9007199254740992.0L);
|
||||
TEST_f_f (rint, -9007199254740992.5L, -9007199254740992.0L);
|
||||
TEST_f_f (rint, -9007199254740992.75L, -9007199254740993.0L);
|
||||
TEST_f_f (rint, -9007199254740993.5L, -9007199254740994.0L);
|
||||
|
||||
TEST_f_f (rint, 72057594037927935.5L, 72057594037927936.0L);
|
||||
TEST_f_f (rint, 72057594037927936.25L, 72057594037927936.0L);
|
||||
TEST_f_f (rint, 72057594037927936.5L, 72057594037927936.0L);
|
||||
TEST_f_f (rint, 72057594037927936.75L, 72057594037927937.0L);
|
||||
TEST_f_f (rint, 72057594037927937.5L, 72057594037927938.0L);
|
||||
|
||||
TEST_f_f (rint, -72057594037927935.5L, -72057594037927936.0L);
|
||||
TEST_f_f (rint, -72057594037927936.25L, -72057594037927936.0L);
|
||||
TEST_f_f (rint, -72057594037927936.5L, -72057594037927936.0L);
|
||||
TEST_f_f (rint, -72057594037927936.75L, -72057594037927937.0L);
|
||||
TEST_f_f (rint, -72057594037927937.5L, -72057594037927938.0L);
|
||||
|
||||
TEST_f_f (rint, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (rint, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (rint, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (rint, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (rint, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L);
|
||||
#endif
|
||||
|
||||
END (rint);
|
||||
}
|
||||
@ -3924,6 +4145,51 @@ round_test (void)
|
||||
TEST_f_f (round, 2097152.5, 2097153);
|
||||
TEST_f_f (round, -2097152.5, -2097153);
|
||||
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
TEST_f_f (round, 4503599627370495.5L, 4503599627370496.0L);
|
||||
TEST_f_f (round, 4503599627370496.25L, 4503599627370496.0L);
|
||||
TEST_f_f (round, 4503599627370496.5L, 4503599627370497.0L);
|
||||
TEST_f_f (round, 4503599627370496.75L, 4503599627370497.0L);
|
||||
TEST_f_f (round, 4503599627370497.5L, 4503599627370498.0L);
|
||||
|
||||
TEST_f_f (round, -4503599627370495.5L, -4503599627370496.0L);
|
||||
TEST_f_f (round, -4503599627370496.25L, -4503599627370496.0L);
|
||||
TEST_f_f (round, -4503599627370496.5L, -4503599627370497.0L);
|
||||
TEST_f_f (round, -4503599627370496.75L, -4503599627370497.0L);
|
||||
TEST_f_f (round, -4503599627370497.5L, -4503599627370498.0L);
|
||||
|
||||
TEST_f_f (round, 9007199254740991.5L, 9007199254740992.0L);
|
||||
TEST_f_f (round, 9007199254740992.25L, 9007199254740992.0L);
|
||||
TEST_f_f (round, 9007199254740992.5L, 9007199254740993.0L);
|
||||
TEST_f_f (round, 9007199254740992.75L, 9007199254740993.0L);
|
||||
TEST_f_f (round, 9007199254740993.5L, 9007199254740994.0L);
|
||||
|
||||
TEST_f_f (round, -9007199254740991.5L, -9007199254740992.0L);
|
||||
TEST_f_f (round, -9007199254740992.25L, -9007199254740992.0L);
|
||||
TEST_f_f (round, -9007199254740992.5L, -9007199254740993.0L);
|
||||
TEST_f_f (round, -9007199254740992.75L, -9007199254740993.0L);
|
||||
TEST_f_f (round, -9007199254740993.5L, -9007199254740994.0L);
|
||||
|
||||
TEST_f_f (round, 72057594037927935.5L, 72057594037927936.0L);
|
||||
TEST_f_f (round, 72057594037927936.25L, 72057594037927936.0L);
|
||||
TEST_f_f (round, 72057594037927936.5L, 72057594037927937.0L);
|
||||
TEST_f_f (round, 72057594037927936.75L, 72057594037927937.0L);
|
||||
TEST_f_f (round, 72057594037927937.5L, 72057594037927938.0L);
|
||||
|
||||
TEST_f_f (round, -72057594037927935.5L, -72057594037927936.0L);
|
||||
TEST_f_f (round, -72057594037927936.25L, -72057594037927936.0L);
|
||||
TEST_f_f (round, -72057594037927936.5L, -72057594037927937.0L);
|
||||
TEST_f_f (round, -72057594037927936.75L, -72057594037927937.0L);
|
||||
TEST_f_f (round, -72057594037927937.5L, -72057594037927938.0L);
|
||||
|
||||
TEST_f_f (round, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (round, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (round, 10141204801825835211973625643008.5L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (round, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L);
|
||||
TEST_f_f (round, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L);
|
||||
#endif
|
||||
|
||||
END (round);
|
||||
}
|
||||
|
||||
@ -4291,6 +4557,50 @@ trunc_test (void)
|
||||
TEST_f_f (trunc, 4294967296.625L, 4294967296.0L);
|
||||
TEST_f_f (trunc, -4294967296.625L, -4294967296.0L);
|
||||
|
||||
#ifdef TEST_LDOUBLE
|
||||
/* The result can only be represented in long double. */
|
||||
TEST_f_f (trunc, 4503599627370495.5L, 4503599627370495.0L);
|
||||
TEST_f_f (trunc, 4503599627370496.25L, 4503599627370496.0L);
|
||||
TEST_f_f (trunc, 4503599627370496.5L, 4503599627370496.0L);
|
||||
TEST_f_f (trunc, 4503599627370496.75L, 4503599627370496.0L);
|
||||
TEST_f_f (trunc, 4503599627370497.5L, 4503599627370497.0L);
|
||||
|
||||
TEST_f_f (trunc, -4503599627370495.5L, -4503599627370495.0L);
|
||||
TEST_f_f (trunc, -4503599627370496.25L, -4503599627370496.0L);
|
||||
TEST_f_f (trunc, -4503599627370496.5L, -4503599627370496.0L);
|
||||
TEST_f_f (trunc, -4503599627370496.75L, -4503599627370496.0L);
|
||||
TEST_f_f (trunc, -4503599627370497.5L, -4503599627370497.0L);
|
||||
|
||||
TEST_f_f (trunc, 9007199254740991.5L, 9007199254740991.0L);
|
||||
TEST_f_f (trunc, 9007199254740992.25L, 9007199254740992.0L);
|
||||
TEST_f_f (trunc, 9007199254740992.5L, 9007199254740992.0L);
|
||||
TEST_f_f (trunc, 9007199254740992.75L, 9007199254740992.0L);
|
||||
TEST_f_f (trunc, 9007199254740993.5L, 9007199254740993.0L);
|
||||
|
||||
TEST_f_f (trunc, -9007199254740991.5L, -9007199254740991.0L);
|
||||
TEST_f_f (trunc, -9007199254740992.25L, -9007199254740992.0L);
|
||||
TEST_f_f (trunc, -9007199254740992.5L, -9007199254740992.0L);
|
||||
TEST_f_f (trunc, -9007199254740992.75L, -9007199254740992.0L);
|
||||
TEST_f_f (trunc, -9007199254740993.5L, -9007199254740993.0L);
|
||||
|
||||
TEST_f_f (trunc, 72057594037927935.5L, 72057594037927935.0L);
|
||||
TEST_f_f (trunc, 72057594037927936.25L, 72057594037927936.0L);
|
||||
TEST_f_f (trunc, 72057594037927936.5L, 72057594037927936.0L);
|
||||
TEST_f_f (trunc, 72057594037927936.75L, 72057594037927936.0L);
|
||||
TEST_f_f (trunc, 72057594037927937.5L, 72057594037927937.0L);
|
||||
|
||||
TEST_f_f (trunc, -72057594037927935.5L, -72057594037927935.0L);
|
||||
TEST_f_f (trunc, -72057594037927936.25L, -72057594037927936.0L);
|
||||
TEST_f_f (trunc, -72057594037927936.5L, -72057594037927936.0L);
|
||||
TEST_f_f (trunc, -72057594037927936.75L, -72057594037927936.0L);
|
||||
TEST_f_f (trunc, -72057594037927937.5L, -72057594037927937.0L);
|
||||
|
||||
TEST_f_f (trunc, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L);
|
||||
TEST_f_f (trunc, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (trunc, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (trunc, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L);
|
||||
TEST_f_f (trunc, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L);
|
||||
#endif
|
||||
|
||||
END (trunc);
|
||||
}
|
||||
|
28
math/math.h
28
math/math.h
@ -1,5 +1,6 @@
|
||||
/* Declarations for math functions.
|
||||
Copyright (C) 1991-1993,1995-1999,2001,2002,2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991-1993, 1995-1999, 2001, 2002, 2004, 2006
|
||||
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
|
||||
@ -96,10 +97,33 @@ __BEGIN_DECLS
|
||||
# undef _Mdouble_END_NAMESPACE
|
||||
# undef __MATH_PRECNAME
|
||||
|
||||
# if (__STDC__ - 0 || __GNUC__ - 0) && !defined __NO_LONG_DOUBLE_MATH
|
||||
# if (__STDC__ - 0 || __GNUC__ - 0) \
|
||||
&& (!defined __NO_LONG_DOUBLE_MATH || defined __LDBL_COMPAT)
|
||||
# ifdef __LDBL_COMPAT
|
||||
|
||||
# ifdef __USE_ISOC99
|
||||
extern float __nldbl_nexttowardf (float __x, long double __y)
|
||||
__attribute__ ((__const__)) __THROW;
|
||||
# ifdef __REDIRECT_NTH
|
||||
extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
|
||||
__nldbl_nexttowardf)
|
||||
__attribute__ ((__const__));
|
||||
extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
|
||||
nextafter) __attribute__ ((__const__));
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Include the file of declarations again, this time using `long double'
|
||||
instead of `double' and appending l to each function name. */
|
||||
|
||||
# undef __MATHDECL_1
|
||||
# define __MATHDECL_2(type, function,suffix, args, alias) \
|
||||
extern type __REDIRECT(__MATH_PRECNAME(function,suffix), \
|
||||
args, alias) __THROW
|
||||
# define __MATHDECL_1(type, function,suffix, args) \
|
||||
__MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
|
||||
# endif
|
||||
|
||||
# ifndef _Mlong_double_
|
||||
# define _Mlong_double_ long double
|
||||
# endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Return arc hyperbole cosine for double value.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||
|
||||
@ -73,6 +73,9 @@ __cacosh (__complex__ double x)
|
||||
|
||||
y = __csqrt (y);
|
||||
|
||||
if (__real__ x < 0.0)
|
||||
y = -y;
|
||||
|
||||
__real__ y += __real__ x;
|
||||
__imag__ y += __imag__ x;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Return arc hyperbole cosine for float value.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||
|
||||
@ -75,6 +75,9 @@ __cacoshf (__complex__ float x)
|
||||
|
||||
y = __csqrtf (y);
|
||||
|
||||
if (__real__ x < 0.0)
|
||||
y = -y;
|
||||
|
||||
__real__ y += __real__ x;
|
||||
__imag__ y += __imag__ x;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Return arc hyperbole cosine for long double value.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||
|
||||
@ -73,6 +73,9 @@ __cacoshl (__complex__ long double x)
|
||||
|
||||
y = __csqrtl (y);
|
||||
|
||||
if (__real__ x < 0.0)
|
||||
y = -y;
|
||||
|
||||
__real__ y += __real__ x;
|
||||
__imag__ y += __imag__ x;
|
||||
|
||||
|
11
math/w_j0l.c
11
math/w_j0l.c
@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
|
||||
#include "math_private.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
long double j0l(long double x) /* wrapper j0l */
|
||||
long double __j0l(long double x) /* wrapper j0l */
|
||||
#else
|
||||
long double j0l(x) /* wrapper j0 */
|
||||
long double __j0l(x) /* wrapper j0 */
|
||||
long double x;
|
||||
#endif
|
||||
{
|
||||
@ -43,11 +43,12 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
weak_alias (__j0l, j0l)
|
||||
|
||||
#ifdef __STDC__
|
||||
long double y0l(long double x) /* wrapper y0l */
|
||||
long double __y0l(long double x) /* wrapper y0l */
|
||||
#else
|
||||
long double y0l(x) /* wrapper y0 */
|
||||
long double __y0l(x) /* wrapper y0 */
|
||||
long double x;
|
||||
#endif
|
||||
{
|
||||
@ -71,3 +72,5 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
|
||||
weak_alias (__y0l, y0l)
|
||||
|
10
math/w_j1l.c
10
math/w_j1l.c
@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
|
||||
#include "math_private.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
long double j1l(long double x) /* wrapper j1l */
|
||||
long double __j1l(long double x) /* wrapper j1l */
|
||||
#else
|
||||
long double j1l(x) /* wrapper j1l */
|
||||
long double __j1l(x) /* wrapper j1l */
|
||||
long double x;
|
||||
#endif
|
||||
{
|
||||
@ -44,11 +44,12 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
weak_alias (__j1l, j1l)
|
||||
|
||||
#ifdef __STDC__
|
||||
long double y1l(long double x) /* wrapper y1l */
|
||||
long double __y1l(long double x) /* wrapper y1l */
|
||||
#else
|
||||
long double y1l(x) /* wrapper y1l */
|
||||
long double __y1l(x) /* wrapper y1l */
|
||||
long double x;
|
||||
#endif
|
||||
{
|
||||
@ -72,3 +73,4 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
weak_alias (__y1l, y1l)
|
||||
|
10
math/w_jnl.c
10
math/w_jnl.c
@ -48,9 +48,9 @@ static char rcsid[] = "$NetBSD: $";
|
||||
#include "math_private.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
long double jnl(int n, long double x) /* wrapper jnl */
|
||||
long double __jnl(int n, long double x) /* wrapper jnl */
|
||||
#else
|
||||
long double jnl(n,x) /* wrapper jnl */
|
||||
long double __jnl(n,x) /* wrapper jnl */
|
||||
long double x; int n;
|
||||
#endif
|
||||
{
|
||||
@ -66,11 +66,12 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
weak_alias (__jnl, jnl)
|
||||
|
||||
#ifdef __STDC__
|
||||
long double ynl(int n, long double x) /* wrapper ynl */
|
||||
long double __ynl(int n, long double x) /* wrapper ynl */
|
||||
#else
|
||||
long double ynl(n,x) /* wrapper ynl */
|
||||
long double __ynl(n,x) /* wrapper ynl */
|
||||
long double x; int n;
|
||||
#endif
|
||||
{
|
||||
@ -94,3 +95,4 @@ static char rcsid[] = "$NetBSD: $";
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
weak_alias (__ynl, ynl)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991-2002,2003,2004,2005,2006 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
|
||||
@ -25,11 +25,12 @@ subdir := misc
|
||||
headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
|
||||
sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \
|
||||
ar.h a.out.h libgen.h stab.h bits/stab.def sgtty.h \
|
||||
ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \
|
||||
ttyent.h paths.h sys/reboot.h \
|
||||
sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h \
|
||||
sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \
|
||||
sys/select.h ustat.h sys/ustat.h bits/ustat.h sys/sysinfo.h \
|
||||
regexp.h bits/select.h bits/mman.h sys/xattr.h bits/syslog.h
|
||||
regexp.h bits/select.h bits/mman.h sys/xattr.h \
|
||||
syslog.h sys/syslog.h bits/syslog.h bits/syslog-ldbl.h
|
||||
|
||||
routines := brk sbrk sstk ioctl \
|
||||
readv writev \
|
||||
@ -76,7 +77,7 @@ endif
|
||||
gpl2lgpl := error.c error.h
|
||||
|
||||
tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
|
||||
tst-error1
|
||||
tst-error1 tst-pselect
|
||||
ifeq (no,$(cross-compiling))
|
||||
tests: $(objpfx)tst-error1-mem
|
||||
endif
|
||||
|
36
misc/bits/syslog-ldbl.h
Normal file
36
misc/bits/syslog-ldbl.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* -mlong-double-64 compatibility mode for syslog functions.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _SYS_SYSLOG_H
|
||||
# error "Never include <bits/syslog-ldbl.h> directly; use <sys/syslog.h> instead."
|
||||
#endif
|
||||
|
||||
__LDBL_REDIR_DECL (syslog)
|
||||
|
||||
#ifdef __USE_BSD
|
||||
__LDBL_REDIR_DECL (vsyslog)
|
||||
#endif
|
||||
|
||||
#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
|
||||
__LDBL_REDIR_DECL (__syslog_chk)
|
||||
|
||||
# ifdef __USE_BSD
|
||||
__LDBL_REDIR_DECL (__vsyslog_chk)
|
||||
# endif
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
/* Compatibility functions for floating point formatting.
|
||||
Copyright (C) 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -23,6 +24,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <float.h>
|
||||
#include <bits/libc-lock.h>
|
||||
#include <math_ldbl_opt.h>
|
||||
|
||||
#ifndef FLOAT_TYPE
|
||||
# define FLOAT_TYPE double
|
||||
@ -44,10 +46,14 @@
|
||||
# error "NDIGIT_MAX must be precomputed"
|
||||
# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
|
||||
# endif
|
||||
#else
|
||||
# define LONG_DOUBLE_CVT
|
||||
#endif
|
||||
|
||||
#define APPEND(a, b) APPEND2 (a, b)
|
||||
#define APPEND2(a, b) a##b
|
||||
#define __APPEND(a, b) __APPEND2 (a, b)
|
||||
#define __APPEND2(a, b) __##a##b
|
||||
|
||||
|
||||
#define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
|
||||
@ -60,14 +66,14 @@ static char ECVT_BUFFER[MAXDIG];
|
||||
libc_freeres_ptr (static char *FCVT_BUFPTR);
|
||||
|
||||
char *
|
||||
APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
|
||||
__APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
|
||||
FLOAT_TYPE value;
|
||||
int ndigit, *decpt, *sign;
|
||||
{
|
||||
if (FCVT_BUFPTR == NULL)
|
||||
{
|
||||
if (APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
|
||||
FCVT_BUFFER, MAXDIG) != -1)
|
||||
if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
|
||||
FCVT_BUFFER, MAXDIG) != -1)
|
||||
return FCVT_BUFFER;
|
||||
|
||||
FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
|
||||
@ -75,26 +81,26 @@ APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
|
||||
return FCVT_BUFFER;
|
||||
}
|
||||
|
||||
(void) APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
|
||||
FCVT_BUFPTR, FCVT_MAXDIG);
|
||||
(void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
|
||||
FCVT_BUFPTR, FCVT_MAXDIG);
|
||||
|
||||
return FCVT_BUFPTR;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign)
|
||||
__APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign)
|
||||
FLOAT_TYPE value;
|
||||
int ndigit, *decpt, *sign;
|
||||
{
|
||||
(void) APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
|
||||
ECVT_BUFFER, MAXDIG);
|
||||
(void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
|
||||
ECVT_BUFFER, MAXDIG);
|
||||
|
||||
return ECVT_BUFFER;
|
||||
}
|
||||
|
||||
char *
|
||||
APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
|
||||
__APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
|
||||
FLOAT_TYPE value;
|
||||
int ndigit;
|
||||
char *buf;
|
||||
@ -102,3 +108,26 @@ APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
|
||||
sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
|
||||
# ifdef LONG_DOUBLE_CVT
|
||||
# define cvt_symbol(symbol) \
|
||||
cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
|
||||
APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
|
||||
# define cvt_symbol_1(lib, local, symbol, version) \
|
||||
versioned_symbol (lib, local, symbol, version)
|
||||
# else
|
||||
# define cvt_symbol(symbol) \
|
||||
cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
|
||||
APPEND (q, symbol), GLIBC_2_0); \
|
||||
strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
|
||||
# define cvt_symbol_1(lib, local, symbol, version) \
|
||||
compat_symbol (lib, local, symbol, version)
|
||||
# endif
|
||||
#else
|
||||
# define cvt_symbol(symbol) \
|
||||
strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
|
||||
#endif
|
||||
cvt_symbol(fcvt);
|
||||
cvt_symbol(ecvt);
|
||||
cvt_symbol(gcvt);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* Compatibility functions for floating point formatting, reentrant versions.
|
||||
Copyright (C) 1995,96,97,98,99,2000,01,02,04 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006
|
||||
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
|
||||
@ -25,6 +26,7 @@
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <math_ldbl_opt.h>
|
||||
|
||||
#ifndef FLOAT_TYPE
|
||||
# define FLOAT_TYPE double
|
||||
@ -55,10 +57,14 @@
|
||||
# error "FLOAT_MIN_10_NORM must be precomputed"
|
||||
# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP)
|
||||
# endif
|
||||
#else
|
||||
# define LONG_DOUBLE_CVT
|
||||
#endif
|
||||
|
||||
#define APPEND(a, b) APPEND2 (a, b)
|
||||
#define APPEND2(a, b) a##b
|
||||
#define __APPEND(a, b) __APPEND2 (a, b)
|
||||
#define __APPEND2(a, b) __##a##b
|
||||
|
||||
#define FLOOR APPEND(floor, FLOAT_NAME_EXT)
|
||||
#define FABS APPEND(fabs, FLOAT_NAME_EXT)
|
||||
@ -67,7 +73,7 @@
|
||||
|
||||
|
||||
int
|
||||
APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
FLOAT_TYPE value;
|
||||
int ndigit, *decpt, *sign;
|
||||
char *buf;
|
||||
@ -163,10 +169,9 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
|
||||
return 0;
|
||||
}
|
||||
libc_hidden_def (APPEND (FUNC_PREFIX, fcvt_r))
|
||||
|
||||
int
|
||||
APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
__APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
FLOAT_TYPE value;
|
||||
int ndigit, *decpt, *sign;
|
||||
char *buf;
|
||||
@ -229,11 +234,32 @@ APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
|
||||
*sign = isfinite (value) ? signbit (value) != 0 : 0;
|
||||
}
|
||||
else
|
||||
if (APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
|
||||
decpt, sign, buf, len))
|
||||
if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
|
||||
decpt, sign, buf, len))
|
||||
return -1;
|
||||
|
||||
*decpt += exponent;
|
||||
return 0;
|
||||
}
|
||||
libc_hidden_def (APPEND (FUNC_PREFIX, ecvt_r))
|
||||
|
||||
#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
|
||||
# ifdef LONG_DOUBLE_CVT
|
||||
# define cvt_symbol(symbol) \
|
||||
cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
|
||||
APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
|
||||
# define cvt_symbol_1(lib, local, symbol, version) \
|
||||
versioned_symbol (lib, local, symbol, version)
|
||||
# else
|
||||
# define cvt_symbol(symbol) \
|
||||
cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
|
||||
APPEND (q, symbol), GLIBC_2_0); \
|
||||
strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
|
||||
# define cvt_symbol_1(lib, local, symbol, version) \
|
||||
compat_symbol (lib, local, symbol, version)
|
||||
# endif
|
||||
#else
|
||||
# define cvt_symbol(symbol) \
|
||||
strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
|
||||
#endif
|
||||
cvt_symbol(fcvt_r);
|
||||
cvt_symbol(ecvt_r);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user