diff options
Diffstat (limited to 'libc/stdlib')
30 files changed, 113 insertions, 346 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 49d739703..11f362a5e 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -1,153 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. # 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 - -DIRS:= -ifeq ($(MALLOC),y) - DIRS+=malloc -endif -ifeq ($(MALLOC_SIMPLE),y) - DIRS+=malloc-simple -endif -ifeq ($(MALLOC_STANDARD),y) - DIRS+=malloc-standard -endif - - -MSRC = stdlib.c -MOBJ = abs.o labs.o atoi.o atol.o strtol.o strtoul.o _stdlib_strto_l.o \ - qsort.o bsearch.o \ - llabs.o atoll.o strtoll.o strtoull.o _stdlib_strto_ll.o -# (aliases) strtoq.o strtouq.o -ifeq ($(UCLIBC_HAS_XLOCALE),y) - -MOBJx = -MOBJx += strtol_l.o strtoul_l.o _stdlib_strto_l_l.o \ - strtoll_l.o strtoull_l.o _stdlib_strto_ll_l.o -endif - -MSRC1 = strtod.c -MOBJ1 = -MOBJ1x = - -ifeq ($(UCLIBC_HAS_FLOATS),y) - MOBJ += atof.o - MOBJ1 += strtod.o strtof.o strtold.o __strtofpmax.o __fp_range_check.o -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJ1x += strtod_l.o strtof_l.o strtold_l.o __strtofpmax_l.o -endif -ifeq ($(UCLIBC_HAS_WCHAR),y) - MOBJ1 += wcstod.o wcstof.o wcstold.o __wcstofpmax.o -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJ1x += wcstod_l.o wcstof_l.o wcstold_l.o __wcstofpmax_l.o -endif -endif -endif - -ifeq ($(UCLIBC_HAS_WCHAR),y) - MOBJ += mblen.o mbtowc.o wctomb.o mbstowcs.o wcstombs.o \ - _stdlib_mb_cur_max.o _stdlib_wcsto_l.o _stdlib_wcsto_ll.o \ - wcstol.o wcstoul.o wcstoll.o wcstoull.o -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJx += _stdlib_wcsto_l_l.o _stdlib_wcsto_ll_l.o \ - wcstol_l.o wcstoul_l.o wcstoll_l.o wcstoull_l.o -endif -endif -# (aliases) wcstoq.o wcstouq.o -# wcstod wcstof wcstold - -MSRC2 = atexit.c -MOBJ2 = on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o -ifeq ($(COMPAT_ATEXIT),y) -MOBJ2 += old_atexit.o -endif - -CSRC = \ - abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \ - rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \ - getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \ - jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \ - nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \ - valloc.c posix_memalign.c a64l.c l64a.c -ifeq ($(UCLIBC_HAS_FLOATS),y) - CSRC += drand48.c drand48_r.c erand48.c erand48_r.c -endif -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(MOBJ) $(MOBJx) $(MOBJ1) $(MOBJ1x) $(MOBJ2) $(COBJS) - -NONSHARED_OBJS=atexit.o - -OBJ_LIST=../obj.stdlib - -NONSHARED_OBJ_LIST=../nonshared_obj.stdlib - -all: $(OBJ_LIST) $(NONSHARED_OBJ_LIST) subdirs - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, stdlib/%, $(OBJS)) > $(OBJ_LIST) - -$(NONSHARED_OBJ_LIST): $(NONSHARED_OBJS) - echo $(patsubst %, stdlib/%, $(NONSHARED_OBJS)) > $(NONSHARED_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 - -$(MOBJ1): $(MSRC1) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJ1x): $(MSRC1) - $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(MOBJ2) atexit.o: $(MSRC2) - $(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_%, $(ALL_SUBDIRS)) - -$(patsubst %, _dir_%, $(DIRS)) : dummy - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy - $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean - -clean: subdirs_clean - $(RM) *.[oa] *~ core -.PHONY: dummy +top_srcdir=../../ +top_builddir=../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index 6457836e8..07e4a208c 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -92,7 +92,7 @@ void abort(void) /* Unmask SIGABRT to be sure we can get it */ if (__sigemptyset(&sigset) == 0 && __sigaddset(&sigset, SIGABRT) == 0) { - sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL); + __sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL); } while (1) { @@ -121,7 +121,7 @@ abort_it: struct sigaction act; been_there_done_that++; - memset(&act, '\0', sizeof(struct sigaction)); + __memset(&act, '\0', sizeof(struct sigaction)); act.sa_handler = SIG_DFL; __sigfillset(&act.sa_mask); act.sa_flags = 0; diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index e9710b038..a01fb29e2 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -95,7 +95,7 @@ extern struct exit_function *__exit_function_table; #else extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT]; #endif -extern struct exit_function *__new_exitfn (void); +extern struct exit_function *__new_exitfn (void) attribute_hidden; /* this is in the L___cxa_atexit object */ extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle); @@ -237,7 +237,7 @@ struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT]; * Find and return a new exit_function pointer, for atexit, * onexit and __cxa_atexit to initialize */ -struct exit_function *__new_exitfn(void) +struct exit_function attribute_hidden *__new_exitfn(void) { struct exit_function *efp; diff --git a/libc/stdlib/bsd_getpt.c b/libc/stdlib/bsd_getpt.c index 0249abbde..f219afd29 100644 --- a/libc/stdlib/bsd_getpt.c +++ b/libc/stdlib/bsd_getpt.c @@ -48,8 +48,8 @@ __getpt (void) const char *p, *q; char *s; - memcpy (buf, _PATH_PTY, sizeof (_PATH_PTY)); - s = buf + strlen (buf); + __memcpy (buf, _PATH_PTY, sizeof (_PATH_PTY)); + s = buf + __strlen (buf); /* s[0] and s[1] will be filled in the loop. */ s[2] = '\0'; @@ -64,7 +64,7 @@ __getpt (void) s[1] = *q; - fd = open (buf, O_RDWR); + fd = __open (buf, O_RDWR); if (fd != -1) return fd; diff --git a/libc/stdlib/drand48-iter.c b/libc/stdlib/drand48-iter.c index 858253b5a..bc2c15cb6 100644 --- a/libc/stdlib/drand48-iter.c +++ b/libc/stdlib/drand48-iter.c @@ -27,7 +27,7 @@ struct drand48_data __libc_drand48_data; -int +int attribute_hidden __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) { uint64_t X; diff --git a/libc/stdlib/erand48_r.c b/libc/stdlib/erand48_r.c index 85971cc02..159eb83a6 100644 --- a/libc/stdlib/erand48_r.c +++ b/libc/stdlib/erand48_r.c @@ -22,7 +22,7 @@ #include <limits.h> extern int __drand48_iterate(unsigned short xsubi[3], - struct drand48_data *buffer); + struct drand48_data *buffer) attribute_hidden; int erand48_r (xsubi, buffer, result) diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c index 2daf03955..9dfc0d132 100644 --- a/libc/stdlib/getenv.c +++ b/libc/stdlib/getenv.c @@ -29,9 +29,9 @@ char *getenv(const char *var) if (!(ep=__environ)) return NULL; - len = strlen(var); + len = __strlen(var); while(*ep) { - if (memcmp(var, *ep, len) == 0 && (*ep)[len] == '=') { + if (__memcmp(var, *ep, len) == 0 && (*ep)[len] == '=') { return *ep + len + 1; } ep++; diff --git a/libc/stdlib/getpt.c b/libc/stdlib/getpt.c index 71d7d6c5f..c219adb24 100644 --- a/libc/stdlib/getpt.c +++ b/libc/stdlib/getpt.c @@ -55,7 +55,7 @@ getpt (void) if (!have_no_dev_ptmx) #endif { - fd = open (_PATH_DEVPTMX, O_RDWR); + fd = __open (_PATH_DEVPTMX, O_RDWR); if (fd != -1) { #if defined __ASSUME_DEVPTS__ @@ -79,7 +79,7 @@ getpt (void) /* If /dev/pts is not mounted then the UNIX98 pseudo terminals are not usable. */ - close (fd); + __close (fd); #if !defined __UNIX98PTY_ONLY__ have_no_dev_ptmx = 1; #endif diff --git a/libc/stdlib/jrand48_r.c b/libc/stdlib/jrand48_r.c index 86d1ba363..d8c37cdbc 100644 --- a/libc/stdlib/jrand48_r.c +++ b/libc/stdlib/jrand48_r.c @@ -20,7 +20,7 @@ #include <stdlib.h> extern int __drand48_iterate(unsigned short xsubi[3], - struct drand48_data *buffer); + struct drand48_data *buffer) attribute_hidden; int jrand48_r (xsubi, buffer, result) unsigned short int xsubi[3]; diff --git a/libc/stdlib/malloc-simple/Makefile b/libc/stdlib/malloc-simple/Makefile index 161aece1a..4a8f4a072 100644 --- a/libc/stdlib/malloc-simple/Makefile +++ b/libc/stdlib/malloc-simple/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 -# -# 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=alloc.c -MOBJ=malloc.o realloc.o free.o calloc.o memalign.o -OBJS=$(MOBJ) - -OBJ_LIST=../../obj.stdlib.malloc-simple - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, stdlib/malloc-simple/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.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/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index ed14c37c4..7f0a91f0b 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -64,7 +64,7 @@ void * calloc(size_t nmemb, size_t lsize) * doesn't need to actually zero anything.... */ if (result != NULL) { - memset(result, 0, size); + __memset(result, 0, size); } #endif return result; @@ -85,7 +85,7 @@ void *realloc(void *ptr, size_t size) newptr = malloc(size); if (newptr) { - memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t)))); + __memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t)))); free(ptr); } return newptr; diff --git a/libc/stdlib/malloc-standard/Makefile b/libc/stdlib/malloc-standard/Makefile index 331feae20..4a8f4a072 100644 --- a/libc/stdlib/malloc-standard/Makefile +++ b/libc/stdlib/malloc-standard/Makefile @@ -1,56 +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 - -# Turn on malloc debugging if requested -ifeq ($(UCLIBC_MALLOC_DEBUGGING),y) -CFLAGS += -D__MALLOC_DEBUGGING -endif - -# calloc.c can be found at uClibc/libc/stdlib/calloc.c -# valloc.c can be found at uClibc/libc/stdlib/valloc.c -CSRC=malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c - -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(COBJS) - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -OBJ_LIST=../../obj.stdlib.malloc-standard - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, stdlib/malloc-standard/%, $(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/stdlib/malloc-standard/calloc.c b/libc/stdlib/malloc-standard/calloc.c index a67dad738..b8c43d9dc 100644 --- a/libc/stdlib/malloc-standard/calloc.c +++ b/libc/stdlib/malloc-standard/calloc.c @@ -54,7 +54,7 @@ void* calloc(size_t n_elements, size_t elem_size) assert(nclears >= 3); if (nclears > 9) - memset(d, 0, clearsize); + __memset(d, 0, clearsize); else { *(d+0) = 0; @@ -83,7 +83,7 @@ void* calloc(size_t n_elements, size_t elem_size) d = (size_t*)mem; /* Note the additional (sizeof(size_t)) */ clearsize = chunksize(p) - 2*(sizeof(size_t)); - memset(d, 0, clearsize); + __memset(d, 0, clearsize); } #endif } diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h index fbc14924e..dbac0c9d2 100644 --- a/libc/stdlib/malloc-standard/malloc.h +++ b/libc/stdlib/malloc-standard/malloc.h @@ -14,6 +14,8 @@ Hacked up for uClibc by Erik Andersen <andersen@codepoet.org> */ +#define sysconf __sysconf + #include <features.h> #include <stddef.h> #include <unistd.h> diff --git a/libc/stdlib/malloc-standard/realloc.c b/libc/stdlib/malloc-standard/realloc.c index 195013095..3d77442af 100644 --- a/libc/stdlib/malloc-standard/realloc.c +++ b/libc/stdlib/malloc-standard/realloc.c @@ -126,7 +126,7 @@ void* realloc(void* oldmem, size_t bytes) assert(ncopies >= 3); if (ncopies > 9) - memcpy(d, s, copysize); + __memcpy(d, s, copysize); else { *(d+0) = *(s+0); @@ -226,7 +226,7 @@ void* realloc(void* oldmem, size_t bytes) /* Must alloc, copy, free. */ newmem = malloc(nb - MALLOC_ALIGN_MASK); if (newmem != 0) { - memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t))); + __memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t))); free(oldmem); } } diff --git a/libc/stdlib/malloc/Makefile b/libc/stdlib/malloc/Makefile index e4a6f3a43..4a8f4a072 100644 --- a/libc/stdlib/malloc/Makefile +++ b/libc/stdlib/malloc/Makefile @@ -1,58 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2002,03 NEC Electronics Corporation -# Copyright (C) 2002,03 Miles Bader <miles@gnu.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 - -CSRC = malloc.c calloc.c free.c realloc.c memalign.c \ - heap_alloc.c heap_alloc_at.c heap_free.c - -# Turn on malloc debugging if requested -ifeq ($(UCLIBC_MALLOC_DEBUGGING),y) -CSRC += malloc_debug.c heap_debug.c -CFLAGS += -DMALLOC_DEBUGGING -DHEAP_DEBUGGING -ifeq ($(UCLIBC_UCLINUX_BROKEN_MUNMAP),y) -CFLAGS += -DMALLOC_MMB_DEBUGGING -endif -endif - -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.stdlib.malloc - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, stdlib/malloc/%, $(OBJS)) > $(OBJ_LIST) - -malloc.o free.o realloc.o memalign.o: malloc.h -$(COBJS): heap.h - -# Depend on uClinux_config.h to cache changes in __UCLIBC_MALLOC_DEBUGGING__ -$(COBJS): %.o : %.c ../../../include/bits/uClibc_config.h - $(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/stdlib/malloc/calloc.c b/libc/stdlib/malloc/calloc.c index 15281a97f..94031ce29 100644 --- a/libc/stdlib/malloc/calloc.c +++ b/libc/stdlib/malloc/calloc.c @@ -34,7 +34,7 @@ void * calloc(size_t nmemb, size_t lsize) return NULL; } if ((result=malloc(size)) != NULL) { - memset(result, 0, size); + __memset(result, 0, size); } return result; } diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index 85392ae6a..8dcc35360 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -66,7 +66,7 @@ realloc (void *mem, size_t new_size) void *new_mem = malloc (new_size - MALLOC_HEADER_SIZE); if (new_mem) { - memcpy (new_mem, mem, size - MALLOC_HEADER_SIZE); + __memcpy (new_mem, mem, size - MALLOC_HEADER_SIZE); free (mem); } mem = new_mem; diff --git a/libc/stdlib/nrand48_r.c b/libc/stdlib/nrand48_r.c index f08ac9c36..89f098e75 100644 --- a/libc/stdlib/nrand48_r.c +++ b/libc/stdlib/nrand48_r.c @@ -20,7 +20,7 @@ #include <stdlib.h> extern int __drand48_iterate(unsigned short xsubi[3], - struct drand48_data *buffer); + struct drand48_data *buffer) attribute_hidden; int nrand48_r (xsubi, buffer, result) unsigned short int xsubi[3]; diff --git a/libc/stdlib/ptsname.c b/libc/stdlib/ptsname.c index 677505953..539cbcae2 100644 --- a/libc/stdlib/ptsname.c +++ b/libc/stdlib/ptsname.c @@ -17,6 +17,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define _uintmaxtostr __libc__uintmaxtostr + #define _ISOC99_SOURCE #include <stdio.h> #include <errno.h> @@ -101,8 +103,8 @@ int ptsname_r (int fd, char *buf, size_t buflen) return ERANGE; } - strcpy (buf, devpts); - strcat (buf, p); + __strcpy (buf, devpts); + __strcat (buf, p); /* Note: Don't bother with stat on the slave name and checking the driver's major device number - the ioctl above succeeded so we know the fd was a Unix'98 master and the /dev/pts/ prefix @@ -128,7 +130,7 @@ int ptsname_r (int fd, char *buf, size_t buflen) { char *p; - if (buflen < strlen (_PATH_TTY) + 3) + if (buflen < __strlen (_PATH_TTY) + 3) { errno = ERANGE; return ERANGE; @@ -150,14 +152,14 @@ int ptsname_r (int fd, char *buf, size_t buflen) if (major (st.st_rdev) == 4) ptyno -= 128; - if (ptyno / 16 >= strlen (_ptyname1)) + if (ptyno / 16 >= __strlen (_ptyname1)) { errno = ENOTTY; return ENOTTY; } - strcpy (buf, _PATH_TTY); - p = buf + strlen (buf); + __strcpy (buf, _PATH_TTY); + p = buf + __strlen (buf); p[0] = _ptyname1[ptyno / 16]; p[1] = _ptyname2[ptyno % 16]; p[2] = '\0'; diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c index cacad5bf3..a4c739c18 100644 --- a/libc/stdlib/rand.c +++ b/libc/stdlib/rand.c @@ -17,6 +17,8 @@ * write to the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge, MA 02139, USA. */ +#define random __random + #include <stdlib.h> int rand (void) diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c index c3628b745..7266ba4c6 100644 --- a/libc/stdlib/realpath.c +++ b/libc/stdlib/realpath.c @@ -59,11 +59,11 @@ char resolved_path[]; int n; /* Make a copy of the source path since we may need to modify it. */ - if (strlen(path) >= PATH_MAX - 2) { + if (__strlen(path) >= PATH_MAX - 2) { __set_errno(ENAMETOOLONG); return NULL; } - strcpy(copy_path, path); + __strcpy(copy_path, path); path = copy_path; max_path = copy_path + PATH_MAX - 2; /* If it's a relative pathname use getwd for starters. */ @@ -75,7 +75,7 @@ char resolved_path[]; #else getwd(new_path); #endif - new_path += strlen(new_path); + new_path += __strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; } else { @@ -129,7 +129,7 @@ char resolved_path[]; if (errno != EINVAL) { /* Make sure it's null terminated. */ *new_path = '\0'; - strcpy(resolved_path, got_path); + __strcpy(resolved_path, got_path); return NULL; } } else { @@ -142,13 +142,13 @@ char resolved_path[]; /* Otherwise back up over this component. */ while (*(--new_path) != '/'); /* Safe sex check. */ - if (strlen(path) + n >= PATH_MAX - 2) { + if (__strlen(path) + n >= PATH_MAX - 2) { __set_errno(ENAMETOOLONG); return NULL; } /* Insert symlink contents into path. */ - strcat(link_path, path); - strcpy(copy_path, link_path); + __strcat(link_path, path); + __strcpy(copy_path, link_path); path = copy_path; } #endif /* S_IFLNK */ @@ -159,6 +159,6 @@ char resolved_path[]; new_path--; /* Make sure it's null terminated. */ *new_path = '\0'; - strcpy(resolved_path, got_path); + __strcpy(resolved_path, got_path); return resolved_path; } diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c index ec1ef252e..3de07aa31 100644 --- a/libc/stdlib/seed48.c +++ b/libc/stdlib/seed48.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define seed48_r __seed48_r + #include <stdlib.h> /* Global state for non-reentrant functions. Defined in drand48-iter.c. */ diff --git a/libc/stdlib/seed48_r.c b/libc/stdlib/seed48_r.c index 734b5e39d..d1c74f24c 100644 --- a/libc/stdlib/seed48_r.c +++ b/libc/stdlib/seed48_r.c @@ -21,10 +21,10 @@ #include <string.h> #include <limits.h> -int seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer) +int attribute_hidden __seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer) { /* Save old value at a private place to be used as return value. */ - memcpy (buffer->__old_x, buffer->__x, sizeof (buffer->__x)); + __memcpy (buffer->__old_x, buffer->__x, sizeof (buffer->__x)); /* Install new state. */ buffer->__x[2] = seed16v[2]; @@ -36,3 +36,4 @@ int seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer) return 0; } +strong_alias(__seed48_r,seed48_r) diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c index d0cfe526d..8704717a7 100644 --- a/libc/stdlib/setenv.c +++ b/libc/stdlib/setenv.c @@ -19,6 +19,8 @@ modified for uClibc by Erik Andersen <andersen@codepoet.org> */ +#define strndup __strndup + #define _GNU_SOURCE #include <features.h> #include <errno.h> @@ -36,6 +38,7 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; # define UNLOCK #endif +extern int __unsetenv (__const char *__name) attribute_hidden; /* If this variable is not a null pointer we allocated the current environment. */ @@ -48,13 +51,13 @@ static char **last_environ; must be used directly. This is all complicated by the fact that we try to reuse values once generated for a `setenv' call since we can never free the strings. */ -int __add_to_environ (const char *name, const char *value, +int attribute_hidden __add_to_environ (const char *name, const char *value, const char *combined, int replace) { register char **ep; register size_t size; - const size_t namelen = strlen (name); - const size_t vallen = value != NULL ? strlen (value) + 1 : 0; + const size_t namelen = __strlen (name); + const size_t vallen = value != NULL ? __strlen (value) + 1 : 0; LOCK; @@ -65,7 +68,7 @@ int __add_to_environ (const char *name, const char *value, size = 0; if (ep != NULL) { for (; *ep != NULL; ++ep) { - if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + if (!__strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') break; else ++size; @@ -97,13 +100,13 @@ int __add_to_environ (const char *name, const char *value, return -1; } - memcpy (new_environ[size], name, namelen); + __memcpy (new_environ[size], name, namelen); new_environ[size][namelen] = '='; - memcpy (&new_environ[size][namelen + 1], value, vallen); + __memcpy (&new_environ[size][namelen + 1], value, vallen); } if (__environ != last_environ) { - memcpy ((char *) new_environ, (char *) __environ, + __memcpy ((char *) new_environ, (char *) __environ, size * sizeof (char *)); } @@ -121,9 +124,9 @@ int __add_to_environ (const char *name, const char *value, UNLOCK; return -1; } - memcpy (np, name, namelen); + __memcpy (np, name, namelen); np[namelen] = '='; - memcpy (&np[namelen + 1], value, vallen); + __memcpy (&np[namelen + 1], value, vallen); } *ep = np; } @@ -137,21 +140,21 @@ int setenv (const char *name, const char *value, int replace) return __add_to_environ (name, value, NULL, replace); } -int unsetenv (const char *name) +int attribute_hidden __unsetenv (const char *name) { size_t len; char **ep; - if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { + if (name == NULL || *name == '\0' || __strchr (name, '=') != NULL) { __set_errno (EINVAL); return -1; } - len = strlen (name); + len = __strlen (name); LOCK; ep = __environ; while (*ep != NULL) { - if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { + if (!__strncmp (*ep, name, len) && (*ep)[len] == '=') { /* Found it. Remove this pointer by moving later ones back. */ char **dp = ep; do { @@ -165,6 +168,7 @@ int unsetenv (const char *name) UNLOCK; return 0; } +strong_alias(__unsetenv,unsetenv) /* The `clearenv' was planned to be added to POSIX.1 but probably never made it. Nevertheless the POSIX.9 standard (POSIX bindings @@ -187,7 +191,7 @@ int clearenv (void) int putenv (char *string) { int result; - const char *const name_end = strchr (string, '='); + const char *const name_end = __strchr (string, '='); if (name_end != NULL) { char *name = strndup(string, name_end - string); @@ -195,7 +199,7 @@ int putenv (char *string) free(name); return(result); } - unsetenv (string); + __unsetenv (string); return 0; } diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c index eab6db24a..fb8ce186b 100644 --- a/libc/stdlib/stdlib.c +++ b/libc/stdlib/stdlib.c @@ -32,6 +32,11 @@ * Add wscto{inttype} functions. */ +#define wcsrtombs __wcsrtombs +#define mbsrtowcs __mbsrtowcs +#define mbrtowc __mbrtowc +#define mbrlen __mbrlen + #define _ISOC99_SOURCE /* for ULLONG primarily... */ #define _GNU_SOURCE #include <limits.h> diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c index 9c76a2347..47f809f3e 100644 --- a/libc/stdlib/strtod.c +++ b/libc/stdlib/strtod.c @@ -152,7 +152,7 @@ #endif -extern void __fp_range_check(__fpmax_t y, __fpmax_t x); +extern void __fp_range_check(__fpmax_t y, __fpmax_t x) attribute_hidden; /**********************************************************************/ @@ -314,7 +314,7 @@ __fpmax_t __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_ goto LOOP; } #else - if (!pos0 && !memcmp(pos, decpt, decpt_len)) { /* First decimal point? */ + if (!pos0 && !__memcmp(pos, decpt, decpt_len)) { /* First decimal point? */ pos0 = (pos += decpt_len); goto LOOP; } @@ -491,7 +491,7 @@ __fpmax_t __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_ #ifdef L___fp_range_check #if defined(NEED_STRTOF_WRAPPER) || defined(NEED_STRTOD_WRAPPER) -extern void __fp_range_check(__fpmax_t y, __fpmax_t x) +void attribute_hidden __fp_range_check(__fpmax_t y, __fpmax_t x) { if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */ && (y != 0) /* y is not 0 (could have x>0, y==0 if underflow) */ diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c index 06f11abf2..b365ef82e 100644 --- a/libc/stdlib/system.c +++ b/libc/stdlib/system.c @@ -10,7 +10,7 @@ #define vfork fork #endif -int __libc_system(__const char *command) +int __libc_system(char *command) { int wait_val, pid; __sighandler_t save_quit, save_int, save_chld; diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c index 4d1b56adf..5d21ec9f8 100644 --- a/libc/stdlib/unix_grantpt.c +++ b/libc/stdlib/unix_grantpt.c @@ -17,6 +17,10 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define memchr __memchr +#define getgid __getgid +#define setrlimit __setrlimit + #include <assert.h> #include <errno.h> #include <grp.h> diff --git a/libc/stdlib/valloc.c b/libc/stdlib/valloc.c index b008ac399..c1d6d29a5 100644 --- a/libc/stdlib/valloc.c +++ b/libc/stdlib/valloc.c @@ -20,6 +20,8 @@ Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ +#define getpagesize __libc_getpagesize + #include <stdlib.h> #include <unistd.h> #include <malloc.h> |