summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in20
-rw-r--r--Makerules38
-rw-r--r--Rules.mak67
-rw-r--r--TODO8
-rw-r--r--extra/Configs/Config.in21
-rw-r--r--extra/Configs/Config.in.arch59
-rw-r--r--extra/Configs/Config.mips22
-rw-r--r--extra/locale/Makefile.in4
-rw-r--r--extra/locale/gen_wc8bit.c8
-rw-r--r--extra/locale/gen_wctype.c8
-rwxr-xr-xextra/scripts/gen_bits_syscall_h.sh14
-rw-r--r--include/elf.h2
-rw-r--r--include/features.h6
-rw-r--r--include/libc-internal.h2
-rw-r--r--include/math.h76
-rw-r--r--include/printf.h1
-rw-r--r--include/stdio.h7
-rw-r--r--include/stdlib.h6
-rw-r--r--include/string.h4
-rw-r--r--include/strings.h4
-rw-r--r--include/sys/mman.h12
-rw-r--r--include/sys/syscall.h14
-rw-r--r--libc/Makefile.in4
-rw-r--r--libc/misc/Makefile.in1
-rw-r--r--libc/misc/internals/Makefile.in14
-rw-r--r--libc/misc/pthread/Makefile.in3
-rw-r--r--libc/pwd_grp/Makefile.in2
-rw-r--r--libc/pwd_grp/pwd_grp.c2
-rw-r--r--libc/pwd_grp/pwd_grp_internal.c2
-rw-r--r--libc/stdlib/Makefile.in5
-rw-r--r--libc/stdlib/malloc-standard/Makefile.in5
-rw-r--r--libc/string/generic/memmove.c8
-rw-r--r--libc/string/mips/memcpy.S119
-rw-r--r--libc/string/mips/memset.S71
-rw-r--r--libc/string/strdup.c10
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_errno.h8
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_pthread.h25
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h118
-rw-r--r--libc/unistd/sysconf.c49
39 files changed, 623 insertions, 226 deletions
diff --git a/Makefile.in b/Makefile.in
index 814c9962f..06fc78972 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -56,10 +56,6 @@ HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_ARCH),$(HEADERS_BITS_COMMON))
headers: include/bits/uClibc_config.h
$(Q)$(MAKE) headers-y
$(Q)\
- $(SHELL) $(top_srcdir)extra/scripts/fix_includes.sh \
- -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
- $(header_extra_args)
- $(Q)\
set -e; \
if [ -f libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
$(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
@@ -94,7 +90,7 @@ headers: include/bits/uClibc_config.h
cd $(top_builddir); \
tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \
[ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \
- top_builddir=. CC="$(CC)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
+ KERNEL_HEADERS="${KERNEL_HEADERS}" top_builddir=. CC="$(CC) $(CPU_CFLAGS)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \
$(RM) $$tmp; \
else \
@@ -122,9 +118,6 @@ RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/rela
install_headers:
$(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
printf ".svn\n.cvsignore\nCVS\n" > tar_exclude ; \
- if [ "$(KERNEL_SOURCE)" = "$(PREFIX)$(DEVEL_PREFIX)" ] ; then \
- ls -1d include/linux include/asm* >> tar_exclude ; \
- fi ; \
$(TAR) -chf - -X tar_exclude include \
| $(TAR) -xf - -C $(PREFIX)$(DEVEL_PREFIX)
rm -f tar_exclude
@@ -188,7 +181,7 @@ ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
$(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
endif
endif
-ifneq ($(HAS_SHADOW),y)
+ifneq ($(UCLIBC_HAS_SHADOW),y)
# Remove shadow header since shadow password support is disabled.
$(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
endif
@@ -253,6 +246,15 @@ ifeq ($(DOPIC),y)
fi
endif
endif
+ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
+ for file in lib/lib*.gdb; do \
+ if test -f $$file; then \
+ $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \
+ $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \
+ $(PREFIX)$(DEVEL_PREFIX)lib; \
+ fi; \
+ done
+endif
# Installs run-time libraries
install_runtime:
diff --git a/Makerules b/Makerules
index f9810d0a1..b4df69bb6 100644
--- a/Makerules
+++ b/Makerules
@@ -2,7 +2,7 @@
# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
#
-.SUFFIXES: .c .S .o .os .oS .so .a .s .i .E
+.SUFFIXES: .c .S .o .os .oS .so .a .s .i
# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
ifeq ($(HAVE_SHARED),y)
@@ -11,6 +11,9 @@ libs: $(lib-so-y) $(lib-a-y)
$(lib-so-y): $(interp)
else
.LIBPATTERNS: "lib%.a"
+ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
+libs: $(lib-gdb-y)
+endif
libs: $(lib-a-y)
endif
objs: all_objs
@@ -101,7 +104,7 @@ cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
cmd_ar = $(AR) $(ARFLAGS) $@ $^
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
-compile.E = $(cmd_compile.c:-c=-E)
+compile.i = $(cmd_compile.c:-c=-E -dD)
compile.s = $(cmd_compile.c:-c=-S)
compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
@@ -131,6 +134,29 @@ define link.so
$(Q)$(LN) -sf $(1) $@
endef
+# CRT files needed by link-flat.so
+LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
+ $(top_builddir)lib/crtn.o
+
+# Create a shared flat library from the archive named by the first dependency.
+# $@ names the shared library's .gdb file, not the flat file itself.
+# (This is because the .gdb suffix makes the ELF file more distinctive
+# than the suffixless flat file.)
+#
+# Argument 1 is the shared library file -- i.e. $(@:.gdb=) -- and argument 2
+# is the shared library identifier. If it wasn't for $(disp_ld), we could
+# avoid passing $(@:.gdb=) as an argument and use $(@:.gdb=) instead of $(1).
+define link-flat.so
+ $(Q)$(INSTALL) -d $(dir $@)
+ $(Q)$(RM) $(1) $@
+ @$(disp_ld)
+ $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -o $(1) \
+ -elf2flt -shared-lib-id $(2) $(top_builddir)lib/Scrt1.o \
+ $(top_builddir)/lib/crti.o --whole-archive $(firstword $^) \
+ --no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
+ $(top_builddir)/lib/crtn.o
+endef
+
define linkm.so
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@@ -154,10 +180,8 @@ CFLAGS-.oS+=$(PICFLAG) -DSHARED
%.o: %.s ; $(compile.S)
%.os: %.s ; $(compile.S)
%.oS: %.s ; $(compile.S)
-%.E: %.c ; $(compile.E)
-%.E: %.S ; $(compile.E)
-%.i: %.c ; $(compile.E)
-%.i: %.S ; $(compile.E)
+%.i: %.c ; $(compile.i)
+%.i: %.S ; $(compile.i)
%.s: %.c ; $(compile.s)
%.s: %.S ; $(compile.s)
@@ -183,7 +207,7 @@ $(headers_dep):
CRT := crt1
-ifeq ($(HAVE_SHARED),y)
+ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
else
CRTS=$(top_builddir)lib/$(CRT).o
diff --git a/Rules.mak b/Rules.mak
index 7c227eaa4..658850e7b 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -5,6 +5,11 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+# check for proper make version
+ifneq ($(findstring 3.7,$(MAKE_VERSION)),)
+$(error Your make is too old $(MAKE_VERSION). Go get at least 3.80)
+endif
+
#-----------------------------------------------------------
# This file contains rules which are shared between multiple
# Makefiles. All normal configuration options live in the
@@ -59,8 +64,8 @@ TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/
TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
-KERNEL_SOURCE:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_SOURCE))))))
-export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_SOURCE
+KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
+export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
# Now config hard core
@@ -138,7 +143,11 @@ OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
endif
-PICFLAG:=-fPIC
+ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
+ PICFLAG:=-mfdpic
+else
+ PICFLAG:=-fPIC
+endif
PIEFLAG_NAME:=-fPIE
# Some nice CPU specific optimizations
@@ -179,16 +188,18 @@ ifeq ($(TARGET_ARCH),arm)
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=armv4
- CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4
- CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4
- CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4
- CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5
+ 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=arm9tdmi -march=armv5t
+ CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t
CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-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=armv4 -Wa,-mcpu=xscale
+ CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale
+ CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt
endif
ifeq ($(TARGET_ARCH),mips)
@@ -200,6 +211,17 @@ ifeq ($(TARGET_ARCH),mips)
CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
+ ifeq ($(strip $(ARCH_BIG_ENDIAN)),y)
+ CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-melf64btsmip
+ CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-melf32btsmip
+ endif
+ ifeq ($(strip $(ARCH_LITTLE_ENDIAN)),y)
+ CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-melf64ltsmip
+ CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-melf32ltsmip
+ endif
+ CPU_CFLAGS-$(CONFIG_MIPS_N64_ABI)+=-mabi=64
+ CPU_CFLAGS-$(CONFIG_MIPS_O32_ABI)+=-mabi=32
+ CPU_CFLAGS-$(CONFIG_MIPS_N32_ABI)+=-mabi=n32
endif
ifeq ($(TARGET_ARCH),nios)
@@ -262,15 +284,12 @@ ifeq ($(TARGET_ARCH),powerpc)
# faster code.
PICFLAG:=-fpic
PIEFLAG_NAME:=-fpie
-endif
-
-ifeq ($(TARGET_ARCH),bfin)
- PICFLAG:=-mfdpic
+ PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
+ CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
endif
ifeq ($(TARGET_ARCH),frv)
CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd
- CPU_CFLAGS-$(CONFIG_FRV)+=-mfdpic
# Using -pie causes the program to have an interpreter, which is
# forbidden, so we must make do with -shared. Unfortunately,
# -shared by itself would get us global function descriptors
@@ -454,6 +473,7 @@ else
PTNAME :=
PTINC :=
endif
+CFLAGS += -I$(KERNEL_HEADERS)
# Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
#CFLAGS+=-iwithprefix include
@@ -463,12 +483,6 @@ ifneq ($(DOASSERTS),y)
CFLAGS+=-DNDEBUG
endif
-# moved from ldso/{ldso,libdl}
-# BEWARE!!! At least mips* will die if -O0 is used!!!
-ifeq ($(TARGET_ARCH),mips)
-CFLAGS:=$(CFLAGS:-O0=-O1)
-endif
-
# Keep the check_as from being needlessly executed
ifndef ASFLAGS_NOEXEC
ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
@@ -488,16 +502,3 @@ ifeq ($(UCLIBC_CTOR_DTOR),y)
SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
endif
-
-########################################
-#
-# uClinux shared lib support
-#
-
-ifeq ($(CONFIG_BINFMT_SHARED_FLAT),y)
- # For the shared version of this, we specify no stack and its library ID
- FLTFLAGS += -s 0
- LIBID=1
- export LIBID FLTFLAGS
- SHARED_TARGET = lib/libc
-endif
diff --git a/TODO b/TODO
index fbac20901..49eef6123 100644
--- a/TODO
+++ b/TODO
@@ -86,14 +86,6 @@ TODO list for the uClibc 1.0.0 release:
*) Cleanup/scrub all the Makefile copyright junk
*) Fix dlopen, for both static and dynamic cases, and make it
fully comply with SuSv3
- *) From the the ELF spec "...All shared object initializations happen
- before the executable file gains control. ... Before the initialization
- code for any object A is called, the initialization code for any other
- objects that object A depends on are called. For these purposes, an object
- A depends on another object B, if B appears in Ads list of needed objects
- (recorded in the DT_NEEDED entries of the dynamic structure). The order of
- initialization for circular dependencies is undefined." uClibc's shared
- lib loader should be fixed to run ctors in the specified order.
TODO list for AFTER the uClibc 1.0.0 release:
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index f504397a6..c28ec640f 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -217,7 +217,6 @@ config HAVE_SHARED
config FORCE_SHAREABLE_TEXT_SEGMENTS
bool "Only load shared libraries which can share their text segment"
depends on HAVE_SHARED
- select DOPIC
default n
help
If you answer Y here, the uClibc native shared library loader will
@@ -484,7 +483,15 @@ config UCLIBC_SUSV3_LEGACY
Currently applies to bcopy/bzero/bcmp/index/rindex.
WARNING! ABI incompatibility.
-config HAS_SHADOW
+config UCLIBC_SUSV3_LEGACY_MACROS
+ bool "Enable SuSv3 LEGACY macros"
+ default n
+ help
+ Enable this option if you want to have SuSv3 LEGACY macros.
+ Currently applies to bcopy/bzero/bcmp/index/rindex et al.
+ WARNING! ABI incompatibility.
+
+config UCLIBC_HAS_SHADOW
bool "Shadow Password Support"
default y
help
@@ -689,7 +696,7 @@ config UCLIBC_HAS_CTYPE_TABLES
help
Answer Y to use table versions of the 'ctype.h' functions.
While the non-table versions are often smaller when building
- staticly linked apps, they work only in stub locale mode.
+ statically linked apps, they work only in stub locale mode.
Most people will answer Y.
@@ -959,7 +966,7 @@ config UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8
endchoice
config UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT
- bool "Attemt to shutdown stdio subsystem when abort() is called."
+ bool "Attempt to shutdown stdio subsystem when abort() is called."
default n
help
ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was a behavioral
@@ -1152,7 +1159,7 @@ config UCLIBC_HAS_REGEX
help
POSIX regular expression code is really big -- 53k all by itself.
If you don't use regular expressions, turn this off and save space.
- Of course, if you only staticly link, leave this on, since it will
+ Of course, if you only statically link, leave this on, since it will
only be included in your apps if you use regular expressions.
config UCLIBC_HAS_REGEX_OLD
@@ -1448,7 +1455,7 @@ config DODEBUG
config DODEBUG_PT
bool "Build pthread with debugging output"
- depends on UCLIBC_HAS_THREADS
+ depends on UCLIBC_HAS_THREADS && LINUXTHREADS_OLD
default n
help
Enable debug output in libpthread. This is only useful when doing
@@ -1525,7 +1532,7 @@ config SUPPORT_LD_DEBUG_EARLY
config UCLIBC_MALLOC_DEBUGGING
bool "Build malloc with debugging support"
- depends MALLOC
+ depends MALLOC || MALLOC_STANDARD
default n
help
Answer Y here to compile extra debugging support code into malloc.
diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch
index f5c31b276..9789ed547 100644
--- a/extra/Configs/Config.in.arch
+++ b/extra/Configs/Config.in.arch
@@ -3,6 +3,61 @@
# see extra/config/Kconfig-language.txt
#
+
+#
+# Binary format
+#
+if !ARCH_USE_MMU
+choice
+ prompt "Target File Format"
+config UCLIBC_FORMAT_ELF
+ bool "ELF"
+ depends on ARCH_USE_MMU
+config UCLIBC_FORMAT_FDPIC_ELF
+ bool "FDPIC ELF"
+ depends on !ARCH_USE_MMU
+config UCLIBC_FORMAT_FLAT
+ bool "STATIC FLAT"
+ depends on !ARCH_USE_MMU
+ select ARCH_HAS_NO_LDSO
+config UCLIBC_FORMAT_FLAT_SEP_DATA
+ bool "STATIC FLAT (sep-data)"
+ depends on !ARCH_USE_MMU
+ select ARCH_HAS_NO_LDSO
+config UCLIBC_FORMAT_SHARED_FLAT
+ bool "SHARED FLAT"
+ depends on !ARCH_USE_MMU
+ select ARCH_HAS_NO_LDSO
+ help
+ Pick this one if you are using uClinux and wish to build
+ uClibc as a flat-format shared library.
+endchoice
+endif
+if ARCH_USE_MMU
+comment "Using ELF file format"
+endif
+
+config UCLIBC_SHARED_FLAT_ID
+ int "Shared library ID"
+ default 1
+ depends on UCLIBC_FORMAT_SHARED_FLAT
+ help
+ When using flat shared libraries, every library has a unique
+ system-wide identifier. Identifier 0 is reserved for
+ executables and true shared libraries have identifiers
+ starting at 1. The maximum shared library identifier is
+ determined by the kernel and is usually 3. Shared library
+ N must be available on the target system as "/lib/libN.so".
+
+ When a shared C library is used, it usually has identifier 1,
+ but you can use this option to select a different identifier
+ if you need to.
+
+
+
+#
+# Endian Format
+#
config ARCH_ANY_ENDIAN
bool
config ARCH_BIG_ENDIAN
@@ -104,9 +159,9 @@ config DO_C99_MATH
If your applications require the newer C99 math library functions,
then answer Y.
-config KERNEL_SOURCE
+config KERNEL_HEADERS
string "Linux kernel header location"
- default "/usr/src/linux"
+ default "/usr/src/linux/include"
help
The kernel source you use to compile with should be the same as the
Linux kernel you run your apps on. uClibc doesn't even try to achieve binary
diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips
index 43e0bbb46..24c0cf87b 100644
--- a/extra/Configs/Config.mips
+++ b/extra/Configs/Config.mips
@@ -19,8 +19,28 @@ config LIBGCC_CFLAGS
string
choice
+ prompt "Target ABI"
+ default CONFIG_MIPS_O32_ABI
+ help
+ This is the ABI you wish to build use. Choose either O32, N32
+ or N64.
+
+config CONFIG_MIPS_O32_ABI
+ bool "O32 ABI"
+
+config CONFIG_MIPS_N32_ABI
+ bool "N32 ABI"
+
+config CONFIG_MIPS_N64_ABI
+ bool "N64 ABI"
+
+endchoice
+
+choice
prompt "Target Processor Architecture"
- default CONFIG_MIPS_ISA_1
+ default CONFIG_MIPS_ISA_1 if CONFIG_MIPS_O32_ABI
+ default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N32_ABI
+ default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N64_ABI
help
This selects the instruction set architecture of your MIPS CPU. This
information is used for optimizing purposes. To build a library that
diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
index 3cd583b06..bae49417d 100644
--- a/extra/locale/Makefile.in
+++ b/extra/locale/Makefile.in
@@ -10,7 +10,9 @@ WGET := wget --passive-ftp
LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
-BUILD_CFLAGS-locale-common := -D__UCLIBC_GEN_LOCALE
+BUILD_CFLAGS-locale-common := \
+ -D__UCLIBC_GEN_LOCALE \
+ -DUCLIBC_CTYPE_HEADER='"$(top_builddir)/include/bits/uClibc_ctype.h"'
BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index cf72a180c..429421616 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -12,7 +18,7 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#endif
-#include <bits/uClibc_ctype.h>
+#include UCLIBC_CTYPE_HEADER
/* #define CTYPE_PACKED */
diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c
index 5dfd41e48..c5279aadd 100644
--- a/extra/locale/gen_wctype.c
+++ b/extra/locale/gen_wctype.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -14,7 +20,7 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#endif
-#include <bits/uClibc_ctype.h>
+#include UCLIBC_CTYPE_HEADER
/* 0x9 : space blank */
/* 0xa : space */
diff --git a/extra/scripts/gen_bits_syscall_h.sh b/extra/scripts/gen_bits_syscall_h.sh
index 718253e90..116534ab3 100755
--- a/extra/scripts/gen_bits_syscall_h.sh
+++ b/extra/scripts/gen_bits_syscall_h.sh
@@ -14,17 +14,18 @@
#
# Warning!!! This does _no_ error checking!!!
-UNISTD_H_PATH=$top_builddir/include/asm/unistd.h
-INCLUDE_OPTS="-I$top_builddir/include"
+INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
case $CC in
*icc*) CC_SYSNUM_ARGS="-dM" ;;
*) CC_SYSNUM_ARGS="-dN" ;;
esac
-( echo "#include \"$UNISTD_H_PATH\"" ;
- $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS $UNISTD_H_PATH | # needed to strip out any kernel-internal defines
- sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp'
+( echo "#include <asm/unistd.h>";
+ echo "#include <asm/unistd.h>" |
+ $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
+ sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp' \
+ -e 's/^[ ]*#undef[ ]*__NR_\([A-Za-z0-9_]*\).*/UNDEFUCLIBC_\1 __NR_\1/gp' # needed to strip out any kernel-internal defines
) |
$CC -E $INCLUDE_OPTS - |
( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ; echo ;
@@ -36,7 +37,8 @@ $CC -E $INCLUDE_OPTS - |
echo "#endif" ; echo ;
sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
#define __NR_\1 \2\
-#define SYS_\1 __NR_\1/gp'
+#define SYS_\1 __NR_\1/gp' \
+ -e 's/^UNDEFUCLIBC_\([A-Za-z0-9_]*\).*/#undef __NR_\1/gp'
echo ;
echo "#endif" ;
)
diff --git a/include/elf.h b/include/elf.h
index 8ee65267a..19805d7c9 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -1292,6 +1292,8 @@ typedef struct
#define EF_BFIN_PIC 0x00000001 /* -fpic */
#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */
+#define EF_BFIN_CODE_IN_L1 0x00000010 /* --code-in-l1 */
+#define EF_BFIN_DATA_IN_L1 0x00000020 /* --data-in-l1 */
/* FR-V specific definitions. */
#define R_FRV_NONE 0 /* No reloc. */
diff --git a/include/features.h b/include/features.h
index c94d531e8..46a94f7f4 100644
--- a/include/features.h
+++ b/include/features.h
@@ -176,8 +176,10 @@
# define _XOPEN_SOURCE 600
# undef _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
-# undef _LARGEFILE64_SOURCE
-# define _LARGEFILE64_SOURCE 1
+# ifdef __UCLIBC_HAS_LFS__
+# undef _LARGEFILE64_SOURCE
+# define _LARGEFILE64_SOURCE 1
+# endif /* __UCLIBC_HAS_LFS__ */
# undef _BSD_SOURCE
# define _BSD_SOURCE 1
# undef _SVID_SOURCE
diff --git a/include/libc-internal.h b/include/libc-internal.h
index 80bac2362..2f4f7fae3 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -56,6 +56,8 @@ extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen);
# define __pthread_mutex_lock(mutex) ((void)0)
# define __pthread_mutex_trylock(mutex) ((void)0)
# define __pthread_mutex_unlock(mutex) ((void)0)
+# define _pthread_cleanup_push_defer(mutex) ((void)0)
+# define _pthread_cleanup_pop_restore(mutex) ((void)0)
# endif
/* internal access to program name */
diff --git a/include/math.h b/include/math.h
index 8c11b5a76..c50b2e7b0 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,5 +1,6 @@
/* Declarations for math functions.
- Copyright (C) 1991,92,93,95,96,97,98,99,2001 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
@@ -31,15 +32,20 @@ __BEGIN_DECLS
/* Get machine-dependent HUGE_VAL value (returned on overflow).
On all IEEE754 machines, this is +Infinity. */
#include <bits/huge_val.h>
+#ifdef __USE_ISOC99
+# include <bits/huge_valf.h>
+# include <bits/huge_vall.h>
+
+/* Get machine-dependent INFINITY value. */
+# include <bits/inf.h>
-#ifdef __USE_ISOC99
/* Get machine-dependent NAN value (returned for some domain errors). */
# include <bits/nan.h>
-#endif
+#endif /* __USE_ISOC99 */
+
/* Get general and ISO C99 specific information. */
#include <bits/mathdef.h>
-
/* The file <bits/mathcalls.h> contains the prototypes for all the
actual math functions. These macros are used for those prototypes,
so we can easily declare each function as both `name' and `__name',
@@ -60,8 +66,12 @@ __BEGIN_DECLS
#define _Mdouble_ double
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
+# define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
#include <bits/mathcalls.h>
#undef _Mdouble_
+#undef _Mdouble_BEGIN_NAMESPACE
+#undef _Mdouble_END_NAMESPACE
#undef __MATH_PRECNAME
#if defined __USE_MISC || defined __USE_ISOC99
@@ -79,14 +89,44 @@ __BEGIN_DECLS
# else
# define __MATH_PRECNAME(name,r) name/**/f/**/r
# endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
# include <bits/mathcalls.h>
# undef _Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# 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)
+ __THROW __attribute__ ((__const__));
+# 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__));
+extern long double __REDIRECT_NTH (nexttowardl,
+ (long 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_NTH(__MATH_PRECNAME(function,suffix), \
+ args, alias)
+# 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
@@ -96,8 +136,12 @@ __BEGIN_DECLS
# else
# define __MATH_PRECNAME(name,r) name/**/l/**/r
# endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
# include <bits/mathcalls.h>
# undef _Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
# undef __MATH_PRECNAME
# endif /* __STDC__ || __GNUC__ */
@@ -345,18 +389,28 @@ extern int matherr (struct exception *__exc);
# define __NO_MATH_INLINES 1
#endif
+#if defined __USE_ISOC99 && __GNUC_PREREQ(2,97)
+/* ISO C99 defines some macros to compare number while taking care for
+ unordered numbers. Many FPUs provide special instructions to support
+ these operations. Generic support in GCC for these as builtins went
+ in before 3.0.0, but not all cpus added their patterns. We define
+ versions that use the builtins here, and <bits/mathinline.h> will
+ undef/redefine as appropriate for the specific GCC version in use. */
+# define isgreater(x, y) __builtin_isgreater(x, y)
+# define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
+# define isless(x, y) __builtin_isless(x, y)
+# define islessequal(x, y) __builtin_islessequal(x, y)
+# define islessgreater(x, y) __builtin_islessgreater(x, y)
+# define isunordered(u, v) __builtin_isunordered(u, v)
+#endif
+
/* Get machine-dependent inline versions (if there are any). */
#ifdef __USE_EXTERN_INLINES
# include <bits/mathinline.h>
#endif
-
#ifdef __USE_ISOC99
-/* ISO C99 defines some macros to compare number while taking care for
- unordered numbers. Many FPUs provide special instructions to support
- these operations and these tests are defined in <bits/mathinline.h>,
- we define the generic macros at this late point and only if they are
- not defined yet. */
+/* If we've still got undefined comparison macros, provide defaults. */
/* Return nonzero value if X is greater than Y. */
# ifndef isgreater
diff --git a/include/printf.h b/include/printf.h
index 569397cd2..a68c6daad 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -75,6 +75,7 @@ struct printf_info
unsigned int is_short:1; /* h flag. */
unsigned int is_long:1; /* l flag. */
unsigned int is_long_double:1;/* L flag. */
+ unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */
#elif __BYTE_ORDER == __BIG_ENDIAN
diff --git a/include/stdio.h b/include/stdio.h
index 787a6aa52..fd2a73842 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -840,7 +840,14 @@ extern void funlockfile (FILE *__stream) __THROW;
#define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
#endif
+#ifndef __STDIO_GETC_MACRO
+#define __stdin stdin
+#endif
#define getchar() __GETC(__stdin)
+
+#ifndef __STDIO_PUTC_MACRO
+#define __stdout stdout
+#endif
#define putchar(_ch) __PUTC((_ch), __stdout)
#if defined __USE_POSIX || defined __USE_MISC
diff --git a/include/stdlib.h b/include/stdlib.h
index 3ed029c07..982bac72f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -693,10 +693,12 @@ __END_NAMESPACE_C99
#endif
-#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
+#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD
/* Convert floating point numbers to strings. The returned values are
valid only until another call to the same function. */
+# ifdef __UCLIBC_SUSV3_LEGACY__
+
#if 0
/* Convert VALUE to a string with NDIGIT digits and return a pointer to
this. Set *DECPT with the position of the decimal character and *SIGN
@@ -716,7 +718,7 @@ extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
be written to BUF. */
extern char *gcvt (double __value, int __ndigit, char *__buf)
__THROW __nonnull ((3)) __wur;
-
+# endif /* __UCLIBC_SUSV3_LEGACY__ */
# if 0 /*def __USE_MISC*/
/* Long double versions of above functions. */
diff --git a/include/string.h b/include/string.h
index dd5f23f2b..87d953449 100644
--- a/include/string.h
+++ b/include/string.h
@@ -321,8 +321,9 @@ extern char *index (__const char *__s, int __c)
extern char *rindex (__const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# else
+# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
/* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
- * They are replaced as proposed by SuSv3. Don't sync this part
+ * They are replaced as proposed by SuSv3. Don't sync this part
* with glibc and keep it in sync with strings.h. */
# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
@@ -330,6 +331,7 @@ extern char *rindex (__const char *__s, int __c)
# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
# define index(s,c) strchr((s), (c))
# define rindex(s,c) strrchr((s), (c))
+# endif
# endif
/* Return the position of the first bit set in I, or 0 if none are set.
diff --git a/include/strings.h b/include/strings.h
index fe089d960..107c53a4f 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -53,8 +53,9 @@ extern char *index (__const char *__s, int __c)
extern char *rindex (__const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# else
+# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
/* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
- * They are replaced as proposed by SuSv3. Don't sync this part
+ * They are replaced as proposed by SuSv3. Don't sync this part
* with glibc and keep it in sync with string.h. */
# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
@@ -62,6 +63,7 @@ extern char *rindex (__const char *__s, int __c)
# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
# define index(s,c) strchr((s), (c))
# define rindex(s,c) strrchr((s), (c))
+# endif
# endif
/* Return the position of the first bit set in I, or 0 if none are set.
diff --git a/include/sys/mman.h b/include/sys/mman.h
index aeeea7d0e..10f4afe24 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -100,6 +100,7 @@ extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
#endif
#ifdef __ARCH_USE_MMU__
+
/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
be memory resident. */
extern int mlock (__const void *__addr, size_t __len) __THROW;
@@ -115,6 +116,17 @@ extern int mlockall (int __flags) __THROW;
/* All currently mapped pages of the process' address space become
unlocked. */
extern int munlockall (void) __THROW;
+
+#else
+
+/* On no-mmu systems, memory cannot be swapped out, so
+ * these functions will always succeed.
+ */
+static inline int mlock (__const void *__addr, size_t __len) { return 0; }
+static inline int munlock (__const void *__addr, size_t __len) { return 0; }
+static inline int mlockall (int __flags) { return 0; }
+static inline int munlockall (void) { return 0; }
+
#endif
#ifdef __USE_MISC
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
index aef1f998f..4c8ede843 100644
--- a/include/sys/syscall.h
+++ b/include/sys/syscall.h
@@ -19,13 +19,19 @@
#ifndef _SYSCALL_H
#define _SYSCALL_H 1
-/* This file provides us with the nicely useful _syscall[0-5] macros. */
+/* The _syscall#() macros are for uClibc internal use only.
+ * User application code should use syscall() instead.
+ *
+ * The kernel provided _syscall[0-6] macros from asm/unistd.h are not suitable
+ * for use in uClibc as they lack PIC support etc, so for uClibc we use our own
+ * local _syscall# macros to be certain all such variations are handled
+ * properly.
+ */
+
#include <features.h>
+#include <bits/sysnum.h>
#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
# include <bits/syscalls.h>
-#else
-# include <asm/unistd.h>
-# include <bits/sysnum.h>
#endif
#endif
diff --git a/libc/Makefile.in b/libc/Makefile.in
index 450ad5ec2..f3cd20922 100644
--- a/libc/Makefile.in
+++ b/libc/Makefile.in
@@ -50,6 +50,7 @@ libc-multi-y = $(filter-out $(libc-nomulti-y:.o=.c),$(all_sources))
endif
lib-a-y += $(top_builddir)lib/libc.a
+lib-gdb-y += $(top_builddir)lib/libc.gdb
lib-so-y += $(libc)
objclean-y += libc_clean
@@ -89,5 +90,8 @@ $(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
$(do_strip)
$(do_ar)
+$(top_builddir)lib/libc.gdb: $(top_builddir)lib/libc.a $(LINK_FLAT_CRTS)
+ $(call link-flat.so,$(@:.gdb=),$(SHARED_FLAT_ID))
+
libc_clean:
$(RM) $(libc_OUT)/*.{o,os,oS,a}
diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in
index 542859576..104db366e 100644
--- a/libc/misc/Makefile.in
+++ b/libc/misc/Makefile.in
@@ -20,7 +20,6 @@ include $(top_srcdir)libc/misc/gnu/Makefile.in
include $(top_srcdir)libc/misc/internals/Makefile.in
include $(top_srcdir)libc/misc/locale/Makefile.in
include $(top_srcdir)libc/misc/mntent/Makefile.in
-include $(top_srcdir)libc/misc/pthread/Makefile.in
include $(top_srcdir)libc/misc/regex/Makefile.in
include $(top_srcdir)libc/misc/search/Makefile.in
include $(top_srcdir)libc/misc/statfs/Makefile.in
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in
index 8237c2f6c..4d57cf4e3 100644
--- a/libc/misc/internals/Makefile.in
+++ b/libc/misc/internals/Makefile.in
@@ -7,7 +7,7 @@
CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
-CSRC := tempname.c __errno_location.c __h_errno_location.c
+CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c
MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
@@ -16,14 +16,14 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
libc-y += $(MISC_INTERNALS_OBJ)
-libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \
- $(MISC_INTERNALS_OUT)/errno.oS
-libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \
- $(MISC_INTERNALS_OUT)/errno.o
-libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \
- $(MISC_INTERNALS_OUT)/errno.o
+libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS
+libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
libc-so-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \
$(MISC_INTERNALS_OUT)/errno.oS $(MISC_INTERNALS_OBJ:.o=.oS)
+libc-static-$(UCLIBC_FORMAT_SHARED_FLAT) += \
+ $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \
+ $(MISC_INTERNALS_OUT)/shared_flat_add_library.o
+libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
objclean-y += misc_internals_objclean
diff --git a/libc/misc/pthread/Makefile.in b/libc/misc/pthread/Makefile.in
index fc138c91a..0d7a9e49d 100644
--- a/libc/misc/pthread/Makefile.in
+++ b/libc/misc/pthread/Makefile.in
@@ -8,7 +8,8 @@
MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread
MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread
-libc-static-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
+libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/unlock.o
+libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
objclean-y += misc_pthread_objclean
diff --git a/libc/pwd_grp/Makefile.in b/libc/pwd_grp/Makefile.in
index 47699e0fa..28d7ea075 100644
--- a/libc/pwd_grp/Makefile.in
+++ b/libc/pwd_grp/Makefile.in
@@ -11,7 +11,7 @@ PWDGRP_OUT := $(top_builddir)libc/pwd_grp
CSRC := $(notdir $(wildcard $(PWDGRP_DIR)/*.c))
CSRC := $(filter-out pwd_grp.c pwd_grp_internal.c,$(CSRC))
-ifneq ($(HAS_SHADOW),y)
+ifneq ($(UCLIBC_HAS_SHADOW),y)
SHADOW_CSRC := \
fgetspent_r.c fgetspent.c getspent_r.c getspent.c \
getspnam_r.c getspnam.c lckpwdf.c putspent.c \
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 961899af9..2a9d4519a 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -31,7 +31,7 @@
#include <pwd.h>
#include <grp.h>
#include <paths.h>
-#ifdef __HAS_SHADOW__
+#ifdef __UCLIBC_HAS_SHADOW__
#include <shadow.h>
#endif
#ifdef __UCLIBC_HAS_THREADS__
diff --git a/libc/pwd_grp/pwd_grp_internal.c b/libc/pwd_grp/pwd_grp_internal.c
index cb0ae76cf..c89747890 100644
--- a/libc/pwd_grp/pwd_grp_internal.c
+++ b/libc/pwd_grp/pwd_grp_internal.c
@@ -31,7 +31,7 @@
#include <pwd.h>
#include <grp.h>
#include <paths.h>
-#ifdef __HAS_SHADOW__
+#ifdef __UCLIBC_HAS_SHADOW__
#include <shadow.h>
#endif
#ifdef __UCLIBC_HAS_THREADS__
diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in
index e6948849b..f08e24795 100644
--- a/libc/stdlib/Makefile.in
+++ b/libc/stdlib/Makefile.in
@@ -12,7 +12,7 @@ include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in
CSRC := \
abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \
rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
- getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \
+ getpt.c ptsname.c grantpt.c unlockpt.c drand48-iter.c jrand48.c \
jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
valloc.c posix_memalign.c a64l.c l64a.c
@@ -24,6 +24,9 @@ CSRC += mkstemp64.c
endif
ifeq ($(UCLIBC_HAS_FLOATS),y)
CSRC += drand48.c drand48_r.c erand48.c erand48_r.c
+ifeq ($(UCLIBC_SUSV3_LEGACY),y)
+CSRC += gcvt.c
+endif
endif
# multi source stdlib.c
diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in
index 12445bbf1..e3ae73715 100644
--- a/libc/stdlib/malloc-standard/Makefile.in
+++ b/libc/stdlib/malloc-standard/Makefile.in
@@ -5,11 +5,6 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-# Turn on malloc debugging if requested
-ifeq ($(UCLIBC_MALLOC_DEBUGGING),y)
-CFLAGS += -D__MALLOC_DEBUGGING
-endif
-
# calloc.c can be found at uClibc/libc/stdlib/calloc.c
# valloc.c can be found at uClibc/libc/stdlib/valloc.c
CSRC := malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c
index 0e51ea771..68caacd78 100644
--- a/libc/string/generic/memmove.c
+++ b/libc/string/generic/memmove.c
@@ -29,8 +29,7 @@ libc_hidden_proto(memcpy)
static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len)
{
- op_t a0 = 0;
- op_t a1 = 0;
+ op_t a0, a1;
switch (len % 8)
{
@@ -134,10 +133,7 @@ static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len)
static void _wordcopy_bwd_dest_aligned (long int dstp, long int srcp, size_t len)
{
- op_t a0 = 0;
- op_t a1 = 0;
- op_t a2 = 0;
- op_t a3 = 0;
+ op_t a0, a1, a2, a3;
int sh_1, sh_2;
/* Calculate how to shift a word read at the memory operation
diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S
index 155bc1128..9b05ee6da 100644
--- a/libc/string/mips/memcpy.S
+++ b/libc/string/mips/memcpy.S
@@ -22,11 +22,124 @@
#include <endian.h>
#include "sysdep.h"
+/* void *memcpy(void *s1, const void *s2, size_t n); */
+
#ifdef __mips64
-#error mips32 code being compiled for mips64!
+
+#include <sys/asm.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define LDHI ldl /* high part is left in big-endian */
+# define SDHI sdl /* high part is left in big-endian */
+# define LDLO ldr /* low part is right in big-endian */
+# define SDLO sdr /* low part is right in big-endian */
+#else
+# define LDHI ldr /* high part is right in little-endian */
+# define SDHI sdr /* high part is right in little-endian */
+# define LDLO ldl /* low part is left in little-endian */
+# define SDLO sdl /* low part is left in little-endian */
#endif
-/* void *memcpy(void *s1, const void *s2, size_t n); */
+ENTRY (memcpy)
+ .set noreorder
+
+ slti t0, a2, 16 # Less than 16?
+ bne t0, zero, L(last16)
+ move v0, a0 # Setup exit value before too late
+
+ xor t0, a1, a0 # Find a0/a1 displacement
+ andi t0, 0x7
+ bne t0, zero, L(shift) # Go handle the unaligned case
+ PTR_SUBU t1, zero, a1
+ andi t1, 0x7 # a0/a1 are aligned, but are we
+ beq t1, zero, L(chk8w) # starting in the middle of a word?
+ PTR_SUBU a2, t1
+ LDHI t0, 0(a1) # Yes we are... take care of that
+ PTR_ADDU a1, t1
+ SDHI t0, 0(a0)
+ PTR_ADDU a0, t1
+
+L(chk8w):
+ andi t0, a2, 0x3f # 64 or more bytes left?
+ beq t0, a2, L(chk1w)
+ PTR_SUBU a3, a2, t0 # Yes
+ PTR_ADDU a3, a1 # a3 = end address of loop
+ move a2, t0 # a2 = what will be left after loop
+L(lop8w):
+ ld t0, 0(a1) # Loop taking 8 words at a time
+ ld t1, 8(a1)
+ ld t2, 16(a1)
+ ld t3, 24(a1)
+ ld ta0, 32(a1)
+ ld ta1, 40(a1)
+ ld ta2, 48(a1)
+ ld ta3, 56(a1)
+ PTR_ADDIU a0, 64
+ PTR_ADDIU a1, 64
+ sd t0, -64(a0)
+ sd t1, -56(a0)
+ sd t2, -48(a0)
+ sd t3, -40(a0)
+ sd ta0, -32(a0)
+ sd ta1, -24(a0)
+ sd ta2, -16(a0)
+ bne a1, a3, L(lop8w)
+ sd ta3, -8(a0)
+
+L(chk1w):
+ andi t0, a2, 0x7 # 8 or more bytes left?
+ beq t0, a2, L(last16)
+ PTR_SUBU a3, a2, t0 # Yes, handle them one dword at a time
+ PTR_ADDU a3, a1 # a3 again end address
+ move a2, t0
+L(lop1w):
+ ld t0, 0(a1)
+ PTR_ADDIU a0, 8
+ PTR_ADDIU a1, 8
+ bne a1, a3, L(lop1w)
+ sd t0, -8(a0)
+
+L(last16):
+ blez a2, L(lst16e) # Handle last 16 bytes, one at a time
+ PTR_ADDU a3, a2, a1
+L(lst16l):
+ lb t0, 0(a1)
+ PTR_ADDIU a0, 1
+ PTR_ADDIU a1, 1
+ bne a1, a3, L(lst16l)
+ sb t0, -1(a0)
+L(lst16e):
+ jr ra # Bye, bye
+ nop
+
+L(shift):
+ PTR_SUBU a3, zero, a0 # Src and Dest unaligned
+ andi a3, 0x7 # (unoptimized case...)
+ beq a3, zero, L(shft1)
+ PTR_SUBU a2, a3 # a2 = bytes left
+ LDHI t0, 0(a1) # Take care of first odd part
+ LDLO t0, 7(a1)
+ PTR_ADDU a1, a3
+ SDHI t0, 0(a0)
+ PTR_ADDU a0, a3
+L(shft1):
+ andi t0, a2, 0x7
+ PTR_SUBU a3, a2, t0
+ PTR_ADDU a3, a1
+L(shfth):
+ LDHI t1, 0(a1) # Limp through, dword by dword
+ LDLO t1, 7(a1)
+ PTR_ADDIU a0, 8
+ PTR_ADDIU a1, 8
+ bne a1, a3, L(shfth)
+ sd t1, -8(a0)
+ b L(last16) # Handle anything which may be left
+ move a2, t0
+
+ .set reorder
+END (memcpy)
+
+#else /* !__mips64 */
#if __BYTE_ORDER == __BIG_ENDIAN
# define LWHI lwl /* high part is left in big-endian */
@@ -139,4 +252,6 @@ L(shfth):
.set reorder
END (memcpy)
+#endif /* !__mips64 */
+
libc_hidden_def(memcpy)
diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S
index 9169ad58a..ff0554ff9 100644
--- a/libc/string/mips/memset.S
+++ b/libc/string/mips/memset.S
@@ -22,11 +22,76 @@
#include <endian.h>
#include "sysdep.h"
+/* void *memset(void *s, int c, size_t n). */
+
#ifdef __mips64
-#error mips32 code being compiled for mips64!
+
+#include <sys/asm.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define SDHI sdl /* high part is left in big-endian */
+#else
+# define SDHI sdr /* high part is right in little-endian */
#endif
-/* void *memset(void *s, int c, size_t n). */
+ENTRY (memset)
+ .set noreorder
+
+ slti ta1, a2, 16 # Less than 16?
+ bne ta1, zero, L(last16)
+ move v0, a0 # Setup exit value before too late
+
+ beq a1, zero, L(ueven) # If zero pattern, no need to extend
+ andi a1, 0xff # Avoid problems with bogus arguments
+ dsll ta0, a1, 8
+ or a1, ta0
+ dsll ta0, a1, 16
+ or a1, ta0 # a1 is now pattern in full word
+ dsll ta0, a1, 32
+ or a1, ta0 # a1 is now pattern in double word
+
+L(ueven):
+ PTR_SUBU ta0, zero, a0 # Unaligned address?
+ andi ta0, 0x7
+ beq ta0, zero, L(chkw)
+ PTR_SUBU a2, ta0
+ SDHI a1, 0(a0) # Yes, handle first unaligned part
+ PTR_ADDU a0, ta0 # Now both a0 and a2 are updated
+
+L(chkw):
+ andi ta0, a2, 0xf # Enough left for one loop iteration?
+ beq ta0, a2, L(chkl)
+ PTR_SUBU a3, a2, ta0
+ PTR_ADDU a3, a0 # a3 is last loop address +1
+ move a2, ta0 # a2 is now # of bytes left after loop
+L(loopw):
+ PTR_ADDIU a0, 16 # Handle 2 dwords pr. iteration
+ sd a1, -16(a0)
+ bne a0, a3, L(loopw)
+ sd a1, -8(a0)
+
+L(chkl):
+ andi ta0, a2, 0x8 # Check if there is at least a double
+ beq ta0, zero, L(last16) # word remaining after the loop
+ PTR_SUBU a2, ta0
+ sd a1, 0(a0) # Yes...
+ PTR_ADDIU a0, 8
+
+L(last16):
+ blez a2, L(exit) # Handle last 16 bytes (if cnt>0)
+ PTR_ADDU a3, a2, a0 # a3 is last address +1
+L(lst16l):
+ PTR_ADDIU a0, 1
+ bne a0, a3, L(lst16l)
+ sb a1, -1(a0)
+L(exit):
+ j ra # Bye, bye
+ nop
+
+ .set reorder
+END (memset)
+
+#else /* !__mips64 */
#if __BYTE_ORDER == __BIG_ENDIAN
# define SWHI swl /* high part is left in big-endian */
@@ -89,4 +154,6 @@ L(exit):
.set reorder
END (memset)
+#endif /* !__mips64 */
+
libc_hidden_def(memset)
diff --git a/libc/string/strdup.c b/libc/string/strdup.c
index dff5af60a..d15345d0d 100644
--- a/libc/string/strdup.c
+++ b/libc/string/strdup.c
@@ -10,25 +10,23 @@
#ifdef WANT_WIDE
libc_hidden_proto(wcslen)
-libc_hidden_proto(wcscpy)
# define Wstrdup wcsdup
# define Wstrlen wcslen
-# define Wstrcpy wcscpy
#else
libc_hidden_proto(strdup)
libc_hidden_proto(strlen)
-libc_hidden_proto(strcpy)
# define Wstrdup strdup
# define Wstrlen strlen
-# define Wstrcpy strcpy
#endif
+libc_hidden_proto(memcpy)
Wchar *Wstrdup(register const Wchar *s1)
{
register Wchar *s;
+ register size_t l = (Wstrlen(s1) + 1) * sizeof(Wchar);
- if ((s = malloc((Wstrlen(s1) + 1) * sizeof(Wchar))) != NULL) {
- Wstrcpy(s, s1);
+ if ((s = malloc(l)) != NULL) {
+ memcpy(s, s1, l);
}
return s;
diff --git a/libc/sysdeps/linux/common/bits/uClibc_errno.h b/libc/sysdeps/linux/common/bits/uClibc_errno.h
index 9da9f8155..4cb2a8caa 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_errno.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_errno.h
@@ -31,10 +31,12 @@ extern int *__errno_location (void) __THROW __attribute__ ((__const__))
attribute_hidden
# endif
;
-#include <tls.h>
-#if USE___THREAD
+# if defined __UCLIBC_HAS_THREADS__
+# include <tls.h>
+# if USE___THREAD
libc_hidden_proto(__errno_location)
-#endif
+# endif
+# endif
/* We now need a declaration of the `errno' variable. */
# ifndef __UCLIBC_HAS_THREADS__
diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
index a3be2ca35..1d6209f5e 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_pthread.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
@@ -27,11 +27,24 @@
# error "Always include <pthread.h> rather than <bits/uClibc_pthread.h>"
#endif
-extern int __pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
- __const pthread_mutexattr_t *__restrict
- __mutex_attr) attribute_hidden;
-extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) attribute_hidden;
-extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) attribute_hidden;
-extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) attribute_hidden;
+#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
+/* Threading functions internal to uClibc. Make these thread functions
+ * weak so that we can elide them from single-threaded processes. */
+extern int weak_function __pthread_mutex_init (pthread_mutex_t *__mutex,
+ __const pthread_mutexattr_t *__mutex_attr);
+extern int weak_function __pthread_mutex_destroy (pthread_mutex_t *__mutex);
+extern int weak_function __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int weak_function __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+extern void __uclibc_mutex_unlock (void *) attribute_hidden;
+extern int weak_function __pthread_mutex_trylock (pthread_mutex_t *__mutex);
+# ifndef __UCLIBC_HAS_THREADS_NATIVE__
+extern void weak_function _pthread_cleanup_push_defer (
+ struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *), void *__arg);
+extern void weak_function _pthread_cleanup_pop_restore (
+ struct _pthread_cleanup_buffer *__buffer,
+ int __execute);
+# endif
+#endif
#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index d73da9de7..a75f971eb 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -1,21 +1,8 @@
/* Copyright (C) 2002-2004 Manuel Novoa III <mjn3@codepoet.org>
*
- * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
- *
- * This 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.
+ * GNU Library General Public License (LGPL) version 2 or later.
*
- * 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.
+ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
#ifndef _STDIO_H
@@ -242,7 +229,7 @@ typedef struct {
/**********************************************************************/
#ifdef __UCLIBC_HAS_LFS__
-typedef __off64_t __offmax_t; /* TODO -- rename this? */
+typedef __off64_t __offmax_t; /* TODO -- rename this? */
#else
typedef __off_t __offmax_t; /* TODO -- rename this? */
#endif
@@ -252,7 +239,7 @@ typedef __off_t __offmax_t; /* TODO -- rename this? */
typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize);
typedef __ssize_t __io_write_fn(void *__cookie,
- __const char *__buf, size_t __bufsize);
+ __const char *__buf, size_t __bufsize);
/* NOTE: GLIBC difference!!! -- fopencookie seek function
* For glibc, the type of pos is always (__off64_t *) but in our case
* it is type (__off_t *) when the lib is built without large file support.
@@ -359,24 +346,25 @@ struct __STDIO_FILE_STRUCT {
#define __MASK_READING 0x0003U /* (0x0001 | 0x0002) */
#define __FLAG_READING 0x0001U
-#define __FLAG_UNGOT 0x0002U
-#define __FLAG_EOF 0x0004U
+#define __FLAG_UNGOT 0x0002U
+#define __FLAG_EOF 0x0004U
#define __FLAG_ERROR 0x0008U
-#define __FLAG_WRITEONLY 0x0010U
-#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */
+#define __FLAG_WRITEONLY 0x0010U
+#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */
#define __FLAG_WRITING 0x0040U
-#define __FLAG_NARROW 0x0080U
-
-#define __FLAG_FBF 0x0000U /* must be 0 */
-#define __FLAG_LBF 0x0100U
-#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */
-#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */
-#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */
-#define __FLAG_WIDE 0x0800U
-/* available slot 0x1000U */
+#define __FLAG_NARROW 0x0080U
+
+#define __FLAG_FBF 0x0000U /* must be 0 */
+#define __FLAG_LBF 0x0100U
+#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */
+#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */
+#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */
+#define __FLAG_WIDE 0x0800U
+/* available slot 0x1000U */
#define __FLAG_FREEFILE 0x2000U
#define __FLAG_FREEBUF 0x4000U
-#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */
+#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */
+#define __FLAG_FAILED_FREOPEN __FLAG_LARGEFILE
/* Note: In no-buffer mode, it would be possible to pack the necessary
* flags into one byte. Since we wouldn't be buffering and there would
@@ -422,17 +410,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden;
#endif
/**********************************************************************/
-#define __CLEARERR_UNLOCKED(__stream) \
+#define __CLEARERR_UNLOCKED(__stream) \
((void)((__stream)->__modeflags &= ~(__FLAG_EOF|__FLAG_ERROR)))
#define __FEOF_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_EOF)
#define __FERROR_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_ERROR)
#ifdef __UCLIBC_HAS_THREADS__
-# define __CLEARERR(__stream) (clearerr)(__stream)
+# define __CLEARERR(__stream) (clearerr)(__stream)
# define __FERROR(__stream) (ferror)(__stream)
# define __FEOF(__stream) (feof)(__stream)
#else
-# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream)
+# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream)
# define __FERROR(__stream) __FERROR_UNLOCKED(__stream)
# define __FEOF(__stream) __FEOF_UNLOCKED(__stream)
#endif
@@ -440,17 +428,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden;
extern int __fgetc_unlocked(FILE *__stream);
extern int __fputc_unlocked(int __c, FILE *__stream);
-/* First define the default definitions. They will be overwritten below as necessary. */
+/* First define the default definitions. They overriden below as necessary. */
#define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
-#define __FGETC(__stream) (fgetc)((__stream))
-#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream))
+#define __FGETC(__stream) (fgetc)((__stream))
+#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream))
#define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
-#define __GETC(__stream) (fgetc)((__stream))
+#define __GETC(__stream) (fgetc)((__stream))
-#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
+#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
#define __FPUTC(__c, __stream) (fputc)((__c),(__stream))
-#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream))
-#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
+#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream))
+#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
#define __PUTC(__c, __stream) (fputc)((__c),(__stream))
@@ -459,9 +447,9 @@ extern int __fputc_unlocked(int __c, FILE *__stream);
extern FILE *__stdin; /* For getchar() macro. */
# undef __GETC_UNLOCKED_MACRO
-# define __GETC_UNLOCKED_MACRO(__stream) \
+# define __GETC_UNLOCKED_MACRO(__stream) \
( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \
- ? (*(__stream)->__bufpos++) \
+ ? (*(__stream)->__bufpos++) \
: __fgetc_unlocked(__stream) )
# if 0
@@ -476,10 +464,10 @@ extern FILE *__stdin; /* For getchar() macro. */
# else
/* Using gcc extension for safety and additional inlining. */
# undef __FGETC_UNLOCKED
-# define __FGETC_UNLOCKED(__stream) \
+# define __FGETC_UNLOCKED(__stream) \
(__extension__ ({ \
- FILE *__S = (__stream); \
- __GETC_UNLOCKED_MACRO(__S); \
+ FILE *__S = (__stream); \
+ __GETC_UNLOCKED_MACRO(__S); \
}) )
# undef __GETC_UNLOCKED
@@ -487,23 +475,23 @@ extern FILE *__stdin; /* For getchar() macro. */
# ifdef __UCLIBC_HAS_THREADS__
# undef __FGETC
-# define __FGETC(__stream) \
+# define __FGETC(__stream) \
(__extension__ ({ \
- FILE *__S = (__stream); \
- ((__S->__user_locking ) \
- ? __GETC_UNLOCKED_MACRO(__S) \
+ FILE *__S = (__stream); \
+ ((__S->__user_locking ) \
+ ? __GETC_UNLOCKED_MACRO(__S) \
: (fgetc)(__S)); \
}) )
# undef __GETC
-# define __GETC(__stream) __FGETC((__stream))
+# define __GETC(__stream) __FGETC((__stream))
-# else
+# else
# undef __FGETC
# define __FGETC(__stream) __FGETC_UNLOCKED((__stream))
# undef __GETC
-# define __GETC(__stream) __FGETC_UNLOCKED((__stream))
+# define __GETC(__stream) __FGETC_UNLOCKED((__stream))
# endif
# endif
@@ -518,16 +506,16 @@ extern FILE *__stdin; /* For getchar() macro. */
extern FILE *__stdout; /* For putchar() macro. */
# undef __PUTC_UNLOCKED_MACRO
-# define __PUTC_UNLOCKED_MACRO(__c, __stream) \
+# define __PUTC_UNLOCKED_MACRO(__c, __stream) \
( ((__stream)->__bufpos < (__stream)->__bufputc_u) \
- ? (*(__stream)->__bufpos++) = (__c) \
+ ? (*(__stream)->__bufpos++) = (__c) \
: __fputc_unlocked((__c),(__stream)) )
# if 0
/* Classic macro approach. putc{_unlocked} can have side effects.*/
# undef __PUTC_UNLOCKED
-# define __PUTC_UNLOCKED(__c, __stream) \
- __PUTC_UNLOCKED_MACRO((__c), (__stream))
+# define __PUTC_UNLOCKED(__c, __stream) \
+ __PUTC_UNLOCKED_MACRO((__c), (__stream))
# ifndef __UCLIBC_HAS_THREADS__
# undef __PUTC
# define __PUTC(__c, __stream) __PUTC_UNLOCKED_MACRO((__c), (__stream))
@@ -537,10 +525,10 @@ extern FILE *__stdout; /* For putchar() macro. */
/* Using gcc extension for safety and additional inlining. */
# undef __FPUTC_UNLOCKED
-# define __FPUTC_UNLOCKED(__c, __stream) \
- (__extension__ ({ \
+# define __FPUTC_UNLOCKED(__c, __stream) \
+ (__extension__ ({ \
FILE *__S = (__stream); \
- __PUTC_UNLOCKED_MACRO((__c),__S); \
+ __PUTC_UNLOCKED_MACRO((__c),__S); \
}) )
# undef __PUTC_UNLOCKED
@@ -548,11 +536,11 @@ extern FILE *__stdout; /* For putchar() macro. */
# ifdef __UCLIBC_HAS_THREADS__
# undef __FPUTC
-# define __FPUTC(__c, __stream) \
- (__extension__ ({ \
+# define __FPUTC(__c, __stream) \
+ (__extension__ ({ \
FILE *__S = (__stream); \
((__S->__user_locking) \
- ? __PUTC_UNLOCKED_MACRO((__c),__S) \
+ ? __PUTC_UNLOCKED_MACRO((__c),__S) \
: (fputc)((__c),__S)); \
}) )
@@ -562,9 +550,9 @@ extern FILE *__stdout; /* For putchar() macro. */
# else
# undef __FPUTC
-# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
+# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
# undef __PUTC
-# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
+# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
# endif
# endif
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index 430759889..c02a25440 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -1,4 +1,3 @@
-/* vi: set sw=4 ts=4: */
/* Copyright (C) 1991, 93, 95, 96, 97, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -85,26 +84,6 @@ long int sysconf(int name)
__set_errno(EINVAL);
return -1;
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-# ifdef __NR_clock_getres
- case _SC_MONOTONIC_CLOCK:
- /* Check using the clock_getres system call. */
- {
- struct timespec ts;
- INTERNAL_SYSCALL_DECL (err);
- int r;
- r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
- return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION;
- }
-# endif
- case _SC_THREAD_CPUTIME:
-# ifdef _POSIX_THREAD_CPUTIME > 0
- return _POSIX_THREAD_CPUTIME;
-# else
- return -1;
-# endif
-#endif
-
case _SC_ARG_MAX:
#ifdef ARG_MAX
return ARG_MAX;
@@ -907,6 +886,34 @@ long int sysconf(int name)
#else
RETURN_NEG_1;
#endif
+
+#ifdef __NR_clock_getres
+ case _SC_MONOTONIC_CLOCK:
+ /* Check using the clock_getres system call. */
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ {
+ struct timespec ts;
+ INTERNAL_SYSCALL_DECL (err);
+ int r;
+ r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
+ return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION;
+ }
+# else
+ if (clock_getres(CLOCK_MONOTONIC, NULL) >= 0)
+ return _POSIX_VERSION;
+
+ RETURN_NEG_1;
+# endif
+#endif
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ case _SC_THREAD_CPUTIME:
+# ifdef _POSIX_THREAD_CPUTIME > 0
+ return _POSIX_THREAD_CPUTIME;
+# else
+ RETURN_NEG_1;
+# endif
+#endif
}
}
libc_hidden_def(sysconf)