diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2011-06-24 16:24:25 +0200 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2011-06-24 16:24:25 +0200 |
commit | 7682323a3a798d6f15708f228f859a64cb869aa3 (patch) | |
tree | 0f3648e92245745c9828db3175651974b10c9ae4 | |
parent | 3004ce0c9619f89bf8e64931edd696bf4df8d2e1 (diff) | |
parent | 74da7a88552ecf518e64642c90742fddca57be00 (diff) |
Merge remote-tracking branch 'origin/master' into prelink
* origin/master: (61 commits)
fts: fix warning due to old-style function definition
ldso_tls: fix compiler warning due to missing cast
resolv: fix bug in res_init with ipv6 nameservers
config: Fix passing defconfig args
buildsys: pt-initfini.s depends on uClibc_config.h
libdl: search for ELF_RTYPE_CLASS_DLSYM in dlsym()
resolv: try next server on SERVFAIL
getaddrinfo: allow numeric service without any hints
bump version to 0.9.33-git
nptl/pthread: Correct path for machine specific pt-initfini.c
ctor/dtor nptl: Fix init and fini function compilation
Rules.mak: Rearrange appending UCLIBC_EXTRA_CFLAGS to CFLAGS
ARM: remove EABI/OABI selection
ARM: detect BX availibility at build time
ARM: #include <bits/arm_asm.h> where __USE_BX__ is used
ARM: transform the EABI/OABI choice into a boolean
ARM: remove sub-arch/variants selection from menuconfig
ARM: introduce blind options to select & force THUMB mode
ARM: reorder "Use BX" option
Fix __libc_epoll_pwait compile failure on x86
...
Conflicts:
ldso/libdl/libdl.c
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
72 files changed, 613 insertions, 579 deletions
diff --git a/Makefile.help b/Makefile.help index 1c2c96e04..d99cf9634 100644 --- a/Makefile.help +++ b/Makefile.help @@ -60,4 +60,5 @@ help: @echo ' and the include dir (usually "/usr")' @echo ' MULTILIB_DIR= - Directory component for libraries (default "lib").' @echo ' UCLIBC_EXTRA_CFLAGS - extra CFLAGS for compiling uClibc' + @echo ' UCLIBC_EXTRA_CPPFLAGS - extra CPPFLAGS for compiling uClibc' diff --git a/Makefile.in b/Makefile.in index 2f8370b0f..ad9e629e1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -161,7 +161,7 @@ headers-y += $(target-headers-sysdep) headers: $(top_builddir)include/bits/uClibc_config.h | subdirs subdirs: $(addprefix $(top_builddir),$(subdirs)) pregen-headers: $(top_builddir)include/bits/sysnum.h $(pregen-headers-y) -pregen: pregen-headers +pregen: headers pregen-headers $(Q)$(if $(UCLIBC_HAS_LOCALE),$(MAKE) -C extra/locale locale_headers) $(top_builddir)include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh | $(top_builddir)include/bits @@ -338,7 +338,7 @@ else endif ifeq ($(UCLIBC_HAS_BACKTRACE),y) # Add the AS_NEEDED entry for libubacktrace.so - if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_MAJORNAME) ] ; then \ + if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME) ] ; then \ echo "GROUP ( $(UBACKTRACE_ASNEEDED) )" >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \ fi endif @@ -448,8 +448,8 @@ allnoconfig: $(top_builddir)extra/config/conf $(Q)$(top_builddir)extra/config/conf -n extra/Configs/Config.in defconfig: $(top_builddir)extra/config/conf - $(Q)$(top_builddir)extra/config/conf -d extra/Configs/Config.in \ - -D extra/Configs/defconfigs/$(ARCH) + $(Q)$(top_builddir)extra/config/conf \ + -D extra/Configs/defconfigs/$(ARCH) extra/Configs/Config.in menuconfig-clean-y: $(Q)$(MAKE) -C extra/config CLEAN_extra/config @@ -233,12 +233,12 @@ cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) \ $(CFLAGS-$(notdir $<)) \ $(CFLAGS-$(notdir $@)) \ $(CFLAGS_gen.dep) -cmd_compile.i = $(cmd_compile.c:-c=-E -dD $(EXTRA_CPPFLAGS)) +cmd_compile.i = $(cmd_compile.c:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS) cmd_compile.s = $(cmd_compile.c:-c=-S) cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep) cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@)) cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) -cmd_compile.mi= $(cmd_compile.m:-c=-E -dD $(EXTRA_CPPFLAGS)) +cmd_compile.mi= $(cmd_compile.m:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS) cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(sort $(foreach d,$(^:$(top_srcdir)=),$(collect_multi_flags))) cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^ @@ -105,8 +105,8 @@ export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS MULTILIB_DIR # Now config hard core MAJOR_VERSION := 0 MINOR_VERSION := 9 -SUBLEVEL := 32 -EXTRAVERSION :=-rc3-git +SUBLEVEL := 33 +EXTRAVERSION :=-git VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL) ABI_VERSION := $(MAJOR_VERSION) ifneq ($(EXTRAVERSION),) @@ -186,6 +186,7 @@ OPTIMIZATION+=$(call check_gcc,-Os,-O2) OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) # shrinks code by about 0.1% OPTIMIZATION+=$(call check_gcc,-fmerge-all-constants) +OPTIMIZATION+=$(call check_gcc,-fstrict-aliasing) GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1) #GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2) @@ -332,28 +333,9 @@ ifeq ($(TARGET_ARCH),sparc) endif ifeq ($(TARGET_ARCH),arm) - OPTIMIZATION+=-fstrict-aliasing CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian - CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+= - CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3 - CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3 - CPU_CFLAGS-$(CONFIG_ARM7TDMI)+=-mtune=arm7tdmi -march=armv4t - CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4t - CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4t - CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4t - CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9e -march=armv5te - CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t - CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6 - CPU_CFLAGS-$(CONFIG_ARM1176JZ_S)+=-mtune=arm1176jz-s -march=armv6 - CPU_CFLAGS-$(CONFIG_ARM1176JZF_S)+=-mtune=arm1176jzf-s -march=armv6 - CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4 - CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4 - CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110) - CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale - CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt - CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M3)+=-mcpu=cortex-m3 -mthumb - CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M1)+=-mcpu=cortex-m1 -mthumb + CPU_CFLAGS-$(COMPILE_IN_THUMB_MODE)+=-mthumb endif ifeq ($(TARGET_ARCH),mips) @@ -385,7 +367,6 @@ ifeq ($(TARGET_ARCH),nios) endif ifeq ($(TARGET_ARCH),sh) - OPTIMIZATION+=-fstrict-aliasing OPTIMIZATION+= $(call check_gcc,-mprefergot,) CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb @@ -401,7 +382,6 @@ endif endif ifeq ($(TARGET_ARCH),sh64) - OPTIMIZATION+=-fstrict-aliasing CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media @@ -546,10 +526,10 @@ endif endif # Add a bunch of extra pedantic annoyingly strict checks -XWARNINGS=$(call qstrip,$(WARNINGS)) +XWARNINGS=$(call qstrip,$(WARNINGS)) XWARNINGS+=$(foreach w,\ -Wstrict-prototypes \ - -fno-strict-aliasing \ + -Wstrict-aliasing \ , $(call check_gcc,$(w),)) ifeq ($(EXTRA_WARNINGS),y) XWARNINGS+=$(foreach w,\ @@ -587,9 +567,6 @@ CFLAGS := -include $(top_srcdir)include/libc-symbols.h \ -nostdinc -I$(top_builddir)include -I$(top_srcdir)include -I. \ -I$(top_srcdir)libc/sysdeps/linux \ -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) -ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"") -CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS)) -endif # We need this to be checked within libc-symbols.h ifneq ($(HAVE_SHARED),y) @@ -635,6 +612,9 @@ LDFLAGS += -Wl,-s else STRIPTOOL := true -Stripping_disabled endif +ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"") +CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS)) +endif ifeq ($(DOMULTI),y) # we try to compile all sources at once into an object (IMA), but diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm index eb27a3391..0bb2971a9 100644 --- a/extra/Configs/Config.arm +++ b/extra/Configs/Config.arm @@ -12,122 +12,27 @@ config FORCE_OPTIONS_FOR_ARCH default y select ARCH_ANY_ENDIAN -choice - prompt "Target ABI" - default CONFIG_ARM_EABI +config CONFIG_ARM_EABI + bool "Build for EABI" help - If you choose "EABI" here, functions and constants required by the - ARM EABI will be built into the library. You should choose "EABI" + If you say 'y' here, functions and constants required by the + ARM EABI will be built into the library. You should say 'y' if your compiler uses the ARM EABI, in which case you will also - need a kernel supporting the EABI system call interface, or "OABI" - for a compiler using the old Linux ABI. - -config CONFIG_ARM_OABI - bool "OABI" + need a kernel supporting the EABI system call interface. -config CONFIG_ARM_EABI - bool "EABI" + If you say 'n' here, then the library will be built for the + old Linux ABI. -endchoice +config COMPILE_IN_THUMB_MODE + bool "Build using Thumb mode" + select USE_BX + help + Say 'y' here to force building uClibc in thumb mode. + Say 'n' to use your compiler's default mode. config USE_BX bool "Use BX in function return" - default y - depends on !CONFIG_GENERIC_ARM && !CONFIG_ARM610 && !CONFIG_ARM710 - help - Use BX instruction for THUMB aware architectures. - -choice - prompt "Target Processor Type" - default CONFIG_GENERIC_ARM help - This is the processor type of your CPU. This information is used for - optimizing purposes. To build a library that will run on all ARMCPU - types (albeit not optimally fast), you can specify "Generic Arm" here. - If you pick anything other than "Generic Arm", there is no guarantee - that uClibc will even run on anything other than the selected - processor type. - - Here are the settings recommended for greatest speed: - - "Generic Arm" select this if your compiler is already setup to - optimize things properly, or if you want to run on pretty much - everything, or you just don't much care. - - For anything else, pick the ARM core type that best matches the - cpu you will be using on your device. - - If you don't know what to do, choose "Generic Arm". - -config CONFIG_GENERIC_ARM - bool "Generic Arm" - -config CONFIG_ARM610 - bool "Arm 610" - select ARCH_HAS_MMU - -config CONFIG_ARM710 - bool "Arm 710" - select ARCH_HAS_MMU - -config CONFIG_ARM7TDMI - bool "Arm 7TDMI" - select ARCH_HAS_NO_MMU - -config CONFIG_ARM720T - bool "Arm 720T" - select ARCH_HAS_MMU - -config CONFIG_ARM920T - bool "Arm 920T" - select ARCH_HAS_MMU - -config CONFIG_ARM922T - bool "Arm 922T" - select ARCH_HAS_MMU - -config CONFIG_ARM926T - bool "Arm 926T" - select ARCH_HAS_MMU - -config CONFIG_ARM10T - bool "Arm 10T" - select ARCH_HAS_MMU - -config CONFIG_ARM1136JF_S - bool "Arm 1136JF-S" - select ARCH_HAS_MMU - -config CONFIG_ARM1176JZ_S - bool "Arm 1176JZ-S" - select ARCH_HAS_MMU - -config CONFIG_ARM1176JZF_S - bool "Arm 1176JZF-S" - select ARCH_HAS_MMU - -config CONFIG_ARM_CORTEX_M3 - bool "Arm Cortex-M3" - select ARCH_HAS_NO_MMU - select USE_BX - -config CONFIG_ARM_CORTEX_M1 - bool "Arm Cortex-M1" - select ARCH_HAS_NO_MMU - select USE_BX - -config CONFIG_ARM_SA110 - bool "Intel StrongArm SA-110" - select ARCH_HAS_MMU - -config CONFIG_ARM_SA1100 - bool "Intel StrongArm SA-1100" - select ARCH_HAS_MMU - -config CONFIG_ARM_XSCALE - bool "Intel Xscale" - select ARCH_HAS_MMU - -config CONFIG_ARM_IWMMXT - bool "Intel Xscale With WMMX PXA27x" - select ARCH_HAS_MMU - -endchoice + Say 'y' to use BX to return from functions on your thumb-aware + processor. Say 'y' if you need to use interworking. Say 'n' if not. + It is safe to say 'y' even if you're not doing interworking. diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 843988959..2fa0b076d 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -942,8 +942,10 @@ config UCLIBC_LINUX_SPECIFIC bool "Linux specific functions" default y help + accept4(), capget(), capset(), fstatfs(), inotify_*(), ioperm(), iopl(), - madvise(), modify_ldt(), personality(), prctl()/arch_prctl(), + madvise(), modify_ldt(), pipe2(), personality(), + prctl()/arch_prctl(), ppoll(), readahead(), reboot(), remap_file_pages(), sched_getaffinity(), sched_setaffinity(), sendfile(), setfsgid(), setfsuid(), setresuid(), diff --git a/include/sys/socket.h b/include/sys/socket.h index 0824fc855..6037f92ae 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -227,6 +227,15 @@ extern int accept (int __fd, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len); libc_hidden_proto(accept) +#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU +/* Similar to 'accept' but takes an additional parameter to specify flags. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int accept4 (int __fd, __SOCKADDR_ARG __addr, + socklen_t *__restrict __addr_len, int __flags); +#endif + /* Shut down all or part of the connection open on socket FD. HOW determines what to shut down: SHUT_RD = No more receptions; diff --git a/include/unistd.h b/include/unistd.h index c421cb308..956879003 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -389,6 +389,13 @@ extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n, extern int pipe (int __pipedes[2]) __THROW __wur; libc_hidden_proto(pipe) +#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU +/* Same as pipe but apply flags passed in FLAGS to the new file + descriptors. */ +extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur; +libc_hidden_proto(pipe2) +#endif + /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. If SECONDS is zero, any currently scheduled alarm will be cancelled. The function returns the number of seconds remaining until the last diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h index d387c0bb9..11edc4dfc 100644 --- a/ldso/include/dl-defs.h +++ b/ldso/include/dl-defs.h @@ -179,6 +179,14 @@ typedef struct { #define DL_LOOKUP_ADDRESS(ADDRESS) (ADDRESS) #endif +/* On some architectures dladdr can't use st_size of all symbols this way. */ +#define DL_ADDR_SYM_MATCH(SYM_ADDR, SYM, MATCHSYM, ADDR) \ + ((ADDR) >= (SYM_ADDR) \ + && ((((SYM)->st_shndx == SHN_UNDEF || (SYM)->st_size == 0) \ + && (ADDR) == (SYM_ADDR)) \ + || (ADDR) < (SYM_ADDR) + (SYM)->st_size) \ + && (!(MATCHSYM) || MATCHSYM < (SYM_ADDR))) + /* Use this macro to convert a pointer to a function's entry point to * a pointer to function. The pointer is assumed to have already been * relocated. LOADADDR is passed because it may contain additional diff --git a/ldso/ldso/arm/dl-startup.h b/ldso/ldso/arm/dl-startup.h index a95389d98..2dfdaffda 100644 --- a/ldso/ldso/arm/dl-startup.h +++ b/ldso/ldso/arm/dl-startup.h @@ -7,6 +7,7 @@ */ #include <features.h> +#include <bits/arm_asm.h> #if !defined(__thumb__) __asm__( diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 9e1415b83..5cf50d4ed 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -718,6 +718,9 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, DL_UPDATE_LOADADDR_HDR(lib_loadaddr, new_addr + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); + /* This has invalidated all pointers into the previously readonly segment. + Update any them to point into the remapped segment. */ + _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr); #endif } } diff --git a/ldso/ldso/dl-tls.c b/ldso/ldso/dl-tls.c index 43dd5a00a..362efbbec 100644 --- a/ldso/ldso/dl-tls.c +++ b/ldso/ldso/dl-tls.c @@ -1025,7 +1025,7 @@ init_tls (void) /* And finally install it for the main thread. If ld.so itself uses TLS we know the thread pointer was initialized earlier. */ - const char *lossage = TLS_INIT_TP (tcbp, USE___THREAD); + const char *lossage = (char *)TLS_INIT_TP (tcbp, USE___THREAD); if(__builtin_expect (lossage != NULL, 0)) { _dl_debug_early("cannot set up thread-local storage: %s\n", lossage); _dl_exit(30); diff --git a/ldso/ldso/x86_64/dl-startup.h b/ldso/ldso/x86_64/dl-startup.h index 7e05846dd..b2ea93db7 100644 --- a/ldso/ldso/x86_64/dl-startup.h +++ b/ldso/ldso/x86_64/dl-startup.h @@ -58,6 +58,9 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, ElfW(Addr) *reloc_addr, case R_X86_64_TPOFF64: *reloc_addr = sym->st_value + rpnt->r_addend - symbol_addr; break; +/*TODO: case R_X86_64_RELATIVE: + *reloc_addr = load_addr + rpnt->r_addend; + break; */ default: _dl_exit(1); } diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 83dfd0898..4ecd1c55e 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -706,12 +706,12 @@ void *dlsym(void *vhandle, const char *name) tpnt = NULL; if (handle == _dl_symbol_tables) tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ - ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, 0, &sym_ref); + ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref); #if defined(USE_TLS) && USE_TLS && defined SHARED if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) { /* The found symbol is a thread-local storage variable. - Return the address for to the current thread. */ + Return its address for the current thread. */ ret = _dl_tls_symaddr ((struct link_map *)sym_ref.tpnt, (Elf32_Addr)ret); } #endif @@ -1118,7 +1118,11 @@ int dladdr(const void *__address, Dl_info * __info) ElfW(Addr) symbol_addr; symbol_addr = (ElfW(Addr)) DL_RELOC_ADDR(pelf->loadaddr, symtab[si].st_value); - if (symbol_addr <= (ElfW(Addr))__address && (!sf || sa < symbol_addr)) { + if ((symtab[si].st_shndx != SHN_UNDEF + || symtab[si].st_value != 0) + && ELF_ST_TYPE(symtab[si].st_info) != STT_TLS + && DL_ADDR_SYM_MATCH(symbol_addr, &symtab[si], sa, + (ElfW(Addr)) __address)) { sa = symbol_addr; sn = si; sf = 1; @@ -1134,7 +1138,11 @@ int dladdr(const void *__address, Dl_info * __info) ElfW(Addr) symbol_addr; symbol_addr = (ElfW(Addr)) DL_RELOC_ADDR(pelf->loadaddr, symtab[si].st_value); - if (symbol_addr <= (ElfW(Addr))__address && (!sf || sa < symbol_addr)) { + if ((symtab[si].st_shndx != SHN_UNDEF + || symtab[si].st_value != 0) + && ELF_ST_TYPE(symtab[si].st_info) != STT_TLS + && DL_ADDR_SYM_MATCH(symbol_addr, &symtab[si], sa, + (ElfW(Addr)) __address)) { sa = symbol_addr; sn = si; sf = 1; diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index abcf2f7d7..d58822074 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -44,11 +44,12 @@ CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \ ## CSRC-y += encodep.c decodep.c formquery.c # multi source socketcalls.c -socketcalls_CSRC += \ +socketcalls_CSRC-y += \ accept.c bind.c connect.c getpeername.c getsockname.c \ getsockopt.c listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c \ sendto.c setsockopt.c shutdown.c socket.c socketpair.c -CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC) opensock.c +socketcalls_CSRC-$(UCLIBC_LINUX_SPECIFIC) += accept4.c +CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC-y) opensock.c CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ethers.c ether_addr.c diff --git a/libc/inet/accept4.c b/libc/inet/accept4.c new file mode 100644 index 000000000..e2fdd6c2f --- /dev/null +++ b/libc/inet/accept4.c @@ -0,0 +1,8 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#define L_accept4 +#include "socketcalls.c" diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 1a77c5199..e7511f6c4 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -820,13 +820,6 @@ getaddrinfo(const char *name, const char *service, if (hints->ai_flags & AI_NUMERICSERV) return EAI_NONAME; gaih_service.num = -1; - } else { - /* - * Can't specify a numerical socket unless a protocol - * family was given. - */ - if (hints->ai_socktype == 0 && hints->ai_protocol == 0) - return EAI_SERVICE; } pservice = &gaih_service; } else diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 021d5bf5d..dc8a752fa 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -1461,7 +1461,7 @@ int attribute_hidden __dns_lookup(const char *name, /* bug 660 says we treat negative response as an error * and retry, which is, eh, an error. :) * We were incurring long delays because of this. */ - if (h.rcode == NXDOMAIN) { + if (h.rcode == NXDOMAIN || h.rcode == SERVFAIL) { /* if possible, try next search domain */ if (!ends_with_dot) { DPRINTF("variant:%d sdomains:%d\n", variant, sdomains); @@ -2964,7 +2964,7 @@ int res_init(void) if (__nameserver[i].sa.sa_family == AF_INET6 && m < ARRAY_SIZE(rp->_u._ext.nsaddrs) ) { - struct sockaddr_in6 *sa6 = malloc(sizeof(sa6)); + struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6)); if (sa6) { *sa6 = __nameserver[i].sa6; /* struct copy */ rp->_u._ext.nsaddrs[m] = sa6; @@ -2981,7 +2981,7 @@ int res_init(void) #else /* IPv6 only */ while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs) && i < __nameservers) { - struct sockaddr_in6 *sa6 = malloc(sizeof(sa6)); + struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6)); if (sa6) { *sa6 = __nameserver[i].sa6; /* struct copy */ rp->_u._ext.nsaddrs[m] = sa6; diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c index 42a5a563f..aae7e93bf 100644 --- a/libc/inet/socketcalls.c +++ b/libc/inet/socketcalls.c @@ -31,6 +31,7 @@ extern int __socketcall(int call, unsigned long *args) attribute_hidden; #define SYS_GETSOCKOPT 15 #define SYS_SENDMSG 16 #define SYS_RECVMSG 17 +#define SYS_ACCEPT4 18 #endif #ifdef __UCLIBC_HAS_THREADS_NATIVE__ @@ -82,6 +83,46 @@ weak_alias(__libc_accept,accept) libc_hidden_weak(accept) #endif +#ifdef L_accept4 +#ifdef __NR_accept4 +# define __NR___sys_accept4 __NR_accept4 +static _syscall4(int, __sys_accept4, int, fd, struct sockaddr *, addr, socklen_t *, addrlen, int, flags) +int accept4(int fd, struct sockaddr *addr, socklen_t * addrlen, int flags) +{ + if (SINGLE_THREAD_P) + return __sys_accept4(fd, addr, addrlen, flags); +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + else { + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __sys_accept4(fd, addr, addrlen, flags); + LIBC_CANCEL_RESET (oldtype); + return result; + } +#endif +} +#elif defined(__NR_socketcall) +int accept4(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags) +{ + unsigned long args[4]; + + args[0] = fd; + args[1] = (unsigned long) addr; + args[2] = (unsigned long) addrlen; + args[3] = flags; + if (SINGLE_THREAD_P) + return __socketcall(SYS_ACCEPT4, args); +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + else { + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __socketcall(SYS_ACCEPT4, args); + LIBC_CANCEL_RESET (oldtype); + return result; + } +#endif +} +#endif +#endif + #ifdef L_bind #ifdef __NR_bind _syscall3(int, bind, int, sockfd, const struct sockaddr *, myaddr, socklen_t, addrlen) @@ -560,3 +601,4 @@ int socketpair(int family, int type, int protocol, int sockvec[2]) } #endif #endif + diff --git a/libc/misc/fts/fts.c b/libc/misc/fts/fts.c index ce5d1586b..deb8f4adc 100644 --- a/libc/misc/fts/fts.c +++ b/libc/misc/fts/fts.c @@ -87,10 +87,8 @@ static int fts_safe_changedir (FTS *, FTSENT *, int, const char *) #define BREAD 3 /* fts_read */ FTS * -fts_open(argv, options, compar) - char * const *argv; - register int options; - int (*compar) (const FTSENT **, const FTSENT **); +fts_open( char * const *argv, register int options, + int (*compar) (const FTSENT **, const FTSENT **)) { register FTS *sp; register FTSENT *p, *root; @@ -204,9 +202,7 @@ mem1: free(sp); static void internal_function -fts_load(sp, p) - FTS *sp; - register FTSENT *p; +fts_load(FTS *sp, register FTSENT *p) { register int len; register char *cp; @@ -230,8 +226,7 @@ fts_load(sp, p) } int -fts_close(sp) - FTS *sp; +fts_close(FTS *sp) { register FTSENT *freep, *p; int saved_errno; @@ -284,8 +279,7 @@ fts_close(sp) ? p->fts_pathlen - 1 : p->fts_pathlen) FTSENT * -fts_read(sp) - register FTS *sp; +fts_read(register FTS *sp) { register FTSENT *p, *tmp; register int instr; @@ -481,10 +475,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); */ /* ARGSUSED */ int -fts_set(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; +fts_set(FTS *sp, FTSENT *p, int instr) { if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && instr != FTS_NOINSTR && instr != FTS_SKIP) { @@ -496,9 +487,7 @@ fts_set(sp, p, instr) } FTSENT * -fts_children(sp, instr) - register FTS *sp; - int instr; +fts_children(register FTS *sp, int instr) { register FTSENT *p; int fd; @@ -579,9 +568,7 @@ fts_children(sp, instr) */ static FTSENT * internal_function -fts_build(sp, type) - register FTS *sp; - int type; +fts_build(register FTS *sp, int type) { register struct dirent *dp; register FTSENT *p, *head; @@ -851,10 +838,7 @@ mem1: saved_errno = errno; static u_short internal_function -fts_stat(sp, p, follow) - FTS *sp; - register FTSENT *p; - int follow; +fts_stat(FTS *sp, register FTSENT *p, int follow) { register FTSENT *t; register dev_t dev; @@ -935,10 +919,7 @@ err: memset(sbp, 0, sizeof(struct stat)); static FTSENT * internal_function -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - register int nitems; +fts_sort(FTS *sp, FTSENT *head, register int nitems) { register FTSENT **ap, *p; @@ -973,10 +954,7 @@ fts_sort(sp, head, nitems) static FTSENT * internal_function -fts_alloc(sp, name, namelen) - FTS *sp; - const char *name; - size_t namelen; +fts_alloc(FTS *sp, const char *name, size_t namelen) { register FTSENT *p; size_t len; @@ -1013,8 +991,7 @@ fts_alloc(sp, name, namelen) static void internal_function -fts_lfree(head) - register FTSENT *head; +fts_lfree(register FTSENT *head) { register FTSENT *p; @@ -1033,9 +1010,7 @@ fts_lfree(head) */ static int internal_function -fts_palloc(sp, more) - FTS *sp; - size_t more; +fts_palloc(FTS *sp, size_t more) { char *p; @@ -1067,9 +1042,7 @@ fts_palloc(sp, more) */ static void internal_function -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; +fts_padjust(FTS *sp, FTSENT *head) { FTSENT *p; char *addr = sp->fts_path; @@ -1094,8 +1067,7 @@ fts_padjust(sp, head) static size_t internal_function -fts_maxarglen(argv) - char * const *argv; +fts_maxarglen(char * const *argv) { size_t len, max; @@ -1112,11 +1084,7 @@ fts_maxarglen(argv) */ static int internal_function -fts_safe_changedir(sp, p, fd, path) - FTS *sp; - FTSENT *p; - int fd; - const char *path; +fts_safe_changedir(FTS *sp, FTSENT *p, int fd, const char *path) { int ret, oerrno, newfd; struct stat64 sb; diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c index 4c25d2860..700ea2c23 100644 --- a/libc/misc/wordexp/wordexp.c +++ b/libc/misc/wordexp/wordexp.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include <features.h> +#include <bits/kernel-features.h> #include <sys/types.h> #include <sys/wait.h> #include <fcntl.h> @@ -757,16 +758,21 @@ exec_comm_child(char *comm, int *fildes, int showerr, int noexec) /* Redirect output. */ fd = fildes[1]; - if (fd != 1) { - dup2(fd, 1); + if (likely(fd != STDOUT_FILENO)) { + dup2(fd, STDOUT_FILENO); close(fd); } - +#if defined O_CLOEXEC && defined __UCLIBC_LINUX_SPECIFIC__ && defined __ASSUME_PIPE2 + else { + /* Reset the close-on-exec flag (if necessary). */ + fcntl (fd, F_SETFD, 0); + } +#endif /* Redirect stderr to /dev/null if we have to. */ if (showerr == 0) { - close(2); + close(STDERR_FILENO); fd = open(_PATH_DEVNULL, O_WRONLY); - if (fd >= 0 && fd != 2) { + if (fd >= 0 && fd != STDERR_FILENO) { dup2(fd, 2); close(fd); } @@ -802,10 +808,15 @@ exec_comm(char *comm, char **word, size_t * word_length, /* Don't fork() unless necessary */ if (!comm || !*comm) return 0; - - if (pipe(fildes)) +#if defined O_CLOEXEC && defined __UCLIBC_LINUX_SPECIFIC__ && defined __ASSUME_PIPE2 + if (pipe2(fildes, O_CLOEXEC) < 0) /* Bad */ return WRDE_NOSPACE; +#else + if (pipe(fildes) < 0) + /* Bad */ + return WRDE_NOSPACE; +#endif if ((pid = fork()) < 0) { /* Bad */ diff --git a/libc/stdlib/__uc_malloc.c b/libc/stdlib/__uc_malloc.c index 2a2e223ef..449f014fc 100644 --- a/libc/stdlib/__uc_malloc.c +++ b/libc/stdlib/__uc_malloc.c @@ -39,6 +39,7 @@ void *__uc_malloc(size_t size) return p; if (!__uc_malloc_failed) _exit(1); + free(p); __uc_malloc_failed(size); } } diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch index b53c539bf..14279e0d7 100644 --- a/libc/sysdeps/linux/arm/Makefile.arch +++ b/libc/sysdeps/linux/arm/Makefile.arch @@ -24,7 +24,12 @@ ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y) CSRC += posix_fadvise.c posix_fadvise64.c endif -ifeq ($(CONFIG_ARM_EABI),y) +# Is our compiler set up for EABI ? +IS_EABI:=$(shell $(CC) $(CFLAGS) -x c - -E -dM </dev/null 2>/dev/null \ + |sed -r -e '/^\#[[:space:]]*define[[:space:]]+__ARM_EABI__([[:space:]]+1)?$$/!d; s/.+/y/;' \ + ) + +ifeq ($(IS_EABI),y) CSRC += aeabi_assert.c aeabi_atexit.c aeabi_errno_addr.c \ aeabi_localeconv.c aeabi_memclr.c aeabi_memcpy.c \ aeabi_memmove.c aeabi_memset.c find_exidx.c @@ -37,7 +42,7 @@ else CSRC += syscall.c endif -ifeq ($(CONFIG_ARM_EABI),y) +ifeq ($(IS_EABI),y) libc-static-y += $(ARCH_OUT)/aeabi_lcsts.o $(ARCH_OUT)/aeabi_math.o \ $(ARCH_OUT)/aeabi_sighandlers.o libc-nonshared-y += $(ARCH_OUT)/aeabi_lcsts.os $(ARCH_OUT)/aeabi_math.os \ diff --git a/libc/sysdeps/linux/arm/bits/arm_asm.h b/libc/sysdeps/linux/arm/bits/arm_asm.h index 1d87df6eb..921c9a3c9 100644 --- a/libc/sysdeps/linux/arm/bits/arm_asm.h +++ b/libc/sysdeps/linux/arm/bits/arm_asm.h @@ -24,5 +24,12 @@ #define THUMB1_ONLY 1 #endif -#endif /* _ARM_ASM_H */ +#if defined(__USE_BX__) +# if ( defined (__ARM_ARCH_2__) || defined (__ARM_ARCH_3__) \ + || defined (__ARM_ARCH_3M__) || defined (__ARM_ARCH_4__) \ + ) +# error Use of BX was requested, but is not available on the target processor. +# endif /* ARCH level */ +#endif /* __USE_BX__ */ +#endif /* _ARM_ASM_H */ diff --git a/libc/sysdeps/linux/arm/bits/huge_val.h b/libc/sysdeps/linux/arm/bits/huge_val.h index a215f3c0b..745e0bbd5 100644 --- a/libc/sysdeps/linux/arm/bits/huge_val.h +++ b/libc/sysdeps/linux/arm/bits/huge_val.h @@ -32,7 +32,7 @@ # define HUGE_VAL (__extension__ 0x1.0p2047) #elif defined __GNUC__ -#ifndef __CONFIG_ARM_EABI__ +#ifndef __ARM_EABI__ # define HUGE_VAL \ (__extension__ \ ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ @@ -50,7 +50,7 @@ typedef union { unsigned char __c[8]; double __d; } __huge_val_t; -#ifndef __CONFIG_ARM_EABI__ +#ifndef __ARM_EABI__ # if __BYTE_ORDER == __BIG_ENDIAN # define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 } # endif diff --git a/libc/sysdeps/linux/arm/crtn.S b/libc/sysdeps/linux/arm/crtn.S index de01b38dc..a4752c186 100644 --- a/libc/sysdeps/linux/arm/crtn.S +++ b/libc/sysdeps/linux/arm/crtn.S @@ -15,7 +15,6 @@ .arm ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} #endif - .size _init, .-_init .section .fini .global _fini @@ -29,7 +28,6 @@ .arm ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} #endif - .size _fini, .-_fini @ In fact this is modified to 3.4.4 .ident "GCC: (GNU) 3.3.2 20031005 (Debian prerelease)" diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h index 013f88cdd..e498695be 100644 --- a/libc/sysdeps/linux/arm/sysdep.h +++ b/libc/sysdeps/linux/arm/sysdep.h @@ -21,6 +21,7 @@ #define _LINUX_ARM_SYSDEP_H 1 #include <common/sysdep.h> +#include <bits/arm_asm.h> #include <sys/syscall.h> /* For Linux we can use the system call table in the header file diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind.h b/libc/sysdeps/linux/arm/unwind.h index eeb9cf8b6..eeb9cf8b6 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind.h +++ b/libc/sysdeps/linux/arm/unwind.h diff --git a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S index f7d104070..c37f7d201 100644 --- a/libc/sysdeps/linux/avr32/crtn.S +++ b/libc/sysdeps/linux/avr32/crtn.S @@ -4,11 +4,9 @@ .global _init .type _init, @function ldm sp++, r6, pc - .size _init, . - _init .section .fini .align 2 .global _fini .type _fini, @function ldm sp++, r6, pc - .size _fini, . - _fini diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index 8811268d0..8f936ffcc 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -19,14 +19,14 @@ CSRC-$(UCLIBC_LINUX_MODULE_24) += create_module.c query_module.c \ get_kernel_syms.c # we need these internally: fstatfs.c statfs.c CSRC-$(UCLIBC_LINUX_SPECIFIC) += capget.c capset.c inotify.c ioperm.c iopl.c \ - madvise.c modify_ldt.c personality.c ppoll.c prctl.c readahead.c reboot.c \ + modify_ldt.c pipe2.c personality.c ppoll.c prctl.c \ + readahead.c reboot.c \ remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \ sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \ splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \ sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c -ifeq ($(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE),yy) -CSRC-y += madvise.c -endif +# NPTL needs these internally: madvise.c +CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) CSRC- += fork.c getpid.c raise.c open.c close.c read.c write.c CSRC- += $(if $(findstring =arm=,=$(TARGET_ARCH)=),vfork.c) @@ -52,7 +52,7 @@ CSRC-$(UCLIBC_HAS_XATTR) += xattr.c CSRC-$(UCLIBC_HAS_PROFILING) += noophooks.c #pcprofile.c CSRC-$(UCLIBC_SV4_DEPRECATED) += ustat.c CSRC- += $(if $(findstring =c6x=,=$(TARGET_ARCH)=),vfork.c) -CSRC- += $(if $(findstring =sh=,=$(TARGET_ARCH)=),longjmp.c vfork.c) +CSRC- += $(if $(findstring =sh=,=$(TARGET_ARCH)=),vfork.c) CSRC- += $(if $(findstring =sparc=,=$(TARGET_ARCH)=),vfork.c) CSRC- += $(if $(findstring =i386=,=$(TARGET_ARCH)=),vfork.c) diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h index 68b881c09..6bf554457 100644 --- a/libc/sysdeps/linux/common/bits/kernel-features.h +++ b/libc/sysdeps/linux/common/bits/kernel-features.h @@ -309,6 +309,19 @@ # define __ASSUME_O_CLOEXEC 1 #endif +/* Support for various CLOEXEC and NONBLOCK flags was added for x86, + * x86-64, PPC, IA-64, and SPARC in 2.6.27. */ +#if __LINUX_KERNEL_VERSION >= 0x02061b \ + && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \ + || defined __ia64__ || defined __sparc__ || defined __s390__) +/* # define __ASSUME_SOCK_CLOEXEC 1 */ +/* # define __ASSUME_IN_NONBLOCK 1 */ +# define __ASSUME_PIPE2 1 +/* # define __ASSUME_EVENTFD2 1 */ +/* # define __ASSUME_SIGNALFD4 1 */ +#endif + + /* These features were surely available with 2.4.12. */ #if __LINUX_KERNEL_VERSION >= 132108 && defined __mc68000__ # define __ASSUME_MMAP2_SYSCALL 1 @@ -454,6 +467,18 @@ #define __ASSUME_IEEE_RAISE_EXCEPTION 1 #endif +/* Support for the accept4 syscall was added in 2.6.28. */ +#if __LINUX_KERNEL_VERSION >= 0x02061c \ + && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \ + || defined __sparc__ || defined __s390__) +# define __ASSUME_ACCEPT4 1 +#endif + +/* Support for the accept4 syscall for alpha was added after 2.6.33-rc1. */ +#if __LINUX_KERNEL_VERSION >= 0x020621 && defined __alpha__ +# define __ASSUME_ACCEPT4 1 +#endif + /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */ #if __LINUX_KERNEL_VERSION >= 0x02061d # define __ASSUME_FUTEX_CLOCK_REALTIME 1 diff --git a/libc/sysdeps/linux/common/epoll.c b/libc/sysdeps/linux/common/epoll.c index dda92282e..ab3e73bb7 100644 --- a/libc/sysdeps/linux/common/epoll.c +++ b/libc/sysdeps/linux/common/epoll.c @@ -9,6 +9,11 @@ #include <sys/syscall.h> #include <sys/epoll.h> +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include <sysdep-cancel.h> +#else +# define SINGLE_THREAD_P 1 +#endif /* * epoll_create() @@ -18,6 +23,13 @@ _syscall1(int, epoll_create, int, size) #endif /* + * epoll_create1() + */ +#ifdef __NR_epoll_create1 +_syscall1(int, epoll_create1, int, flags) +#endif + +/* * epoll_ctl() */ #ifdef __NR_epoll_ctl @@ -28,5 +40,44 @@ _syscall4(int,epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, even * epoll_wait() */ #ifdef __NR_epoll_wait -_syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout) +extern __typeof(epoll_wait) __libc_epoll_wait; +int __libc_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) +{ + if (SINGLE_THREAD_P) + return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout); +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ + else { + int oldtype = LIBC_CANCEL_ASYNC (); + int result = INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout); + LIBC_CANCEL_RESET (oldtype); + return result; + } +# endif +} +weak_alias(__libc_epoll_wait, epoll_wait) +#endif + +/* + * epoll_pwait() + */ +#ifdef __NR_epoll_pwait +# include <signal.h> + +extern __typeof(epoll_pwait) __libc_epoll_pwait; +int __libc_epoll_pwait(int epfd, struct epoll_event *events, int maxevents, + int timeout, const sigset_t *set) +{ + int nsig = _NSIG / 8; + if (SINGLE_THREAD_P) + return INLINE_SYSCALL(epoll_pwait, 6, epfd, events, maxevents, timeout, set, nsig); +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ + else { + int oldtype = LIBC_CANCEL_ASYNC (); + int result = INLINE_SYSCALL(epoll_pwait, 6, epfd, events, maxevents, timeout, set, nsig); + LIBC_CANCEL_RESET (oldtype); + return result; + } +# endif +} +weak_alias(__libc_epoll_pwait, epoll_pwait) #endif diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index 75d7a1c8b..87510019e 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -69,7 +69,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path slen++; dp = opendir(path_buf); - if (dp == 0) { + if (!dp) { goto oops; } @@ -78,6 +78,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path if (slow_search || this_ino == d->d_ino) { # endif if (slen + strlen(d->d_name) > path_size) { + closedir(dp); goto oops; } strcpy(ptr + 1, d->d_name); diff --git a/libc/sysdeps/linux/common/longjmp.c b/libc/sysdeps/linux/common/longjmp.c index b07eced6a..f3448bc6f 100644 --- a/libc/sysdeps/linux/common/longjmp.c +++ b/libc/sysdeps/linux/common/longjmp.c @@ -24,7 +24,7 @@ extern void __longjmp (__jmp_buf __env, int __val) attribute_noreturn; libc_hidden_proto(__longjmp) -#if 0 +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ extern void _longjmp_unwind (jmp_buf env, int val); #endif @@ -34,7 +34,7 @@ extern __typeof(longjmp) __libc_longjmp attribute_noreturn; call there to return VAL, or 1 if VAL is 0. */ void __libc_longjmp (sigjmp_buf env, int val) { -#if 0 +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ /* Perform any cleanups needed by the frames being unwound. */ _longjmp_unwind (env, val); #endif diff --git a/libc/sysdeps/linux/common/pipe2.c b/libc/sysdeps/linux/common/pipe2.c new file mode 100644 index 000000000..0a3686d81 --- /dev/null +++ b/libc/sysdeps/linux/common/pipe2.c @@ -0,0 +1,16 @@ +/* vi: set sw=4 ts=4: */ +/* + * pipe2() for uClibc + * + * Copyright (C) 2011 Bernhard Reutner-Fischer <uclibc@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/syscall.h> +#include <unistd.h> + +#ifdef __NR_pipe2 +_syscall2(int, pipe2, int *, filedes, int, flags) +libc_hidden_def(pipe2) +#endif diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c index 655c64001..e14bbc3a0 100644 --- a/libc/sysdeps/linux/common/stubs.c +++ b/libc/sysdeps/linux/common/stubs.c @@ -31,10 +31,48 @@ static int enosys_stub(void) # undef __NR_sync_file_range #endif +#ifndef __UCLIBC_LINUX_SPECIFIC__ +# undef __NR_pipe2 +#endif + +#ifndef __UCLIBC_HAS_SOCKET__ +# undef __NR_accept +# undef __NR_accept4 +# undef __NR_bind +# undef __NR_connect +# undef __NR_getpeername +# undef __NR_getsockname +# undef __NR_getsockopt +# undef __NR_listen +# undef __NR_recv +# undef __NR_recvfrom +# undef __NR_recvmsg +# undef __NR_send +# undef __NR_sendmsg +# undef __NR_sendto +# undef __NR_setsockopt +# undef __NR_shutdown +# undef __NR_socket +# undef __NR_socketcall +# undef __NR_socketpair +#endif + +#if !defined __NR_accept && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(accept) +#endif + +#if !defined __NR_accept4 && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(accept4) +#endif + #ifndef __NR_bdflush make_stub(bdflush) #endif +#if !defined __NR_bind && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(bind) +#endif + #ifndef __NR_capget make_stub(capget) #endif @@ -43,6 +81,10 @@ make_stub(capget) make_stub(capset) #endif +#if !defined __NR_connect && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(connect) +#endif + #ifndef __NR_create_module make_stub(create_module) #endif @@ -91,10 +133,22 @@ make_stub(fsetxattr) make_stub(get_kernel_syms) #endif +#if !defined __NR_getpeername && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(getpeername) +#endif + #if !defined(__NR_getpgrp) && (defined(__NR_getpgid) && (defined(__NR_getpid) || defined(__NR_getxpid))) make_stub(getpgrp) #endif +#if !defined __NR_getsockname && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(getsockname) +#endif + +#if !defined __NR_getsockopt && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(getsockopt) +#endif + #ifndef __NR_getxattr make_stub(getxattr) #endif @@ -107,6 +161,10 @@ make_stub(init_module) make_stub(lgetxattr) #endif +#if !defined __NR_listen && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(listen) +#endif + #ifndef __NR_listxattr make_stub(listxattr) #endif @@ -123,6 +181,10 @@ make_stub(lremovexattr) make_stub(lsetxattr) #endif +#ifndef __NR_pipe2 +make_stub(pipe2) +#endif + #ifndef __NR_pivot_root make_stub(pivot_root) #endif @@ -131,6 +193,18 @@ make_stub(pivot_root) make_stub(query_module) #endif +#if !defined __NR_recv && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(recv) +#endif + +#if !defined __NR_recvfrom && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(recvfrom) +#endif + +#if !defined __NR_recvmsg && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(recvmsg) +#endif + #ifndef __NR_removexattr make_stub(removexattr) #endif @@ -143,14 +217,46 @@ make_stub(sched_getaffinity) make_stub(sched_setaffinity) #endif +#if !defined __NR_send && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(send) +#endif + +#if !defined __NR_sendmsg && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(sendmsg) +#endif + +#if !defined __NR_sendto && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(sendto) +#endif + +#if !defined __NR_setsockopt && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(setsockopt) +#endif + #ifndef __NR_setxattr make_stub(setxattr) #endif +#if !defined __NR_shutdown && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(shutdown) +#endif + #if !defined(__NR_signalfd4) && !defined(__NR_signalfd) make_stub(signalfd) #endif +#if !defined __NR_socket && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(socket) +#endif + +#if !defined __NR_socketcall && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(socketcall) +#endif + +#if !defined __NR_socketpair && !defined __NR_socketcall && !defined __UCLIBC_HAS_SOCKET__ +make_stub(socketpair) +#endif + #ifndef __NR_rt_sigtimedwait make_stub(sigtimedwait) make_stub(sigwaitinfo) diff --git a/libc/sysdeps/linux/common/sys/epoll.h b/libc/sysdeps/linux/common/sys/epoll.h index 44e814bfd..a04bd704c 100644 --- a/libc/sysdeps/linux/common/sys/epoll.h +++ b/libc/sysdeps/linux/common/sys/epoll.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002-2006, 2007, 2008, 2009 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,6 +22,42 @@ #include <stdint.h> #include <sys/types.h> +/* Get __sigset_t. */ +#include <bits/sigset.h> + +#ifndef __sigset_t_defined +# define __sigset_t_defined +typedef __sigset_t sigset_t; +#endif + + +/* Flags to be passed to epoll_create1. */ + +enum + { +#if defined __alpha__ + EPOLL_CLOEXEC = 010000000, +# define EPOLL_CLOEXEC EPOLL_CLOEXEC + EPOLL_NONBLOCK = 04 +# define EPOLL_NONBLOCK EPOLL_NONBLOCK +#else +# if defined __sparc__ + EPOLL_CLOEXEC = 020000000, +# else + EPOLL_CLOEXEC = 02000000, +# endif +# define EPOLL_CLOEXEC EPOLL_CLOEXEC +# if defined __mips__ + EPOLL_NONBLOCK = 0200 +# elif defined __sparc__ + EPOLL_NONBLOCK = 040000 +# else + EPOLL_NONBLOCK = 04000 +# endif +#define EPOLL_NONBLOCK EPOLL_NONBLOCK +#endif + }; + enum EPOLL_EVENTS { @@ -55,9 +91,9 @@ enum EPOLL_EVENTS /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ -#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */ -#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */ -#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */ +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ typedef union epoll_data @@ -72,7 +108,11 @@ struct epoll_event { uint32_t events; /* Epoll events */ epoll_data_t data; /* User data variable */ -}; +} +#if defined __x86_64__ +__attribute__((packed)) +#endif +; __BEGIN_DECLS @@ -83,6 +123,10 @@ __BEGIN_DECLS returned by epoll_create() should be closed with close(). */ extern int epoll_create (int __size) __THROW; +/* Same as epoll_create but with a FLAGS parameter. The unused SIZE + parameter has been dropped. */ +extern int epoll_create1 (int __flags) __THROW; + /* Manipulate an epoll instance "epfd". Returns 0 in case of success, -1 in case of error ( the "errno" variable will contain the @@ -107,6 +151,16 @@ extern int epoll_ctl (int __epfd, int __op, int __fd, extern int epoll_wait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout); + +/* Same as epoll_wait, but the thread's signal mask is temporarily + and atomically replaced with the one provided as parameter. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int epoll_pwait (int __epfd, struct epoll_event *__events, + int __maxevents, int __timeout, + __const __sigset_t *__ss); + __END_DECLS #endif /* sys/epoll.h */ diff --git a/libpthread/nptl/sysdeps/generic/unwind.h b/libc/sysdeps/linux/common/unwind.h index 81fc4db55..81fc4db55 100644 --- a/libpthread/nptl/sysdeps/generic/unwind.h +++ b/libc/sysdeps/linux/common/unwind.h diff --git a/libc/sysdeps/linux/cris/crtn.S b/libc/sysdeps/linux/cris/crtn.S index 951ae5449..7b2dce17c 100644 --- a/libc/sysdeps/linux/cris/crtn.S +++ b/libc/sysdeps/linux/cris/crtn.S @@ -9,7 +9,6 @@ move.d [$sp+],$r1 Ret nop - .size _init, .-_init .section .fini .align 1 @@ -20,4 +19,3 @@ move.d [$sp+],$r1 Ret nop - .size _fini, .-_fini diff --git a/libc/sysdeps/linux/frv/crtn.S b/libc/sysdeps/linux/frv/crtn.S index 1d58c0207..bd11901ad 100644 --- a/libc/sysdeps/linux/frv/crtn.S +++ b/libc/sysdeps/linux/frv/crtn.S @@ -32,7 +32,6 @@ Cambridge, MA 02139, USA. */ ld @(sp,gr0), fp addi sp,#16,sp jmpl @(gr5,gr0) - .size _init, .-_init .section .fini,"x" .globl _fini @@ -41,4 +40,3 @@ Cambridge, MA 02139, USA. */ ld @(sp,gr0), fp addi sp,#16,sp jmpl @(gr5,gr0) - .size _fini, .-_fini diff --git a/libc/sysdeps/linux/h8300/crtn.S b/libc/sysdeps/linux/h8300/crtn.S index 89e321868..8f9fa1fac 100644 --- a/libc/sysdeps/linux/h8300/crtn.S +++ b/libc/sysdeps/linux/h8300/crtn.S @@ -14,7 +14,6 @@ ; #NO_APP mov.l @er7+,er6 rts - .size __init, .-__init ; #APP .section .fini @@ -24,7 +23,6 @@ ; #NO_APP mov.l @er7+,er6 rts - .size __fini, .-__fini ; #APP .end diff --git a/libc/sysdeps/linux/i386/crtn.S b/libc/sysdeps/linux/i386/crtn.S index 191250487..34d5b38e2 100644 --- a/libc/sysdeps/linux/i386/crtn.S +++ b/libc/sysdeps/linux/i386/crtn.S @@ -6,7 +6,6 @@ popl %ebx popl %ebp ret -.size _init,.-_init @@ -16,7 +15,6 @@ popl %ebx popl %ebp ret -.size _fini,.-_fini diff --git a/libc/sysdeps/linux/i386/posix_fadvise64.S b/libc/sysdeps/linux/i386/posix_fadvise64.S index b4aeff1f4..8a8947d7b 100644 --- a/libc/sysdeps/linux/i386/posix_fadvise64.S +++ b/libc/sysdeps/linux/i386/posix_fadvise64.S @@ -22,7 +22,7 @@ #include <bits/errno.h> #include <sys/syscall.h> -#if defined __NR_fadvise64_64 +#if defined __NR_fadvise64_64 || defined __NR_fadvise64 /* Was named __libc_posix_fadvise64 for some inexplicable reason. ** google says only uclibc has *__libc*_posix_fadviseXXX, @@ -35,6 +35,7 @@ .global posix_fadvise64 .type posix_fadvise64,%function posix_fadvise64: +#if defined __NR_fadvise64_64 /* Save regs */ pushl %ebp pushl %ebx @@ -91,6 +92,7 @@ overflow: /* Returns 0 on success, else an error code. */ negl %eax +#endif /* Successful; return the syscall's value. */ ret diff --git a/libc/sysdeps/linux/microblaze/crtn.S b/libc/sysdeps/linux/microblaze/crtn.S index da8c920ef..6f4ef60d3 100644 --- a/libc/sysdeps/linux/microblaze/crtn.S +++ b/libc/sysdeps/linux/microblaze/crtn.S @@ -26,7 +26,6 @@ .end _init $Lfe2: - .size _init,$Lfe2-_init .section .fini .align 2 @@ -40,6 +39,5 @@ $Lfe2: .end _fini $Lfe3: - .size _fini,$Lfe3-_fini /*@TRAILER_BEGINS*/ diff --git a/libc/sysdeps/linux/mips/crtn.S b/libc/sysdeps/linux/mips/crtn.S index cedd593f0..f3756a2f1 100644 --- a/libc/sysdeps/linux/mips/crtn.S +++ b/libc/sysdeps/linux/mips/crtn.S @@ -10,7 +10,6 @@ #NO_APP .align 2 .globl _init - .ent _init .type _init, @function #NO_APP lw $31,28($sp) @@ -22,14 +21,12 @@ .set macro .set reorder - .end _init #APP .section .fini #NO_APP .align 2 .globl _fini - .ent _fini .type _fini, @function #NO_APP lw $31,28($sp) @@ -41,7 +38,6 @@ .set macro .set reorder - .end _fini #APP .ident "GCC: (GNU) 3.3.2" @@ -54,10 +50,8 @@ .section .init #NO_APP - .align 2 .align 3 .globl _init - .ent _init .type _init, @function #NO_APP ld $31,8($sp) @@ -68,16 +62,12 @@ addiu $sp,$sp,16 .set macro .set reorder - - .end _init #APP .section .fini #NO_APP - .align 2 .align 3 .globl _fini - .ent _fini .type _fini, @function #NO_APP ld $31,8($sp) @@ -89,7 +79,6 @@ .set macro .set reorder - .end _fini #APP .ident "GCC: (GNU) 3.4.3" @@ -105,7 +94,6 @@ #NO_APP .align 2 .globl _init - .ent _init .type _init, @function #NO_APP ld $31,24($sp) @@ -118,14 +106,12 @@ .set macro .set reorder - .end _init #APP .section .fini #NO_APP .align 2 .globl _fini - .ent _fini .type _fini, @function #NO_APP ld $31,24($sp) @@ -138,7 +124,6 @@ .set macro .set reorder - .end _fini #APP .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/powerpc/crtn.S b/libc/sysdeps/linux/powerpc/crtn.S index ba6d0e0c8..938367caa 100644 --- a/libc/sysdeps/linux/powerpc/crtn.S +++ b/libc/sysdeps/linux/powerpc/crtn.S @@ -9,7 +9,6 @@ addi 1,1,32 mtlr 0 blr - .size _init, .-_init .section .fini .align 2 @@ -20,4 +19,3 @@ addi 1,1,32 mtlr 0 blr - .size _fini, .-_fini diff --git a/libc/sysdeps/linux/sh/Makefile.arch b/libc/sysdeps/linux/sh/Makefile.arch index 3e32e1095..92e262b6c 100644 --- a/libc/sysdeps/linux/sh/Makefile.arch +++ b/libc/sysdeps/linux/sh/Makefile.arch @@ -7,6 +7,6 @@ # CSRC := \ - mmap.c pipe.c __init_brk.c brk.c sbrk.c pread_write.c longjmp.c cacheflush.c + mmap.c pipe.c __init_brk.c brk.c sbrk.c pread_write.c cacheflush.c -SSRC := setjmp.S __longjmp.S ___fpscr_values.S +SSRC := setjmp.S __longjmp.S ___fpscr_values.S vfork.S diff --git a/libc/sysdeps/linux/sh/crtn.S b/libc/sysdeps/linux/sh/crtn.S index 437f8ebc3..e8be7e51f 100644 --- a/libc/sysdeps/linux/sh/crtn.S +++ b/libc/sysdeps/linux/sh/crtn.S @@ -15,7 +15,6 @@ .align 2 .L6: .L7: - .size _init, .-_init .section .fini .hidden _fini @@ -31,6 +30,5 @@ .align 2 .L11: .L12: - .size _fini, .-_fini .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/sh/longjmp.c b/libc/sysdeps/linux/sh/longjmp.c deleted file mode 100644 index dd0616d8a..000000000 --- a/libc/sysdeps/linux/sh/longjmp.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 1991, 92, 94, 95, 97, 98, 2000 Free Software Foundation, Inc. - Copyright (C) 2001 Hewlett-Packard Australia - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU Library General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more - details. - - You should have received a copy of the GNU Library General Public License - along with this program; if not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Derived in part from the Linux-8086 C library, the GNU C Library, and several - other sundry sources. Files within this library are copyright by their - respective copyright holders. -*/ - -#include <stddef.h> -#include <setjmp.h> -#include <signal.h> - -libc_hidden_proto(sigprocmask) - -extern int __longjmp(char *env, int val); -libc_hidden_proto(__longjmp) - -extern void _longjmp_unwind (jmp_buf env, int val); - - -/* Set the signal mask to the one specified in ENV, and jump - to the position specified in ENV, causing the setjmp - call there to return VAL, or 1 if VAL is 0. */ -void __libc_siglongjmp (sigjmp_buf env, int val) -{ - /* Perform any cleanups needed by the frames being unwound. */ - - _longjmp_unwind (env, val); - - if (env[0].__mask_was_saved) - /* Restore the saved signal mask. */ - (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask, - (sigset_t *) NULL); - - /* Call the machine-dependent function to restore machine state. */ - __longjmp ((char *) env[0].__jmpbuf, val ?: 1); -} - -__asm__(".weak longjmp; longjmp = __libc_siglongjmp"); -__asm__(".weak _longjmp; _longjmp = __libc_siglongjmp"); -__asm__(".weak siglongjmp; siglongjmp = __libc_siglongjmp"); -strong_alias(__libc_siglongjmp, __libc_longjmp) diff --git a/libc/sysdeps/linux/sh64/crtn.S b/libc/sysdeps/linux/sh64/crtn.S index eb6479a56..501fe9167 100644 --- a/libc/sysdeps/linux/sh64/crtn.S +++ b/libc/sysdeps/linux/sh64/crtn.S @@ -14,7 +14,6 @@ ptabs r18, tr0 addi.l r15, 16, r15 blink tr0, r63 - .size _init, .-_init .section .fini .hidden _fini @@ -28,6 +27,5 @@ ptabs r18, tr0 addi.l r15, 16, r15 blink tr0, r63 - .size _fini, .-_fini .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/sparc/crtn.S b/libc/sysdeps/linux/sparc/crtn.S index 24b4bf43c..d64ffd020 100644 --- a/libc/sysdeps/linux/sparc/crtn.S +++ b/libc/sysdeps/linux/sparc/crtn.S @@ -7,7 +7,6 @@ .proc 020 ret restore - .size _init, .-_init .section .fini .align 4 @@ -16,4 +15,3 @@ .proc 020 ret restore - .size _fini, .-_fini diff --git a/libc/sysdeps/linux/v850/crtn.S b/libc/sysdeps/linux/v850/crtn.S index aecb55737..6bb0b39ac 100644 --- a/libc/sysdeps/linux/v850/crtn.S +++ b/libc/sysdeps/linux/v850/crtn.S @@ -8,7 +8,6 @@ .type __init, @function #NO_APP jr __return_r31 - .size __init, .-__init #APP .section .fini @@ -18,7 +17,6 @@ .type __fini, @function #NO_APP jr __return_r31 - .size __fini, .-__fini #APP .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/vax/crtn.S b/libc/sysdeps/linux/vax/crtn.S index 6ca5c4fcd..1153fd50b 100644 --- a/libc/sysdeps/linux/vax/crtn.S +++ b/libc/sysdeps/linux/vax/crtn.S @@ -9,7 +9,6 @@ __gnu_compiled_c: .type _init,@function ret .Lfe2: - .size _init,.Lfe2-_init .section .fini .align 1 @@ -17,5 +16,4 @@ __gnu_compiled_c: .type _fini,@function ret .Lfe3: - .size _fini,.Lfe3-_fini .ident "GCC: (GNU) 2.95.2 19991024 (release) (Linux/VAX CVS)" diff --git a/libc/sysdeps/linux/x86_64/crtn.S b/libc/sysdeps/linux/x86_64/crtn.S index 5b110d967..9804e0f76 100644 --- a/libc/sysdeps/linux/x86_64/crtn.S +++ b/libc/sysdeps/linux/x86_64/crtn.S @@ -7,7 +7,6 @@ .type _init, %function addq $8, %rsp ret -.size _init,.-_init .section .fini @@ -15,4 +14,3 @@ .type _fini, %function addq $8, %rsp ret -.size _fini, .-_fini diff --git a/libc/sysdeps/linux/x86_64/sys/epoll.h b/libc/sysdeps/linux/x86_64/sys/epoll.h deleted file mode 100644 index 02672d3c7..000000000 --- a/libc/sysdeps/linux/x86_64/sys/epoll.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 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 - 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_EPOLL_H -#define _SYS_EPOLL_H 1 - -#include <stdint.h> -#include <sys/types.h> - - -enum EPOLL_EVENTS - { - EPOLLIN = 0x001, -#define EPOLLIN EPOLLIN - EPOLLPRI = 0x002, -#define EPOLLPRI EPOLLPRI - EPOLLOUT = 0x004, -#define EPOLLOUT EPOLLOUT - EPOLLRDNORM = 0x040, -#define EPOLLRDNORM EPOLLRDNORM - EPOLLRDBAND = 0x080, -#define EPOLLRDBAND EPOLLRDBAND - EPOLLWRNORM = 0x100, -#define EPOLLWRNORM EPOLLWRNORM - EPOLLWRBAND = 0x200, -#define EPOLLWRBAND EPOLLWRBAND - EPOLLMSG = 0x400, -#define EPOLLMSG EPOLLMSG - EPOLLERR = 0x008, -#define EPOLLERR EPOLLERR - EPOLLHUP = 0x010, -#define EPOLLHUP EPOLLHUP - EPOLLONESHOT = (1 << 30), -#define EPOLLONESHOT EPOLLONESHOT - EPOLLET = (1 << 31) -#define EPOLLET EPOLLET - }; - - -/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ -#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */ -#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */ -#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */ - - -typedef union epoll_data -{ - void *ptr; - int fd; - uint32_t u32; - uint64_t u64; -} epoll_data_t; - -struct epoll_event -{ - uint32_t events; /* Epoll events */ - epoll_data_t data; /* User data variable */ -} __attribute__ ((__packed__)); - - -__BEGIN_DECLS - -/* Creates an epoll instance. Returns an fd for the new instance. - The "size" parameter is a hint specifying the number of file - descriptors to be associated with the new instance. The fd - returned by epoll_create() should be closed with close(). */ -extern int epoll_create (int __size) __THROW; - - -/* Manipulate an epoll instance "epfd". Returns 0 in case of success, - -1 in case of error ( the "errno" variable will contain the - specific error code ) The "op" parameter is one of the EPOLL_CTL_* - constants defined above. The "fd" parameter is the target of the - operation. The "event" parameter describes which events the caller - is interested in and any associated user data. */ -extern int epoll_ctl (int __epfd, int __op, int __fd, - struct epoll_event *__event) __THROW; - - -/* Wait for events on an epoll instance "epfd". Returns the number of - triggered events returned in "events" buffer. Or -1 in case of - error with the "errno" variable set to the specific error code. The - "events" parameter is a buffer that will contain triggered - events. The "maxevents" is the maximum number of events to be - returned ( usually size of "events" ). The "timeout" parameter - specifies the maximum wait time in milliseconds (-1 == infinite). - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int epoll_wait (int __epfd, struct epoll_event *__events, - int __maxevents, int __timeout); - -__END_DECLS - -#endif /* sys/epoll.h */ diff --git a/libm/Makefile.in b/libm/Makefile.in index 223593304..f0aaa2aff 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -20,7 +20,7 @@ # by Erik Andersen <andersen@codepoet.org> # -subdirs += libm +subdirs += libm libm/$(TARGET_ARCH) CFLAGS-libm := -DNOT_IN_libc -DIS_IN_libm $(SSP_ALL_CFLAGS) CFLAGS-libm += -D_IEEE_LIBM diff --git a/libpthread/linuxthreads.old/cancel.c b/libpthread/linuxthreads.old/cancel.c index 47534be66..0e5defb17 100644 --- a/libpthread/linuxthreads.old/cancel.c +++ b/libpthread/linuxthreads.old/cancel.c @@ -213,7 +213,7 @@ void __pthread_perform_cleanup(char *currentframe) } #ifndef __PIC__ -/* We need a hook to force the cancelation wrappers to be linked in when +/* We need a hook to force the cancellation wrappers to be linked in when static libpthread is used. */ extern const char __pthread_provide_wrappers; static const char *const __pthread_require_wrappers = diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c index a8830b1a4..42e03f4dc 100644 --- a/libpthread/linuxthreads.old/pthread.c +++ b/libpthread/linuxthreads.old/pthread.c @@ -1159,7 +1159,7 @@ void __pthread_message(char * fmt, ...) #ifndef __PIC__ -/* We need a hook to force the cancelation wrappers to be linked in when +/* We need a hook to force the cancellation wrappers to be linked in when static libpthread is used. */ extern const char __pthread_provide_wrappers; static const char *const __pthread_require_wrappers = diff --git a/libpthread/linuxthreads.old/wrapsyscall.c b/libpthread/linuxthreads.old/wrapsyscall.c index 6e18388ca..6c74bd1ff 100644 --- a/libpthread/linuxthreads.old/wrapsyscall.c +++ b/libpthread/linuxthreads.old/wrapsyscall.c @@ -1,4 +1,4 @@ -/* Wrapper arpund system calls to provide cancelation points. +/* Wrapper arpund system calls to provide cancellation points. Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -227,3 +227,16 @@ CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n, socklen_t addr_len), (fd, buf, n, flags, addr, addr_len)) #endif /* __UCLIBC_HAS_SOCKET__ */ + +#ifdef __UCLIBC_HAS_EPOLL__ +# ifdef __NR_epoll_wait +CANCELABLE_SYSCALL (int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout), + (epfd, events, maxevents, timeout)) +# endif +# ifdef __NR_epoll_pwait +# include <signal.h> +CANCELABLE_SYSCALL (int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout, + const sigset_t *set), + (epfd, events, maxevents, timeout, set)) +# endif +#endif diff --git a/libpthread/linuxthreads.old_db/td_ta_delete.c b/libpthread/linuxthreads.old_db/td_ta_delete.c index 0e6ec17d0..be1165af2 100644 --- a/libpthread/linuxthreads.old_db/td_ta_delete.c +++ b/libpthread/linuxthreads.old_db/td_ta_delete.c @@ -45,7 +45,7 @@ td_ta_delete (td_thragent_t *ta) runp = runp->next; if (runp->next == NULL) - /* It's not a valid decriptor since it is not in the list. */ + /* It's not a valid descriptor since it is not in the list. */ return TD_BADTA; runp->next = runp->next->next; diff --git a/libpthread/linuxthreads_db/td_ta_delete.c b/libpthread/linuxthreads_db/td_ta_delete.c index 0e6ec17d0..be1165af2 100644 --- a/libpthread/linuxthreads_db/td_ta_delete.c +++ b/libpthread/linuxthreads_db/td_ta_delete.c @@ -45,7 +45,7 @@ td_ta_delete (td_thragent_t *ta) runp = runp->next; if (runp->next == NULL) - /* It's not a valid decriptor since it is not in the list. */ + /* It's not a valid descriptor since it is not in the list. */ return TD_BADTA; runp->next = runp->next->next; diff --git a/libpthread/nptl/.gitignore b/libpthread/nptl/.gitignore index ac44e0c5d..06395e1f5 100644 --- a/libpthread/nptl/.gitignore +++ b/libpthread/nptl/.gitignore @@ -18,6 +18,9 @@ sysdeps/unix/sysv/linux/lowlevelrobustlock.h sysdeps/unix/sysv/linux/structsem.h sysdeps/unix/sysv/linux/unwindbuf.h sysdeps/unix/sysv/linux/pthread-pi-defines.h +sysdeps/pthread/crt[in].S +sysdeps/pthread/defs.h +sysdeps/pthread/pt-initfini.s # # symlinks # diff --git a/libpthread/nptl/ChangeLog b/libpthread/nptl/ChangeLog index c81eb03b7..ec22ebb64 100644 --- a/libpthread/nptl/ChangeLog +++ b/libpthread/nptl/ChangeLog @@ -6717,7 +6717,7 @@ 2003-07-15 Ulrich Drepper <drepper@redhat.com> - * tst-tcancel-wrappers.sh: lseek and llseek are not cancelation points. + * tst-tcancel-wrappers.sh: lseek and llseek are not cancellation points. 2003-07-14 Ulrich Drepper <drepper@redhat.com> @@ -10308,7 +10308,7 @@ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Define SINGLE_THREAD_P. If in libc or libpthread examine multiple_thread - member of thread decriptor, otherwise return unconditionally 1. + member of thread descriptor, otherwise return unconditionally 1. 2002-12-14 Ulrich Drepper <drepper@redhat.com> @@ -10990,7 +10990,7 @@ the static TLS block. (allocate_stack): Call _dl_allocate_tls_init for user-provided stack. - * cancellation.c: Renamed from cancelation.c. + * cancellation.c: Renamed from cancellation.c. * Makefile: Adjust accordingly. * pthreadP.h (CANCELLATION_P): Renamed from CANCELATION_P. * cleanup_defer.c: Use CANCELLATION_P. diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in index 3e9676ac8..849bd5965 100644 --- a/libpthread/nptl/Makefile.in +++ b/libpthread/nptl/Makefile.in @@ -63,9 +63,11 @@ librt-a-y += $(librt_OBJS) endif librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS) -ifneq ($(UCLIBC_CTOR_DTOR),y) -START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES) -END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o +ifeq ($(UCLIBC_CTOR_DTOR),y) +START_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o +END_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crtn.o +LDFLAGS-libpthread.so += -nostartfiles +$(top_builddir)lib/libpthread.so: | $(START_FILE-libpthread.so) $(END_FILE-libpthread.so) endif libpthread_FULL_NAME := libpthread-$(VERSION).so @@ -137,9 +139,9 @@ CLEAN_libpthread/nptl: $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a) ifeq ($(PTHREADS_DEBUG_SUPPORT),y) -LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs +LDFLAGS-libpthread.so += $(LDFLAGS_NOSTRIP) -Wl,-z,defs else -LDFLAGS-libpthread.so := $(LDFLAGS) +LDFLAGS-libpthread.so += $(LDFLAGS) endif LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so \ diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h index fb354eaa3..850562b1f 100644 --- a/libpthread/nptl/pthreadP.h +++ b/libpthread/nptl/pthreadP.h @@ -312,7 +312,7 @@ __do_cancel (void) # define LIBC_CANCEL_HANDLED() /* Nothing. */ #endif -/* The signal used for asynchronous cancelation. */ +/* The signal used for asynchronous cancellation. */ #define SIGCANCEL __SIGRTMIN diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in index fc0c6ac3e..be5c022b1 100644 --- a/libpthread/nptl/sysdeps/pthread/Makefile.in +++ b/libpthread/nptl/sysdeps/pthread/Makefile.in @@ -67,22 +67,48 @@ librt-pt-shared-only-routines-y = rt-unwind-resume.c ifeq ($(UCLIBC_CTOR_DTOR),y) CFLAGS-OMIT-pt-initfini.c = $(CFLAGS-pthread) -CFLAGS-pt-initfini.c = -S -g0 -fPIC -fno-inline-functions \ +CFLAGS-pt-initfini.c = -S -g0 $(PICFLAG) -fno-inline-functions \ $(call check_gcc,-fno-unit-at-a-time,) \ + $(SSP_DISABLE_FLAGS) \ -finhibit-size-directive \ + -fno-asynchronous-unwind-tables -fno-unwind-tables \ $(patsubst -f%,-fno-%,$(call check_gcc,-fexceptions,)) -ASFLAGS-crti.S = -g0 -ASFLAGS-crtn.S = -g0 -$(libpthread_pthread_OUT)/pt-initfini.s: $(libpthread_pthread_DIR)/pt-initfini.c +#ASFLAGS += $(PICFLAG) -I$(top_srcdir)include -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) +ifneq ($(wildcard $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c),) +PTHREAD_INITFINI := $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c +else +PTHREAD_INITFINI := $(libpthread_pthread_DIR)/pt-initfini.c +endif + +ASFLAGS-pt-crti.S = $(PICFLAG) +ASFLAGS-pt-crtn.S = $(PICFLAG) + +$(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S + $(compile.S) + +$(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S + $(compile.S) + +$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI) | $(top_builddir)include/bits/uClibc_config.h $(compile.c) - $(do_sed) '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ - $(do_awk) $(libpthread_pthread_DIR)/defs.awk > $(libpthread_pthread_OUT)/defs.h +$(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI) + $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ + $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp + $(Q)mv $@.tmp $@ -$(libpthread_pthread_OUT)/crti.S $(libpthread_pthread_OUT)/crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s - $(do_sed) -e '1,/@HEADER_ENDS/p' \ +$(libpthread_pthread_OUT)/pt-crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h + $(do_sed) -n -e '/[ ]*\.file/d' \ + -e '1,/@HEADER_ENDS/p' \ -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \ - -e '/@TRAILER_BEGINS/,$$p' $< > $@ + -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp + $(Q)mv $@.tmp $@ +$(libpthread_pthread_OUT)/pt-crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h + $(do_sed) -n -e '/[ ]*\.file/d' \ + -e '1,/@HEADER_ENDS/p' \ + -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \ + -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp + $(Q)mv $@.tmp $@ endif # It would have been easier to just add dummy files that include the real # impl, but ok. diff --git a/libpthread/nptl/sysdeps/pthread/defs.awk b/libpthread/nptl/sysdeps/pthread/defs.awk deleted file mode 100644 index d41d57bd7..000000000 --- a/libpthread/nptl/sysdeps/pthread/defs.awk +++ /dev/null @@ -1,24 +0,0 @@ -/^[ ]*\.endp/ { need_endp = 1 } -/^[ ]*\.end/ { need_end = 1 } -/^[ ]*\.align/ { if($2 > max) max = $2; } - -END { - if(need_endp) - { - print "#define END_INIT .endp _init"; - print "#define END_FINI .endp _fini"; - } else if(need_end) - { - print "#define END_INIT .end _init"; - print "#define END_FINI .end _fini"; - } - else - { - print "#define END_INIT"; - print "#define END_FINI"; - } - if(max) - print "#define ALIGN .align", max; - else - print "#define ALIGN"; -} diff --git a/libpthread/nptl/sysdeps/pthread/pt-initfini.c b/libpthread/nptl/sysdeps/pthread/pt-initfini.c index 1f81144d0..ccdce3e22 100644 --- a/libpthread/nptl/sysdeps/pthread/pt-initfini.c +++ b/libpthread/nptl/sysdeps/pthread/pt-initfini.c @@ -44,6 +44,10 @@ /* Embed an #include to pull in the alignment and .end directives. */ __asm__ ("\n#include \"defs.h\""); +__asm__ ("\n#if defined __i686 && defined __ASSEMBLER__"); +__asm__ ("\n#undef __i686"); +__asm__ ("\n#define __i686 __i686"); +__asm__ ("\n#endif"); /* The initial common code ends here. */ __asm__ ("\n/*@HEADER_ENDS*/"); diff --git a/libpthread/nptl/sysdeps/pthread/pthread_once.c b/libpthread/nptl/sysdeps/pthread/pthread_once.c index 57bb6b977..55131091a 100644 --- a/libpthread/nptl/sysdeps/pthread/pthread_once.c +++ b/libpthread/nptl/sysdeps/pthread/pthread_once.c @@ -38,7 +38,7 @@ __pthread_once ( lll_lock (once_lock, LLL_PRIVATE); /* XXX This implementation is not complete. It doesn't take - cancelation and fork into account. */ + cancellation and fork into account. */ if (*once_control == PTHREAD_ONCE_INIT) { init_routine (); diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h index ab1a9395e..db951a10e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h @@ -336,7 +336,7 @@ LLL_STUB_UNWIND_INFO_END }) #define lll_robust_lock(futex, id, private) \ - ({ int __result, ignore1, ignore2; \ + ({ int __ret, ignore1, ignore2; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %2\n\t" \ "jnz _L_robust_lock_%=\n\t" \ ".subsection 1\n\t" \ @@ -350,11 +350,11 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_4 \ "18:" \ - : "=a" (__result), "=c" (ignore1), "=m" (futex), \ + : "=a" (__ret), "=c" (ignore1), "=m" (futex), \ "=&d" (ignore2) \ : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\ : "memory"); \ - __result; }) + __ret; }) /* Special version of lll_lock which causes the unlock function to @@ -383,7 +383,7 @@ LLL_STUB_UNWIND_INFO_END #define lll_robust_cond_lock(futex, id, private) \ - ({ int __result, ignore1, ignore2; \ + ({ int __ret, ignore1, ignore2; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %2\n\t" \ "jnz _L_robust_cond_lock_%=\n\t" \ ".subsection 1\n\t" \ @@ -397,16 +397,16 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_4 \ "18:" \ - : "=a" (__result), "=c" (ignore1), "=m" (futex), \ + : "=a" (__ret), "=c" (ignore1), "=m" (futex), \ "=&d" (ignore2) \ : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex), \ "g" ((int) (private)) \ : "memory"); \ - __result; }) + __ret; }) #define lll_timedlock(futex, timeout, private) \ - ({ int __result, ignore1, ignore2, ignore3; \ + ({ int __ret, ignore1, ignore2, ignore3; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %3\n\t" \ "jnz _L_timedlock_%=\n\t" \ ".subsection 1\n\t" \ @@ -420,16 +420,16 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_4 \ "18:" \ - : "=a" (__result), "=c" (ignore1), "=&d" (ignore2), \ + : "=a" (__ret), "=c" (ignore1), "=&d" (ignore2), \ "=m" (futex), "=S" (ignore3) \ : "0" (0), "1" (1), "m" (futex), "m" (timeout), \ "4" ((int) (private)) \ : "memory"); \ - __result; }) + __ret; }) #define lll_robust_timedlock(futex, timeout, id, private) \ - ({ int __result, ignore1, ignore2, ignore3; \ + ({ int __ret, ignore1, ignore2, ignore3; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %3\n\t" \ "jnz _L_robust_timedlock_%=\n\t" \ ".subsection 1\n\t" \ @@ -443,12 +443,12 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_4 \ "18:" \ - : "=a" (__result), "=c" (ignore1), "=&d" (ignore2), \ + : "=a" (__ret), "=c" (ignore1), "=&d" (ignore2), \ "=m" (futex), "=S" (ignore3) \ : "0" (0), "1" (id), "m" (futex), "m" (timeout), \ "4" ((int) (private)) \ : "memory"); \ - __result; }) + __ret; }) #if defined NOT_IN_libc || defined UP # define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t" @@ -570,15 +570,15 @@ extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) __attribute__ ((regparm (2))) attribute_hidden; #define lll_timedwait_tid(tid, abstime) \ ({ \ - int __result = 0; \ + int __ret = 0; \ if (tid != 0) \ { \ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \ - __result = EINVAL; \ + __ret = EINVAL; \ else \ - __result = __lll_timedwait_tid (&tid, abstime); \ + __ret = __lll_timedwait_tid (&tid, abstime); \ } \ - __result; }) + __ret; }) #endif /* !__ASSEMBLER__ */ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h index 0ea67e0ef..d10cd6116 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h @@ -98,7 +98,7 @@ extern int __lll_unlock_wake_private (int *__futex) attribute_hidden; extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; #define lll_trylock(futex) \ - ({ unsigned char __result; \ + ({ unsigned char __ret; \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -112,15 +112,15 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; 1: mov r1,r15\n\ mov #-1,%0\n\ negc %0,%0"\ - : "=r" (__result) \ + : "=r" (__ret) \ : "r" (&(futex)), \ "r" (LLL_LOCK_INITIALIZER_LOCKED), \ "r" (LLL_LOCK_INITIALIZER) \ : "r0", "r1", "r2", "t", "memory"); \ - __result; }) + __ret; }) #define lll_robust_trylock(futex, id) \ - ({ unsigned char __result; \ + ({ unsigned char __ret; \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -134,15 +134,15 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; 1: mov r1,r15\n\ mov #-1,%0\n\ negc %0,%0"\ - : "=r" (__result) \ + : "=r" (__ret) \ : "r" (&(futex)), \ "r" (id), \ "r" (LLL_LOCK_INITIALIZER) \ : "r0", "r1", "r2", "t", "memory"); \ - __result; }) + __ret; }) #define lll_cond_trylock(futex) \ - ({ unsigned char __result; \ + ({ unsigned char __ret; \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -156,15 +156,15 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; 1: mov r1,r15\n\ mov #-1,%0\n\ negc %0,%0"\ - : "=r" (__result) \ + : "=r" (__ret) \ : "r" (&(futex)), \ "r" (LLL_LOCK_INITIALIZER_WAITERS), \ "r" (LLL_LOCK_INITIALIZER) \ : "r0", "r1", "r2", "t", "memory"); \ - __result; }) + __ret; }) #define lll_lock(futex, private) \ - (void) ({ int __result, *__futex = &(futex); \ + (void) ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -176,20 +176,20 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (1), "r" (__futex) \ + : "=&r" (__ret) : "r" (1), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ + if (__ret) \ { \ if (__builtin_constant_p (private) \ && (private) == LLL_PRIVATE) \ - __lll_lock_wait_private (__result, __futex); \ + __lll_lock_wait_private (__ret, __futex); \ else \ - __lll_lock_wait (__result, __futex, (private)); \ + __lll_lock_wait (__ret, __futex, (private)); \ } \ }) #define lll_robust_lock(futex, id, private) \ - ({ int __result, *__futex = &(futex); \ + ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -201,16 +201,16 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (id), "r" (__futex) \ + : "=&r" (__ret) : "r" (id), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ - __result = __lll_robust_lock_wait (__result, __futex, private); \ - __result; }) + if (__ret) \ + __ret = __lll_robust_lock_wait (__ret, __futex, private); \ + __ret; }) /* Special version of lll_mutex_lock which causes the unlock function to always wakeup waiters. */ #define lll_cond_lock(futex, private) \ - (void) ({ int __result, *__futex = &(futex); \ + (void) ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -222,13 +222,13 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (2), "r" (__futex) \ + : "=&r" (__ret) : "r" (2), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ - __lll_lock_wait (__result, __futex, private); }) + if (__ret) \ + __lll_lock_wait (__ret, __futex, private); }) #define lll_robust_cond_lock(futex, id, private) \ - ({ int __result, *__futex = &(futex); \ + ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -240,14 +240,14 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (id | FUTEX_WAITERS), "r" (__futex) \ + : "=&r" (__ret) : "r" (id | FUTEX_WAITERS), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ - __result = __lll_robust_lock_wait (__result, __futex, private); \ - __result; }) + if (__ret) \ + __ret = __lll_robust_lock_wait (__ret, __futex, private); \ + __ret; }) #define lll_timedlock(futex, timeout, private) \ - ({ int __result, *__futex = &(futex); \ + ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -259,14 +259,14 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (1), "r" (__futex) \ + : "=&r" (__ret) : "r" (1), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ - __result = __lll_timedlock_wait (__result, __futex, timeout, private); \ - __result; }) + if (__ret) \ + __ret = __lll_timedlock_wait (__ret, __futex, timeout, private); \ + __ret; }) #define lll_robust_timedlock(futex, timeout, id, private) \ - ({ int __result, *__futex = &(futex); \ + ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -278,15 +278,15 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; bf 1f\n\ mov.l %1,@%2\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (id), "r" (__futex) \ + : "=&r" (__ret) : "r" (id), "r" (__futex) \ : "r0", "r1", "t", "memory"); \ - if (__result) \ - __result = __lll_robust_timedlock_wait (__result, __futex, \ + if (__ret) \ + __ret = __lll_robust_timedlock_wait (__ret, __futex, \ timeout, private); \ - __result; }) + __ret; }) #define lll_unlock(futex, private) \ - (void) ({ int __result, *__futex = &(futex); \ + (void) ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -296,9 +296,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; add #-1,%0\n\ mov.l %0,@%1\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (__futex) \ + : "=&r" (__ret) : "r" (__futex) \ : "r0", "r1", "memory"); \ - if (__result) \ + if (__ret) \ { \ if (__builtin_constant_p (private) \ && (private) == LLL_PRIVATE) \ @@ -309,7 +309,7 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; }) #define lll_robust_unlock(futex, private) \ - (void) ({ int __result, *__futex = &(futex); \ + (void) ({ int __ret, *__futex = &(futex); \ __asm__ __volatile__ ("\ .align 2\n\ mova 1f,r0\n\ @@ -319,9 +319,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden; and %2,%0\n\ mov.l %0,@%1\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (__futex), "r" (FUTEX_WAITERS) \ + : "=&r" (__ret) : "r" (__futex), "r" (FUTEX_WAITERS) \ : "r0", "r1", "memory"); \ - if (__result) \ + if (__ret) \ __lll_unlock_wake (__futex, private); }) #define lll_robust_dead(futex, private) \ @@ -405,15 +405,15 @@ extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) attribute_hidden; #define lll_timedwait_tid(tid, abstime) \ ({ \ - int __result = 0; \ + int __ret = 0; \ if (tid != 0) \ { \ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \ - __result = EINVAL; \ + __ret = EINVAL; \ else \ - __result = __lll_timedwait_tid (&tid, abstime); \ + __ret = __lll_timedwait_tid (&tid, abstime); \ } \ - __result; }) + __ret; }) #endif /* !__ASSEMBLER__ */ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index ffab81eb5..afc40133e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -332,7 +332,7 @@ LLL_STUB_UNWIND_INFO_END }) \ #define lll_robust_lock(futex, id, private) \ - ({ int result, ignore1, ignore2; \ + ({ int __ret, ignore1, ignore2; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %4, %2\n\t" \ "jnz 1f\n\t" \ ".subsection 1\n\t" \ @@ -348,10 +348,10 @@ LLL_STUB_UNWIND_INFO_END LLL_STUB_UNWIND_INFO_5 \ "24:" \ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \ - "=a" (result) \ + "=a" (__ret) \ : "1" (id), "m" (futex), "3" (0), "0" (private) \ : "cx", "r11", "cc", "memory"); \ - result; }) + __ret; }) #define lll_cond_lock(futex, private) \ (void) \ @@ -377,7 +377,7 @@ LLL_STUB_UNWIND_INFO_END }) #define lll_robust_cond_lock(futex, id, private) \ - ({ int result, ignore1, ignore2; \ + ({ int __ret, ignore1, ignore2; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %4, %2\n\t" \ "jnz 1f\n\t" \ ".subsection 1\n\t" \ @@ -393,14 +393,14 @@ LLL_STUB_UNWIND_INFO_END LLL_STUB_UNWIND_INFO_5 \ "24:" \ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \ - "=a" (result) \ + "=a" (__ret) \ : "1" (id | FUTEX_WAITERS), "m" (futex), "3" (0), \ "0" (private) \ : "cx", "r11", "cc", "memory"); \ - result; }) + __ret; }) #define lll_timedlock(futex, timeout, private) \ - ({ int result, ignore1, ignore2, ignore3; \ + ({ int __ret, ignore1, ignore2, ignore3; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %4\n\t" \ "jnz 1f\n\t" \ ".subsection 1\n\t" \ @@ -416,15 +416,15 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_6 \ "24:" \ - : "=a" (result), "=D" (ignore1), "=S" (ignore2), \ + : "=a" (__ret), "=D" (ignore1), "=S" (ignore2), \ "=&d" (ignore3), "=m" (futex) \ : "0" (0), "1" (1), "m" (futex), "m" (timeout), \ "2" (private) \ : "memory", "cx", "cc", "r10", "r11"); \ - result; }) + __ret; }) #define lll_robust_timedlock(futex, timeout, id, private) \ - ({ int result, ignore1, ignore2, ignore3; \ + ({ int __ret, ignore1, ignore2, ignore3; \ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %4\n\t" \ "jnz 1f\n\t" \ ".subsection 1\n\t" \ @@ -440,12 +440,12 @@ LLL_STUB_UNWIND_INFO_END ".previous\n" \ LLL_STUB_UNWIND_INFO_6 \ "24:" \ - : "=a" (result), "=D" (ignore1), "=S" (ignore2), \ + : "=a" (__ret), "=D" (ignore1), "=S" (ignore2), \ "=&d" (ignore3), "=m" (futex) \ : "0" (0), "1" (id), "m" (futex), "m" (timeout), \ "2" (private) \ : "memory", "cx", "cc", "r10", "r11"); \ - result; }) + __ret; }) #if defined NOT_IN_libc || defined UP # define __lll_unlock_asm_start LOCK_INSTR "decl %0\n\t" \ @@ -583,15 +583,15 @@ extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) attribute_hidden; #define lll_timedwait_tid(tid, abstime) \ ({ \ - int __result = 0; \ + int __ret = 0; \ if (tid != 0) \ { \ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \ - __result = EINVAL; \ + __ret = EINVAL; \ else \ - __result = __lll_timedwait_tid (&tid, abstime); \ + __ret = __lll_timedwait_tid (&tid, abstime); \ } \ - __result; }) + __ret; }) #endif /* !__ASSEMBLER__ */ |