diff options
186 files changed, 933 insertions, 1487 deletions
diff --git a/libc/Makefile b/libc/Makefile index ecbb4f79c..c8dc9b466 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -1,130 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. -# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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. - -#-------------------------------------------------------- -# -#There are a number of configurable options in "Config" -# -#-------------------------------------------------------- - -TOPDIR=../ -include $(TOPDIR)Rules.mak - -DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd - -# Check if the target architecture has a version script for -# libc, and if so, include it when linking. -VERSION_SCRIPT:=${shell if [ -f sysdeps/linux/$(TARGET_ARCH)/libc.map ] ; then \ - echo "--version-script sysdeps/linux/$(TARGET_ARCH)/libc.map"; fi} - -# we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak -LIB_NAME=libc -AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a -SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so -SO_FULL_NAME=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so - -ifeq ($(strip $(HAVE_SHARED)),y) -all: $(SO_LIB_NAME) -else -all: $(AR_LIB_NAME) -endif - -# Some functions are duplicated across subdirs, and when you pass $(AR) -# the same object file more than once, it'll add it to the archive multiple -# times (boo!). So what we do here is: -# - import all the objects (thus we may have dupes) -# - delete all the dupes -# - re-import certain objects based upon preference -# - the sysdeps dir should override all other symbols for example -# We need to use shell globbing with obj.* because if we use make's wildcard, -# the wildcard will be evaluated when `make` is run instead of when the make -# target is evaluated. That means if you run `rm obj.* ; make`, the wildcard -# will evaluate to no files :(. -shared_$(LIB_NAME).a: subdirs - $(RM) shared_$(LIB_NAME).a obj.pthread.* - objs=`cat obj.*` ; \ - $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs && \ - $(AR) dN 2 shared_$(LIB_NAME).a $$objs && \ - $(AR) dN 2 shared_$(LIB_NAME).a $$objs - @for objfile in obj.signal \ - obj.string.generic obj.string.$(TARGET_ARCH) obj.string \ - obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \ - if [ -e $$objfile ] ; then \ - if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \ - echo $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objfile ; \ - fi ; \ - objs=`cat $$objfile` ; \ - fi ; \ - $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs || exit 1 ; \ - done - -$(AR_LIB_NAME): shared_$(LIB_NAME).a - $(INSTALL) -d $(TOPDIR)lib - $(RM) $(AR_LIB_NAME) - cp shared_$(LIB_NAME).a $(AR_LIB_NAME) - $(AR) $(ARFLAGS) $(AR_LIB_NAME) `cat nonshared_obj.*` -ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) - $(MAKE) -C $(TOPDIR)libpthread/nptl obj.pthread.ar - $(AR) $(ARFLAGS) $(AR_LIB_NAME) `cat obj.pthread.ar` -endif - -$(SO_LIB_NAME): $(AR_LIB_NAME) - $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) $(SO_LIB_NAME) -ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) - $(MAKE) -C $(TOPDIR)libpthread/nptl obj.pthread.so - $(AR) $(ARFLAGS) shared_$(LIB_NAME).a `cat obj.pthread.so` -endif - $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) \ - -o $(TOPDIR)lib/$(SO_FULL_NAME) --whole-archive shared_$(LIB_NAME).a \ - --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \ - -init __uClibc_init $(TOPDIR)lib/$(UCLIBC_LDSO) $(LDADD_LIBFLOAT) $(LIBGCC) - $(LN) -sf $(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) - $(RM) $(TOPDIR)lib/$(NONSHARED_LIBNAME) - $(AR) $(ARFLAGS) $(TOPDIR)lib/$(NONSHARED_LIBNAME) `cat nonshared_obj.*` - echo "/* GNU ld script" > $(SO_LIB_NAME) - echo " * Use the shared library, but some functions are only in" >> $(SO_LIB_NAME) - echo " * the static library, so try that secondarily. */" >> $(SO_LIB_NAME) - #OUT_FORMAT:=$(shell $(LD) --verbose | grep OUTPUT_FORMAT | awk -F '"' '{print $2}') - #echo "OUTPUT_FORMAT($(OUT_FORMAT))" >> $(SO_LIB_NAME) -ifeq ($(strip $(COMPAT_ATEXIT)),y) - echo "GROUP ( $(TOPDIR)lib/$(NONSHARED_LIBNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) )" >> $(SO_LIB_NAME) -else - echo "GROUP ( $(TOPDIR)lib/$(SHARED_MAJORNAME) $(TOPDIR)lib/$(NONSHARED_LIBNAME) )" >> $(SO_LIB_NAME) -endif - -tags: - ctags -R - -clean: subdirs_clean - $(RM) *.a obj.* nonshared_obj.* - -subdirs: $(patsubst %, _dir_%, $(DIRS)) -subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) - -$(patsubst %, _dir_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean -.PHONY: dummy subdirs +top_srcdir=../ +top_builddir=../ +include $(top_builddir)Rules.mak +all: libs +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/signal/Makefile b/libc/signal/Makefile index 2ce6216e9..11f362a5e 100644 --- a/libc/signal/Makefile +++ b/libc/signal/Makefile @@ -1,44 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../ -include $(TOPDIR)Rules.mak - -CSRC= allocrtsig.c killpg.c raise.c sigaction.c sigaddset.c sigandset.c \ - sigblock.c sigdelset.c sigempty.c sigfillset.c siggetmask.c sighold.c \ - sigignore.c sigintr.c sigisempty.c sigismem.c sigjmp.c signal.c \ - sigorset.c sigpause.c sigrelse.c sigset.c sigsetmask.c sigsetops.c \ - sysv_signal.c sigwait.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(COBJS) - -OBJ_LIST=../obj.signal - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, signal/%, $(OBJS)) > $(OBJ_LIST) - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/signal/sigaction.c b/libc/signal/sigaction.c index eedf98169..66ed7ad8c 100644 --- a/libc/signal/sigaction.c +++ b/libc/signal/sigaction.c @@ -45,7 +45,7 @@ __libc_sigaction (sig, act, oact) if (act) { kact.k_sa_handler = act->sa_handler; - memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); + __memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); kact.sa_flags = act->sa_flags; # ifdef HAVE_SA_RESTORER kact.sa_restorer = act->sa_restorer; @@ -60,7 +60,7 @@ __libc_sigaction (sig, act, oact) if (oact && result >= 0) { oact->sa_handler = koact.k_sa_handler; - memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask)); + __memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask)); oact->sa_flags = koact.sa_flags; # ifdef HAVE_SA_RESTORER oact->sa_restorer = koact.sa_restorer; diff --git a/libc/signal/sigblock.c b/libc/signal/sigblock.c index c02c234b6..70af609aa 100644 --- a/libc/signal/sigblock.c +++ b/libc/signal/sigblock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 94, 95, 96, 97, 98, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994-1998, 2001-2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,37 +19,20 @@ #include <errno.h> #include <signal.h> +#include "sigset-cvt-mask.h" + /* Block signals in MASK, returning the old mask. */ int __sigblock (int mask) { - register unsigned int sig; - sigset_t set, oset; - - if (__sigemptyset (&set) < 0) - return -1; - - if (sizeof (mask) == sizeof (set)) - *(int *) &set = mask; - else if (sizeof (unsigned long int) == sizeof (set)) - *(unsigned long int *) &set = (unsigned int) mask; - else - for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0) - return -1; - - if (sigprocmask (SIG_BLOCK, &set, &oset) < 0) - return -1; - - if (sizeof (mask) == sizeof (oset)) - mask = *(int *) &oset; - else if (sizeof (unsigned long int) == sizeof (oset)) - mask = *(unsigned long int*) &oset; - else - for (sig = 1, mask = 0; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if (__sigismember (&oset, sig)) - mask |= sigmask (sig); - - return mask; + sigset_t set, oset; + + if (sigset_set_old_mask (&set, mask) < 0) + return -1; + + if (__sigprocmask (SIG_BLOCK, &set, &oset) < 0) + return -1; + + return sigset_get_old_mask (&oset); } strong_alias (__sigblock, sigblock) diff --git a/libc/signal/sigempty.c b/libc/signal/sigempty.c index 75b5be420..777edbdd5 100644 --- a/libc/signal/sigempty.c +++ b/libc/signal/sigempty.c @@ -31,7 +31,7 @@ sigemptyset (set) return -1; } - memset (set, 0, sizeof (sigset_t)); + __memset (set, 0, sizeof (sigset_t)); return 0; } diff --git a/libc/signal/sigfillset.c b/libc/signal/sigfillset.c index 03361787e..f06334216 100644 --- a/libc/signal/sigfillset.c +++ b/libc/signal/sigfillset.c @@ -31,7 +31,7 @@ sigfillset (set) return -1; } - memset (set, 0xff, sizeof (sigset_t)); + __memset (set, 0xff, sizeof (sigset_t)); /* If the implementation uses a cancellation signal don't set the bit. */ #ifdef SIGCANCEL diff --git a/libc/signal/sighold.c b/libc/signal/sighold.c index 670a4872e..29b452f63 100644 --- a/libc/signal/sighold.c +++ b/libc/signal/sighold.c @@ -30,7 +30,7 @@ sighold (sig) sigset_t set; /* Retrieve current signal set. */ - if (sigprocmask (SIG_SETMASK, NULL, &set) < 0) + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) return -1; /* Add the specified signal. */ @@ -38,5 +38,5 @@ sighold (sig) return -1; /* Set the new mask. */ - return sigprocmask (SIG_SETMASK, &set, NULL); + return __sigprocmask (SIG_SETMASK, &set, NULL); } diff --git a/libc/signal/sigjmp.c b/libc/signal/sigjmp.c index 59fe6db7a..37f19595a 100644 --- a/libc/signal/sigjmp.c +++ b/libc/signal/sigjmp.c @@ -27,7 +27,7 @@ int __sigjmp_save (sigjmp_buf env, int savemask) { env[0].__mask_was_saved = (savemask && - sigprocmask (SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0); + __sigprocmask (SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0); return 0; } diff --git a/libc/signal/sigpause.c b/libc/signal/sigpause.c index dd05e6e0a..35d58c680 100644 --- a/libc/signal/sigpause.c +++ b/libc/signal/sigpause.c @@ -21,35 +21,24 @@ #include <signal.h> #include <stddef.h> /* For NULL. */ +#include "sigset-cvt-mask.h" + /* Set the mask of blocked signals to MASK, wait for a signal to arrive, and then restore the mask. */ int __sigpause (int sig_or_mask, int is_sig) { sigset_t set; - int sig; if (is_sig != 0) { /* The modern X/Open implementation is requested. */ - if (sigprocmask (0, NULL, &set) < 0 + if (__sigprocmask (0, NULL, &set) < 0 /* Yes, we call `sigdelset' and not `__sigdelset'. */ || sigdelset (&set, sig_or_mask) < 0) return -1; } - else - { - if (sigemptyset (&set) < 0) - return -1; - - if (sizeof (sig_or_mask) == sizeof (set)) - *(int *) &set = sig_or_mask; - else if (sizeof (unsigned long int) == sizeof (set)) - *(unsigned long int *) &set = (unsigned int) sig_or_mask; - else - for (sig = 1; sig < NSIG; ++sig) - if ((sig_or_mask & sigmask (sig)) && __sigaddset (&set, sig) < 0) - return -1; - } + else if (sigset_set_old_mask (&set, sig_or_mask) < 0) + return -1; return sigsuspend (&set); } diff --git a/libc/signal/sigrelse.c b/libc/signal/sigrelse.c index 091f97de5..5519480e1 100644 --- a/libc/signal/sigrelse.c +++ b/libc/signal/sigrelse.c @@ -30,7 +30,7 @@ sigrelse (sig) sigset_t set; /* Retrieve current signal set. */ - if (sigprocmask (SIG_SETMASK, NULL, &set) < 0) + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) return -1; /* Remove the specified signal. */ @@ -38,5 +38,5 @@ sigrelse (sig) return -1; /* Set the new mask. */ - return sigprocmask (SIG_SETMASK, &set, NULL); + return __sigprocmask (SIG_SETMASK, &set, NULL); } diff --git a/libc/signal/sigset.c b/libc/signal/sigset.c index 0ce411c8c..350e3cb2d 100644 --- a/libc/signal/sigset.c +++ b/libc/signal/sigset.c @@ -46,7 +46,7 @@ sigset (sig, disp) return SIG_ERR; /* Add the signal set to the current signal mask. */ - if (sigprocmask (SIG_BLOCK, &set, NULL) < 0) + if (__sigprocmask (SIG_BLOCK, &set, NULL) < 0) return SIG_ERR; return SIG_HOLD; @@ -76,7 +76,7 @@ sigset (sig, disp) return SIG_ERR; /* Remove the signal set from the current signal mask. */ - if (sigprocmask (SIG_UNBLOCK, &set, NULL) < 0) + if (__sigprocmask (SIG_UNBLOCK, &set, NULL) < 0) return SIG_ERR; return oact.sa_handler; diff --git a/libc/signal/sigsetmask.c b/libc/signal/sigsetmask.c index 4c7a43e5f..1c16d6411 100644 --- a/libc/signal/sigsetmask.c +++ b/libc/signal/sigsetmask.c @@ -19,35 +19,22 @@ #include <errno.h> #include <signal.h> +#include "sigset-cvt-mask.h" + /* Set the mask of blocked signals to MASK, returning the old mask. */ -int sigsetmask (int mask) +int +__sigsetmask (int mask) { - register unsigned int sig; - sigset_t set, oset; - - if (__sigemptyset (&set) < 0) - return -1; - - if (sizeof (mask) == sizeof (set)) - *(int *) &set = mask; - else if (sizeof (unsigned long int) == sizeof (set)) - *(unsigned long int *) &set = (unsigned int) mask; - else - for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0) - return -1; - - if (sigprocmask (SIG_SETMASK, &set, &oset) < 0) - return -1; - - if (sizeof (mask) == sizeof (oset)) - mask = *(int *) &oset; - else if (sizeof (unsigned long int) == sizeof (oset)) - mask = *(unsigned long int *) &oset; - else - for (sig = 1, mask = 0; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if (__sigismember (&oset, sig)) - mask |= sigmask (sig); - - return mask; + sigset_t set, oset; + + if (sigset_set_old_mask (&set, mask) < 0) + return -1; + + if (__sigprocmask (SIG_SETMASK, &set, &oset) < 0) + return -1; + + + return sigset_get_old_mask (&oset); } + +weak_alias (__sigsetmask, sigsetmask) diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile index cde1d17b3..11f362a5e 100644 --- a/libc/stdio/Makefile +++ b/libc/stdio/Makefile @@ -1,161 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. -# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org> -# Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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. - -TOPDIR=../../ -include $(TOPDIR)Rules.mak - -# Note: The *64.o objects are empty when compiled without large file support. - -# SUSv3 functions -CSRC = fclose.c fcloseall.c fdopen.c fgetpos.c fopen.c freopen.c \ - fseeko.c fsetpos.c ftello.c getdelim.c getline.c gets.c getw.c \ - perror.c puts.c putw.c remove.c rewind.c setbuf.c setbuffer.c \ - setlinebuf.c setvbuf.c ungetc.c \ - printf.c vprintf.c vsprintf.c fprintf.c snprintf.c dprintf.c \ - asprintf.c sprintf.c vasprintf.c vdprintf.c vsnprintf.c \ - tmpfile.c tmpnam.c tmpnam_r.c popen.c tempnam.c ctermid.c - -# getc -> alias for fgetc -# putc -> alias for fputc -# rename is a syscall - -# Implementation support functions -CSRC += _READ.c _WRITE.c _adjust_pos.c _fopen.c _fwrite.c \ - _rfill.c _stdio.c _trans2r.c _trans2w.c _wcommit.c \ - _cs_funcs.c _load_inttype.c _store_inttype.c _uintmaxtostr.c -ifeq ($(strip $(UCLIBC_HAS_FLOATS)),y) -CSRC += _fpmaxtostr.c -endif - -# stdio_ext.h functions -CSRC += __fbufsize.c __flbf.c __fpending.c __fpurge.c __freadable.c \ - __freading.c __fsetlocking.c __fwritable.c __fwriting.c _flushlbf.c - -# Other glibc extensions -ifeq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS)),y) -CSRC += fopencookie.c fmemopen.c open_memstream.c -endif - -# pthread functions -CSRC += flockfile.c ftrylockfile.c funlockfile.c - -# Functions with unlocked versions -CUSRC = clearerr.c feof.c ferror.c fflush.c fgetc.c fgets.c fileno.c \ - fputc.c fputs.c fread.c fwrite.c getchar.c putchar.c -# getc_unlocked -> alias for fgetc_unlocked -# putc_unlocked -> alias for fputc_unlocked - -# Largefile functions -CLOBJS = fgetpos64.o fopen64.o freopen64.o fseeko64.o fsetpos64.o ftello64.o -# tmpfile64.o - -# vfprintf and support functions -MSRC2= vfprintf.c -ifneq ($(USE_OLD_VFPRINTF),y) -MOBJ2= vfprintf.o \ - _ppfs_init.o _ppfs_prepargs.o _ppfs_setargs.o _ppfs_parsespec.o \ - register_printf_function.o parse_printf_format.o -else -MOBJ2= -CSRC += old_vfprintf.c -endif - -# vfscanf and support functions plus other *scanf funcs -MSRC3= scanf.c -MOBJ3= vfscanf.o __scan_cookie.o __psfs_parse_spec.o __psfs_do_numeric.o \ - scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o - -MWSRC= wstdio.c -MWOBJ= - -CWSRC = -ifeq ($(UCLIBC_HAS_WCHAR),y) -CWSRC += _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \ - fwide.c ungetwc.c -CUSRC += fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c -# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias) -# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias) -MOBJ2 += vfwprintf.o -MOBJ3 += wscanf.o swscanf.o fwscanf.o vwscanf.o vswscanf.o vfwscanf.o -endif - -CSRC += $(CUSRC) - -COBJS = $(patsubst %.c,%.o, $(CSRC)) -CUOBJS = $(patsubst %.c,%_unlocked.o, $(CUSRC)) -CWOBJS = $(patsubst %.c,%.o, $(CWSRC)) - -ifeq ($(strip $(UCLIBC_HAS_WCHAR)),y) -COBJS += $(CWOBJS) -endif - -OBJS = $(COBJS) $(CUOBJS) $(MOBJ2) $(MOBJ3) $(MWOBJ) - -ifeq ($(strip $(UCLIBC_HAS_LFS)),y) -OBJS += $(CLOBJS) -endif - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y) -CFLAGS += -D__USE_STDIO_FUTEXES__ -endif - -OBJ_LIST=../obj.stdio - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, stdio/%, $(OBJS)) > $(OBJ_LIST) - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ - -%_unlocked.o : %.c - $(CC) $(CFLAGS) -D__DO_UNLOCKED -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ - -%64.o : %.c - $(CC) $(CFLAGS) -D__DO_LARGEFILE -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ - -$(MOBJ2): $(MSRC2) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJ3): $(MSRC3) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MWOBJ): $(MWSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(OBJ): Makefile -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/stdio/Makefile.in b/libc/stdio/Makefile.in index dfdf4ff14..3a6f739b4 100644 --- a/libc/stdio/Makefile.in +++ b/libc/stdio/Makefile.in @@ -17,8 +17,9 @@ CSRC := \ asprintf.c sprintf.c vasprintf.c vdprintf.c vsnprintf.c \ tmpfile.c tmpnam.c tmpnam_r.c popen.c tempnam.c ctermid.c -# Note: The *64.o objects are empty when compiled without large file support +ifeq ($(UCLIBC_HAS_LFS),y) CSRC += fgetpos64.c fopen64.c freopen64.c fseeko64.c fsetpos64.c ftello64.c +endif # getc -> alias for fgetc # putc -> alias for fputc @@ -110,9 +111,9 @@ STDIO_MOBJ := $(STDIO_MOBJ1) $(STDIO_MOBJ2) STDIO_DEF := $(patsubst %,-DL_%,$(subst .o,,$(filter-out $(STDIO_MOBJ_NO_MULTI),$(notdir $(STDIO_MOBJ))))) -STDIO_OBJS := $(STDIO_OBJ) $(STDIO_MOBJ) $(STDIO_CUOBJ) $(STDIO_CLOBJ) +STDIO_OBJS := $(STDIO_OBJ) $(STDIO_MOBJ) $(STDIO_CUOBJ) -STDIO_NO_MULTI := $(STDIO_CUOBJ) $(STDIO_CLOBJ) +STDIO_NO_MULTI := $(STDIO_CUOBJ) # these need special handling or rewrite to support multi-build # CUOBJ diff --git a/libc/stdio/__fsetlocking.c b/libc/stdio/__fsetlocking.c index f49503207..77690e269 100644 --- a/libc/stdio/__fsetlocking.c +++ b/libc/stdio/__fsetlocking.c @@ -15,7 +15,7 @@ * glibc treats invalid locking_mode args as FSETLOCKING_INTERNAL. */ -int __fsetlocking(FILE *stream, int locking_mode) +int attribute_hidden __libc_fsetlocking(FILE *stream, int locking_mode) { #ifdef __UCLIBC_HAS_THREADS__ int current = 1 + (stream->__user_locking & 1); @@ -43,3 +43,5 @@ int __fsetlocking(FILE *stream, int locking_mode) return FSETLOCKING_INTERNAL; #endif } + +strong_alias(__libc_fsetlocking,__fsetlocking) diff --git a/libc/stdio/_cs_funcs.c b/libc/stdio/_cs_funcs.c index 9df93f227..3bec64c19 100644 --- a/libc/stdio/_cs_funcs.c +++ b/libc/stdio/_cs_funcs.c @@ -13,14 +13,14 @@ ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize) { - return read(*((int *) cookie), buf, bufsize); + return __read(*((int *) cookie), buf, bufsize); } /**********************************************************************/ ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize) { - return write(*((int *) cookie), (char *) buf, bufsize); + return __write(*((int *) cookie), (char *) buf, bufsize); } /**********************************************************************/ @@ -42,7 +42,7 @@ int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence int attribute_hidden _cs_close(void *cookie) { - return close(*((int *) cookie)); + return __close(*((int *) cookie)); } /**********************************************************************/ diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c index 508c36d1c..f4df3f2de 100644 --- a/libc/stdio/_fopen.c +++ b/libc/stdio/_fopen.c @@ -132,7 +132,7 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, & O_LARGEFILE) ); } else { __STDIO_WHEN_LFS( if (filedes < -1) open_mode |= O_LARGEFILE ); - if ((stream->__filedes = open(((const char *) fname_or_mode), + if ((stream->__filedes = __open(((const char *) fname_or_mode), open_mode, 0666)) < 0) { goto FREE_STREAM; } diff --git a/libc/stdio/_fpmaxtostr.c b/libc/stdio/_fpmaxtostr.c index 9ffa5493e..2024caca1 100644 --- a/libc/stdio/_fpmaxtostr.c +++ b/libc/stdio/_fpmaxtostr.c @@ -417,7 +417,7 @@ ssize_t attribute_hidden _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info if (mode == 'f') { round += exp; if (round < -1) { - memset(buf, '0', DECIMAL_DIG); /* OK, since 'f' -> decimal case. */ + __memset(buf, '0', DECIMAL_DIG); /* OK, since 'f' -> decimal case. */ exp = -1; round = -1; } diff --git a/libc/stdio/_fwrite.c b/libc/stdio/_fwrite.c index d9d0bc2a8..600b15e6d 100644 --- a/libc/stdio/_fwrite.c +++ b/libc/stdio/_fwrite.c @@ -5,6 +5,9 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define memrchr __memrchr +#define memchr __memchr + #include "_stdio.h" #ifdef __STDIO_BUFFERS @@ -32,7 +35,7 @@ size_t attribute_hidden __stdio_fwrite(const unsigned char * __restrict buffer, if (pending > bytes) { pending = bytes; } - memcpy(stream->__bufpos, buffer, pending); + __memcpy(stream->__bufpos, buffer, pending); stream->__bufpos += pending; __STDIO_STREAM_VALIDATE(stream); return bytes; @@ -40,7 +43,7 @@ size_t attribute_hidden __stdio_fwrite(const unsigned char * __restrict buffer, /* RETRY: */ if (bytes <= __STDIO_STREAM_BUFFER_WAVAIL(stream)) { - memcpy(stream->__bufpos, buffer, bytes); + __memcpy(stream->__bufpos, buffer, bytes); stream->__bufpos += bytes; if (__STDIO_STREAM_IS_LBF(stream) && memrchr(buffer, '\n', bytes) /* Search backwards. */ diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c index b21beb728..db4b48400 100644 --- a/libc/stdio/_stdio.c +++ b/libc/stdio/_stdio.c @@ -178,7 +178,7 @@ void __stdio_init_mutex(pthread_mutex_t *m) static const pthread_mutex_t __stdio_mutex_initializer = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; - memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer)); + __memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer)); } #endif diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h index e900edac6..fdab8b8dc 100644 --- a/libc/stdio/_stdio.h +++ b/libc/stdio/_stdio.h @@ -7,6 +7,7 @@ #define _GNU_SOURCE +#include <features.h> #include <assert.h> #include <errno.h> #include <fcntl.h> @@ -17,7 +18,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <features.h> #ifdef __UCLIBC_HAS_WCHAR__ #include <wchar.h> @@ -360,20 +360,20 @@ extern int __stdio_trans2w_o(FILE *__restrict stream, int oflag) attribute_hidde #endif /* __STDIO_BUFFERS */ /**********************************************************************/ -extern int __fputs_unlocked(const char *__restrict s, FILE *__restrict stream); +extern int __fputs_unlocked(const char *__restrict s, FILE *__restrict stream) attribute_hidden; extern int __putchar_unlocked(int c); extern size_t __fwrite_unlocked(const void *__restrict ptr, size_t size, - size_t nmemb, FILE *__restrict stream); + size_t nmemb, FILE *__restrict stream) attribute_hidden; extern size_t __fread_unlocked(void *__restrict ptr, size_t size, - size_t nmemb, FILE *__restrict stream); + size_t nmemb, FILE *__restrict stream) attribute_hidden; -extern int __fputc_unlocked(int c, FILE *stream); +extern int __libc_fputc_unlocked(int c, FILE *stream) attribute_hidden; -extern int __fflush_unlocked(FILE *stream); +extern int __fflush_unlocked(FILE *stream) attribute_hidden; extern int __stdio_adjust_position(FILE *__restrict stream, __offmax_t *pos) attribute_hidden; @@ -381,17 +381,19 @@ extern void __clearerr_unlocked(FILE *stream); extern int __feof_unlocked(FILE *stream); extern int __ferror_unlocked(FILE *stream); -extern int __fgetc_unlocked(FILE *stream); +extern int __libc_fgetc_unlocked(FILE *stream) attribute_hidden; extern char *__fgets_unlocked(char *__restrict s, int n, - FILE * __restrict stream); + FILE * __restrict stream) attribute_hidden; -extern int __fileno_unlocked(FILE *stream); +extern int __fileno_unlocked(FILE *stream) attribute_hidden; -extern int __getchar_unlocked(void); +extern int __getchar_unlocked(void) attribute_hidden; +extern int __fseek(FILE *stream, long int offset, int whence) attribute_hidden; +extern long int __ftell(FILE *stream) attribute_hidden; #ifdef __UCLIBC_HAS_LFS__ -extern int __fseeko64(FILE *stream, __off64_t offset, int whence); -extern __off64_t __ftello64(FILE *stream); +extern int __fseeko64(FILE *stream, __off64_t offset, int whence) attribute_hidden; +extern __off64_t __ftello64(FILE *stream) attribute_hidden; #endif #ifdef __STDIO_HAS_OPENLIST @@ -433,10 +435,10 @@ extern FILE *_stdio_fopen(intptr_t fname_or_mode, #ifdef __UCLIBC_HAS_WCHAR__ extern size_t _wstdio_fwrite(const wchar_t *__restrict ws, size_t n, - FILE *__restrict stream); + FILE *__restrict stream) attribute_hidden; -extern wint_t __fgetwc_unlocked(register FILE *stream); -extern wint_t __fputwc_unlocked(wchar_t wc, FILE *stream); +extern wint_t __fgetwc_unlocked(register FILE *stream) attribute_hidden; +extern wint_t __fputwc_unlocked(wchar_t wc, FILE *stream) attribute_hidden; #endif /**********************************************************************/ diff --git a/libc/stdio/_uintmaxtostr.c b/libc/stdio/_uintmaxtostr.c index 858a39118..847d23560 100644 --- a/libc/stdio/_uintmaxtostr.c +++ b/libc/stdio/_uintmaxtostr.c @@ -17,7 +17,7 @@ #define INTERNAL_DIV_MOD #endif -char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, +char attribute_hidden *__libc__uintmaxtostr(register char * __restrict bufend, uintmax_t uval, int base, __UIM_CASE alphacase) { int negative; @@ -61,7 +61,7 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, #ifndef __LOCALE_C_ONLY if (!grouping) { /* Finished a group. */ bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len; - memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, + __memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, __UCLIBC_CURLOCALE_DATA.thousands_sep_len); if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */ /* Note: g[1] == -1 means no further grouping. But since @@ -79,7 +79,7 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, #ifndef __LOCALE_C_ONLY if (unlikely(outdigit)) { bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]; - memcpy(bufend, + __memcpy(bufend, (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit], __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]); } else @@ -104,7 +104,7 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, #ifndef __LOCALE_C_ONLY if (!grouping) { /* Finished a group. */ bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len; - memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, + __memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, __UCLIBC_CURLOCALE_DATA.thousands_sep_len); if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */ /* Note: g[1] == -1 means no further grouping. But since @@ -131,7 +131,7 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, #ifndef __LOCALE_C_ONLY if (unlikely(outdigit)) { bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]; - memcpy(bufend, + __memcpy(bufend, (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit], __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]); } else @@ -149,3 +149,4 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, return bufend; } +strong_alias(__libc__uintmaxtostr,_uintmaxtostr) diff --git a/libc/stdio/_wfwrite.c b/libc/stdio/_wfwrite.c index 8f9469162..792cff604 100644 --- a/libc/stdio/_wfwrite.c +++ b/libc/stdio/_wfwrite.c @@ -5,6 +5,8 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define wmemcpy __wmemcpy + #include "_stdio.h" #include <wchar.h> @@ -16,10 +18,10 @@ #warning TODO: Fix prototype. #endif extern size_t __wcsnrtombs(char *__restrict dst, - const wchar_t **__restrict src, - size_t NWC, size_t len, mbstate_t *__restrict ps); + const wchar_t **__restrict src, + size_t NWC, size_t len, mbstate_t *__restrict ps) attribute_hidden; -size_t _wstdio_fwrite(const wchar_t *__restrict ws, size_t n, +size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n, register FILE *__restrict stream) { size_t r, count; diff --git a/libc/stdio/ctermid.c b/libc/stdio/ctermid.c index 118608780..11e43f336 100644 --- a/libc/stdio/ctermid.c +++ b/libc/stdio/ctermid.c @@ -21,6 +21,6 @@ char *ctermid(register char *s) return s; #else /* glibc always returns /dev/tty for linux. */ - return strcpy((s ? s : sbuf), "/dev/tty"); + return __strcpy((s ? s : sbuf), "/dev/tty"); #endif } diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c index fa50db15a..b4226d0f1 100644 --- a/libc/stdio/fflush.c +++ b/libc/stdio/fflush.c @@ -31,7 +31,7 @@ #endif -int __fflush_unlocked(register FILE *stream) +int attribute_hidden __fflush_unlocked(register FILE *stream) { #ifdef __STDIO_BUFFERS diff --git a/libc/stdio/fgetc.c b/libc/stdio/fgetc.c index c68c1fdb5..78fca8422 100644 --- a/libc/stdio/fgetc.c +++ b/libc/stdio/fgetc.c @@ -14,7 +14,7 @@ #ifdef __DO_UNLOCKED -int __fgetc_unlocked(FILE *stream) +int attribute_hidden __libc_fgetc_unlocked(FILE *stream) { __STDIO_STREAM_VALIDATE(stream); @@ -69,11 +69,12 @@ int __fgetc_unlocked(FILE *stream) return EOF; } -weak_alias(__fgetc_unlocked,fgetc_unlocked); -weak_alias(__fgetc_unlocked,getc_unlocked); +strong_alias(__libc_fgetc_unlocked,__fgetc_unlocked) +weak_alias(__fgetc_unlocked,fgetc_unlocked) +weak_alias(__fgetc_unlocked,getc_unlocked) #ifndef __UCLIBC_HAS_THREADS__ -weak_alias(__fgetc_unlocked,fgetc); -weak_alias(__fgetc_unlocked,getc); +weak_alias(__fgetc_unlocked,fgetc) +weak_alias(__fgetc_unlocked,getc) #endif #elif defined __UCLIBC_HAS_THREADS__ diff --git a/libc/stdio/fgetpos.c b/libc/stdio/fgetpos.c index 84cf0b98c..03c18ab93 100644 --- a/libc/stdio/fgetpos.c +++ b/libc/stdio/fgetpos.c @@ -7,6 +7,10 @@ #include "_stdio.h" +#ifndef __DO_LARGEFILE +#define FTELL __ftell +#endif + int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos) { #ifdef __STDIO_MBSTATE @@ -16,7 +20,7 @@ int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos) __STDIO_AUTO_THREADLOCK(stream); - if ((pos->__pos = ftell(stream)) >= 0) { + if ((pos->__pos = FTELL(stream)) >= 0) { __COPY_MBSTATE(&(pos->__mbstate), &(stream->__state)); pos->__mblen_pending = stream->__ungot_width[0]; retval = 0; @@ -28,7 +32,7 @@ int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos) #else - return ((pos->__pos = ftell(stream)) >= 0) ? 0 : -1; + return ((pos->__pos = FTELL(stream)) >= 0) ? 0 : -1; #endif } diff --git a/libc/stdio/fgetpos64.c b/libc/stdio/fgetpos64.c index d222a1a98..6f46746b1 100644 --- a/libc/stdio/fgetpos64.c +++ b/libc/stdio/fgetpos64.c @@ -1,16 +1,14 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define fgetpos fgetpos64 -# define fpos_t fpos64_t -# define ftell ftello64 -# include "fgetpos.c" -#endif +#define __DO_LARGEFILE +#define fgetpos fgetpos64 +#define fpos_t fpos64_t +#define FTELL __ftello64 +#include "fgetpos.c" diff --git a/libc/stdio/fgets.c b/libc/stdio/fgets.c index 4b32ad612..743a2ea54 100644 --- a/libc/stdio/fgets.c +++ b/libc/stdio/fgets.c @@ -5,11 +5,13 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define __fgetc_unlocked __libc_fgetc_unlocked + #include "_stdio.h" #ifdef __DO_UNLOCKED -char *__fgets_unlocked(char *__restrict s, int n, +char attribute_hidden *__fgets_unlocked(char *__restrict s, int n, register FILE * __restrict stream) { register char *p; diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c index a78f52212..cb200851b 100644 --- a/libc/stdio/fgetwc.c +++ b/libc/stdio/fgetwc.c @@ -5,6 +5,8 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define mbrtowc __mbrtowc + #include "_stdio.h" #ifdef __DO_UNLOCKED @@ -17,7 +19,7 @@ static void munge_stream(register FILE *stream, unsigned char *buf) __STDIO_STREAM_DISABLE_PUTC(stream); } -wint_t __fgetwc_unlocked(register FILE *stream) +wint_t attribute_hidden __fgetwc_unlocked(register FILE *stream) { wint_t wi; wchar_t wc[1]; diff --git a/libc/stdio/fgetws.c b/libc/stdio/fgetws.c index 16f8873b3..e31ea3c41 100644 --- a/libc/stdio/fgetws.c +++ b/libc/stdio/fgetws.c @@ -8,11 +8,11 @@ #include "_stdio.h" extern wchar_t *__fgetws_unlocked(wchar_t *__restrict ws, int n, - FILE *__restrict stream); + FILE *__restrict stream) attribute_hidden; #ifdef __DO_UNLOCKED -wchar_t *__fgetws_unlocked(wchar_t *__restrict ws, int n, +wchar_t attribute_hidden *__fgetws_unlocked(wchar_t *__restrict ws, int n, FILE *__restrict stream) { register wchar_t *p = ws; diff --git a/libc/stdio/fileno.c b/libc/stdio/fileno.c index 30ae90ad3..4ea21d748 100644 --- a/libc/stdio/fileno.c +++ b/libc/stdio/fileno.c @@ -9,7 +9,7 @@ #ifdef __DO_UNLOCKED -int __fileno_unlocked(register FILE *stream) +int attribute_hidden __fileno_unlocked(register FILE *stream) { __STDIO_STREAM_VALIDATE(stream); diff --git a/libc/stdio/fmemopen.c b/libc/stdio/fmemopen.c index ff03cb426..7febe1a6e 100644 --- a/libc/stdio/fmemopen.c +++ b/libc/stdio/fmemopen.c @@ -35,7 +35,7 @@ static ssize_t fmo_read(register void *cookie, char *buf, size_t bufsize) bufsize = count; } - memcpy(buf, COOKIE->buf + COOKIE->pos, bufsize); + __memcpy(buf, COOKIE->buf + COOKIE->pos, bufsize); COOKIE->pos += bufsize; return bufsize; @@ -62,7 +62,7 @@ static ssize_t fmo_write(register void *cookie, const char *buf, size_t bufsize) } } - memcpy(COOKIE->buf + COOKIE->pos, buf, bufsize); + __memcpy(COOKIE->buf + COOKIE->pos, buf, bufsize); COOKIE->pos += bufsize; if (COOKIE->pos > COOKIE->eof) { diff --git a/libc/stdio/fopen64.c b/libc/stdio/fopen64.c index 95cd7a02b..64ba30501 100644 --- a/libc/stdio/fopen64.c +++ b/libc/stdio/fopen64.c @@ -1,15 +1,13 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define fopen fopen64 -# define FILEDES_ARG (-2) -# include "fopen.c" -#endif +#define __DO_LARGEFILE +#define fopen fopen64 +#define FILEDES_ARG (-2) +#include "fopen.c" diff --git a/libc/stdio/fputc.c b/libc/stdio/fputc.c index ad3c95517..46ebb163c 100644 --- a/libc/stdio/fputc.c +++ b/libc/stdio/fputc.c @@ -14,7 +14,7 @@ #ifdef __DO_UNLOCKED -int __fputc_unlocked(int c, register FILE *stream) +int attribute_hidden __libc_fputc_unlocked(int c, register FILE *stream) { __STDIO_STREAM_VALIDATE(stream); @@ -69,11 +69,12 @@ int __fputc_unlocked(int c, register FILE *stream) return EOF; } -weak_alias(__fputc_unlocked,fputc_unlocked); -weak_alias(__fputc_unlocked,putc_unlocked); +strong_alias(__libc_fputc_unlocked,__fputc_unlocked) +weak_alias(__fputc_unlocked,fputc_unlocked) +weak_alias(__fputc_unlocked,putc_unlocked) #ifndef __UCLIBC_HAS_THREADS__ -weak_alias(__fputc_unlocked,fputc); -weak_alias(__fputc_unlocked,putc); +weak_alias(__fputc_unlocked,fputc) +weak_alias(__fputc_unlocked,putc) #endif #elif defined __UCLIBC_HAS_THREADS__ @@ -91,6 +92,6 @@ int fputc(int c, register FILE *stream) } } -weak_alias(fputc,putc); +weak_alias(fputc,putc) #endif diff --git a/libc/stdio/fputs.c b/libc/stdio/fputs.c index e4d10659f..211fc1018 100644 --- a/libc/stdio/fputs.c +++ b/libc/stdio/fputs.c @@ -14,10 +14,10 @@ #ifdef __DO_UNLOCKED -int __fputs_unlocked(register const char * __restrict s, +int attribute_hidden __fputs_unlocked(register const char * __restrict s, FILE * __restrict stream) { - size_t n = strlen(s); + size_t n = __strlen(s); return ((__fwrite_unlocked(s, 1, n, stream) == n) ? n : EOF); } diff --git a/libc/stdio/fputwc.c b/libc/stdio/fputwc.c index ef7a6d627..dbea948dc 100644 --- a/libc/stdio/fputwc.c +++ b/libc/stdio/fputwc.c @@ -9,7 +9,7 @@ #ifdef __DO_UNLOCKED -wint_t __fputwc_unlocked(wchar_t wc, FILE *stream) +wint_t attribute_hidden __fputwc_unlocked(wchar_t wc, FILE *stream) { return _wstdio_fwrite(&wc, 1, stream) ? wc : WEOF; } diff --git a/libc/stdio/fputws.c b/libc/stdio/fputws.c index f3270fde8..e83cc9fcb 100644 --- a/libc/stdio/fputws.c +++ b/libc/stdio/fputws.c @@ -5,14 +5,16 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define wcslen __wcslen + #include "_stdio.h" extern int __fputws_unlocked(const wchar_t *__restrict ws, - FILE *__restrict stream); + FILE *__restrict stream) attribute_hidden; #ifdef __DO_UNLOCKED -int __fputws_unlocked(const wchar_t *__restrict ws, +int attribute_hidden __fputws_unlocked(const wchar_t *__restrict ws, register FILE *__restrict stream) { size_t n = wcslen(ws); @@ -20,9 +22,9 @@ int __fputws_unlocked(const wchar_t *__restrict ws, return (_wstdio_fwrite(ws, n, stream) == n) ? 0 : -1; } -weak_alias(__fputws_unlocked,fputws_unlocked); +weak_alias(__fputws_unlocked,fputws_unlocked) #ifndef __UCLIBC_HAS_THREADS__ -weak_alias(__fputws_unlocked,fputws); +weak_alias(__fputws_unlocked,fputws) #endif #elif defined __UCLIBC_HAS_THREADS__ diff --git a/libc/stdio/fread.c b/libc/stdio/fread.c index 73414e26c..42a29b067 100644 --- a/libc/stdio/fread.c +++ b/libc/stdio/fread.c @@ -9,7 +9,7 @@ #ifdef __DO_UNLOCKED -size_t __fread_unlocked(void * __restrict ptr, size_t size, size_t nmemb, +size_t attribute_hidden __fread_unlocked(void * __restrict ptr, size_t size, size_t nmemb, FILE * __restrict stream) { __STDIO_STREAM_VALIDATE(stream); @@ -44,7 +44,7 @@ size_t __fread_unlocked(void * __restrict ptr, size_t size, size_t nmemb, if (avail > todo) { avail = todo; } - memcpy(buffer, stream->__bufpos, avail); + __memcpy(buffer, stream->__bufpos, avail); buffer += avail; stream->__bufpos += avail; if (!(todo -= avail)) { diff --git a/libc/stdio/freopen64.c b/libc/stdio/freopen64.c index bc278194d..e44c972f1 100644 --- a/libc/stdio/freopen64.c +++ b/libc/stdio/freopen64.c @@ -1,15 +1,13 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define freopen freopen64 -# define FILEDES_ARG (-2) -# include "freopen.c" -#endif +#define __DO_LARGEFILE +#define freopen freopen64 +#define FILEDES_ARG (-2) +#include "freopen.c" diff --git a/libc/stdio/fseeko.c b/libc/stdio/fseeko.c index 852557901..c795356e7 100644 --- a/libc/stdio/fseeko.c +++ b/libc/stdio/fseeko.c @@ -12,11 +12,11 @@ #endif #ifndef __DO_LARGEFILE -# define FSEEK fseek -# define OFFSET_TYPE long int +# define FSEEK __fseek +# define OFFSET_TYPE long int #endif -int FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence) +int attribute_hidden FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence) { #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE) @@ -74,7 +74,8 @@ int FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence) } #ifdef __DO_LARGEFILE -weak_alias(__fseeko64,fseeko64); +weak_alias(__fseeko64,fseeko64) #else -weak_alias(fseek,fseeko); +weak_alias(__fseek,fseek) +weak_alias(fseek,fseeko) #endif diff --git a/libc/stdio/fseeko64.c b/libc/stdio/fseeko64.c index 93768c528..5bc4ae34e 100644 --- a/libc/stdio/fseeko64.c +++ b/libc/stdio/fseeko64.c @@ -1,15 +1,13 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define FSEEK __fseeko64 -# define OFFSET_TYPE __off64_t -# include "fseeko.c" -#endif +#define __DO_LARGEFILE +#define FSEEK __fseeko64 +#define OFFSET_TYPE __off64_t +#include "fseeko.c" diff --git a/libc/stdio/fsetpos64.c b/libc/stdio/fsetpos64.c index faae7a5b0..92906e302 100644 --- a/libc/stdio/fsetpos64.c +++ b/libc/stdio/fsetpos64.c @@ -1,16 +1,14 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define fsetpos fsetpos64 -# define fpos_t fpos64_t -# define fseek fseeko64 -# include "fsetpos.c" -#endif +#define __DO_LARGEFILE +#define fsetpos fsetpos64 +#define fpos_t fpos64_t +#define fseek fseeko64 +#include "fsetpos.c" diff --git a/libc/stdio/ftello.c b/libc/stdio/ftello.c index a69ce23df..7f5c53126 100644 --- a/libc/stdio/ftello.c +++ b/libc/stdio/ftello.c @@ -8,11 +8,11 @@ #include "_stdio.h" #ifndef __DO_LARGEFILE -# define FTELL ftell -# define OFFSET_TYPE long int +# define FTELL __ftell +# define OFFSET_TYPE long int #endif -OFFSET_TYPE FTELL(register FILE *stream) +OFFSET_TYPE attribute_hidden FTELL(register FILE *stream) { #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE) @@ -47,7 +47,8 @@ OFFSET_TYPE FTELL(register FILE *stream) } #ifdef __DO_LARGEFILE -weak_alias(__ftello64,ftello64); +weak_alias(__ftello64,ftello64) #else -weak_alias(ftell,ftello); +weak_alias(__ftell,ftell) +weak_alias(ftell,ftello) #endif diff --git a/libc/stdio/ftello64.c b/libc/stdio/ftello64.c index f3b289eee..32a37d368 100644 --- a/libc/stdio/ftello64.c +++ b/libc/stdio/ftello64.c @@ -1,15 +1,13 @@ /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #include "_stdio.h" -#ifdef __UCLIBC_HAS_LFS__ -# define __DO_LARGEFILE -# define FTELL __ftello64 -# define OFFSET_TYPE __off64_t -# include "ftello.c" -#endif +#define __DO_LARGEFILE +#define FTELL __ftello64 +#define OFFSET_TYPE __off64_t +#include "ftello.c" diff --git a/libc/stdio/fwrite.c b/libc/stdio/fwrite.c index 7bb0a8022..50af8f7a5 100644 --- a/libc/stdio/fwrite.c +++ b/libc/stdio/fwrite.c @@ -9,7 +9,7 @@ #ifdef __DO_UNLOCKED -size_t __fwrite_unlocked(const void * __restrict ptr, size_t size, +size_t attribute_hidden __fwrite_unlocked(const void * __restrict ptr, size_t size, size_t nmemb, register FILE * __restrict stream) { __STDIO_STREAM_VALIDATE(stream); diff --git a/libc/stdio/getchar.c b/libc/stdio/getchar.c index 902cec16e..ec578919b 100644 --- a/libc/stdio/getchar.c +++ b/libc/stdio/getchar.c @@ -12,7 +12,7 @@ #ifdef __DO_UNLOCKED -int __getchar_unlocked(void) +int attribute_hidden __getchar_unlocked(void) { register FILE *stream = stdin; diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c index cf3cf4c10..f21b16062 100644 --- a/libc/stdio/getdelim.c +++ b/libc/stdio/getdelim.c @@ -20,7 +20,7 @@ #define GETDELIM_GROWBY 64 -ssize_t __getdelim(char **__restrict lineptr, size_t *__restrict n, +ssize_t attribute_hidden __libc_getdelim(char **__restrict lineptr, size_t *__restrict n, int delimiter, register FILE *__restrict stream) { register char *buf; @@ -74,4 +74,5 @@ ssize_t __getdelim(char **__restrict lineptr, size_t *__restrict n, return pos; } -weak_alias(__getdelim,getdelim); +strong_alias(__libc_getdelim,__getdelim) +weak_alias(__getdelim,getdelim) diff --git a/libc/stdio/getline.c b/libc/stdio/getline.c index 0708aedaa..7424dc024 100644 --- a/libc/stdio/getline.c +++ b/libc/stdio/getline.c @@ -5,6 +5,8 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define __getdelim __libc_getdelim + #include "_stdio.h" ssize_t getline(char **__restrict lineptr, size_t *__restrict n, diff --git a/libc/stdio/old_vfprintf.c b/libc/stdio/old_vfprintf.c index 8caa3d66d..abf535a16 100644 --- a/libc/stdio/old_vfprintf.c +++ b/libc/stdio/old_vfprintf.c @@ -127,6 +127,9 @@ /**************************************************************************/ +#define _uintmaxtostr __libc__uintmaxtostr +#define strnlen __strnlen + #define _ISOC99_SOURCE /* for ULLONG primarily... */ #define _GNU_SOURCE /* for strnlen */ #include "_stdio.h" @@ -188,7 +191,7 @@ static void _outnstr(FILE *stream, const unsigned char *s, size_t n) if (r > n) { r = n; } - memcpy(f->bufpos, s, r); + __memcpy(f->bufpos, s, r); f->bufpos += r; } } @@ -234,7 +237,7 @@ static void _charpad(FILE * __restrict stream, int padchar, size_t numpad) static void _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf) { if (type & 0x80) { /* Some type of padding needed. */ - int buflen = strlen((const char *) buf); + int buflen = __strlen((const char *) buf); if ((len -= buflen) > 0) { _charpad(fp, (type & 0x7f), len); } diff --git a/libc/stdio/open_memstream.c b/libc/stdio/open_memstream.c index 0e3df43d1..358486010 100644 --- a/libc/stdio/open_memstream.c +++ b/libc/stdio/open_memstream.c @@ -51,7 +51,7 @@ static ssize_t oms_write(register void *cookie, const char *buf, size_t bufsize) } } - memcpy(COOKIE->buf + COOKIE->pos, buf, bufsize); + __memcpy(COOKIE->buf + COOKIE->pos, buf, bufsize); COOKIE->pos += bufsize; if (COOKIE->pos > COOKIE->eof) { @@ -90,7 +90,7 @@ static int oms_seek(register void *cookie, __offmax_t *pos, int whence) if (buf) { *COOKIE->bufloc = COOKIE->buf = buf; COOKIE->len = leastlen; - memset(buf + COOKIE->eof, leastlen - COOKIE->eof, 0); /* 0-fill */ + __memset(buf + COOKIE->eof, leastlen - COOKIE->eof, 0); /* 0-fill */ } else { /* TODO: check glibc errno setting... */ return -1; @@ -100,7 +100,7 @@ static int oms_seek(register void *cookie, __offmax_t *pos, int whence) *pos = COOKIE->pos = --leastlen; if (leastlen > COOKIE->eof) { - memset(COOKIE->buf + COOKIE->eof, leastlen - COOKIE->eof, 0); + __memset(COOKIE->buf + COOKIE->eof, leastlen - COOKIE->eof, 0); *COOKIE->sizeloc = COOKIE->eof; } diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c index c7887ad41..6de09253c 100644 --- a/libc/stdio/popen.c +++ b/libc/stdio/popen.c @@ -84,23 +84,23 @@ FILE *popen(const char *command, const char *modes) parent_fd = pipe_fd[1-child_writing]; if (!(fp = fdopen(parent_fd, modes))) { - close(parent_fd); - close(child_fd); + __close(parent_fd); + __close(child_fd); goto FREE_PI; } VFORK_LOCK; if ((pid = vfork()) == 0) { /* Child of vfork... */ - close(parent_fd); + __close(parent_fd); if (child_fd != child_writing) { dup2(child_fd, child_writing); - close(child_fd); + __close(child_fd); } /* SUSv3 requires that any previously popen()'d streams in the * parent shall be closed in the child. */ for (po = popen_list ; po ; po = po->next) { - close(po->f->__filedes); + __close(po->f->__filedes); } execl("/bin/sh", "sh", "-c", command, (char *)0); @@ -113,7 +113,7 @@ FILE *popen(const char *command, const char *modes) /* We need to close the child filedes whether vfork failed or * it succeeded and we're in the parent. */ - close(child_fd); + __close(child_fd); if (pid > 0) { /* Parent of vfork... */ pi->pid = pid; diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c index a7d0eaf19..37ae243bf 100644 --- a/libc/stdio/puts.c +++ b/libc/stdio/puts.c @@ -5,6 +5,8 @@ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ +#define __fputc_unlocked __libc_fputc_unlocked + #include "_stdio.h" int puts(register const char * __restrict s) diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c index d99896893..1d6522417 100644 --- a/libc/stdio/scanf.c +++ b/libc/stdio/scanf.c @@ -43,6 +43,9 @@ * standards and from an official C standard defect report. */ +#define wcslen __wcslen +#define mbsrtowcs __mbsrtowcs +#define mbrtowc __mbrtowc #define _ISOC99_SOURCE /* for LLONG_MAX primarily... */ #define _GNU_SOURCE @@ -247,7 +250,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) f.__bufstart = f.__bufpos = (unsigned char *) ((void *) sp); f.__bufread = - f.__bufend = f.__bufstart + strlen(sp); + f.__bufend = f.__bufstart + __strlen(sp); __STDIO_STREAM_ENABLE_GETC(&f); __STDIO_STREAM_DISABLE_PUTC(&f); @@ -261,7 +264,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) __FILE_vsscanf f; f.bufpos = (unsigned char *) ((void *) sp); - f.bufread = f.bufpos + strlen(sp); + f.bufread = f.bufpos + __strlen(sp); /* __STDIO_STREAM_RESET_GCS(&f.f); */ #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ @@ -303,7 +306,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) FILE *f; int rv = EOF; - if ((f = fmemopen((char *)sp, strlen(sp), "r")) != NULL) { + if ((f = fmemopen((char *)sp, __strlen(sp), "r")) != NULL) { rv = vfscanf(f, fmt, ap); fclose(f); } @@ -1027,7 +1030,7 @@ static int sc_getc(register struct scan_cookie *sc) sc->fp->__modeflags |= __FLAG_EOF; return EOF; } - } else if ((wc = fgetwc_unlocked(sc->fp)) == WEOF) { + } else if ((wc = __fgetwc_unlocked(sc->fp)) == WEOF) { return EOF; } @@ -1073,7 +1076,7 @@ static int scan_getwc(register struct scan_cookie *sc) sc->ungot_flag |= 2; return -1; } - } else if ((wc = fgetwc_unlocked(sc->fp)) == WEOF) { + } else if ((wc = __fgetwc_unlocked(sc->fp)) == WEOF) { sc->ungot_flag |= 2; return -1; } @@ -1197,7 +1200,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) #if defined(NL_ARGMAX) && (NL_ARGMAX > 0) psfs.num_pos_args = -1; /* Must start at -1. */ /* Initialize positional arg ptrs to NULL. */ - memset(psfs.pos_args, 0, sizeof(psfs.pos_args)); + __memset(psfs.pos_args, 0, sizeof(psfs.pos_args)); #endif /* defined(NL_ARGMAX) && (NL_ARGMAX > 0) */ __STDIO_AUTO_THREADLOCK(fp); @@ -1429,7 +1432,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) ++fmt; invert = 1; } - memset(scanset, invert, sizeof(scanset)); + __memset(scanset, invert, sizeof(scanset)); invert = 1-invert; if (*fmt == ']') { @@ -1978,14 +1981,14 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) if ((psfs->conv_num > CONV_i) /* float conversion */ && (!pass || (i == nblk1)) /* possible last */ - && !memcmp(sc->thousands_sep, sc->fake_decpt, k) + && !__memcmp(sc->thousands_sep, sc->fake_decpt, k) /* and prefix matched, so could be decpt */ ) { __scan_getc(sc); p = sc->fake_decpt + k; do { if (!*++p) { - strcpy(b, sc->decpt); + __strcpy(b, sc->decpt); b += sc->decpt_len; goto GOT_DECPT; } @@ -2079,7 +2082,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) p = sc->fake_decpt; do { if (!*p) { - strcpy(b, sc->decpt); + __strcpy(b, sc->decpt); b += sc->decpt_len; break; } diff --git a/libc/stdio/tempnam.c b/libc/stdio/tempnam.c index a11f82b5d..d626dc0f8 100644 --- a/libc/stdio/tempnam.c +++ b/libc/stdio/tempnam.c @@ -38,6 +38,6 @@ tempnam (const char *dir, const char *pfx) if (__gen_tempname (buf, __GT_NOCREATE)) return NULL; - return strdup (buf); + return __strdup (buf); } diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c index 5484d5d6c..488ddd763 100644 --- a/libc/stdio/tmpfile.c +++ b/libc/stdio/tmpfile.c @@ -42,7 +42,7 @@ FILE * tmpfile (void) (void) remove (buf); if ((f = fdopen (fd, "w+b")) == NULL) - close (fd); + __close (fd); return f; } diff --git a/libc/stdio/tmpnam.c b/libc/stdio/tmpnam.c index 802c54498..df2399e66 100644 --- a/libc/stdio/tmpnam.c +++ b/libc/stdio/tmpnam.c @@ -41,7 +41,7 @@ char * tmpnam (char *s) return NULL; if (s == NULL) - return (char *) memcpy (tmpnam_buffer, tmpbuf, L_tmpnam); + return (char *) __memcpy (tmpnam_buffer, tmpbuf, L_tmpnam); return s; } diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c index 73bbe63d3..4675dacc2 100644 --- a/libc/stdio/vfprintf.c +++ b/libc/stdio/vfprintf.c @@ -88,6 +88,12 @@ * treats this as an error. */ +#define _uintmaxtostr __libc__uintmaxtostr +#define strnlen __strnlen +#define wcslen __wcslen +#define wcsnlen __wcsnlen +#define wcsrtombs __wcsrtombs +#define mbsrtowcs __mbsrtowcs #define _ISOC99_SOURCE /* for ULLONG primarily... */ #define _GNU_SOURCE @@ -502,7 +508,7 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0) int r; /* First, zero out everything... argnumber[], argtype[], argptr[] */ - memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */ + __memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */ #ifdef NL_ARGMAX --ppfs->maxposarg; /* set to -1 */ #endif /* NL_ARGMAX */ @@ -1108,7 +1114,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs) } else { #endif /* NL_ARGMAX */ ppfs->argnumber[2] = 1; - memcpy(ppfs->argtype, argtype + 2, ppfs->num_data_args * sizeof(int)); + __memcpy(ppfs->argtype, argtype + 2, ppfs->num_data_args * sizeof(int)); #ifdef NL_ARGMAX } @@ -1191,7 +1197,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad); #define VFPRINTF vfprintf #define FMT_TYPE char #define OUTNSTR _outnstr -#define STRLEN strlen +#define STRLEN __strlen #define _PPFS_init _ppfs_init #define OUTPUT(F,S) __fputs_unlocked(S,F) /* #define _outnstr(stream, string, len) __stdio_fwrite(string, len, stream) */ @@ -1205,7 +1211,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf size_t r = 0; if (type & 0x80) { /* Some type of padding needed. */ - int buflen = strlen((const char *) buf); + int buflen = __strlen((const char *) buf); if ((len -= buflen) > 0) { if ((r = _charpad(fp, (type & 0x7f), len)) != len) { return r; @@ -1275,7 +1281,7 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf) int i; if (type & 0x80) { /* Some type of padding needed */ - int buflen = strlen(s); + int buflen = __strlen(s); if ((len -= buflen) > 0) { if ((r = _charpad(fp, (type & 0x7f), len)) != len) { return r; @@ -1319,7 +1325,7 @@ static int _ppwfs_init(register ppfs_t *ppfs, const wchar_t *fmt0) int r; /* First, zero out everything... argnumber[], argtype[], argptr[] */ - memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */ + __memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */ #ifdef NL_ARGMAX --ppfs->maxposarg; /* set to -1 */ #endif /* NL_ARGMAX */ diff --git a/libc/string/Makefile b/libc/string/Makefile index 576f915af..11f362a5e 100644 --- a/libc/string/Makefile +++ b/libc/string/Makefile @@ -2,97 +2,12 @@ # # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# Licensed under the GNU Library General Public License version 2 or later. -# See the COPYING.LIB file in the toplevel for more information. - -TOPDIR=../../ -include $(TOPDIR)Rules.mak - -DIRS= - -ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y) -DIRS += generic -endif - -ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y) -ifeq ($(TARGET_ARCH),$(wildcard $(TARGET_ARCH))) -DIRS += $(TARGET_ARCH) -endif -endif - -ALL_SUBDIRS = generic arm frv i386 mips powerpc sh64 sparc x86_64 - -MSRC= wstring.c -MOBJ= basename.o bcopy.o bzero.o dirname.o ffs.o memccpy.o memchr.o memcmp.o \ - memcpy.o memmove.o mempcpy.o memrchr.o memset.o rawmemchr.o stpcpy.o \ - stpncpy.o strcasecmp.o strcasestr.o strcat.o strchrnul.o strchr.o \ - strcmp.o strcpy.o strcspn.o strdup.o strlen.o strncasecmp.o strncat.o \ - strncmp.o strncpy.o strndup.o strnlen.o strpbrk.o strrchr.o strsep.o \ - strspn.o strstr.o strtok.o strtok_r.o strerror.o __xpg_strerror_r.o \ - _string_syserrmsgs.o __glibc_strerror_r.o \ - _string_syssigmsgs.o sys_siglist.o strsignal.o psignal.o \ - __xpg_basename.o strlcat.o strlcpy.o sys_errlist.o memmem.o - -MOBJW= wcscasecmp.o wcscat.o wcschrnul.o wcschr.o wcscmp.o wcscpy.o wcscspn.o \ - wcsdup.o wcslen.o wcsncasecmp.o wcsncat.o wcsncmp.o wcsncpy.o \ - wcsnlen.o wcspbrk.o wcsrchr.o wcsspn.o wcsstr.o wcstok.o wmemchr.o \ - wmemcmp.o wmemcpy.o wmemmove.o wmempcpy.o wmemset.o wcpcpy.o wcpncpy.o \ - __wcslcpy.o \ - wcsxfrm.o strxfrm.o # wcscoll strcoll.o - -MOBJx= -MOBJWx= - -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJx += strcasecmp_l.o strncasecmp_l.o - MOBJWx += wcscasecmp_l.o wcsncasecmp_l.o wcsxfrm_l.o strxfrm_l.o -endif - -#ffsl ffsll - -OBJS=$(MOBJ) $(MOBJx) - -ifeq ($(UCLIBC_HAS_WCHAR),y) - OBJS += $(MOBJW) $(MOBJWx) -endif - -OBJ_LIST=../obj.string - -all: $(OBJ_LIST) subdirs - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, string/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJx): $(MSRC) - $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJW): $(MSRC) - $(CC) $(CFLAGS) -DWANT_WIDE -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJWx): $(MSRC) - $(CC) $(CFLAGS) -DWANT_WIDE -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -clean: subdirs_clean - $(RM) *.[oa] *~ core - -subdirs: $(patsubst %, _dir_%, $(DIRS)) -subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) - -$(patsubst %, _dir_%, $(DIRS)) : $(OBJS) - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# -.PHONY: dummy +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/string/arm/Makefile b/libc/string/arm/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/arm/Makefile +++ b/libc/string/arm/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/frv/Makefile b/libc/string/frv/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/frv/Makefile +++ b/libc/string/frv/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/generic/Makefile b/libc/string/generic/Makefile index fac678a59..4a8f4a072 100644 --- a/libc/string/generic/Makefile +++ b/libc/string/generic/Makefile @@ -1,46 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../../ -include $(TOPDIR)Rules.mak - -CSRC= memchr.c memcmp.c memcpy.c memmem.c memmove.c mempcpy.c memrchr.c \ - memset.c rawmemchr.c strcat.c strchr.c strchrnul.c strcmp.c strcpy.c \ - strcspn.c strlen.c strncat.c strncmp.c strncpy.c strnlen.c \ - strrchr.c strsep.c strspn.c strstr.c strtok_r.c - -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.string.generic - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, string/generic/%, $(OBJS)) > $(OBJ_LIST) - -# $(MOBJ): $(MSRC) -# $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o -# $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../../ +top_builddir=../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/string/generic/bp-checks.h b/libc/string/generic/bp-checks.h index efbb84716..08c70aa5d 100644 --- a/libc/string/generic/bp-checks.h +++ b/libc/string/generic/bp-checks.h @@ -92,7 +92,7 @@ extern void *__unbounded __ubp_memchr (const void *__unbounded, int, unsigned); cover a region of NBYTES. Such a vector occupies one byte per page of memory. */ # define CHECK_N_PAGES(ARG, NBYTES) \ - ({ int _page_size_ = sysconf (_SC_PAGE_SIZE); \ + ({ int _page_size_ = __sysconf (_SC_PAGE_SIZE); \ CHECK_N ((const char *) (ARG), \ ((NBYTES) + _page_size_ - 1) / _page_size_); }) diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c index 5f2c1e244..05d7de639 100644 --- a/libc/string/generic/memmem.c +++ b/libc/string/generic/memmem.c @@ -41,7 +41,7 @@ void attribute_hidden *__memmem (const void *haystack, size_t haystack_len, for (begin = (const char *) haystack; begin <= last_possible; ++begin) if (begin[0] == ((const char *) needle)[0] && - !memcmp ((const void *) &begin[1], + !__memcmp ((const void *) &begin[1], (const void *) ((const char *) needle + 1), needle_len - 1)) return (void *) begin; diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c index ddf7c8aa4..0e649a1a9 100644 --- a/libc/string/generic/memmove.c +++ b/libc/string/generic/memmove.c @@ -219,7 +219,7 @@ void attribute_hidden *__memmove (void *dest, const void *src, size_t len) { #if 1 #warning REMINDER: generic-opt memmove assumes memcpy does forward copying! - memcpy(dest, src, len); + __memcpy(dest, src, len); #else /* Copy from the beginning to the end. */ diff --git a/libc/string/generic/mempcpy.c b/libc/string/generic/mempcpy.c index cda156edf..f2c860107 100644 --- a/libc/string/generic/mempcpy.c +++ b/libc/string/generic/mempcpy.c @@ -11,8 +11,8 @@ void attribute_hidden *__mempcpy (void *dstpp, const void *srcpp, size_t len) { - memcpy(dstpp, srcpp, len); + __memcpy(dstpp, srcpp, len); return (void *)(((char *)dstpp) + len); } -strong_alias (__mempcpy, mempcpy) +strong_alias(__mempcpy,mempcpy) diff --git a/libc/string/generic/strcspn.c b/libc/string/generic/strcspn.c index c41132cf6..a10912e25 100644 --- a/libc/string/generic/strcspn.c +++ b/libc/string/generic/strcspn.c @@ -27,7 +27,7 @@ size_t attribute_hidden __strcspn (const char *s, const char *reject) size_t count = 0; while (*s != '\0') - if (strchr (reject, *s++) == NULL) + if (__strchr (reject, *s++) == NULL) ++count; else return count; diff --git a/libc/string/generic/strrchr.c b/libc/string/generic/strrchr.c index bde4d4da0..325be7d48 100644 --- a/libc/string/generic/strrchr.c +++ b/libc/string/generic/strrchr.c @@ -30,10 +30,10 @@ char attribute_hidden *__strrchr (const char *s, int c) /* Since strchr is fast, we use it rather than the obvious loop. */ if (c == '\0') - return strchr (s, '\0'); + return __strchr (s, '\0'); found = NULL; - while ((p = strchr (s, c)) != NULL) + while ((p = __strchr (s, c)) != NULL) { found = p; s = p + 1; diff --git a/libc/string/generic/strsep.c b/libc/string/generic/strsep.c index 77670607b..9515fa193 100644 --- a/libc/string/generic/strsep.c +++ b/libc/string/generic/strsep.c @@ -16,6 +16,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define strpbrk __strpbrk + #include <string.h> #undef strsep @@ -44,7 +46,7 @@ char attribute_hidden *__strsep (char **stringp, const char *delim) else if (*begin == '\0') end = NULL; else - end = strchr (begin + 1, ch); + end = __strchr (begin + 1, ch); } } else diff --git a/libc/string/generic/strtok_r.c b/libc/string/generic/strtok_r.c index 40d4e1a78..6daa68124 100644 --- a/libc/string/generic/strtok_r.c +++ b/libc/string/generic/strtok_r.c @@ -17,6 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define rawmemchr __rawmemchr +#define strspn __strspn +#define strpbrk __strpbrk + #define _GNU_SOURCE #include <string.h> diff --git a/libc/string/i386/Makefile b/libc/string/i386/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/i386/Makefile +++ b/libc/string/i386/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/mempcpy.c b/libc/string/mempcpy.c index 7fb1954cd..9f7fab351 100644 --- a/libc/string/mempcpy.c +++ b/libc/string/mempcpy.c @@ -9,6 +9,6 @@ #include "wstring.c" -strong_alias(__mempcpy, mempcpy) +strong_alias(__mempcpy,mempcpy) #undef L_mempcpy diff --git a/libc/string/mips/Makefile b/libc/string/mips/Makefile index a6d7d4a4b..ac0063770 100644 --- a/libc/string/mips/Makefile +++ b/libc/string/mips/Makefile @@ -1,38 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../../ -include $(TOPDIR)Rules.mak - -SSRC= memcpy.S memset.S -SOBJS=$(patsubst %.S,%.o, $(SSRC)) -OBJS=$(SOBJS) - -OBJ_LIST=../../obj.string.$(TARGET_ARCH) - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, string/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) - -$(SOBJS): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../../ +top_builddir=../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/string/mips/sysdep.h b/libc/string/mips/sysdep.h index 2c96ced0d..89674fef7 100644 --- a/libc/string/mips/sysdep.h +++ b/libc/string/mips/sysdep.h @@ -43,9 +43,9 @@ #endif #ifdef libc_hidden_builtin_def -#error WHOA!!! libc_hidden_builtin_def is defined +#error "WHOA!!! libc_hidden_builtin_def is defined" #else -#define libc_hidden_builtin_def(name) +#define libc_hidden_builtin_def(name) .global __ ## name ; __ ## name = name #endif #endif diff --git a/libc/string/powerpc/Makefile b/libc/string/powerpc/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/powerpc/Makefile +++ b/libc/string/powerpc/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/sh64/Makefile b/libc/string/sh64/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/sh64/Makefile +++ b/libc/string/sh64/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/sparc/Makefile b/libc/string/sparc/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/sparc/Makefile +++ b/libc/string/sparc/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/string/strdup.c b/libc/string/strdup.c index 19c2d6ad1..2bf2462fb 100644 --- a/libc/string/strdup.c +++ b/libc/string/strdup.c @@ -9,8 +9,8 @@ #undef Wstrlen #undef Wstrcpy -#define Wstrlen strlen -#define Wstrcpy strcpy +#define Wstrlen __strlen +#define Wstrcpy __strcpy #include "wstring.c" diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c index ac86cb168..3f92c034d 100644 --- a/libc/string/strtok_r.c +++ b/libc/string/strtok_r.c @@ -8,9 +8,9 @@ #define Wstrtok_r __strtok_r #undef Wstrspn -#define Wstrspn strspn +#define Wstrspn __strspn #undef Wstrpbrk -#define Wstrpbrk strpbrk +#define Wstrpbrk __strpbrk #include "wstring.c" diff --git a/libc/string/wcsdup.c b/libc/string/wcsdup.c index f1af0d683..25043ced1 100644 --- a/libc/string/wcsdup.c +++ b/libc/string/wcsdup.c @@ -10,8 +10,8 @@ #undef Wstrlen #undef Wstrcpy -#define Wstrlen wcslen -#define Wstrcpy wcscpy +#define Wstrlen __wcslen +#define Wstrcpy __wcscpy #include "wstring.c" diff --git a/libc/string/wcstok.c b/libc/string/wcstok.c index 2afbd9f22..625ee65e8 100644 --- a/libc/string/wcstok.c +++ b/libc/string/wcstok.c @@ -9,9 +9,9 @@ #define Wstrtok_r __wcstok #undef Wstrspn -#define Wstrspn wcsspn +#define Wstrspn __wcsspn #undef Wstrpbrk -#define Wstrpbrk wcspbrk +#define Wstrpbrk __wcspbrk #include "wstring.c" diff --git a/libc/string/wstring.c b/libc/string/wstring.c index 797329a89..826c4b8ce 100644 --- a/libc/string/wstring.c +++ b/libc/string/wstring.c @@ -26,7 +26,10 @@ * mapping of signal strings (alpha, mips, hppa, sparc). */ +#define _uintmaxtostr __libc__uintmaxtostr + #define _GNU_SOURCE +#include <features.h> #include <string.h> #include <strings.h> #include <stdio.h> @@ -59,6 +62,21 @@ typedef unsigned char __string_uchar_t; #endif + +extern size_t __strnlen (__const char *__string, size_t __maxlen) attribute_hidden; +extern char *__strpbrk (__const char *__s, __const char *__accept) attribute_hidden; +extern size_t __strspn (__const char *__s, __const char *__accept) attribute_hidden; +extern char *__strsignal (int __sig) attribute_hidden; + +#ifdef WANT_WIDE +extern wchar_t *__wcsdup (__const wchar_t *__s) attribute_hidden; +extern size_t __wcslen (__const wchar_t *__s) attribute_hidden; +extern wchar_t *__wcscpy (wchar_t *__restrict __dest, + __const wchar_t *__restrict __src) attribute_hidden; +extern size_t __wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept) attribute_hidden; +extern wchar_t *__wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept) attribute_hidden; +#endif + /**********************************************************************/ /* NOTE: If we ever do internationalized syserr messages, this will * have to be changed! */ @@ -1649,20 +1667,20 @@ int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen) #endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */ s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown); - memcpy(s, unknown, sizeof(unknown)); + __memcpy(s, unknown, sizeof(unknown)); GOT_MESG: if (!strerrbuf) { /* SUSv3 */ buflen = 0; } - i = strlen(s) + 1; + i = __strlen(s) + 1; if (i > buflen) { i = buflen; retval = ERANGE; } if (i) { - memcpy(strerrbuf, s, i); + __memcpy(strerrbuf, s, i); strerrbuf[i-1] = 0; /* In case buf was too small. */ } @@ -1685,7 +1703,7 @@ int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen) }; s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown); - memcpy(s, unknown, sizeof(unknown)); + __memcpy(s, unknown, sizeof(unknown)); if (!strerrbuf) { /* SUSv3 */ buflen = 0; @@ -1701,7 +1719,7 @@ int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen) } if (i) { - memcpy(strerrbuf, s, i); + __memcpy(strerrbuf, s, i); strerrbuf[i-1] = 0; /* In case buf was too small. */ } @@ -1914,7 +1932,7 @@ Wchar attribute_hidden *Wstpncpy(register Wchar * __restrict s1, void attribute_hidden __bzero(void *s, size_t n) { #if 1 - (void)memset(s, 0, n); + (void)__memset(s, 0, n); #else register unsigned char *p = s; #ifdef __BCC__ @@ -1945,7 +1963,7 @@ strong_alias(__bzero, bzero) void attribute_hidden __bcopy(const void *s2, void *s1, size_t n) { #if 1 - memmove(s1, s2, n); + __memmove(s1, s2, n); #else #ifdef __BCC__ register char *s; @@ -1985,7 +2003,7 @@ void attribute_hidden __bcopy(const void *s2, void *s1, size_t n) #endif } -strong_alias(__bcopy, bcopy) +//strong_alias(__bcopy, bcopy) #endif /**********************************************************************/ @@ -2043,10 +2061,10 @@ char attribute_hidden *__strndup(register const char *s1, size_t n) { register char *s; - n = strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */ + n = __strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */ if ((s = malloc(n + 1)) != NULL) { - memcpy(s, s1, n); + __memcpy(s, s1, n); s[n] = 0; } @@ -2067,7 +2085,7 @@ char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s #if 1 p = NULL; - if (s && *s && (p = strpbrk(s, s2))) { + if (s && *s && (p = __strpbrk(s, s2))) { *p++ = 0; } #else @@ -2504,7 +2522,7 @@ char attribute_hidden *__strsignal(int signum) } s = _int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown); - memcpy(s, unknown, sizeof(unknown)); + __memcpy(s, unknown, sizeof(unknown)); DONE: return s; @@ -2519,7 +2537,7 @@ char attribute_hidden *__strsignal(int signum) 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ' }; - return (char *) memcpy(_int10tostr(buf+sizeof(buf)-1, signum) + return (char *) __memcpy(_int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown), unknown, sizeof(unknown)); } @@ -2547,7 +2565,7 @@ void psignal(int signum, register const char *message) message = (sep += 2); /* or passed an empty string. */ } - fprintf(stderr, "%s%s%s\n", message, sep, strsignal(signum)); + fprintf(stderr, "%s%s%s\n", message, sep, __strsignal(signum)); } #endif @@ -2674,7 +2692,7 @@ static int lookup(wchar_t wc __LOCALE_PARAM ) static void init_col_state(col_state_t *cs, const Wchar *wcs) { - memset(cs, 0, sizeof(col_state_t)); + __memset(cs, 0, sizeof(col_state_t)); cs->s = wcs; cs->bp = cs->back_buf = cs->ibb; cs->bb_size = 128; @@ -2906,7 +2924,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM ) cs->weight = 0; return; } - memcpy(cs->bp, cs->back_buf, cs->bb_size); + __memcpy(cs->bp, cs->back_buf, cs->bb_size); } else { cs->bp = realloc(cs->back_buf, cs->bb_size + 128); @@ -3040,7 +3058,7 @@ int __XL(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM ) #ifdef WANT_WIDE return wcscmp(s0, s1); #else /* WANT_WIDE */ - return strcmp(s0, s1); + return __strcmp(s0, s1); #endif /* WANT_WIDE */ } diff --git a/libc/string/x86_64/Makefile b/libc/string/x86_64/Makefile index a7cbf6fa1..ac0063770 100644 --- a/libc/string/x86_64/Makefile +++ b/libc/string/x86_64/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../ top_builddir=../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/Makefile b/libc/sysdeps/Makefile index f0d2ebd72..11f362a5e 100644 --- a/libc/sysdeps/Makefile +++ b/libc/sysdeps/Makefile @@ -1,37 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -DIRS = linux - -all: subdirs - -tags: - ctags -R - -clean: subdirs_clean - -subdirs: $(patsubst %, _dir_%, $(DIRS)) -subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) - -$(patsubst %, _dir_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean -.PHONY: dummy +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/Makefile b/libc/sysdeps/linux/Makefile index 0e891d193..4a8f4a072 100644 --- a/libc/sysdeps/linux/Makefile +++ b/libc/sysdeps/linux/Makefile @@ -1,42 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../../ -include $(TOPDIR)Rules.mak - -ALL_SUBDIRS = arm common cris h8300 i386 m68k mips nios nios2 powerpc sh sh64 sparc v850 - -all: common $(TARGET_ARCH) - -tags: - ctags -R - -common: dummy - $(MAKE) -C common - -$(TARGET_ARCH): common - $(MAKE) -C $(TARGET_ARCH) - -clean: subdirs_clean - -subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) - -$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean -.PHONY: dummy $(TARGET_ARCH) +top_srcdir=../../../ +top_builddir=../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/alpha/Makefile b/libc/sysdeps/linux/alpha/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/alpha/Makefile +++ b/libc/sysdeps/linux/alpha/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/arm/Makefile b/libc/sysdeps/linux/arm/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/arm/Makefile +++ b/libc/sysdeps/linux/arm/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/arm/bits/mman.h b/libc/sysdeps/linux/arm/bits/mman.h index 715e0f04c..596bd316c 100644 --- a/libc/sysdeps/linux/arm/bits/mman.h +++ b/libc/sysdeps/linux/arm/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/arm/ioperm.c b/libc/sysdeps/linux/arm/ioperm.c index 357d987f8..f887d54f1 100644 --- a/libc/sysdeps/linux/arm/ioperm.c +++ b/libc/sysdeps/linux/arm/ioperm.c @@ -157,7 +157,7 @@ init_iosys (void) /* translate systype name into i/o system: */ for (i = 0; i < sizeof (platform) / sizeof (platform[0]); ++i) { - if (strcmp (platform[i].name, systype) == 0) { + if (__strcmp (platform[i].name, systype) == 0) { io.shift = platform[i].shift; io.io_base = platform[i].io_base; io.initdone = 1; @@ -185,14 +185,14 @@ int ioperm (unsigned long int from, unsigned long int num, int turn_on) if (! io.base) { int fd; - fd = open ("/dev/mem", O_RDWR); + fd = __open ("/dev/mem", O_RDWR); if (fd < 0) return -1; io.base = (unsigned long int) mmap (0, MAX_PORT << io.shift, PROT_READ | PROT_WRITE, MAP_SHARED, fd, io.io_base); - close (fd); + __close (fd); if ((long) io.base == -1) return -1; } diff --git a/libc/sysdeps/linux/arm/sigaction.c b/libc/sysdeps/linux/arm/sigaction.c index 5fbb7fbf1..822fd0d97 100644 --- a/libc/sysdeps/linux/arm/sigaction.c +++ b/libc/sysdeps/linux/arm/sigaction.c @@ -58,7 +58,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa if (act) { kact.k_sa_handler = act->sa_handler; - memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); + __memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); kact.sa_flags = act->sa_flags; # ifdef HAVE_SA_RESTORER /* If the user specified SA_ONSTACK this means she is trying to @@ -83,7 +83,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa oact ? __ptrvalue (&koact) : NULL, _NSIG / 8); if (oact && result >= 0) { oact->sa_handler = koact.k_sa_handler; - memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t)); + __memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t)); oact->sa_flags = koact.sa_flags; # ifdef HAVE_SA_RESTORER oact->sa_restorer = koact.sa_restorer; diff --git a/libc/sysdeps/linux/bfin/bits/mman.h b/libc/sysdeps/linux/bfin/bits/mman.h index 0e0f8d113..d57eeb587 100644 --- a/libc/sysdeps/linux/bfin/bits/mman.h +++ b/libc/sysdeps/linux/bfin/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/common/__socketcall.c b/libc/sysdeps/linux/common/__socketcall.c index 8e9fbf7f3..48a083c3a 100644 --- a/libc/sysdeps/linux/common/__socketcall.c +++ b/libc/sysdeps/linux/common/__socketcall.c @@ -10,5 +10,5 @@ #include "syscalls.h" #ifdef __NR_socketcall #define __NR___socketcall __NR_socketcall -_syscall2(int, __socketcall, int, call, unsigned long *, args); +attribute_hidden _syscall2(int, __socketcall, int, call, unsigned long *, args); #endif diff --git a/libc/sysdeps/linux/common/bits/mman.h b/libc/sysdeps/linux/common/bits/mman.h index f567b9baa..0c1590270 100644 --- a/libc/sysdeps/linux/common/bits/mman.h +++ b/libc/sysdeps/linux/common/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for BSD-style memory management. - Copyright (C) 1994-1998,2000,01 Free Software Foundation, Inc. + Copyright (C) 1994-1998,2000,01,02,05 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 @@ -80,6 +80,16 @@ # define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ #endif +/* Flags to `msync'. */ +#define MS_ASYNC 1 /* Sync memory asynchronously. */ +#define MS_SYNC 0 /* Synchronous memory sync. */ +#define MS_INVALIDATE 2 /* Invalidate the caches. */ + +/* Flags for `mremap'. */ +#ifdef __USE_GNU +# define MREMAP_MAYMOVE 1 /* Mapping address may change. */ +# define MREMAP_FIXED 2 /* Fifth argument sets new address. */ +#endif /* Flags for `mlockall' (can be OR'd together). */ #define MCL_CURRENT 1 /* Lock all currently mapped pages. */ diff --git a/libc/sysdeps/linux/common/bits/utmp.h b/libc/sysdeps/linux/common/bits/utmp.h index 2ed29bbb4..e855ad73f 100644 --- a/libc/sysdeps/linux/common/bits/utmp.h +++ b/libc/sysdeps/linux/common/bits/utmp.h @@ -1,5 +1,6 @@ /* The `struct utmp' type, describing entries in the utmp file. GNU version. - Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +25,7 @@ #include <paths.h> #include <sys/time.h> #include <sys/types.h> +#include <bits/wordsize.h> #define UT_LINESIZE 32 @@ -35,7 +37,11 @@ previous logins. */ struct lastlog { +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + int32_t ll_time; +#else __time_t ll_time; +#endif char ll_line[UT_LINESIZE]; char ll_host[UT_HOSTSIZE]; }; @@ -61,8 +67,21 @@ struct utmp char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ struct exit_status ut_exit; /* Exit status of a process marked as DEAD_PROCESS. */ +/* The ut_session and ut_tv fields must be the same size when compiled + 32- and 64-bit. This allows data files and shared memory to be + shared between 32- and 64-bit applications. */ +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + int32_t ut_session; /* Session ID, used for windowing. */ + struct + { + int32_t tv_sec; /* Seconds. */ + int32_t tv_usec; /* Microseconds. */ + } ut_tv; /* Time entry was made. */ +#else long int ut_session; /* Session ID, used for windowing. */ struct timeval ut_tv; /* Time entry was made. */ +#endif + int32_t ut_addr_v6[4]; /* Internet address of remote host. */ char __unused[20]; /* Reserved for future use. */ }; diff --git a/libc/sysdeps/linux/common/bits/utmpx.h b/libc/sysdeps/linux/common/bits/utmpx.h index 99735370b..c84cda6fe 100644 --- a/libc/sysdeps/linux/common/bits/utmpx.h +++ b/libc/sysdeps/linux/common/bits/utmpx.h @@ -1,5 +1,5 @@ /* Structures and definitions for the user accounting database. GNU version. - Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,6 +23,7 @@ #include <bits/types.h> #include <sys/time.h> +#include <bits/wordsize.h> #ifdef __USE_GNU @@ -62,8 +63,21 @@ struct utmpx char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ struct __exit_status ut_exit; /* Exit status of a process marked as DEAD_PROCESS. */ + +/* The fields ut_session and ut_tv must be the same size when compiled + 32- and 64-bit. This allows files and shared memory to be shared + between 32- and 64-bit applications. */ +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + __int32_t ut_session; /* Session ID, used for windowing. */ + struct + { + __int32_t tv_sec; /* Seconds. */ + __int32_t tv_usec; /* Microseconds. */ + } ut_tv; /* Time entry was made. */ +#else long int ut_session; /* Session ID, used for windowing. */ struct timeval ut_tv; /* Time entry was made. */ +#endif __int32_t ut_addr_v6[4]; /* Internet address of remote host. */ char __unused[20]; /* Reserved for future use. */ }; diff --git a/libc/sysdeps/linux/common/clock_getres.c b/libc/sysdeps/linux/common/clock_getres.c index 0ae2bb07d..7aff495d0 100644 --- a/libc/sysdeps/linux/common/clock_getres.c +++ b/libc/sysdeps/linux/common/clock_getres.c @@ -19,6 +19,8 @@ * */ +#define sysconf __sysconf + #define _GNU_SOURCE #include "syscalls.h" #include <time.h> diff --git a/libc/sysdeps/linux/common/close.c b/libc/sysdeps/linux/common/close.c index 1e03b091e..2e9c2073d 100644 --- a/libc/sysdeps/linux/common/close.c +++ b/libc/sysdeps/linux/common/close.c @@ -10,6 +10,7 @@ #include "syscalls.h" #include <unistd.h> -#define __NR___libc_close __NR_close -_syscall1(int, __libc_close, int, fd); -weak_alias(__libc_close, close); +#define __NR___close __NR_close +attribute_hidden _syscall1(int, __close, int, fd); +strong_alias(__close,close) +weak_alias(__close,__libc_close) diff --git a/libc/sysdeps/linux/common/cmsg_nxthdr.c b/libc/sysdeps/linux/common/cmsg_nxthdr.c index 20c490dcc..cc17c28f5 100644 --- a/libc/sysdeps/linux/common/cmsg_nxthdr.c +++ b/libc/sysdeps/linux/common/cmsg_nxthdr.c @@ -22,8 +22,8 @@ #include <sys/socket.h> -struct cmsghdr * -__cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg) +struct cmsghdr attribute_hidden * +__libc_cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg) { if ((size_t) cmsg->cmsg_len < sizeof (struct cmsghdr)) /* The kernel header does this so there may be a reason. */ @@ -39,3 +39,4 @@ __cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg) return NULL; return cmsg; } +strong_alias(__libc_cmsg_nxthdr,__cmsg_nxthdr) diff --git a/libc/sysdeps/linux/common/creat64.c b/libc/sysdeps/linux/common/creat64.c index deeda3892..759f5bed8 100644 --- a/libc/sysdeps/linux/common/creat64.c +++ b/libc/sysdeps/linux/common/creat64.c @@ -16,6 +16,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define open64 __open64 + #include <features.h> #include <fcntl.h> #include <sys/types.h> diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c index 0c8f50999..a54f13be5 100644 --- a/libc/sysdeps/linux/common/create_module.c +++ b/libc/sysdeps/linux/common/create_module.c @@ -34,7 +34,7 @@ # ifdef __STR_NR_create_module # define __STR_NR___create_module __STR_NR_create_module # endif -_syscall2(long, __create_module, const char *, name, size_t, size); +static inline _syscall2(long, __create_module, const char *, name, size_t, size); /* By checking the value of errno, we know if we have been fooled * by the syscall2 macro making a very high address look like a * negative, so we we fix it up here. */ @@ -53,7 +53,7 @@ unsigned long create_module(const char *name, size_t size) # define __NR___create_module __NR_create_module /* Alpha doesn't have the same problem, exactly, but a bug in older kernels fails to clear the error flag. Clear it here explicitly. */ -_syscall4(unsigned long, __create_module, const char *, name, +static inline _syscall4(unsigned long, __create_module, const char *, name, size_t, size, size_t, dummy, size_t, err); unsigned long create_module(const char *name, size_t size) { diff --git a/libc/sysdeps/linux/common/dl-osinfo.h b/libc/sysdeps/linux/common/dl-osinfo.h index 4976b2b46..7998b08a4 100644 --- a/libc/sysdeps/linux/common/dl-osinfo.h +++ b/libc/sysdeps/linux/common/dl-osinfo.h @@ -10,35 +10,35 @@ #include <features.h> #ifdef __UCLIBC_HAS_SSP__ -#include <stdint.h> -#include <sys/time.h> +# if defined IS_IN_libc || defined IS_IN_rtld -#ifdef IS_IN_libc -#include <ssp-internal.h> -#if 0 -#ifndef __SSP_QUICK_CANARY__ -#define OPEN __libc_open -#define READ __libc_read -#define CLOSE __libc_close -#endif -#define GETTIMEOFDAY gettimeofday -#endif -#else -#ifdef __SSP__ -#error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector" -#endif -#ifndef __SSP_QUICK_CANARY__ -#define OPEN _dl_open -#define READ _dl_read -#define CLOSE _dl_close -#endif -#define GETTIMEOFDAY _dl_gettimeofday -#endif +# if defined __SSP__ || defined __SSP_ALL__ +# error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector" +# endif + +# include <stdint.h> +# include <sys/time.h> + +# ifdef IS_IN_libc +# ifndef __SSP_QUICK_CANARY__ +# define OPEN __open +# define READ __read +# define CLOSE __close +# endif +# define GETTIMEOFDAY gettimeofday +# else +# ifndef __SSP_QUICK_CANARY__ +# define OPEN _dl_open +# define READ _dl_read +# define CLOSE _dl_close +# endif +# define GETTIMEOFDAY _dl_gettimeofday +# endif static __always_inline uintptr_t _dl_setup_stack_chk_guard(void) { uintptr_t ret; -#ifndef __SSP_QUICK_CANARY__ +# ifndef __SSP_QUICK_CANARY__ { int fd = OPEN("/dev/urandom", O_RDONLY, 0); if (fd >= 0) { @@ -48,7 +48,7 @@ static __always_inline uintptr_t _dl_setup_stack_chk_guard(void) return ret; } } -#endif /* !__SSP_QUICK_CANARY__ */ +# endif /* !__SSP_QUICK_CANARY__ */ /* Start with the "terminator canary". */ ret = 0xFF0A0D00UL; @@ -62,6 +62,7 @@ static __always_inline uintptr_t _dl_setup_stack_chk_guard(void) } return ret; } +# endif /* libc || rtld */ #endif /* __UCLIBC_HAS_SSP__ */ #endif /* _DL_OSINFO_H */ diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index c6a2fc005..d007993eb 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -47,13 +47,13 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path slow_search = 1; #endif - slen = strlen(path_buf); + slen = __strlen(path_buf); ptr = path_buf + slen - 1; if (*ptr != '/') { if (slen + 2 > path_size) { goto oops; } - strcpy(++ptr, "/"); + __strcpy(++ptr, "/"); slen++; } slen++; @@ -67,10 +67,10 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path #ifdef FAST_DIR_SEARCH_POSSIBLE if (slow_search || this_ino == d->d_ino) { #endif - if (slen + strlen(d->d_name) > path_size) { + if (slen + __strlen(d->d_name) > path_size) { goto oops; } - strcpy(ptr + 1, d->d_name); + __strcpy(ptr + 1, d->d_name); if (stat(path_buf, &st) < 0) continue; if (st.st_ino == this_ino && st.st_dev == this_dev) { @@ -108,13 +108,13 @@ static char *recurser(char *path_buf, int path_size, dev_t root_dev, ino_t root_ if (path_size < 2) { goto oops; } - strcpy(path_buf, "/"); + __strcpy(path_buf, "/"); return path_buf; } - if (strlen(path_buf) + 4 > path_size) { + if (__strlen(path_buf) + 4 > path_size) { goto oops; } - strcat(path_buf, "/.."); + __strcat(path_buf, "/.."); if (recurser(path_buf, path_size, root_dev, root_ino) == 0) return 0; @@ -141,11 +141,11 @@ int __syscall_getcwd(char * buf, unsigned long size) return -1; } /* start with actual dir */ - if (buf) strncpy(buf, ".", size); + if (buf) __strncpy(buf, ".", size); cwd = recurser(buf, size, st.st_dev, st.st_ino); if (cwd) { - len = strlen(buf); + len = __strlen(buf); __set_errno(olderrno); } return len; diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c index 876420664..24ce2c8ba 100644 --- a/libc/sysdeps/linux/common/getdents.c +++ b/libc/sysdeps/linux/common/getdents.c @@ -28,7 +28,7 @@ #include <sys/types.h> #include <sys/syscall.h> - +#undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) struct kernel_dirent @@ -90,7 +90,7 @@ ssize_t attribute_hidden __getdents (int fd, char *buf, size_t nbytes) dp->d_off = kdp->d_off; dp->d_reclen = new_reclen; dp->d_type = DT_UNKNOWN; - memcpy (dp->d_name, kdp->d_name, + __memcpy (dp->d_name, kdp->d_name, kdp->d_reclen - offsetof (struct kernel_dirent, d_name)); dp = (struct dirent *) ((char *) dp + new_reclen); kdp = (struct kernel_dirent *) (((char *) kdp) + kdp->d_reclen); diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c index e45d9d364..a475c948a 100644 --- a/libc/sysdeps/linux/common/getdents64.c +++ b/libc/sysdeps/linux/common/getdents64.c @@ -31,7 +31,7 @@ #if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 - +#undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) struct kernel_dirent64 @@ -95,7 +95,7 @@ ssize_t attribute_hidden __getdents64 (int fd, char *buf, size_t nbytes) dp->d_off = kdp->d_off; dp->d_reclen = new_reclen; dp->d_type = DT_UNKNOWN; - memcpy (dp->d_name, kdp->d_name, + __memcpy (dp->d_name, kdp->d_name, kdp->d_reclen - offsetof (struct kernel_dirent64, d_name)); dp = (struct dirent64 *) ((char *) dp + new_reclen); kdp = (struct kernel_dirent64 *) (((char *) kdp) + kdp->d_reclen); diff --git a/libc/sysdeps/linux/common/getdirname.c b/libc/sysdeps/linux/common/getdirname.c index 4cc528fc7..d0865fba5 100644 --- a/libc/sysdeps/linux/common/getdirname.c +++ b/libc/sysdeps/linux/common/getdirname.c @@ -49,7 +49,7 @@ get_current_dir_name (void) && pwdstat.st_dev == dotstat.st_dev && pwdstat.st_ino == dotstat.st_ino) /* The PWD value is correct. Use it. */ - return strdup (pwd); + return __strdup (pwd); return getcwd ((char *) NULL, 0); } diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c index aa5a7d756..3c48b4ca0 100644 --- a/libc/sysdeps/linux/common/getdnnm.c +++ b/libc/sysdeps/linux/common/getdnnm.c @@ -18,10 +18,10 @@ getdomainname(char *name, size_t len) if (uname(&uts) == -1) return -1; - if (strlen(uts.domainname)+1 > len) { + if (__strlen(uts.domainname)+1 > len) { __set_errno(EINVAL); return -1; } - strcpy(name, uts.domainname); + __strcpy(name, uts.domainname); return 0; } diff --git a/libc/sysdeps/linux/common/getdtablesize.c b/libc/sysdeps/linux/common/getdtablesize.c index 016e6f62e..8cbcebdce 100644 --- a/libc/sysdeps/linux/common/getdtablesize.c +++ b/libc/sysdeps/linux/common/getdtablesize.c @@ -16,6 +16,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define getrlimit __getrlimit + #include <stdlib.h> #include <unistd.h> #include <sys/resource.h> diff --git a/libc/sysdeps/linux/common/getgroups.c b/libc/sysdeps/linux/common/getgroups.c index 17a7b51c7..402d87e66 100644 --- a/libc/sysdeps/linux/common/getgroups.c +++ b/libc/sysdeps/linux/common/getgroups.c @@ -7,6 +7,8 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define sysconf __sysconf + #include "syscalls.h" #include <unistd.h> diff --git a/libc/sysdeps/linux/common/gethstnm.c b/libc/sysdeps/linux/common/gethstnm.c index 0f7a04681..8a23e9516 100644 --- a/libc/sysdeps/linux/common/gethstnm.c +++ b/libc/sysdeps/linux/common/gethstnm.c @@ -15,10 +15,10 @@ gethostname(char *name, size_t len) if (uname(&uts) == -1) return -1; - if (strlen(uts.nodename)+1 > len) { + if (__strlen(uts.nodename)+1 > len) { __set_errno(EINVAL); return -1; } - strcpy(name, uts.nodename); + __strcpy(name, uts.nodename); return 0; } diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c index 0844d5b79..8469cbb76 100644 --- a/libc/sysdeps/linux/common/getpagesize.c +++ b/libc/sysdeps/linux/common/getpagesize.c @@ -22,7 +22,7 @@ extern size_t __pagesize; /* Return the system page size. */ -int __getpagesize(void) +int attribute_hidden __libc_getpagesize(void) { if (__pagesize != 0) return __pagesize; @@ -40,5 +40,6 @@ int __getpagesize(void) #endif /* NBPG. */ #endif /* EXEC_PAGESIZE. */ } -weak_alias(__getpagesize, getpagesize); +strong_alias(__libc_getpagesize, __getpagesize) +weak_alias(__getpagesize, getpagesize) diff --git a/libc/sysdeps/linux/common/getrlimit.c b/libc/sysdeps/linux/common/getrlimit.c index faeba92f4..fef907a03 100644 --- a/libc/sysdeps/linux/common/getrlimit.c +++ b/libc/sysdeps/linux/common/getrlimit.c @@ -13,9 +13,10 @@ #ifdef __NR_ugetrlimit #define __NR___ugetrlimit __NR_ugetrlimit +static inline _syscall2(int, __ugetrlimit, enum __rlimit_resource, resource, struct rlimit *, rlim); -int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) +int attribute_hidden __getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) { return (__ugetrlimit(resource, rlimits)); } @@ -23,15 +24,15 @@ int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) #else /* __NR_ugetrlimit */ /* Only include the old getrlimit if the new one (ugetrlimit) is not around */ -#define __NR___getrlimit __NR_getrlimit +#define __NR___syscall_getrlimit __NR_getrlimit static inline -_syscall2(int, __getrlimit, int, resource, struct rlimit *, rlim); +_syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim); -int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) +int attribute_hidden __getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) { int result; - result = __getrlimit(resource, rlimits); + result = __syscall_getrlimit(resource, rlimits); if (result == -1) return result; @@ -45,3 +46,5 @@ int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits) return result; } #endif + +strong_alias(__getrlimit,getrlimit) diff --git a/libc/sysdeps/linux/common/getrlimit64.c b/libc/sysdeps/linux/common/getrlimit64.c index 1af7870af..76c3196ad 100644 --- a/libc/sysdeps/linux/common/getrlimit64.c +++ b/libc/sysdeps/linux/common/getrlimit64.c @@ -16,6 +16,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define getrlimit __getrlimit + #include <features.h> #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64 diff --git a/libc/sysdeps/linux/common/longjmp.c b/libc/sysdeps/linux/common/longjmp.c index 1a4201922..5b4eff5f5 100644 --- a/libc/sysdeps/linux/common/longjmp.c +++ b/libc/sysdeps/linux/common/longjmp.c @@ -36,7 +36,7 @@ void __libc_longjmp (sigjmp_buf env, int val) if (env[0].__mask_was_saved) /* Restore the saved signal mask. */ - (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask, + (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask, (sigset_t *) NULL); /* Call the machine-dependent function to restore machine state. */ diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c index 332d6a402..90e990a4f 100644 --- a/libc/sysdeps/linux/common/open.c +++ b/libc/sysdeps/linux/common/open.c @@ -18,7 +18,7 @@ static inline _syscall3(int, __syscall_open, const char *, file, int, flags, __kernel_mode_t, mode); -int __libc_open(const char *file, int flags, ...) +int attribute_hidden __open(const char *file, int flags, ...) { /* gcc may warn about mode being uninitialized. * Just ignore that, since gcc is wrong. */ @@ -33,9 +33,10 @@ int __libc_open(const char *file, int flags, ...) } return __syscall_open(file, flags, mode); } -weak_alias(__libc_open, open); +strong_alias(__open,open) +weak_alias(__open,__libc_open) int creat(const char *file, mode_t mode) { - return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode); + return __open(file, O_WRONLY | O_CREAT | O_TRUNC, mode); } diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c index d9a27a7bc..c1cd47141 100644 --- a/libc/sysdeps/linux/common/open64.c +++ b/libc/sysdeps/linux/common/open64.c @@ -26,11 +26,9 @@ #endif #ifdef __UCLIBC_HAS_LFS__ -extern int __libc_open (__const char *file, int oflag, ...); - /* Open FILE with access OFLAG. If OFLAG includes O_CREAT, a third argument is the file protection. */ -int __libc_open64 (const char *file, int oflag, ...) +int attribute_hidden __open64 (const char *file, int oflag, ...) { int mode = 0; @@ -42,7 +40,8 @@ int __libc_open64 (const char *file, int oflag, ...) va_end (arg); } - return __libc_open(file, oflag | O_LARGEFILE, mode); + return __open(file, oflag | O_LARGEFILE, mode); } -weak_alias (__libc_open64, open64); +strong_alias(__open64,open64) +weak_alias(__open64,__libc_open64) #endif /* __UCLIBC_HAS_LFS__ */ diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c index 06c857c43..87d0dbb27 100644 --- a/libc/sysdeps/linux/common/poll.c +++ b/libc/sysdeps/linux/common/poll.c @@ -62,9 +62,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) /* We can't call FD_ZERO, since FD_ZERO only works with sets of exactly __FD_SETSIZE size. */ - memset (rset, 0, bytes); - memset (wset, 0, bytes); - memset (xset, 0, bytes); + __memset (rset, 0, bytes); + __memset (wset, 0, bytes); + __memset (xset, 0, bytes); for (f = fds; f < &fds[nfds]; ++f) { @@ -86,13 +86,13 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) nwset = alloca (nbytes); nxset = alloca (nbytes); - memset ((char *) nrset + bytes, 0, nbytes - bytes); - memset ((char *) nwset + bytes, 0, nbytes - bytes); - memset ((char *) nxset + bytes, 0, nbytes - bytes); + __memset ((char *) nrset + bytes, 0, nbytes - bytes); + __memset ((char *) nwset + bytes, 0, nbytes - bytes); + __memset ((char *) nxset + bytes, 0, nbytes - bytes); - rset = memcpy (nrset, rset, bytes); - wset = memcpy (nwset, wset, bytes); - xset = memcpy (nxset, xset, bytes); + rset = __memcpy (nrset, rset, bytes); + wset = __memcpy (nwset, wset, bytes); + xset = __memcpy (nxset, xset, bytes); bytes = nbytes; } @@ -126,9 +126,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) struct timeval sngl_tv; /* Clear the original set. */ - memset (rset, 0, bytes); - memset (wset, 0, bytes); - memset (xset, 0, bytes); + __memset (rset, 0, bytes); + __memset (wset, 0, bytes); + __memset (xset, 0, bytes); /* This means we don't wait for input. */ sngl_tv.tv_sec = 0; @@ -145,9 +145,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) { int n; - memset (sngl_rset, 0, bytes); - memset (sngl_wset, 0, bytes); - memset (sngl_xset, 0, bytes); + __memset (sngl_rset, 0, bytes); + __memset (sngl_wset, 0, bytes); + __memset (sngl_xset, 0, bytes); if (f->events & POLLIN) FD_SET (f->fd, sngl_rset); diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c index a1888134b..52fc35700 100644 --- a/libc/sysdeps/linux/common/posix_fadvise.c +++ b/libc/sysdeps/linux/common/posix_fadvise.c @@ -8,22 +8,20 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +/* need to hide the posix_fadvise64 prototype or the weak_alias() + * will fail when __NR_fadvise64_64 doesnt exist */ +#define posix_fadvise64 __hide_posix_fadvise64 #include "syscalls.h" #include <fcntl.h> +#undef posix_fadvise64 #ifdef __NR_fadvise64 -#define __NR___syscall_fadvise64 __NR_fadvise64 -_syscall4(int, __syscall_fadvise64, int, fd, off_t, offset, +#define __NR_posix_fadvise __NR_fadvise64 +_syscall4(int, posix_fadvise, int, fd, off_t, offset, off_t, len, int, advice); -int __libc_posix_fadvise(int fd, off_t offset, off_t len, int advice) -{ - return (__syscall_fadvise64(fd, offset, len, advice)); -} -weak_alias(__libc_posix_fadvise, posix_fadvise); -#if defined __UCLIBC_HAS_LFS__ && !defined __NR_fadvise64_64 && \ - !defined __USE_LARGEFILE64 -weak_alias(__libc_posix_fadvise, posix_fadvise64); +#if defined __UCLIBC_HAS_LFS__ && !defined __NR_fadvise64_64 +weak_alias(posix_fadvise, posix_fadvise64); #endif #else diff --git a/libc/sysdeps/linux/common/posix_fadvise64.c b/libc/sysdeps/linux/common/posix_fadvise64.c index a5dbe8de2..5c5cf9906 100644 --- a/libc/sysdeps/linux/common/posix_fadvise64.c +++ b/libc/sysdeps/linux/common/posix_fadvise64.c @@ -19,34 +19,30 @@ #ifdef __UCLIBC_HAS_LFS__ #ifdef __NR_fadvise64_64 -#define __NR___syscall_fadvise64_64 __NR_fadvise64_64 /* 64 bit implementation is cake ... or more like pie ... */ #if __WORDSIZE == 64 -_syscall4(int, __syscall_fadvise64_64, int, fd, __off64_t, offset, + +#define __NR_posix_fadvise64 __NR_fadvise64_64 +_syscall4(int, posix_fadvise64, int, fd, __off64_t, offset, __off64_t, len, int, advice); -int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) -{ - return (__syscall_fadvise64_64(fd, offset, len, advice)); -} -weak_alias(__libc_posix_fadvise64, posix_fadvise64); /* 32 bit implementation is kind of a pita */ #elif __WORDSIZE == 32 #ifdef _syscall6 /* workaround until everyone has _syscall6() */ -_syscall6(int, __syscall_fadvise64_64, int, fd, +#define __NR___syscall_fadvise64_64 __NR_fadvise64_64 +static inline _syscall6(int, __syscall_fadvise64_64, int, fd, unsigned long, high_offset, unsigned long, low_offset, unsigned long, high_len, unsigned long, low_len, int, advice); -int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) +int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) { return (__syscall_fadvise64_64(fd, __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff), __LONG_LONG_PAIR(len >> 32, len & 0xffffffff), advice)); } -weak_alias(__libc_posix_fadvise64, posix_fadvise64); #else #warning _syscall6 has not been defined for your machine :( #endif /* _syscall6 */ @@ -56,7 +52,7 @@ weak_alias(__libc_posix_fadvise64, posix_fadvise64); #endif #elif !defined __NR_fadvise64 -/* This is declared as a weak alias in posix_fadvice.c if __NR_fadvise64 +/* This is declared as a weak alias in posix_fadvise.c if __NR_fadvise64 * is defined. */ int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) diff --git a/libc/sysdeps/linux/common/read.c b/libc/sysdeps/linux/common/read.c index 9b9ea5bc9..6490bccbc 100644 --- a/libc/sysdeps/linux/common/read.c +++ b/libc/sysdeps/linux/common/read.c @@ -10,6 +10,7 @@ #include "syscalls.h" #include <unistd.h> -#define __NR___libc_read __NR_read -_syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count); -weak_alias(__libc_read, read); +#define __NR___read __NR_read +attribute_hidden _syscall3(ssize_t, __read, int, fd, __ptr_t, buf, size_t, count); +strong_alias(__read,read) +weak_alias(__read,__libc_read) diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c index 4b4a1ddec..d92840370 100644 --- a/libc/sysdeps/linux/common/setgroups.c +++ b/libc/sysdeps/linux/common/setgroups.c @@ -7,6 +7,8 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define sysconf __sysconf + #include "syscalls.h" #include <unistd.h> #include <grp.h> diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c index c7ebe6c98..9c5466a09 100644 --- a/libc/sysdeps/linux/common/setrlimit.c +++ b/libc/sysdeps/linux/common/setrlimit.c @@ -12,12 +12,13 @@ #ifndef __NR_ugetrlimit /* Only wrap setrlimit if the new ugetrlimit is not present */ -#define __NR___setrlimit __NR_setrlimit +#define __NR___syscall_setrlimit __NR_setrlimit #include <unistd.h> #include <sys/resource.h> #define RMIN(x, y) ((x) < (y) ? (x) : (y)) -_syscall2(int, __setrlimit, int, resource, const struct rlimit *, rlim); -int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits) +static inline +_syscall2(int, __syscall_setrlimit, int, resource, const struct rlimit *, rlim); +int attribute_hidden __setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits) { struct rlimit rlimits_small; @@ -27,7 +28,7 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits) RLIM_INFINITY >> 1); rlimits_small.rlim_max = RMIN((unsigned long int) rlimits->rlim_max, RLIM_INFINITY >> 1); - return (__setrlimit(resource, &rlimits_small)); + return (__syscall_setrlimit(resource, &rlimits_small)); } #undef RMIN @@ -36,6 +37,9 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits) #include <unistd.h> struct rlimit; -_syscall2(int, setrlimit, unsigned int, resource, +#define __NR___setrlimit __NR_setrlimit +attribute_hidden _syscall2(int, __setrlimit, unsigned int, resource, const struct rlimit *, rlim); #endif + +strong_alias(__setrlimit,setrlimit) diff --git a/libc/sysdeps/linux/common/setrlimit64.c b/libc/sysdeps/linux/common/setrlimit64.c index 8d190f573..d59057c90 100644 --- a/libc/sysdeps/linux/common/setrlimit64.c +++ b/libc/sysdeps/linux/common/setrlimit64.c @@ -16,6 +16,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define setrlimit __setrlimit #include <features.h> diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 43708fe61..4c52d070f 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -30,10 +30,10 @@ static __always_inline void block_signals(void) sigfillset(&mask); sigdelset(&mask, SSP_SIGTYPE); /* Block all signal handlers */ - SIGPROCMASK(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */ + __sigprocmask(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */ /* Make the default handler associated with the signal handler */ - memset(&sa, 0, sizeof(struct sigaction)); + __memset(&sa, 0, sizeof(struct sigaction)); sigfillset(&sa.sa_mask); /* Block all signals */ sa.sa_flags = 0; sa.sa_handler = SIG_DFL; @@ -42,10 +42,10 @@ static __always_inline void block_signals(void) static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) { - WRITE(fd, msg1, strlen(msg1)); - WRITE(fd, msg2, strlen(msg2)); - WRITE(fd, msg3, strlen(msg3)); - WRITE(fd, "()\n", 3); + __write(fd, msg1, __strlen(msg1)); + __write(fd, msg2, __strlen(msg2)); + __write(fd, msg3, __strlen(msg3)); + __write(fd, "()\n", 3); openlog("ssp", LOG_CONS | LOG_PID, LOG_USER); syslog(LOG_INFO, "%s%s%s()", msg1, msg2, msg3); closelog(); diff --git a/libc/sysdeps/linux/common/syscalls.h b/libc/sysdeps/linux/common/syscalls.h index b42f82100..743ac8a74 100644 --- a/libc/sysdeps/linux/common/syscalls.h +++ b/libc/sysdeps/linux/common/syscalls.h @@ -29,10 +29,8 @@ #include <endian.h> #undef __OPTIMIZE__ -/* - * We absolutely do _NOT_ want interfaces silently - * renamed under us or very bad things will happen... - */ +/* We absolutely do _NOT_ want interfaces silently + * * * renamed under us or very bad things will happen... */ #ifdef __USE_FILE_OFFSET64 # undef __USE_FILE_OFFSET64 #endif diff --git a/libc/sysdeps/linux/common/ulimit.c b/libc/sysdeps/linux/common/ulimit.c index 2394edaae..b8e09fc8f 100644 --- a/libc/sysdeps/linux/common/ulimit.c +++ b/libc/sysdeps/linux/common/ulimit.c @@ -18,6 +18,10 @@ * */ +#define sysconf __sysconf +#define getrlimit __getrlimit +#define setrlimit __setrlimit + #define _GNU_SOURCE #define _LARGEFILE64_SOURCE #include <features.h> diff --git a/libc/sysdeps/linux/common/write.c b/libc/sysdeps/linux/common/write.c index b7e34f81c..d3b5fab93 100644 --- a/libc/sysdeps/linux/common/write.c +++ b/libc/sysdeps/linux/common/write.c @@ -10,9 +10,12 @@ #include "syscalls.h" #include <unistd.h> -#define __NR___libc_write __NR_write -_syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count); -weak_alias(__libc_write, write); +#define __NR___write __NR_write +attribute_hidden _syscall3(ssize_t, __write, int, fd, const __ptr_t, buf, size_t, count); +strong_alias(__write,write) +weak_alias(__write,__libc_write) +#if 0 /* Stupid libgcc.a from gcc 2.95.x uses __write in pure.o * which is a blatent GNU libc-ism... */ weak_alias(__libc_write, __write); +#endif diff --git a/libc/sysdeps/linux/cris/Makefile b/libc/sysdeps/linux/cris/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/cris/Makefile +++ b/libc/sysdeps/linux/cris/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/cris/bits/mman.h b/libc/sysdeps/linux/cris/bits/mman.h index 16216855f..b1f22a1c4 100644 --- a/libc/sysdeps/linux/cris/bits/mman.h +++ b/libc/sysdeps/linux/cris/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/e1/bits/mman.h b/libc/sysdeps/linux/e1/bits/mman.h index 34f14ee5b..7f644b99b 100644 --- a/libc/sysdeps/linux/e1/bits/mman.h +++ b/libc/sysdeps/linux/e1/bits/mman.h @@ -72,4 +72,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/e1/longjmp.c b/libc/sysdeps/linux/e1/longjmp.c index 5770d4997..89d6b76d9 100644 --- a/libc/sysdeps/linux/e1/longjmp.c +++ b/libc/sysdeps/linux/e1/longjmp.c @@ -43,7 +43,7 @@ void longjmp(jmp_buf state, int value ) void siglongjmp(sigjmp_buf state, int value ) { if( state->__mask_was_saved ) - sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL); + __sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL); if(!value) state->__jmpbuf->ReturnValue = 1; diff --git a/libc/sysdeps/linux/e1/setjmp.c b/libc/sysdeps/linux/e1/setjmp.c index 2942cb193..502e89b22 100644 --- a/libc/sysdeps/linux/e1/setjmp.c +++ b/libc/sysdeps/linux/e1/setjmp.c @@ -32,7 +32,7 @@ int sigsetjmp( sigjmp_buf state , int savesigs) if(savesigs) { state->__mask_was_saved = 1; /* how arg in <sigprocmask> is not significant */ - sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask); + __sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask); } else state->__mask_was_saved = 0; diff --git a/libc/sysdeps/linux/frv/bits/mman.h b/libc/sysdeps/linux/frv/bits/mman.h index 9e87f804c..0802005f4 100644 --- a/libc/sysdeps/linux/frv/bits/mman.h +++ b/libc/sysdeps/linux/frv/bits/mman.h @@ -72,4 +72,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/h8300/bits/mman.h b/libc/sysdeps/linux/h8300/bits/mman.h index 34f14ee5b..7f644b99b 100644 --- a/libc/sysdeps/linux/h8300/bits/mman.h +++ b/libc/sysdeps/linux/h8300/bits/mman.h @@ -72,4 +72,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/hppa/Makefile b/libc/sysdeps/linux/hppa/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/hppa/Makefile +++ b/libc/sysdeps/linux/hppa/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/i386/Makefile +++ b/libc/sysdeps/linux/i386/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/i386/bits/mman.h b/libc/sysdeps/linux/i386/bits/mman.h index 0778afbb5..f7a855aba 100644 --- a/libc/sysdeps/linux/i386/bits/mman.h +++ b/libc/sysdeps/linux/i386/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c index 229a95ff5..0875796cf 100644 --- a/libc/sysdeps/linux/i386/sigaction.c +++ b/libc/sysdeps/linux/i386/sigaction.c @@ -29,9 +29,8 @@ #if defined __NR_rt_sigaction -#warning "Yes there are two warnings here. Don't worry about it." -static void restore_rt (void) asm ("__restore_rt"); -static void restore (void) asm ("__restore"); +extern void restore_rt (void) asm ("__restore_rt") attribute_hidden; +extern void restore (void) asm ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ @@ -49,7 +48,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa if (act) { kact.k_sa_handler = act->sa_handler; - memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); + __memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); kact.sa_flags = act->sa_flags; kact.sa_flags = act->sa_flags | SA_RESTORER; @@ -64,7 +63,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa if (oact && result >= 0) { oact->sa_handler = koact.k_sa_handler; - memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask)); + __memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask)); oact->sa_flags = koact.sa_flags; oact->sa_restorer = koact.sa_restorer; } @@ -73,8 +72,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa #else -#warning "Yes there is a warning here. Don't worry about it." -static void restore (void) asm ("__restore"); +extern void restore (void) asm ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ @@ -121,10 +119,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa } #endif - -#ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, sigaction) -#endif diff --git a/libc/sysdeps/linux/i960/bits/mman.h b/libc/sysdeps/linux/i960/bits/mman.h index 45663c963..48f46c274 100644 --- a/libc/sysdeps/linux/i960/bits/mman.h +++ b/libc/sysdeps/linux/i960/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/m68k/Makefile b/libc/sysdeps/linux/m68k/Makefile index 5173b2165..633c91f3e 100644 --- a/libc/sysdeps/linux/m68k/Makefile +++ b/libc/sysdeps/linux/m68k/Makefile @@ -1,89 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../../../ -include $(TOPDIR)Rules.mak - -# If you're looking for vfork(), it is defined in include/unistd.h - - -ifeq ($(ARCH_HAS_MMU),y) -CRT_SRC := crt0.c -else -CRT_SRC := crt0.S -endif -CRT_OBJ := crt0.o crt1.o -CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o - -SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S -SOBJ := $(patsubst %.S,%.o, $(SSRC)) - -CSRC := ptrace.c brk.c -COBJ := $(patsubst %.c,%.o, $(CSRC)) - -OBJS := $(SOBJ) $(COBJ) - -OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH) - -all: $(OBJ_LIST) $(CTOR_TARGETS) - -$(OBJ_LIST): $(OBJS) $(CRT_OBJ) - $(STRIPTOOL) -x -R .note -R .comment $^ - $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT_OBJ) $(TOPDIR)lib/ - echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@ - -$(CRT_OBJ): $(CRT_SRC) -ifeq ($(ARCH_HAS_MMU),y) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o -else - $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o -endif - -$(SOBJ): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - -$(COBJ): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -ifeq ($(UCLIBC_CTOR_DTOR),y) -$(TOPDIR)lib/crti.o: crti.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ - -$(TOPDIR)lib/crtn.o: crtn.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ -else -$(CTOR_TARGETS): - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $@ -endif - -headers: -ifneq ($(HAVE_ELF),y) - echo "Working around compiler bug in the m68k-pic-coff toolchain" - $(LN) -fs ../libc/sysdeps/linux/m68k/float.h $(TOPDIR)/include/ -endif - $(LN) -fs ../libc/sysdeps/linux/m68k/fpu_control.h $(TOPDIR)/include/ -clean: - $(RM) *.o *~ core -ifneq ($(HAVE_ELF),y) - $(RM) $(TOPDIR)/include/float.h -endif +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/m68k/clone.S b/libc/sysdeps/linux/m68k/clone.S index f2e0122da..916488146 100644 --- a/libc/sysdeps/linux/m68k/clone.S +++ b/libc/sysdeps/linux/m68k/clone.S @@ -5,6 +5,7 @@ and invokes a function in the right context after its all over. */ #define _ERRNO_H +#include <features.h> #include <bits/errno.h> #include <sys/syscall.h> @@ -12,9 +13,6 @@ .text .align 4 -.type clone,@function -.globl clone; -clone: .type __clone,@function .globl __clone; __clone: @@ -82,4 +80,3 @@ thread_start: #else .set clone,__clone #endif - diff --git a/libc/sysdeps/linux/microblaze/bits/mman.h b/libc/sysdeps/linux/microblaze/bits/mman.h index 8c457158f..d051c8fa7 100644 --- a/libc/sysdeps/linux/microblaze/bits/mman.h +++ b/libc/sysdeps/linux/microblaze/bits/mman.h @@ -95,4 +95,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/mips/Makefile b/libc/sysdeps/linux/mips/Makefile index 6d51205e9..633c91f3e 100644 --- a/libc/sysdeps/linux/mips/Makefile +++ b/libc/sysdeps/linux/mips/Makefile @@ -1,91 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../../../ -include $(TOPDIR)Rules.mak - -CRT_SRC = crt1.S -CRT_OBJ = crt1.o -SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ)) -CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o - -SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S syscall.S pipe.S vfork.S -SOBJS=$(patsubst %.S,%.o, $(SSRC)) - -CSRC=__longjmp.c brk.c setjmp_aux.c mmap.c __syscall_error.c \ - cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(SOBJS) $(COBJS) - -OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) - echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) - $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/ - -$(CRT_OBJ): $(CRT_SRC) - $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(SCRT_OBJ): $(CRT_SRC) - $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(SOBJS): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) -crti.o: crti.S - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o - -$(TOPDIR)lib/crti.o: crti.o - $(INSTALL) -d $(TOPDIR)lib/ - cp crti.o $(TOPDIR)lib/ - -crtn.o: crtn.S - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o - -$(TOPDIR)lib/crtn.o: crtn.o - $(INSTALL) -d $(TOPDIR)lib/ - cp crtn.o $(TOPDIR)lib/ -else -$(TOPDIR)lib/crti.o: - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o -$(TOPDIR)lib/crtn.o: - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o -endif - -headers: - $(LN) -fs ../libc/sysdeps/linux/mips/sgidefs.h $(TOPDIR)/include/ - $(LN) -fs ../libc/sysdeps/linux/mips/fpu_control.h $(TOPDIR)/include/ - cp sysdep.h $(TOPDIR)/include/ -clean: - $(RM) *.o *~ core - $(RM) $(TOPDIR)/include/sgidefs.h $(TOPDIR)/include/sysdep.h +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/mips/bits/kernel_types.h b/libc/sysdeps/linux/mips/bits/kernel_types.h index 3605b1644..f23b24874 100644 --- a/libc/sysdeps/linux/mips/bits/kernel_types.h +++ b/libc/sysdeps/linux/mips/bits/kernel_types.h @@ -14,7 +14,7 @@ typedef unsigned int __kernel_mode_t; typedef unsigned int __kernel_nlink_t; typedef long __kernel_off_t; typedef int __kernel_pid_t; -typedef int __kernel_ipc_pid_t; +typedef long int __kernel_ipc_pid_t; typedef int __kernel_uid_t; typedef int __kernel_gid_t; typedef unsigned long __kernel_size_t; @@ -50,7 +50,7 @@ typedef unsigned long __kernel_nlink_t; typedef long __kernel_off_t; typedef int __kernel_pid_t; -typedef int __kernel_ipc_pid_t; +typedef long int __kernel_ipc_pid_t; typedef int __kernel_uid_t; typedef int __kernel_gid_t; typedef unsigned int __kernel_size_t; diff --git a/libc/sysdeps/linux/mips/bits/mman.h b/libc/sysdeps/linux/mips/bits/mman.h index 61886e27e..33f9a11df 100644 --- a/libc/sysdeps/linux/mips/bits/mman.h +++ b/libc/sysdeps/linux/mips/bits/mman.h @@ -83,4 +83,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/nios/bits/mman.h b/libc/sysdeps/linux/nios/bits/mman.h index 34f14ee5b..7f644b99b 100644 --- a/libc/sysdeps/linux/nios/bits/mman.h +++ b/libc/sysdeps/linux/nios/bits/mman.h @@ -72,4 +72,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/nios2/bits/mman.h b/libc/sysdeps/linux/nios2/bits/mman.h index 34f14ee5b..7f644b99b 100644 --- a/libc/sysdeps/linux/nios2/bits/mman.h +++ b/libc/sysdeps/linux/nios2/bits/mman.h @@ -72,4 +72,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/powerpc/Makefile b/libc/sysdeps/linux/powerpc/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/powerpc/Makefile +++ b/libc/sysdeps/linux/powerpc/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/powerpc/bits/mman.h b/libc/sysdeps/linux/powerpc/bits/mman.h index 72c24132c..f92bc7fc3 100644 --- a/libc/sysdeps/linux/powerpc/bits/mman.h +++ b/libc/sysdeps/linux/powerpc/bits/mman.h @@ -73,6 +73,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/sh/Makefile b/libc/sysdeps/linux/sh/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/sh/Makefile +++ b/libc/sysdeps/linux/sh/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/sh/bits/mman.h b/libc/sysdeps/linux/sh/bits/mman.h index 1c17bf616..65eb86581 100644 --- a/libc/sysdeps/linux/sh/bits/mman.h +++ b/libc/sysdeps/linux/sh/bits/mman.h @@ -72,6 +72,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/sh/longjmp.c b/libc/sysdeps/linux/sh/longjmp.c index c36344cd1..ee3afcd74 100644 --- a/libc/sysdeps/linux/sh/longjmp.c +++ b/libc/sysdeps/linux/sh/longjmp.c @@ -33,7 +33,7 @@ void __libc_siglongjmp (sigjmp_buf env, int val) { if (env[0].__mask_was_saved) /* Restore the saved signal mask. */ - (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask, + (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask, (sigset_t *) NULL); /* Call the machine-dependent function to restore machine state. */ diff --git a/libc/sysdeps/linux/sh64/bits/mman.h b/libc/sysdeps/linux/sh64/bits/mman.h index 3b18b2133..afa889dbf 100644 --- a/libc/sysdeps/linux/sh64/bits/mman.h +++ b/libc/sysdeps/linux/sh64/bits/mman.h @@ -75,6 +75,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/sparc/Makefile b/libc/sysdeps/linux/sparc/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/sparc/Makefile +++ b/libc/sysdeps/linux/sparc/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h index 12e9cffd2..5dc8bf32f 100644 --- a/libc/sysdeps/linux/sparc/bits/fcntl.h +++ b/libc/sysdeps/linux/sparc/bits/fcntl.h @@ -1,5 +1,6 @@ /* O_*, F_*, FD_* bit values for Linux/SPARC. - Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004 + 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 @@ -43,7 +44,8 @@ #ifdef __USE_GNU # define O_DIRECTORY 0x10000 /* must be a directory */ # define O_NOFOLLOW 0x20000 /* don't follow links */ -# define O_STREAMING 0x4000000/* streaming access */ +# define O_DIRECT 0x100000 /* direct disk access hint */ +# define O_NOATIME 0x200000 /* Do not set atime. */ #endif #ifdef __USE_LARGEFILE64 @@ -76,7 +78,7 @@ #define F_SETFD 2 /* Set file descriptor flags. */ #define F_GETFL 3 /* Get file status flags. */ #define F_SETFL 4 /* Set file status flags. */ -#if defined __USE_BSD || defined __USE_XOPEN2K +#if defined __USE_BSD || defined __USE_UNIX98 # define F_GETOWN 5 /* Get owner of socket (receiver of SIGIO). */ # define F_SETOWN 6 /* Set owner of socket (receiver of SIGIO). */ #endif @@ -196,3 +198,11 @@ struct flock64 # define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */ # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +__BEGIN_DECLS + +/* Provide kernel hint to read ahead. */ +extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) + __THROW; + +__END_DECLS diff --git a/libc/sysdeps/linux/sparc/bits/mman.h b/libc/sysdeps/linux/sparc/bits/mman.h index 7db39902d..26425876f 100644 --- a/libc/sysdeps/linux/sparc/bits/mman.h +++ b/libc/sysdeps/linux/sparc/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/SPARC version. - Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2000, 2003, 2005 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 @@ -34,6 +34,10 @@ #define PROT_WRITE 0x2 /* Page can be written. */ #define PROT_EXEC 0x4 /* Page can be executed. */ #define PROT_NONE 0x0 /* Page can not be accessed. */ +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of + growsdown vma (mprotect only). */ +#define PROT_GROWSUP 0x02000000 /* Extend change to start of + growsup vma (mprotect only). */ /* Sharing types (must choose one and only one of these). */ #define MAP_SHARED 0x01 /* Share changes. */ @@ -53,12 +57,14 @@ /* These are Linux-specific. */ #ifdef __USE_MISC -# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */ +# define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */ # define MAP_DENYWRITE 0x0800 /* ETXTBSY */ # define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ # define MAP_LOCKED 0x0100 /* Lock the mapping. */ # define MAP_NORESERVE 0x0040 /* Don't check for reservations. */ # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */ +# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ #endif /* Flags to `msync'. */ @@ -74,6 +80,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/sparc/bits/resource.h b/libc/sysdeps/linux/sparc/bits/resource.h index 40c30d01d..3f2c60014 100644 --- a/libc/sysdeps/linux/sparc/bits/resource.h +++ b/libc/sysdeps/linux/sparc/bits/resource.h @@ -1,5 +1,6 @@ /* Bit values & structures for resource limits. Linux/SPARC version. - Copyright (C) 1994,1996,1997,1998,1999,2000 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005 + 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 @@ -55,34 +56,54 @@ enum __rlimit_resource This affects swapping; processes that are exceeding their resident set size will be more likely to have physical memory taken from them. */ - RLIMIT_RSS = 5, -#define RLIMIT_RSS RLIMIT_RSS + __RLIMIT_RSS = 5, +#define RLIMIT_RSS __RLIMIT_RSS /* Number of open files. */ RLIMIT_NOFILE = 6, - RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */ + __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */ #define RLIMIT_NOFILE RLIMIT_NOFILE -#define RLIMIT_OFILE RLIMIT_OFILE +#define RLIMIT_OFILE __RLIMIT_OFILE /* Address space limit (?) */ RLIMIT_AS = 9, #define RLIMIT_AS RLIMIT_AS /* Number of processes. */ - RLIMIT_NPROC = 7, -#define RLIMIT_NPROC RLIMIT_NPROC + __RLIMIT_NPROC = 7, +#define RLIMIT_NPROC __RLIMIT_NPROC /* Locked-in-memory address space. */ - RLIMIT_MEMLOCK = 8, -#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK + __RLIMIT_MEMLOCK = 8, +#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK /* Maximum number of file locks. */ - RLIMIT_LOCKS = 10, -#define RLIMIT_LOCKS RLIMIT_LOCKS - - RLIM_NLIMITS = 11 -#define RLIMIT_NLIMITS RLIMIT_NLIMITS -#define RLIM_NLIMITS RLIM_NLIMITS + __RLIMIT_LOCKS = 10, +#define RLIMIT_LOCKS __RLIMIT_LOCKS + + /* Maximum number of pending signals. */ + __RLIMIT_SIGPENDING = 11, +#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING + + /* Maximum bytes in POSIX message queues. */ + __RLIMIT_MSGQUEUE = 12, +#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE + + /* Maximum nice priority allowed to raise to. + Nice levels 19 .. -20 correspond to 0 .. 39 + values of this resource limit. */ + __RLIMIT_NICE = 13, +#define RLIMIT_NICE __RLIMIT_NICE + + /* Maximum realtime priority allowed for non-priviledged + processes. */ + __RLIMIT_RTPRIO = 14, +#define RLIMIT_RTPRIO __RLIMIT_RTPRIO + + __RLIMIT_NLIMITS = 15, + __RLIM_NLIMITS = __RLIMIT_NLIMITS +#define RLIMIT_NLIMITS __RLIMIT_NLIMITS +#define RLIM_NLIMITS __RLIM_NLIMITS }; /* Value to indicate that there is no limit. */ @@ -153,12 +174,8 @@ enum __rusage_who #define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1, + RUSAGE_CHILDREN = -1 #define RUSAGE_CHILDREN RUSAGE_CHILDREN - - /* Both. */ - RUSAGE_BOTH = -2 -#define RUSAGE_BOTH RUSAGE_BOTH }; #define __need_timeval diff --git a/libc/sysdeps/linux/sparc/bits/setjmp.h b/libc/sysdeps/linux/sparc/bits/setjmp.h index 574085664..dac9ac5cb 100644 --- a/libc/sysdeps/linux/sparc/bits/setjmp.h +++ b/libc/sysdeps/linux/sparc/bits/setjmp.h @@ -17,7 +17,7 @@ 02111-1307 USA. */ #ifndef _BITS_SETJMP_H -#define _BITS_SETJMP_H 1 +#define _BITS_SETJMP_H 1 #if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." @@ -77,8 +77,8 @@ typedef int __jmp_buf[3]; /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ #define _JMPBUF_UNWINDS(jmpbuf, address) \ - ((void *) (address) < (void *) (jmpbuf)[JB_SP]) + ((int) (address) < (jmpbuf)[JB_SP]) #endif -#endif /* bits/setjmp.h */ +#endif /* bits/setjmp.h */ diff --git a/libc/sysdeps/linux/sparc/bits/shm.h b/libc/sysdeps/linux/sparc/bits/shm.h index f075be8d8..03decb110 100644 --- a/libc/sysdeps/linux/sparc/bits/shm.h +++ b/libc/sysdeps/linux/sparc/bits/shm.h @@ -81,6 +81,7 @@ struct shmid_ds # define SHM_DEST 01000 /* segment will be destroyed on last detach */ # define SHM_LOCKED 02000 /* segment will not be swapped */ # define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */ +# define SHM_NORESERVE 010000 /* don't check for reservations */ struct shminfo { diff --git a/libc/sysdeps/linux/sparc/bits/siginfo.h b/libc/sysdeps/linux/sparc/bits/siginfo.h index da2aed678..7ff1971c2 100644 --- a/libc/sysdeps/linux/sparc/bits/siginfo.h +++ b/libc/sysdeps/linux/sparc/bits/siginfo.h @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Linux/SPARC version. - Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997-2002, 2003 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 @@ -69,8 +69,9 @@ typedef struct siginfo /* POSIX.1b timers. */ struct { - unsigned int _timer1; - unsigned int _timer2; + int si_tid; /* Timer ID. */ + int si_overrun; /* Overrun count. */ + sigval_t si_sigval; /* Signal value. */ } _timer; /* POSIX.1b signals. */ @@ -111,8 +112,8 @@ typedef struct siginfo /* X/Open requires some more fields with fixed names. */ # define si_pid _sifields._kill.si_pid # define si_uid _sifields._kill.si_uid -# define si_timer1 _sifields._timer._timer1 -# define si_timer2 _sifields._timer._timer2 +# define si_timerid _sifields._timer.si_tid +# define si_overrun _sifields._timer.si_overrun # define si_status _sifields._sigchld.si_status # define si_utime _sifields._sigchld.si_utime # define si_stime _sifields._sigchld.si_stime @@ -129,8 +130,10 @@ typedef struct siginfo signals. */ enum { - SI_ASYNCNL = -6, /* Sent by asynch name lookup completion. */ + SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */ # define SI_ASYNCNL SI_ASYNCNL + SI_TKILL = -6, /* Sent by tkill. */ +# define SI_TKILL SI_TKILL SI_SIGIO, /* Sent by queued SIGIO. */ # define SI_SIGIO SI_SIGIO SI_ASYNCIO, /* Sent by AIO completion. */ @@ -276,9 +279,6 @@ enum # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) # endif -/* Forward declaration of the `pthread_attr_t' type. */ -struct __pthread_attr_s; - typedef struct sigevent { sigval_t sigev_value; @@ -291,8 +291,8 @@ typedef struct sigevent struct { - void (*_function) (sigval_t); /* Function to start. */ - struct __pthread_attr_s *_attribute; /* Really pthread_attr_t. */ + void (*_function) (sigval_t); /* Function to start. */ + void *_attribute; /* Really pthread_attr_t. */ } _sigev_thread; } _sigev_un; } sigevent_t; @@ -308,8 +308,11 @@ enum # define SIGEV_SIGNAL SIGEV_SIGNAL SIGEV_NONE, /* Other notification: meaningless. */ # define SIGEV_NONE SIGEV_NONE - SIGEV_THREAD /* Deliver via thread creation. */ + SIGEV_THREAD, /* Deliver via thread creation. */ # define SIGEV_THREAD SIGEV_THREAD + + SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */ +#define SIGEV_THREAD_ID SIGEV_THREAD_ID }; #endif /* have _SIGNAL_H. */ diff --git a/libc/sysdeps/linux/sparc/bits/signum.h b/libc/sysdeps/linux/sparc/bits/signum.h index 48d39402d..6b58ec29d 100644 --- a/libc/sysdeps/linux/sparc/bits/signum.h +++ b/libc/sysdeps/linux/sparc/bits/signum.h @@ -1,5 +1,5 @@ /* Signal number definitions. Linux/SPARC version. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2003 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 @@ -70,7 +70,7 @@ #define SIGUSR1 30 #define SIGUSR2 31 -#define _NSIG 64 /* Biggest signal number + 1 +#define _NSIG 65 /* Biggest signal number + 1 (including real-time signals). */ #define SIGRTMIN (__libc_current_sigrtmin ()) diff --git a/libc/sysdeps/linux/sparc/bits/stat.h b/libc/sysdeps/linux/sparc/bits/stat.h index aefcf9ee1..cc454117b 100644 --- a/libc/sysdeps/linux/sparc/bits/stat.h +++ b/libc/sysdeps/linux/sparc/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1992,95,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -61,11 +61,11 @@ struct stat __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ #endif __time_t st_atime; /* Time of last access. */ - unsigned long int __unused1; + unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ - unsigned long int __unused2; + unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ - unsigned long int __unused3; + unsigned long int st_ctimensec; /* Nsecs of last status change. */ unsigned long int __unused4; unsigned long int __unused5; }; @@ -89,11 +89,11 @@ struct stat64 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ __time_t st_atime; /* Time of last access. */ - unsigned long int __unused1; + unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ - unsigned long int __unused2; + unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ - unsigned long int __unused3; + unsigned long int st_ctimensec; /* Nsecs of last status change. */ unsigned long int __unused4; unsigned long int __unused5; }; @@ -102,6 +102,8 @@ struct stat64 /* Tell code we have these members. */ #define _STATBUF_ST_BLKSIZE #define _STATBUF_ST_RDEV +/* Nanosecond resolution time values are supported. */ +#define _STATBUF_ST_NSEC /* Encoding of the file mode. */ diff --git a/libc/sysdeps/linux/sparc/bits/termios.h b/libc/sysdeps/linux/sparc/bits/termios.h index 409ed233d..cea13227f 100644 --- a/libc/sysdeps/linux/sparc/bits/termios.h +++ b/libc/sysdeps/linux/sparc/bits/termios.h @@ -1,5 +1,6 @@ /* termios type and macro definitions. Linux/SPARC version. - Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2005 + 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 @@ -73,6 +74,7 @@ struct termios #define IXANY 0x00000800 #define IXOFF 0x00001000 #define IMAXBEL 0x00002000 +#define IUTF8 0x00004000 /* c_oflag bits */ #define OPOST 0x00000001 @@ -83,34 +85,41 @@ struct termios #define ONLRET 0x00000020 #define OFILL 0x00000040 #define OFDEL 0x00000080 -#define NLDLY 0x00000100 -#define NL0 0x00000000 -#define NL1 0x00000100 -#define CRDLY 0x00000600 -#define CR0 0x00000000 -#define CR1 0x00000200 -#define CR2 0x00000400 -#define CR3 0x00000600 -#define TABDLY 0x00001800 -#define TAB0 0x00000000 -#define TAB1 0x00000800 -#define TAB2 0x00001000 -#define TAB3 0x00001800 -#define XTABS 0x00001800 -#define BSDLY 0x00002000 -#define BS0 0x00000000 -#define BS1 0x00002000 -#define VTDLY 0x00004000 -#define VT0 0x00000000 -#define VT1 0x00004000 +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY 0x00000100 +# define NL0 0x00000000 +# define NL1 0x00000100 +# define CRDLY 0x00000600 +# define CR0 0x00000000 +# define CR1 0x00000200 +# define CR2 0x00000400 +# define CR3 0x00000600 +# define TABDLY 0x00001800 +# define TAB0 0x00000000 +# define TAB1 0x00000800 +# define TAB2 0x00001000 +# define TAB3 0x00001800 +# define BSDLY 0x00002000 +# define BS0 0x00000000 +# define BS1 0x00002000 #define FFDLY 0x00008000 #define FF0 0x00000000 #define FF1 0x00008000 +#endif +#define VTDLY 0x00004000 +#define VT0 0x00000000 +#define VT1 0x00004000 #define PAGEOUT 0x00010000 /* SUNOS specific */ #define WRAP 0x00020000 /* SUNOS specific */ +#ifdef __USE_MISC +# define XTABS 0x00001800 +#endif + /* c_cflag bit meaning */ -#define CBAUD 0x0000100f +#ifdef __USE_MISC +# define CBAUD 0x0000100f +#endif #define B0 0x00000000 /* hang up */ #define B50 0x00000001 #define B75 0x00000002 @@ -127,8 +136,10 @@ struct termios #define B9600 0x0000000d #define B19200 0x0000000e #define B38400 0x0000000f -#define EXTA B19200 -#define EXTB B38400 +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +#endif #define CSIZE 0x00000030 #define CS5 0x00000000 #define CS6 0x00000010 @@ -140,7 +151,9 @@ struct termios #define PARODD 0x00000200 #define HUPCL 0x00000400 #define CLOCAL 0x00000800 -#define CBAUDEX 0x00001000 +#ifdef __USE_MISC +# define CBAUDEX 0x00001000 +#endif #define B57600 0x00001001 #define B115200 0x00001002 #define B230400 0x00001003 @@ -158,26 +171,32 @@ struct termios #define B2000000 0x0000100f #define __MAX_BAUD B2000000 -#define CIBAUD 0x100f0000 /* input baud rate (not used) */ -#define CMSPAR 0x40000000 /* mark or space (stick) parity */ -#define CRTSCTS 0x80000000 /* flow control */ +#ifdef __USE_MISC +# define CIBAUD 0x100f0000 /* input baud rate (not used) */ +# define CMSPAR 0x40000000 /* mark or space (stick) parity */ +# define CRTSCTS 0x80000000 /* flow control */ +#endif /* c_lflag bits */ #define ISIG 0x00000001 #define ICANON 0x00000002 -#define XCASE 0x00000004 +#if defined __USE_MISC || defined __USE_XOPEN +# define XCASE 0x00000004 +#endif #define ECHO 0x00000008 #define ECHOE 0x00000010 #define ECHOK 0x00000020 #define ECHONL 0x00000040 #define NOFLSH 0x00000080 #define TOSTOP 0x00000100 -#define ECHOCTL 0x00000200 -#define ECHOPRT 0x00000400 -#define ECHOKE 0x00000800 -#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ -#define FLUSHO 0x00002000 -#define PENDIN 0x00004000 +#ifdef __USE_MISC +# define ECHOCTL 0x00000200 +# define ECHOPRT 0x00000400 +# define ECHOKE 0x00000800 +# define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ +# define FLUSHO 0x00002000 +# define PENDIN 0x00004000 +#endif #define IEXTEN 0x00008000 /* modem lines */ diff --git a/libc/sysdeps/linux/sparc/sys/procfs.h b/libc/sysdeps/linux/sparc/sys/procfs.h index e5d35f524..2827b1ec3 100644 --- a/libc/sysdeps/linux/sparc/sys/procfs.h +++ b/libc/sysdeps/linux/sparc/sys/procfs.h @@ -35,7 +35,7 @@ __BEGIN_DECLS #if __WORDSIZE == 64 -#define ELF_NGREG 20 +#define ELF_NGREG 36 typedef struct { @@ -139,6 +139,73 @@ typedef __pid_t lwpid_t; typedef struct elf_prstatus prstatus_t; typedef struct elf_prpsinfo prpsinfo_t; +#if __WORDSIZE == 64 + +/* Provide 32-bit variants so that BFD can read 32-bit + core files. */ +#define ELF_NGREG32 38 +typedef struct + { + union + { + unsigned int pr_regs[32]; + double pr_dregs[16]; + } pr_fr; + unsigned int __unused; + unsigned int pr_fsr; + unsigned char pr_qcnt; + unsigned char pr_q_entrysize; + unsigned char pr_en; + unsigned int pr_q[64]; + } elf_fpregset_t32; + +typedef unsigned int elf_greg_t32; +typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG32]; + +struct elf_prstatus32 + { + struct elf_siginfo pr_info; /* Info associated with signal. */ + short int pr_cursig; /* Current signal. */ + unsigned int pr_sigpend; /* Set of pending signals. */ + unsigned int pr_sighold; /* Set of held signals. */ + __pid_t pr_pid; + __pid_t pr_ppid; + __pid_t pr_pgrp; + __pid_t pr_sid; + struct + { + int tv_sec, tv_usec; + } pr_utime, /* User time. */ + pr_stime, /* System time. */ + pr_cutime, /* Cumulative user time. */ + pr_cstime; /* Cumulative system time. */ + elf_gregset_t32 pr_reg; /* GP registers. */ + int pr_fpvalid; /* True if math copro being used. */ + }; + +struct elf_prpsinfo32 + { + char pr_state; /* Numeric process state. */ + char pr_sname; /* Char for pr_state. */ + char pr_zomb; /* Zombie. */ + char pr_nice; /* Nice val. */ + unsigned int pr_flag; /* Flags. */ + unsigned short int pr_uid; + unsigned short int pr_gid; + int pr_pid, pr_ppid, pr_pgrp, pr_sid; + /* Lots missing */ + char pr_fname[16]; /* Filename of executable. */ + char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ + }; + +typedef elf_gregset_t32 prgregset32_t; +typedef elf_fpregset_t32 prfpregset32_t; + +typedef struct elf_prstatus32 prstatus32_t; +typedef struct elf_prpsinfo32 prpsinfo32_t; + +#endif /* sparc64 */ + __END_DECLS #endif /* sys/procfs.h */ diff --git a/libc/sysdeps/linux/v850/bits/mman.h b/libc/sysdeps/linux/v850/bits/mman.h index b32e636c9..4393d0344 100644 --- a/libc/sysdeps/linux/v850/bits/mman.h +++ b/libc/sysdeps/linux/v850/bits/mman.h @@ -95,4 +95,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/libc/sysdeps/linux/x86_64/Makefile b/libc/sysdeps/linux/x86_64/Makefile index b1bf1ef10..633c91f3e 100644 --- a/libc/sysdeps/linux/x86_64/Makefile +++ b/libc/sysdeps/linux/x86_64/Makefile @@ -5,9 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -TOPDIR=../../../../ - -top_srcdir=$(TOPDIR) +top_srcdir=../../../../ top_builddir=../../../../ all: objs include $(top_builddir)Rules.mak diff --git a/libc/sysdeps/linux/x86_64/bits/mman.h b/libc/sysdeps/linux/x86_64/bits/mman.h index a7bac2693..c25900372 100644 --- a/libc/sysdeps/linux/x86_64/bits/mman.h +++ b/libc/sysdeps/linux/x86_64/bits/mman.h @@ -79,6 +79,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/libc/sysdeps/linux/x86_64/bits/wordsize.h b/libc/sysdeps/linux/x86_64/bits/wordsize.h index a40a0d816..e96a9f1ad 100644 --- a/libc/sysdeps/linux/x86_64/bits/wordsize.h +++ b/libc/sysdeps/linux/x86_64/bits/wordsize.h @@ -2,7 +2,6 @@ #if defined __x86_64__ # define __WORDSIZE 64 -# define __WORDSIZE_COMPAT32 1 #else # define __WORDSIZE 32 #endif diff --git a/libc/sysdeps/linux/x86_64/sigaction.c b/libc/sysdeps/linux/x86_64/sigaction.c index 3ea9ad7d3..ac10bc5aa 100644 --- a/libc/sysdeps/linux/x86_64/sigaction.c +++ b/libc/sysdeps/linux/x86_64/sigaction.c @@ -17,30 +17,42 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ + #include <errno.h> +#include <stddef.h> #include <signal.h> #include <string.h> + + #include <sys/syscall.h> + + + +/* The difference here is that the sigaction structure used in the + kernel is not the same as we use in the libc. Therefore we must + translate it here. */ #include <bits/kernel_sigaction.h> +/* We do not globally define the SA_RESTORER flag so do it here. */ #define SA_RESTORER 0x04000000 - #if defined __NR_rt_sigaction -#warning Yes there are two warnings here. Don't worry about it. -static void restore_rt (void) asm ("__restore_rt"); -static void restore (void) asm ("__restore"); +/* Using the hidden attribute here does not change the code but it + helps to avoid warnings. */ +extern void restore_rt (void) asm ("__restore_rt") attribute_hidden; +extern void restore (void) asm ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ -int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +int +__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { int result; struct kernel_sigaction kact, koact; if (act) { kact.k_sa_handler = act->sa_handler; - memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); + __memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); kact.sa_flags = act->sa_flags | SA_RESTORER; kact.sa_restorer = &restore_rt; @@ -53,7 +65,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa oact ? __ptrvalue (&koact) : NULL, _NSIG / 8); if (oact && result >= 0) { oact->sa_handler = koact.k_sa_handler; - memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t)); + __memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t)); oact->sa_flags = koact.sa_flags; oact->sa_restorer = koact.sa_restorer; } @@ -61,12 +73,12 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa } #else -#warning "Yes there is a warning here. Don't worry about it." -static void restore (void) asm ("__restore"); +extern void restore (void) asm ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ -int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +int +__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { int result; struct old_kernel_sigaction kact, koact; @@ -106,9 +118,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa } #endif -#ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, sigaction) -#endif /* NOTE: Please think twice before making any changes to the bits of code below. GDB needs some intimate knowledge about it to diff --git a/libc/termios/Makefile b/libc/termios/Makefile index 4e43039eb..11f362a5e 100644 --- a/libc/termios/Makefile +++ b/libc/termios/Makefile @@ -1,53 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. -# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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. - -TOPDIR=../../ -include $(TOPDIR)Rules.mak - -MSRC=termios.c -MOBJ= tcdrain.o tcflow.o tcflush.o tcsendbreak.o tcsetpgrp.o tcgetpgrp.o \ - isatty.o cfgetospeed.o cfgetispeed.o cfsetospeed.o cfsetispeed.o \ - cfmakeraw.o cfsetspeed.o - - -CSRC=tcgetattr.c tcgetsid.c tcsetattr.c ttyname.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(MOBJ) $(COBJS) - -OBJ_LIST=../obj.termios - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, termios/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/termios/tcgetattr.c b/libc/termios/tcgetattr.c index 8e011b95e..1f1f0562b 100644 --- a/libc/termios/tcgetattr.c +++ b/libc/termios/tcgetattr.c @@ -16,6 +16,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define mempcpy __mempcpy + #include <features.h> #define __USE_GNU #include <string.h> @@ -53,18 +55,18 @@ int tcgetattr (int fd, struct termios *termios_p) if (sizeof (cc_t) == 1 || _POSIX_VDISABLE == 0 || (unsigned char) _POSIX_VDISABLE == (unsigned char) -1) { - memset (mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], + __memset (mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], __KERNEL_NCCS * sizeof (cc_t)), _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t)); #if 0 - memset ( (memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], + __memset ( (__memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], __KERNEL_NCCS * sizeof (cc_t)) + (__KERNEL_NCCS * sizeof (cc_t))) , _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t)); #endif } else { size_t cnt; - memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], + __memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], __KERNEL_NCCS * sizeof (cc_t)); for (cnt = __KERNEL_NCCS; cnt < NCCS; ++cnt) diff --git a/libc/termios/tcsetattr.c b/libc/termios/tcsetattr.c index 83bf61d99..76d73796e 100644 --- a/libc/termios/tcsetattr.c +++ b/libc/termios/tcsetattr.c @@ -80,7 +80,7 @@ int tcsetattr (int fd, int optional_actions, const struct termios *termios_p) #ifdef _HAVE_C_OSPEED k_termios.c_ospeed = termios_p->c_ospeed; #endif - memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0], + __memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0], __KERNEL_NCCS * sizeof (cc_t)); retval = ioctl (fd, cmd, &k_termios); diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c index 7b937fb0b..15093f8a5 100644 --- a/libc/termios/ttyname.c +++ b/libc/termios/ttyname.c @@ -68,7 +68,7 @@ int ttyname_r(int fd, char *ubuf, size_t ubuflen) assert(len + 2 <= TTYNAME_BUFLEN); /* dirname + 1 char + nul */ - strcpy(buf, p); + __strcpy(buf, p); s = buf + len; len = (TTYNAME_BUFLEN-2) - len; /* Available non-nul space. */ @@ -79,11 +79,11 @@ int ttyname_r(int fd, char *ubuf, size_t ubuflen) while ((d = readdir(fp)) != NULL) { /* This should never trigger for standard names, but we * check it to be safe. */ - if (strlen(d->d_name) > len) { /* Too big? */ + if (__strlen(d->d_name) > len) { /* Too big? */ continue; } - strcpy(s, d->d_name); + __strcpy(s, d->d_name); if ((lstat(buf, &dst) == 0) #if 0 @@ -100,8 +100,8 @@ int ttyname_r(int fd, char *ubuf, size_t ubuflen) /* We treat NULL buf as ERANGE rather than EINVAL. */ rv = ERANGE; - if (ubuf && (strlen(buf) <= ubuflen)) { - strcpy(ubuf, buf); + if (ubuf && (__strlen(buf) <= ubuflen)) { + __strcpy(ubuf, buf); rv = 0; } goto DONE; diff --git a/libc/unistd/Makefile b/libc/unistd/Makefile index 6493615b2..11f362a5e 100644 --- a/libc/unistd/Makefile +++ b/libc/unistd/Makefile @@ -1,74 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -TOPDIR=../../ -include $(TOPDIR)Rules.mak -DIRS:= - -MSRC1 = exec.c -MOBJ1 = execl.o execv.o execle.o execlp.o execvp.o - -CSRC= sleep.c usleep.c ualarm.c getpass.c sysconf.c getlogin.c \ - fpathconf.c confstr.c pathconf.c swab.c usershell.c \ - getsubopt.c daemon.c - -ifneq ($(strip $(ARCH_HAS_MMU)),y) - MOBJ1 += __exec_alloc.o -endif - -ifeq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y) - CSRC += getopt.c -else - CSRC += getopt-susv3.c -endif - -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) $(MOBJ1) - -OBJ_LIST=../obj.unistd - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, unistd/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ1): $(MSRC1) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(OBJ): Makefile - -subdirs: $(patsubst %, _dir_%, $(DIRS)) -subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) - -$(patsubst %, _dir_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean - -.PHONY: dummy -dummy: - -clean: - $(RM) *.[oa] *~ core +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/unistd/confstr.c b/libc/unistd/confstr.c index 017cf1e8e..bfaecb198 100644 --- a/libc/unistd/confstr.c +++ b/libc/unistd/confstr.c @@ -48,10 +48,10 @@ size_t confstr ( int name, char *buf, size_t len) if (len > 0 && buf != NULL) { if (string_len <= len) - memcpy (buf, string, string_len); + __memcpy (buf, string, string_len); else { - memcpy (buf, string, len - 1); + __memcpy (buf, string, len - 1); buf[len - 1] = '\0'; } } diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c index c584d8fc5..3c54ad234 100644 --- a/libc/unistd/daemon.c +++ b/libc/unistd/daemon.c @@ -55,12 +55,12 @@ int daemon( int nochdir, int noclose ) if (!nochdir) chdir("/"); - if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + if (!noclose && (fd = __open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); if (fd > 2) - close(fd); + __close(fd); } return(0); } diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c index 21f335da9..7bf58289b 100644 --- a/libc/unistd/exec.c +++ b/libc/unistd/exec.c @@ -232,7 +232,7 @@ int execvp(const char *path, char *const argv[]) return -1; } - if (strchr(path, '/')) { + if (__strchr(path, '/')) { execve(path, argv, __environ); CHECK_ENOEXEC: if (errno == ENOEXEC) { @@ -245,7 +245,7 @@ int execvp(const char *path, char *const argv[]) nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2); nargv[0] = argv[0]; nargv[1] = (char *)path; - memcpy(nargv+2, argv+1, n*sizeof(char *)); + __memcpy(nargv+2, argv+1, n*sizeof(char *)); execve("/bin/sh", nargv, __environ); EXEC_FREE(nargv, size2); } @@ -258,7 +258,7 @@ int execvp(const char *path, char *const argv[]) p = (char *) default_path; } - plen = strlen(path); + plen = __strlen(path); if (plen > (FILENAME_MAX - 1)) { ALL_TOO_LONG: __set_errno(ENAMETOOLONG); @@ -269,7 +269,7 @@ int execvp(const char *path, char *const argv[]) if ((buf = EXEC_ALLOC(FILENAME_MAX, size)) != NULL) { int seen_small = 0; s0 = buf + len; - memcpy(s0, path, plen+1); + __memcpy(s0, path, plen+1); do { s = s0; @@ -283,7 +283,7 @@ int execvp(const char *path, char *const argv[]) goto NEXT; } s -= plen; - memcpy(s, p, plen); + __memcpy(s, p, plen); s[plen-1] = '/'; } diff --git a/libc/unistd/getlogin.c b/libc/unistd/getlogin.c index d6a11b01e..e1685692c 100644 --- a/libc/unistd/getlogin.c +++ b/libc/unistd/getlogin.c @@ -41,7 +41,7 @@ int getlogin_r(char *name, size_t len) if (! foo) return -1; - strncpy(name, foo, len); + __strncpy(name, foo, len); name[len-1] = '\0'; return 0; } @@ -50,7 +50,7 @@ char *cuserid(char *s) { char *name = getlogin(); if (s) { - return(strcpy(s, name ? name : "")); + return(__strcpy(s, name ? name : "")); } return name; } diff --git a/libc/unistd/getopt-susv3.c b/libc/unistd/getopt-susv3.c index c53e2b089..d9ee18c43 100644 --- a/libc/unistd/getopt-susv3.c +++ b/libc/unistd/getopt-susv3.c @@ -87,7 +87,7 @@ int getopt(int argc, char * const argv[], const char *optstring) #endif retval = (unsigned char) *o; /* Avoid problems for char val of -1. */ - if ((*o == ':') || !(s = strchr(optstring, *o))) { /* Illegal option? */ + if ((*o == ':') || !(s = __strchr(optstring, *o))) { /* Illegal option? */ s = illegal; retval = '?'; goto BAD; diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c index 0dc0e0509..216e0575a 100644 --- a/libc/unistd/getopt.c +++ b/libc/unistd/getopt.c @@ -62,7 +62,7 @@ #include "getopt.h" extern int _getopt_internal (int argc, char *const *argv, const char *optstring, - const struct option *longopts, int *longind, int long_only); + const struct option *longopts, int *longind, int long_only) attribute_hidden; /* For communication from `getopt' to the caller. @@ -149,7 +149,7 @@ static enum } ordering; # include <string.h> -# define my_index strchr +# define my_index __strchr /* Handle permutation of arguments. */ @@ -311,7 +311,7 @@ static const char *_getopt_initialize (int argc, char *const * argv, const char If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ -int _getopt_internal (int argc, char *const *argv, const char *optstring, +int attribute_hidden _getopt_internal (int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only) { int print_errors = opterr; @@ -371,7 +371,7 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ - if (optind != argc && !strcmp (argv[optind], "--")) + if (optind != argc && !__strcmp (argv[optind], "--")) { optind++; @@ -447,10 +447,10 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) + if (!__strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) + == (unsigned int) __strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -479,7 +479,7 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); optind++; optopt = 0; return '?'; @@ -517,7 +517,7 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); optopt = pfound->val; return '?'; @@ -535,12 +535,12 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) @@ -651,9 +651,9 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) + if (!__strncmp (p->name, nextchar, nameend - nextchar)) { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + if ((unsigned int) (nameend - nextchar) == __strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -678,7 +678,7 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); optind++; return '?'; } @@ -700,7 +700,7 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, argv[0], pfound->name); } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); return '?'; } } @@ -716,11 +716,11 @@ int _getopt_internal (int argc, char *const *argv, const char *optstring, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } - nextchar += strlen (nextchar); + nextchar += __strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c index ac2159036..5dc6f5cf1 100644 --- a/libc/unistd/getpass.c +++ b/libc/unistd/getpass.c @@ -80,7 +80,7 @@ getpass (prompt) fgets (buf, PWD_BUFFER_SIZE-1, in); if (buf != NULL) { - nread = strlen(buf); + nread = __strlen(buf); if (nread < 0) buf[0] = '\0'; else if (buf[nread - 1] == '\n') diff --git a/libc/unistd/getsubopt.c b/libc/unistd/getsubopt.c index 682eb4bc4..bebfbc4ed 100644 --- a/libc/unistd/getsubopt.c +++ b/libc/unistd/getsubopt.c @@ -18,6 +18,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define memchr __memchr + #include <stdlib.h> #include <string.h> @@ -48,7 +50,7 @@ int getsubopt(char **optionp, char *const *tokens, char **valuep) /* Try to match the characters between *OPTIONP and VSTART against one of the TOKENS. */ for (cnt = 0; tokens[cnt] != NULL; ++cnt) - if (memcmp (*optionp, tokens[cnt], vstart - *optionp) == 0 + if (__memcmp (*optionp, tokens[cnt], vstart - *optionp) == 0 && tokens[cnt][vstart - *optionp] == '\0') { /* We found the current option in TOKENS. */ diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c index 20689da0e..01a9b641b 100644 --- a/libc/unistd/sleep.c +++ b/libc/unistd/sleep.c @@ -56,7 +56,7 @@ unsigned int sleep (unsigned int seconds) in libc. We block SIGCHLD first. */ if (__sigemptyset (&set) < 0 || __sigaddset (&set, SIGCHLD) < 0 - || sigprocmask (SIG_BLOCK, &set, &oset)) + || __sigprocmask (SIG_BLOCK, &set, &oset)) return -1; /* If SIGCHLD is already blocked, we don't have to do anything. */ @@ -73,7 +73,7 @@ unsigned int sleep (unsigned int seconds) { saved_errno = errno; /* Restore the original signal mask. */ - (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); + (void) __sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); __set_errno (saved_errno); return -1; } @@ -85,13 +85,13 @@ unsigned int sleep (unsigned int seconds) saved_errno = errno; /* Restore the original signal mask. */ - (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); + (void) __sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); __set_errno (saved_errno); } else { /* We should unblock SIGCHLD. Restore the original signal mask. */ - (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); + (void) __sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); result = nanosleep (&ts, &ts); } } diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index 902697b45..2346ad831 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -16,6 +16,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define getpagesize __libc_getpagesize + #define _XOPEN_SOURCE 500 #include <features.h> #include <errno.h> @@ -37,9 +39,6 @@ #error __UCLIBC_CLK_TCK_CONST not defined! #endif -extern int getpagesize (void); -extern int getdtablesize (void); - /***********************************************************************/ /* * Manuel Novoa III Jan 2001 @@ -71,7 +70,7 @@ extern int getdtablesize (void); #endif /* _UCLIBC_GENERATE_SYSCONF_ARCH */ /* Get the value of the system variable NAME. */ -long int __sysconf(int name) +long int attribute_hidden __sysconf(int name) { switch (name) { @@ -883,5 +882,4 @@ long int __sysconf(int name) #endif } } -weak_alias(__sysconf, sysconf); - +strong_alias(__sysconf,sysconf) diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c index 96ceaca51..323ed6a55 100644 --- a/libc/unistd/usershell.c +++ b/libc/unistd/usershell.c @@ -30,6 +30,8 @@ * November 2002, Erik Andersen <andersen@codepoet.org> */ +#define __fsetlocking __libc_fsetlocking + #define _GNU_SOURCE #include <sys/param.h> #include <sys/file.h> diff --git a/test/Makefile b/test/Makefile index 51fcde843..a259ae49a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,23 +1,12 @@ # Makefile for uClibc # -# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 -TOPDIR=../ --include $(TOPDIR).config +top_builddir=../ +-include $(top_builddir).config .EXPORT_ALL_VARIABLES: @@ -29,11 +18,16 @@ DIRS := $(ALL_SUBDIRS) ifeq ($(HAVE_SHARED),y) DIRS += dlopen +ALL_SUBDIRS += dlopen endif ifeq ($(UCLIBC_HAS_THREADS),y) DIRS += pthread +ALL_SUBDIRS += pthread +endif +ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) + DIRS += tls nptl +ALL_SUBDIRS += tls nptl endif -ALL_SUBDIRS += pthread dlopen all: subdirs diff --git a/test/Rules.mak b/test/Rules.mak index 51a45c86b..3b9856be7 100644 --- a/test/Rules.mak +++ b/test/Rules.mak @@ -1,14 +1,17 @@ # Rules.mak for uClibc test subdirs # # Copyright (C) 2001 by Lineo, inc. +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # # Note: This does not read the top level Rules.mak file # -TOPDIR = ../../ -TESTDIR=$(TOPDIR)test/ +top_builddir = ../../ +TESTDIR=$(top_builddir)test/ --include $(TOPDIR).config +-include $(top_builddir).config ifndef UCLIBC_LDSO UCLIBC_LDSO := ld-uClibc.so.0 @@ -51,14 +54,14 @@ CC = $(CROSS)gcc STRIPTOOL = strip RM = rm -f ifeq ($(LDSO_LDD_SUPPORT),y) -LDD = $(TOPDIR)utils/ldd +LDD = $(top_builddir)utils/ldd else LDD = @true endif # Select the compiler needed to build binaries for your development system HOSTCC = gcc -HOSTCFLAGS = -O2 -Wall +BUILD_CFLAGS = -O2 -Wall #-------------------------------------------------------- @@ -103,5 +106,5 @@ ifneq ($(strip $(HAVE_SHARED)),y) LDFLAGS += -static GLIBC_LDFLAGS += -static else - LDFLAGS += -Wl,-dynamic-linker,$(TOPDIR)lib/$(UCLIBC_LDSO) + LDFLAGS += -Wl,-dynamic-linker,$(top_builddir)lib/$(UCLIBC_LDSO) endif |