diff options
140 files changed, 1093 insertions, 3643 deletions
diff --git a/Makefile.in b/Makefile.in index c9327802d..f9279a600 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,9 +35,9 @@ include $(top_srcdir)extra/locale/Makefile.in # last included to catch all the objects added by others (locales/threads) include $(top_srcdir)libc/Makefile.in -include/bits/uClibc_config.h: .config extra/config/conf - $(INSTALL) -d include/bits - @extra/config/conf -o $(top_srcdir)extra/Configs/Config.in +include/bits/uClibc_config.h: extra/config/conf .config + $(INSTALL) -d $(dir $@) + @$< -o $(top_srcdir)extra/Configs/Config.in # For the moment, we have to keep re-running this target # because the fix includes scripts rely on pre-processers @@ -60,7 +60,9 @@ headers: include/bits/uClibc_config.h else \ $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \ fi - $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h include/ + for f in dl-osinfo.h hp-timing.h ; do \ + $(LN) -fs ../libc/sysdeps/linux/common/$$f include/ ; \ + done @cd include/bits; \ set -e; \ for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \ diff --git a/extra/scripts/Makefile.arch.lvl3 b/extra/scripts/Makefile.arch.lvl3 index a7cbf6fa1..ac0063770 100644 --- a/extra/scripts/Makefile.arch.lvl3 +++ b/extra/scripts/Makefile.arch.lvl3 @@ -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/extra/scripts/Makefile.arch.lvl4 b/extra/scripts/Makefile.arch.lvl4 index b1bf1ef10..633c91f3e 100644 --- a/extra/scripts/Makefile.arch.lvl4 +++ b/extra/scripts/Makefile.arch.lvl4 @@ -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/extra/scripts/Makefile.libs.lvl0 b/extra/scripts/Makefile.libs.lvl0 index 655d04313..4709fc2ca 100644 --- a/extra/scripts/Makefile.libs.lvl0 +++ b/extra/scripts/Makefile.libs.lvl0 @@ -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=./ #include $(top_builddir)Rules.mak #all: libs diff --git a/extra/scripts/Makefile.libs.lvl1 b/extra/scripts/Makefile.libs.lvl1 index 2dea1b3e9..c8dc9b466 100644 --- a/extra/scripts/Makefile.libs.lvl1 +++ b/extra/scripts/Makefile.libs.lvl1 @@ -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=../ include $(top_builddir)Rules.mak all: libs diff --git a/extra/scripts/Makefile.libs.lvl2 b/extra/scripts/Makefile.libs.lvl2 index f92f205a5..f9100219a 100644 --- a/extra/scripts/Makefile.libs.lvl2 +++ b/extra/scripts/Makefile.libs.lvl2 @@ -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=../../ include $(top_builddir)Rules.mak all: libs diff --git a/extra/scripts/Makefile.objs.lvl2 b/extra/scripts/Makefile.objs.lvl2 index 41567d9e9..11f362a5e 100644 --- a/extra/scripts/Makefile.objs.lvl2 +++ b/extra/scripts/Makefile.objs.lvl2 @@ -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/extra/scripts/Makefile.objs.lvl3 b/extra/scripts/Makefile.objs.lvl3 index 493484b27..4a8f4a072 100644 --- a/extra/scripts/Makefile.objs.lvl3 +++ b/extra/scripts/Makefile.objs.lvl3 @@ -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/extra/scripts/Makefile.objs.lvl4 b/extra/scripts/Makefile.objs.lvl4 index 4f2969fcd..3ed177ae2 100644 --- a/extra/scripts/Makefile.objs.lvl4 +++ b/extra/scripts/Makefile.objs.lvl4 @@ -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/extra/scripts/create_makefiles.sh b/extra/scripts/create_makefiles.sh index 087028673..89ea4a9b6 100755 --- a/extra/scripts/create_makefiles.sh +++ b/extra/scripts/create_makefiles.sh @@ -31,6 +31,11 @@ for x in */Makefile.in ; do ${USE_CMD} extra/scripts/Makefile.libs.lvl1 $(dirname ${x})/Makefile done +for x in utils/Makefile.in ; do + ${RM} $(dirname ${x})/Makefile + ${USE_CMD} extra/scripts/Makefile.utils.lvl1 $(dirname ${x})/Makefile +done + for x in */*/Makefile.in ; do ${RM} $(dirname ${x})/Makefile ${USE_CMD} extra/scripts/Makefile.objs.lvl2 $(dirname ${x})/Makefile diff --git a/include/libc-internal.h b/include/libc-internal.h index 0ce501900..11e020ee1 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -116,4 +116,68 @@ /* --- this is added to integrate linuxthreads */ #define __USE_UNIX98 1 +#ifndef __ASSEMBLER__ +# ifdef IS_IN_libc + +# include <bits/types.h> + +# ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +# endif + +# define __need_size_t +# include <stddef.h> + +# include <bits/sigset.h> + +/* prototypes for internal use, please keep these in sync w/ updated headers */ +/* #include <fcntl.h> */ +extern int __open(__const char *__file, int __oflag, ...) attribute_hidden; + +/* #include <string.h> */ +extern int __memcmp (__const void *__s1, __const void *__s2, size_t __n) attribute_hidden; +extern void *__memcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) attribute_hidden; +extern void *__memmove (void *__dest, __const void *__src, size_t __n) attribute_hidden; +extern void *__memset (void *__s, int __c, size_t __n) attribute_hidden; +extern char *__strcpy (char *__restrict __dest, __const char *__restrict __src) attribute_hidden; +extern size_t __strlen (__const char *__s) attribute_hidden; +extern int __strcmp (__const char *__s1, __const char *__s2) attribute_hidden; +extern char *__strcat (char *__restrict __dest, __const char *__restrict __src) attribute_hidden; +extern char *__strncpy (char *__restrict __dest, + __const char *__restrict __src, size_t __n) attribute_hidden; +extern char *__strchr (__const char *__s, int __c) attribute_hidden; +extern int __strncmp (__const char *__s1, __const char *__s2, size_t __n) attribute_hidden; +extern char *__strdup (__const char *__s) attribute_hidden; + +/* #include <unistd.h> */ +extern ssize_t __read(int __fd, void *__buf, size_t __nbytes) attribute_hidden; +extern ssize_t __write(int __fd, __const void *__buf, size_t __n) attribute_hidden; +extern int __close(int __fd) attribute_hidden; + +/* #include <signal.h> */ +extern int __sigprocmask (int __how, __const __sigset_t *__restrict __set, + __sigset_t *__restrict __oset) attribute_hidden; + +/* #include <sys/time.h> */ +# if 0 /* undoable here */ +# define __need_timeval +# include <bits/time.h> +extern int __gettimeofday(struct timeval *__restrict __tv, *__restrict __timezone__ptr_t __tz) attribute_hidden; +# else +# define gettimeofday __gettimeofday +# endif + +# elif IS_IN_libpthread + +# define gettimeofday __libc_gettimeofday + +# else + +# define open __libc_open + +# endif +#endif + #endif /* _LIBC_INTERNAL_H */ diff --git a/include/ssp-internal.h b/include/ssp-internal.h index 81a83f70c..cd44b4f5d 100644 --- a/include/ssp-internal.h +++ b/include/ssp-internal.h @@ -21,6 +21,10 @@ #include <signal.h> #include <linux/unistd.h> +#ifndef errno +extern int errno; +#endif + #ifndef __SSP_QUICK_CANARY__ #define __NR___kernel_open __NR_open static __always_inline _syscall3(int,__kernel_open,const char *,path,int,flags,__kernel_mode_t,mode); diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 788468180..3b82571a3 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -2,19 +2,19 @@ This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ #ifndef _SYSCALL_H #define _SYSCALL_H 1 diff --git a/libc/inet/Makefile b/libc/inet/Makefile index 6d59e1856..11f362a5e 100644 --- a/libc/inet/Makefile +++ b/libc/inet/Makefile @@ -1,100 +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 - -ifeq ($(strip $(UCLIBC_HAS_RPC)),y) - DIRS=rpc -else - DIRS= -endif -ALL_SUBDIRS = rpc - -MSRC=addr.c -MOBJ=inet_aton.o inet_addr.o inet_ntoa.o inet_makeaddr.o inet_lnaof.o \ - inet_netof.o - -MSRC2=resolv.c -MOBJ2=encodeh.o decodeh.o encoded.o decoded.o lengthd.o encodeq.o \ - decodeq.o lengthq.o encodea.o decodea.o encodep.o decodep.o \ - formquery.o dnslookup.o resolveaddress.o opennameservers.o \ - closenameservers.o resolvename.o gethostbyname.o res_init.o \ - res_query.o gethostbyaddr.o read_etc_hosts_r.o get_hosts_byname_r.o \ - get_hosts_byaddr_r.o gethostbyname2.o getnameinfo.o gethostent.o \ - gethostbyname_r.o gethostbyname2_r.o gethostbyaddr_r.o \ - res_comp.o ns_name.o - -MSRC3=socketcalls.c -MOBJ3= accept.o bind.o connect.o getpeername.o getsockname.o getsockopt.o \ - listen.o recv.o recvfrom.o recvmsg.o send.o sendmsg.o sendto.o \ - setsockopt.o shutdown.o socket.o socketpair.o - -CSRC =getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \ - inet_net.c ntop.c herror.c if_nametoindex.c gai_strerror.c getaddrinfo.c \ - in6_addr.c ether_addr.c ntohl.c - -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -OBJS=$(MOBJ) $(MOBJ2) $(MOBJ3) $(COBJS) - -OBJ_LIST=../obj.inet - -all: $(OBJ_LIST) subdirs - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, inet/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(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 - -$(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)) : dummy - $(MAKE) -C $(patsubst _dir_%, %, $@) - -$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : 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/inet/addr.c b/libc/inet/addr.c index 5c4005a18..a03b7575b 100644 --- a/libc/inet/addr.c +++ b/libc/inet/addr.c @@ -16,6 +16,10 @@ * Changed to use _int10tostr. */ +#define _uintmaxtostr __libc__uintmaxtostr +/* for some reason this does not work here */ +#define memmove __memmove + #define _GNU_SOURCE #define __FORCE_GLIBC #include <features.h> @@ -142,7 +146,7 @@ char *inet_ntoa(struct in_addr in) * Formulate an Internet address from network + host. Used in * building addresses stored in the ifnet structure. */ -struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host) +struct in_addr attribute_hidden __inet_makeaddr(in_addr_t net, in_addr_t host) { in_addr_t addr; @@ -157,6 +161,7 @@ struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host) addr = htonl(addr); return (*(struct in_addr *)&addr); } +strong_alias(__inet_makeaddr,inet_makeaddr) #endif diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 553d5a944..d2d0e151e 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -44,6 +44,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */ +/* strdupa is using these */ +#if 0 +#define memcpy __memcpy +#define strlen __strlen +#endif + #define _GNU_SOURCE #define __FORCE_GLIBC #include <features.h> @@ -149,7 +155,7 @@ static int addrconfig (sa_family_t af) ret = (errno == EMFILE) ? 1 : 0; else { - close(s); + __close(s); ret = 1; } __set_errno (saved_errno); @@ -173,10 +179,10 @@ gaih_local (const char *name, const struct gaih_service *service, if (name != NULL) { - if (strcmp(name, "localhost") && - strcmp(name, "local") && - strcmp(name, "unix") && - strcmp(name, utsname.nodename)) + if (__strcmp(name, "localhost") && + __strcmp(name, "local") && + __strcmp(name, "unix") && + __strcmp(name, utsname.nodename)) return GAIH_OKIFUNSPEC | -EAI_NONAME; } @@ -203,7 +209,7 @@ gaih_local (const char *name, const struct gaih_service *service, *pai = malloc (sizeof (struct addrinfo) + sizeof (struct sockaddr_un) + ((req->ai_flags & AI_CANONNAME) - ? (strlen(utsname.nodename) + 1): 0)); + ? (__strlen(utsname.nodename) + 1): 0)); if (*pai == NULL) return -EAI_MEMORY; @@ -221,22 +227,22 @@ gaih_local (const char *name, const struct gaih_service *service, #endif /* SALEN */ ((struct sockaddr_un *)(*pai)->ai_addr)->sun_family = AF_LOCAL; - memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX); + __memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX); if (service) { struct sockaddr_un *sunp = (struct sockaddr_un *) (*pai)->ai_addr; - if (strchr (service->name, '/') != NULL) + if (__strchr (service->name, '/') != NULL) { - if (strlen (service->name) >= sizeof (sunp->sun_path)) + if (__strlen (service->name) >= sizeof (sunp->sun_path)) return GAIH_OKIFUNSPEC | -EAI_SERVICE; - strcpy (sunp->sun_path, service->name); + __strcpy (sunp->sun_path, service->name); } else { - if (strlen (P_tmpdir "/") + 1 + strlen (service->name) >= + if (__strlen (P_tmpdir "/") + 1 + __strlen (service->name) >= sizeof (sunp->sun_path)) return GAIH_OKIFUNSPEC | -EAI_SERVICE; @@ -258,7 +264,7 @@ gaih_local (const char *name, const struct gaih_service *service, } if (req->ai_flags & AI_CANONNAME) - (*pai)->ai_canonname = strcpy ((char *) *pai + sizeof (struct addrinfo) + (*pai)->ai_canonname = __strcpy ((char *) *pai + sizeof (struct addrinfo) + sizeof (struct sockaddr_un), utsname.nodename); else @@ -338,7 +344,7 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp, } \ (*pat)->next = NULL; \ (*pat)->family = _family; \ - memcpy ((*pat)->addr, h->h_addr_list[i], \ + __memcpy ((*pat)->addr, h->h_addr_list[i], \ sizeof(_type)); \ pat = &((*pat)->next); \ } \ @@ -489,7 +495,7 @@ gaih_inet (const char *name, const struct gaih_service *service, char *namebuf = strdupa (name); char *scope_delim; - scope_delim = strchr (namebuf, SCOPE_DELIMITER); + scope_delim = __strchr (namebuf, SCOPE_DELIMITER); if (scope_delim != NULL) *scope_delim = '\0'; @@ -572,12 +578,12 @@ gaih_inet (const char *name, const struct gaih_service *service, { struct gaih_addrtuple *atr; atr = at = alloca (sizeof (struct gaih_addrtuple)); - memset (at, '\0', sizeof (struct gaih_addrtuple)); + __memset (at, '\0', sizeof (struct gaih_addrtuple)); if (req->ai_family == 0) { at->next = alloca (sizeof (struct gaih_addrtuple)); - memset (at->next, '\0', sizeof (struct gaih_addrtuple)); + __memset (at->next, '\0', sizeof (struct gaih_addrtuple)); } #if __UCLIBC_HAS_IPV6__ @@ -586,7 +592,7 @@ gaih_inet (const char *name, const struct gaih_service *service, extern const struct in6_addr __in6addr_loopback; at->family = AF_INET6; if ((req->ai_flags & AI_PASSIVE) == 0) - memcpy (at->addr, &__in6addr_loopback, sizeof (struct in6_addr)); + __memcpy (at->addr, &__in6addr_loopback, sizeof (struct in6_addr)); atr = at->next; } #endif @@ -658,7 +664,7 @@ gaih_inet (const char *name, const struct gaih_service *service, if (c == NULL) return GAIH_OKIFUNSPEC | -EAI_NONAME; - namelen = strlen (c) + 1; + namelen = __strlen (c) + 1; } else namelen = 0; @@ -702,7 +708,7 @@ gaih_inet (const char *name, const struct gaih_service *service, sin6p->sin6_flowinfo = 0; if (at2->family == AF_INET6) { - memcpy (&sin6p->sin6_addr, + __memcpy (&sin6p->sin6_addr, at2->addr, sizeof (struct in6_addr)); } else @@ -710,7 +716,7 @@ gaih_inet (const char *name, const struct gaih_service *service, sin6p->sin6_addr.s6_addr32[0] = 0; sin6p->sin6_addr.s6_addr32[1] = 0; sin6p->sin6_addr.s6_addr32[2] = htonl(0x0000ffff); - memcpy(&sin6p->sin6_addr.s6_addr32[3], + __memcpy(&sin6p->sin6_addr.s6_addr32[3], at2->addr, sizeof (sin6p->sin6_addr.s6_addr32[3])); } sin6p->sin6_port = st2->port; @@ -722,17 +728,17 @@ gaih_inet (const char *name, const struct gaih_service *service, struct sockaddr_in *sinp = (struct sockaddr_in *) (*pai)->ai_addr; - memcpy (&sinp->sin_addr, + __memcpy (&sinp->sin_addr, at2->addr, sizeof (struct in_addr)); sinp->sin_port = st2->port; - memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero)); + __memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero)); } if (c) { (*pai)->ai_canonname = ((void *) (*pai) + sizeof (struct addrinfo) + socklen); - strcpy ((*pai)->ai_canonname, c); + __strcpy ((*pai)->ai_canonname, c); } else (*pai)->ai_canonname = NULL; diff --git a/libc/inet/getnetbynm.c b/libc/inet/getnetbynm.c index 456c337c1..5479c654b 100644 --- a/libc/inet/getnetbynm.c +++ b/libc/inet/getnetbynm.c @@ -30,10 +30,10 @@ getnetbyname(const char *name) setnetent(_net_stayopen); while ((p = getnetent())) { - if (strcmp(p->n_name, name) == 0) + if (__strcmp(p->n_name, name) == 0) break; for (cp = p->n_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) + if (__strcmp(*cp, name) == 0) goto found; } found: diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c index c9f35f149..e7221f3a2 100644 --- a/libc/inet/getproto.c +++ b/libc/inet/getproto.c @@ -51,6 +51,8 @@ ** SUCH DAMAGE. */ +#define strpbrk __strpbrk + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -211,10 +213,10 @@ int getprotobyname_r(const char *name, LOCK; setprotoent(proto_stayopen); while (!(ret=getprotoent_r(result_buf, buf, buflen, result))) { - if (strcmp(result_buf->p_name, name) == 0) + if (__strcmp(result_buf->p_name, name) == 0) break; for (cp = result_buf->p_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) + if (__strcmp(*cp, name) == 0) goto found; } found: diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c index cbe5c503b..d5402ba3e 100644 --- a/libc/inet/getservice.c +++ b/libc/inet/getservice.c @@ -51,6 +51,7 @@ ** SUCH DAMAGE. */ +#define strpbrk __strpbrk #define __FORCE_GLIBC #define _GNU_SOURCE @@ -238,14 +239,14 @@ int getservbyname_r(const char *name, const char *proto, LOCK; setservent(serv_stayopen); while (!(ret=getservent_r(result_buf, buf, buflen, result))) { - if (strcmp(name, result_buf->s_name) == 0) + if (__strcmp(name, result_buf->s_name) == 0) goto gotname; for (cp = result_buf->s_aliases; *cp; cp++) - if (strcmp(name, *cp) == 0) + if (__strcmp(name, *cp) == 0) goto gotname; continue; gotname: - if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) + if (proto == 0 || __strcmp(result_buf->s_proto, proto) == 0) break; } if (!serv_stayopen) @@ -265,7 +266,7 @@ int getservbyport_r(int port, const char *proto, while (!(ret=getservent_r(result_buf, buf, buflen, result))) { if (result_buf->s_port != port) continue; - if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) + if (proto == 0 || __strcmp(result_buf->s_proto, proto) == 0) break; } if (!serv_stayopen) diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c index e90cf256c..be3bacb96 100644 --- a/libc/inet/hostid.c +++ b/libc/inet/hostid.c @@ -18,10 +18,10 @@ int sethostid(long int new_id) int ret; if (geteuid() || getuid()) return __set_errno(EPERM); - if ((fd=open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1; - ret = write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id) + if ((fd=__open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1; + ret = __write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id) ? 0 : -1; - close (fd); + __close (fd); return ret; } @@ -34,12 +34,12 @@ long int gethostid(void) * It is not an error if we cannot read this file. It is not even an * error if we cannot read all the bytes, we just carry on trying... */ - if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,(void *)&id,sizeof(id))) + if ((fd=__open(HOSTID,O_RDONLY))>=0 && __read(fd,(void *)&id,sizeof(id))) { - close (fd); + __close (fd); return id; } - if (fd >= 0) close (fd); + if (fd >= 0) __close (fd); /* Try some methods of returning a unique 32 bit id. Clearly IP * numbers, if on the internet, will have a unique address. If they @@ -65,7 +65,7 @@ long int gethostid(void) */ return 0; else { - memcpy((char *) &in, (char *) hp->h_addr, hp->h_length); + __memcpy((char *) &in, (char *) hp->h_addr, hp->h_length); /* Just so it doesn't look exactly like the IP addr */ return(in.s_addr<<16|in.s_addr>>16); diff --git a/libc/inet/if_nametoindex.c b/libc/inet/if_nametoindex.c index 45b319f97..0e556dba8 100644 --- a/libc/inet/if_nametoindex.c +++ b/libc/inet/if_nametoindex.c @@ -51,15 +51,15 @@ unsigned int if_nametoindex(const char* ifname) fd = __opensock(); if (fd < 0) return 0; - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); + __strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(fd,SIOCGIFINDEX,&ifr) < 0) { int saved_errno = errno; - close(fd); + __close(fd); if (saved_errno == EINVAL) __set_errno(ENOSYS); return 0; } - close(fd); + __close(fd); return ifr.ifr_ifindex; #endif /* SIOCGIFINDEX */ @@ -103,7 +103,7 @@ struct if_nameindex * if_nameindex (void) do { ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len = rq_len); if (ifc.ifc_buf == NULL || ioctl(fd, SIOCGIFCONF, &ifc) < 0) { - close(fd); + __close(fd); return NULL; } rq_len *= 2; @@ -113,21 +113,21 @@ struct if_nameindex * if_nameindex (void) idx = malloc ((nifs + 1) * sizeof(struct if_nameindex)); if (idx == NULL) { - close(fd); + __close(fd); __set_errno(ENOBUFS); return NULL; } for (i = 0; i < nifs; ++i) { struct ifreq *ifr = &ifc.ifc_req[i]; - idx[i].if_name = strdup (ifr->ifr_name); + idx[i].if_name = __strdup (ifr->ifr_name); if (idx[i].if_name == NULL || ioctl(fd,SIOCGIFINDEX,ifr) < 0) { int saved_errno = errno; unsigned int j; for (j = 0; j < i; ++j) free (idx[j].if_name); free(idx); - close(fd); + __close(fd); if (saved_errno == EINVAL) saved_errno = ENOSYS; else if (saved_errno == ENOMEM) @@ -141,7 +141,7 @@ struct if_nameindex * if_nameindex (void) idx[i].if_index = 0; idx[i].if_name = NULL; - close(fd); + __close(fd); return idx; #endif } @@ -161,13 +161,13 @@ char * if_indextoname (unsigned int ifindex, char *ifname) ifr.ifr_ifindex = ifindex; if (ioctl (fd, SIOCGIFNAME, &ifr) < 0) { saved_errno = errno; - close (fd); + __close (fd); __set_errno (saved_errno); return NULL; } - close (fd); + __close (fd); - return strncpy (ifname, ifr.ifr_name, IFNAMSIZ); + return __strncpy (ifname, ifr.ifr_name, IFNAMSIZ); #else struct if_nameindex *idx; struct if_nameindex *p; @@ -177,7 +177,7 @@ char * if_indextoname (unsigned int ifindex, char *ifname) if (idx != NULL) { for (p = idx; p->if_index || p->if_name; ++p) { if (p->if_index == ifindex) { - result = strncpy (ifname, p->if_name, IFNAMSIZ); + result = __strncpy (ifname, p->if_name, IFNAMSIZ); break; } } diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c index 35c302950..65ff1842b 100644 --- a/libc/inet/ntop.c +++ b/libc/inet/ntop.c @@ -76,12 +76,12 @@ inet_ntop4(const u_char *src, char *dst, size_t size) } tmp[i - 1] = '\0'; - if (strlen (tmp) > size) { + if (__strlen (tmp) > size) { __set_errno (ENOSPC); return (NULL); } - return strcpy(dst, tmp); + return __strcpy(dst, tmp); } @@ -114,7 +114,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) * Copy the input (bytewise) array into a wordwise array. * Find the longest run of 0x00's in src[] for :: shorthanding. */ - memset(words, '\0', sizeof words); + __memset(words, '\0', sizeof words); for (i = 0; i < 16; i += 2) words[i / 2] = (src[i] << 8) | src[i + 1]; best.base = -1; @@ -160,7 +160,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) return (NULL); - tp += strlen(tp); + tp += __strlen(tp); break; } tp += sprintf(tp, "%x", words[i]); @@ -177,7 +177,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size) __set_errno (ENOSPC); return (NULL); } - return strcpy(dst, tmp); + return __strcpy(dst, tmp); } #endif /* __UCLIBC_HAS_IPV6__ */ @@ -224,7 +224,7 @@ inet_pton4(const char *src, u_char *dst) } if (octets < 4) return (0); - memcpy(dst, tmp, 4); + __memcpy(dst, tmp, 4); return (1); } @@ -261,7 +261,7 @@ inet_pton6(const char *src, u_char *dst) u_int val; - tp = memset(tmp, '\0', 16); + tp = __memset(tmp, '\0', 16); endp = tp + 16; colonp = NULL; /* Leading :: requires some special handling. */ @@ -274,7 +274,7 @@ inet_pton6(const char *src, u_char *dst) while ((ch = tolower (*src++)) != '\0') { const char *pch; - pch = strchr(xdigits, ch); + pch = __strchr(xdigits, ch); if (pch != NULL) { val <<= 4; val |= (pch - xdigits); @@ -333,7 +333,7 @@ inet_pton6(const char *src, u_char *dst) } if (tp != endp) return (0); - memcpy(dst, tmp, 16); + __memcpy(dst, tmp, 16); return (1); } diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index eab86c0e8..bcc4e78f8 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -133,6 +133,11 @@ * */ +#define strnlen __strnlen +#define strncat __strncat +#define strstr __strstr +#define random __random + #define __FORCE_GLIBC #include <features.h> #include <string.h> @@ -232,50 +237,55 @@ extern int __get_hosts_byname_r(const char * name, int type, struct hostent * result_buf, char * buf, size_t buflen, struct hostent ** result, - int * h_errnop); + int * h_errnop) attribute_hidden; extern int __get_hosts_byaddr_r(const char * addr, int len, int type, struct hostent * result_buf, char * buf, size_t buflen, struct hostent ** result, - int * h_errnop); -extern void __open_etc_hosts(FILE **fp); + int * h_errnop) attribute_hidden; +extern void __open_etc_hosts(FILE **fp) attribute_hidden; extern int __read_etc_hosts_r(FILE *fp, const char * name, int type, enum etc_hosts_action action, struct hostent * result_buf, char * buf, size_t buflen, struct hostent ** result, - int * h_errnop); + int * h_errnop) attribute_hidden; extern int __dns_lookup(const char * name, int type, int nscount, - char ** nsip, unsigned char ** outpacket, struct resolv_answer * a); + char ** nsip, unsigned char ** outpacket, struct resolv_answer * a) attribute_hidden; -extern int __encode_dotted(const char * dotted, unsigned char * dest, int maxlen); +extern int __encode_dotted(const char * dotted, unsigned char * dest, int maxlen) attribute_hidden; extern int __decode_dotted(const unsigned char * message, int offset, - char * dest, int maxlen); -extern int __length_dotted(const unsigned char * message, int offset); -extern int __encode_header(struct resolv_header * h, unsigned char * dest, int maxlen); -extern int __decode_header(unsigned char * data, struct resolv_header * h); + char * dest, int maxlen) attribute_hidden; +extern int __length_dotted(const unsigned char * message, int offset) attribute_hidden; +extern int __encode_header(struct resolv_header * h, unsigned char * dest, int maxlen) attribute_hidden; +extern int __decode_header(unsigned char * data, struct resolv_header * h) attribute_hidden; extern int __encode_question(struct resolv_question * q, - unsigned char * dest, int maxlen); + unsigned char * dest, int maxlen) attribute_hidden; extern int __decode_question(unsigned char * message, int offset, struct resolv_question * q); extern int __encode_answer(struct resolv_answer * a, - unsigned char * dest, int maxlen); + unsigned char * dest, int maxlen) attribute_hidden; extern int __decode_answer(unsigned char * message, int offset, - struct resolv_answer * a); -extern int __length_question(unsigned char * message, int offset); -extern int __open_nameservers(void); -extern void __close_nameservers(void); + struct resolv_answer * a) attribute_hidden; +extern int __length_question(unsigned char * message, int offset) attribute_hidden; +extern int __open_nameservers(void) attribute_hidden; +extern void __close_nameservers(void) attribute_hidden; extern int __dn_expand(const u_char *, const u_char *, const u_char *, char *, int); -extern int __ns_name_uncompress(const u_char *, const u_char *, - const u_char *, char *, size_t); -extern int __ns_name_ntop(const u_char *, char *, size_t); -extern int __ns_name_unpack(const u_char *, const u_char *, const u_char *, - u_char *, size_t); +extern int __libc_ns_name_uncompress(const u_char *, const u_char *, + const u_char *, char *, size_t) attribute_hidden; +extern int __libc_ns_name_ntop(const u_char *, char *, size_t) attribute_hidden; +extern int __libc_ns_name_unpack(const u_char *, const u_char *, const u_char *, + u_char *, size_t) attribute_hidden; + +extern int __gethostent_r (struct hostent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct hostent **__restrict __result, + int *__restrict __h_errnop) attribute_hidden; #ifdef L_encodeh -int __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen) +int attribute_hidden __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen) { if (maxlen < HFIXEDSZ) return -1; @@ -302,7 +312,7 @@ int __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen) #endif #ifdef L_decodeh -int __decode_header(unsigned char *data, struct resolv_header *h) +int attribute_hidden __decode_header(unsigned char *data, struct resolv_header *h) { h->id = (data[0] << 8) | data[1]; h->qr = (data[2] & 0x80) ? 1 : 0; @@ -326,19 +336,19 @@ int __decode_header(unsigned char *data, struct resolv_header *h) This routine is fairly dumb, and doesn't attempt to compress the data */ -int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen) +int attribute_hidden __encode_dotted(const char *dotted, unsigned char *dest, int maxlen) { int used = 0; while (dotted && *dotted) { - char *c = strchr(dotted, '.'); - int l = c ? c - dotted : strlen(dotted); + char *c = __strchr(dotted, '.'); + int l = c ? c - dotted : __strlen(dotted); if (l >= (maxlen - used - 1)) return -1; dest[used++] = l; - memcpy(dest + used, dotted, l); + __memcpy(dest + used, dotted, l); used += l; if (c) @@ -360,7 +370,7 @@ int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen) /* Decode a dotted string from nameserver transport-level encoding. This routine understands compressed data. */ -int __decode_dotted(const unsigned char *data, int offset, +int attribute_hidden __decode_dotted(const unsigned char *data, int offset, char *dest, int maxlen) { int l; @@ -386,7 +396,7 @@ int __decode_dotted(const unsigned char *data, int offset, if ((used + l + 1) >= maxlen) return -1; - memcpy(dest + used, data + offset, l); + __memcpy(dest + used, data + offset, l); offset += l; used += l; if (measure) @@ -411,7 +421,7 @@ int __decode_dotted(const unsigned char *data, int offset, #ifdef L_lengthd -int __length_dotted(const unsigned char *data, int offset) +int attribute_hidden __length_dotted(const unsigned char *data, int offset) { int orig_offset = offset; int l; @@ -434,7 +444,7 @@ int __length_dotted(const unsigned char *data, int offset) #endif #ifdef L_encodeq -int __encode_question(struct resolv_question *q, +int attribute_hidden __encode_question(struct resolv_question *q, unsigned char *dest, int maxlen) { int i; @@ -471,7 +481,7 @@ int __decode_question(unsigned char *message, int offset, offset += i; - q->dotted = strdup(temp); + q->dotted = __strdup(temp); q->qtype = (message[offset + 0] << 8) | message[offset + 1]; q->qclass = (message[offset + 2] << 8) | message[offset + 3]; @@ -480,7 +490,7 @@ int __decode_question(unsigned char *message, int offset, #endif #ifdef L_lengthq -int __length_question(unsigned char *message, int offset) +int attribute_hidden __length_question(unsigned char *message, int offset) { int i; @@ -493,7 +503,7 @@ int __length_question(unsigned char *message, int offset) #endif #ifdef L_encodea -int __encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen) +int attribute_hidden __encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen) { int i; @@ -517,14 +527,14 @@ int __encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen) *dest++ = (a->ttl & 0x000000ff) >> 0; *dest++ = (a->rdlength & 0xff00) >> 8; *dest++ = (a->rdlength & 0x00ff) >> 0; - memcpy(dest, a->rdata, a->rdlength); + __memcpy(dest, a->rdata, a->rdlength); return i + RRFIXEDSZ + a->rdlength; } #endif #ifdef L_decodea -int __decode_answer(unsigned char *message, int offset, +int attribute_hidden __decode_answer(unsigned char *message, int offset, struct resolv_answer *a) { char temp[256]; @@ -536,7 +546,7 @@ int __decode_answer(unsigned char *message, int offset, message += offset + i; - a->dotted = strdup(temp); + a->dotted = __strdup(temp); a->atype = (message[0] << 8) | message[1]; message += 2; a->aclass = (message[0] << 8) | message[1]; @@ -627,7 +637,7 @@ int __form_query(int id, const char *name, int type, unsigned char *packet, struct resolv_question q; int i, j; - memset(&h, 0, sizeof(h)); + __memset(&h, 0, sizeof(h)); h.id = id; h.qdcount = 1; @@ -667,7 +677,7 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; * look anyways. */ static int ns=0, id=1; -int __dns_lookup(const char *name, int type, int nscount, char **nsip, +int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char **nsip, unsigned char **outpacket, struct resolv_answer *a) { int i, j, len, fd, pos, rc; @@ -703,11 +713,11 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, while (retries < MAX_RETRIES) { if (fd != -1) - close(fd); + __close(fd); - memset(packet, 0, PACKETSZ); + __memset(packet, 0, PACKETSZ); - memset(&h, 0, sizeof(h)); + __memset(&h, 0, sizeof(h)); ++local_id; local_id &= 0xffff; @@ -723,7 +733,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, if (i < 0) goto fail; - strncpy(lookup,name,MAXDNAME); + __strncpy(lookup,name,MAXDNAME); if (variant >= 0) { BIGLOCK; if (variant < __searchdomains) { @@ -854,7 +864,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, ma.buf = a->buf; ma.buflen = a->buflen; ma.add_count = a->add_count; - memcpy(a, &ma, sizeof(ma)); + __memcpy(a, &ma, sizeof(ma)); if (a->atype != T_SIG && (0 == a->buf || (type != T_A && type != T_AAAA))) { break; @@ -886,7 +896,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, ma.rdlength, a->rdlength); goto again; } - memcpy(a->buf + (a->add_count * ma.rdlength), ma.rdata, ma.rdlength); + __memcpy(a->buf + (a->add_count * ma.rdlength), ma.rdata, ma.rdlength); ++a->add_count; } } @@ -894,7 +904,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, DPRINTF("Answer name = |%s|\n", a->dotted); DPRINTF("Answer type = |%d|\n", a->atype); - close(fd); + __close(fd); if (outpacket) *outpacket = packet; @@ -946,7 +956,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip, fail: if (fd != -1) - close(fd); + __close(fd); if (lookup) free(lookup); if (packet) @@ -978,7 +988,7 @@ pthread_mutex_t __resolv_lock = PTHREAD_MUTEX_INITIALIZER; * unix systems, we can have a list of nameservers after the keyword. */ -int __open_nameservers() +int attribute_hidden __open_nameservers() { FILE *fp; int i; @@ -1011,21 +1021,21 @@ int __open_nameservers() *p++ = '\0'; } - if (strcmp(argv[0], "nameserver") == 0) { + if (__strcmp(argv[0], "nameserver") == 0) { for (i = 1; i < argc && __nameservers < MAX_SERVERS; i++) { - __nameserver[__nameservers++] = strdup(argv[i]); + __nameserver[__nameservers++] = __strdup(argv[i]); DPRINTF("adding nameserver %s\n", argv[i]); } } /* domain and search are mutually exclusive, the last one wins */ - if (strcmp(argv[0],"domain")==0 || strcmp(argv[0],"search")==0) { + if (__strcmp(argv[0],"domain")==0 || __strcmp(argv[0],"search")==0) { while (__searchdomains > 0) { free(__searchdomain[--__searchdomains]); __searchdomain[__searchdomains] = NULL; } for (i=1; i < argc && __searchdomains < MAX_SEARCH; i++) { - __searchdomain[__searchdomains++] = strdup(argv[i]); + __searchdomain[__searchdomains++] = __strdup(argv[i]); DPRINTF("adding search %s\n", argv[i]); } } @@ -1045,7 +1055,7 @@ int __open_nameservers() #ifdef L_closenameservers -void __close_nameservers(void) +void attribute_hidden __close_nameservers(void) { BIGLOCK; while (__nameservers > 0) { @@ -1187,7 +1197,7 @@ int res_query(const char *dname, int class, int type, return(-1); } - memset((char *) &a, '\0', sizeof(a)); + __memset((char *) &a, '\0', sizeof(a)); BIGLOCK; __nameserversXX=__nameservers; @@ -1204,7 +1214,7 @@ int res_query(const char *dname, int class, int type, if (a.atype == type) { /* CNAME*/ int len = MIN(anslen, i); - memcpy(answer, packet, len); + __memcpy(answer, packet, len); if (packet) free(packet); return(len); @@ -1380,19 +1390,19 @@ int res_querydomain(name, domain, class, type, answer, anslen) * Check for trailing '.'; * copy without '.' if present. */ - n = strlen(name); + n = __strlen(name); if (n + 1 > sizeof(nbuf)) { h_errno = NO_RECOVERY; return (-1); } if (n > 0 && name[--n] == '.') { - strncpy(nbuf, name, n); + __strncpy(nbuf, name, n); nbuf[n] = '\0'; } else longname = name; } else { - n = strlen(name); - d = strlen(domain); + n = __strlen(name); + d = __strlen(domain); if (n + 1 + d + 1 > sizeof(nbuf)) { h_errno = NO_RECOVERY; return (-1); @@ -1430,7 +1440,7 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type) #ifdef L_read_etc_hosts_r -void __open_etc_hosts(FILE **fp) +void attribute_hidden __open_etc_hosts(FILE **fp) { if ((*fp = fopen("/etc/hosts", "r")) == NULL) { *fp = fopen("/etc/config/hosts", "r"); @@ -1438,7 +1448,7 @@ void __open_etc_hosts(FILE **fp) return; } -int __read_etc_hosts_r(FILE * fp, const char * name, int type, +int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type, enum etc_hosts_action action, struct hostent * result_buf, char * buf, size_t buflen, @@ -1509,7 +1519,7 @@ int __read_etc_hosts_r(FILE * fp, const char * name, int type, *h_errnop=HOST_NOT_FOUND; while (fgets(buf, buflen, fp)) { - if ((cp = strchr(buf, '#'))) + if ((cp = __strchr(buf, '#'))) *cp = '\0'; DPRINTF("Looking at: %s\n", buf); aliases = 0; @@ -1534,7 +1544,7 @@ int __read_etc_hosts_r(FILE * fp, const char * name, int type, /* Return whatever the next entry happens to be. */ break; } else if (action==GET_HOSTS_BYADDR) { - if (strcmp(name, alias[0]) != 0) + if (__strcmp(name, alias[0]) != 0) continue; } else { /* GET_HOSTS_BYNAME */ @@ -1610,7 +1620,7 @@ void sethostent (int stay_open) UNLOCK; } -int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, +int attribute_hidden __gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, struct hostent **result, int *h_errnop) { int ret; @@ -1633,6 +1643,7 @@ int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, UNLOCK; return(ret); } +strong_alias(__gethostent_r,gethostent_r) struct hostent *gethostent (void) { @@ -1648,7 +1659,7 @@ struct hostent *gethostent (void) struct hostent *host; LOCK; - gethostent_r(&h, buf, sizeof(buf), &host, &h_errno); + __gethostent_r(&h, buf, sizeof(buf), &host, &h_errno); UNLOCK; return(host); } @@ -1656,7 +1667,7 @@ struct hostent *gethostent (void) #ifdef L_get_hosts_byname_r -int __get_hosts_byname_r(const char * name, int type, +int attribute_hidden __get_hosts_byname_r(const char * name, int type, struct hostent * result_buf, char * buf, size_t buflen, struct hostent ** result, @@ -1669,7 +1680,7 @@ int __get_hosts_byname_r(const char * name, int type, #ifdef L_get_hosts_byaddr_r -int __get_hosts_byaddr_r(const char * addr, int len, int type, +int attribute_hidden __get_hosts_byaddr_r(const char * addr, int len, int type, struct hostent * result_buf, char * buf, size_t buflen, struct hostent ** result, @@ -1764,12 +1775,12 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, && (getdomainname (domain, sizeof(domain)) == 0) && (c = strstr (h->h_name, domain)) && (c != h->h_name) && (*(--c) == '.')) { - strncpy (host, h->h_name, + __strncpy (host, h->h_name, min(hostlen, (size_t) (c - h->h_name))); host[min(hostlen - 1, (size_t) (c - h->h_name))] = '\0'; ok = 1; } else { - strncpy (host, h->h_name, hostlen); + __strncpy (host, h->h_name, hostlen); ok = 1; } } @@ -1810,7 +1821,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, if (if_indextoname (scopeid, scopeptr) == NULL) ++ni_numericscope; else - scopelen = strlen (scopebuf); + scopelen = __strlen (scopebuf); } else { ++ni_numericscope; } @@ -1824,7 +1835,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, if (real_hostlen + scopelen + 1 > hostlen) return EAI_SYSTEM; - memcpy (host + real_hostlen, scopebuf, scopelen + 1); + __memcpy (host + real_hostlen, scopebuf, scopelen + 1); } #endif } else @@ -1847,7 +1858,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, struct utsname utsname; if (!uname (&utsname)) { - strncpy (host, utsname.nodename, hostlen); + __strncpy (host, utsname.nodename, hostlen); break; }; }; @@ -1857,7 +1868,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, return EAI_NONAME; } - strncpy (host, "localhost", hostlen); + __strncpy (host, "localhost", hostlen); break; default: @@ -1875,7 +1886,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, s = getservbyport (((const struct sockaddr_in *) sa)->sin_port, ((flags & NI_DGRAM) ? "udp" : "tcp")); if (s) { - strncpy (serv, s->s_name, servlen); + __strncpy (serv, s->s_name, servlen); break; } } @@ -1884,7 +1895,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, break; case AF_LOCAL: - strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen); + __strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen); break; } } @@ -1969,7 +1980,7 @@ int gethostbyname_r(const char * name, if (buflen<256) return ERANGE; - strncpy(buf, name, buflen); + __strncpy(buf, name, buflen); alias[0] = buf; alias[1] = NULL; @@ -2013,7 +2024,7 @@ int gethostbyname_r(const char * name, } else if(a.add_count > 0) { - memmove(buf - sizeof(struct in_addr*)*2, buf, a.add_count * a.rdlength); + __memmove(buf - sizeof(struct in_addr*)*2, buf, a.add_count * a.rdlength); addr_list = (struct in_addr**)(buf + a.add_count * a.rdlength); addr_list[0] = in; for (i = a.add_count-1; i>=0; --i) @@ -2023,11 +2034,11 @@ int gethostbyname_r(const char * name, buf = (char*)&addr_list[a.add_count + 2]; } - strncpy(buf, a.dotted, buflen); + __strncpy(buf, a.dotted, buflen); free(a.dotted); if (a.atype == T_A) { /* ADDRESS */ - memcpy(in, a.rdata, sizeof(*in)); + __memcpy(in, a.rdata, sizeof(*in)); result_buf->h_name = buf; result_buf->h_addrtype = AF_INET; result_buf->h_length = sizeof(*in); @@ -2126,7 +2137,7 @@ int gethostbyname2_r(const char *name, int family, if (buflen<256) return ERANGE; - strncpy(buf, name, buflen); + __strncpy(buf, name, buflen); /* First check if this is already an address */ if (inet_pton(AF_INET6, name, in)) { @@ -2139,7 +2150,7 @@ int gethostbyname2_r(const char *name, int family, return NETDB_SUCCESS; } - memset((char *) &a, '\0', sizeof(a)); + __memset((char *) &a, '\0', sizeof(a)); for (;;) { BIGLOCK; @@ -2154,7 +2165,7 @@ int gethostbyname2_r(const char *name, int family, return TRY_AGAIN; } - strncpy(buf, a.dotted, buflen); + __strncpy(buf, a.dotted, buflen); free(a.dotted); if (a.atype == T_CNAME) { /* CNAME */ @@ -2172,7 +2183,7 @@ int gethostbyname2_r(const char *name, int family, } continue; } else if (a.atype == T_AAAA) { /* ADDRESS */ - memcpy(in, a.rdata, sizeof(*in)); + __memcpy(in, a.rdata, sizeof(*in)); result_buf->h_name = buf; result_buf->h_addrtype = AF_INET6; result_buf->h_length = sizeof(*in); @@ -2220,7 +2231,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, if (!addr) return EINVAL; - memset((char *) &a, '\0', sizeof(a)); + __memset((char *) &a, '\0', sizeof(a)); switch (type) { case AF_INET: @@ -2294,7 +2305,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, if(type == AF_INET) { unsigned char *tmp_addr = (unsigned char *)addr; - memcpy(&in->s_addr, addr, len); + __memcpy(&in->s_addr, addr, len); addr_list[0] = in; @@ -2302,7 +2313,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]); #ifdef __UCLIBC_HAS_IPV6__ } else { - memcpy(in6->s6_addr, addr, len); + __memcpy(in6->s6_addr, addr, len); addr_list6[0] = in6; qp = buf; @@ -2311,7 +2322,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, qp += sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf, (in6->s6_addr[i] >> 4) & 0xf); } - strcpy(qp, "ip6.int"); + __strcpy(qp, "ip6.int"); #endif /* __UCLIBC_HAS_IPV6__ */ } @@ -2330,7 +2341,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, return TRY_AGAIN; } - strncpy(buf, a.dotted, buflen); + __strncpy(buf, a.dotted, buflen); free(a.dotted); if (a.atype == T_CNAME) { /* CNAME */ @@ -2388,7 +2399,7 @@ int gethostbyaddr_r (const void *addr, socklen_t len, int type, int __dn_expand(const u_char *msg, const u_char *eom, const u_char *src, char *dst, int dstsiz) { - int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); + int n = __libc_ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); if (n > 0 && dst[0] == '.') dst[0] = '\0'; @@ -2440,18 +2451,19 @@ static int special(int ch) * note: * Root domain returns as "." not "". */ -int __ns_name_uncompress(const u_char *msg, const u_char *eom, +int attribute_hidden __libc_ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, char *dst, size_t dstsiz) { u_char tmp[NS_MAXCDNAME]; int n; - if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1) + if ((n = __libc_ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1) return (-1); - if (ns_name_ntop(tmp, dst, dstsiz) == -1) + if (__libc_ns_name_ntop(tmp, dst, dstsiz) == -1) return (-1); return (n); } +strong_alias(__libc_ns_name_uncompress,__ns_name_uncompress) /* @@ -2463,7 +2475,7 @@ int __ns_name_uncompress(const u_char *msg, const u_char *eom, * The root is returned as "." * All other domains are returned in non absolute form */ -int __ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { +int attribute_hidden __libc_ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { const u_char *cp; char *dn, *eom; u_char c; @@ -2532,6 +2544,7 @@ int __ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { *dn++ = '\0'; return (dn - dst); } +strong_alias(__libc_ns_name_ntop,__ns_name_ntop) /* * ns_name_unpack(msg, eom, src, dst, dstsiz) @@ -2539,7 +2552,7 @@ int __ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { * return: * -1 if it fails, or consumed octets if it succeeds. */ -int __ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, +int attribute_hidden __libc_ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, u_char *dst, size_t dstsiz) { const u_char *srcp, *dstlim; @@ -2567,7 +2580,7 @@ int __ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, } checked += n + 1; *dstp++ = n; - memcpy(dstp, srcp, n); + __memcpy(dstp, srcp, n); dstp += n; srcp += n; break; @@ -2606,4 +2619,5 @@ int __ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, len = srcp - src; return (len); } +strong_alias(__libc_ns_name_unpack,__ns_name_unpack) #endif /* L_ns_name */ diff --git a/libc/inet/rpc/Makefile b/libc/inet/rpc/Makefile index 72dba26c5..4a8f4a072 100644 --- a/libc/inet/rpc/Makefile +++ b/libc/inet/rpc/Makefile @@ -1,70 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. -# Copyright (C) 2000,2001,2002 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 - -ifeq ($(strip $(UCLIBC_HAS_FULL_RPC)),y) -CSRC :=auth_none.c auth_unix.c authunix_prot.c bindresvport.c \ - clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c clnt_tcp.c \ - clnt_udp.c rpc_dtablesize.c get_myaddress.c getrpcent.c getrpcport.c \ - pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \ - pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \ - svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \ - svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c \ - rtime.c clnt_unix.c svc_unix.c create_xid.c xdr_intXX_t.c rcmd.c \ - rexec.c sa_len.c ruserpass.c rpc_thread.c -else -# For now, only compile the stuff needed to do an NFS mount.... -CSRC:=create_xid.c pmap_clnt.c pmap_getmaps.c pmap_getport.c \ - pmap_prot.c pmap_prot2.c clnt_simple.c clnt_perror.c \ - clnt_tcp.c clnt_udp.c bindresvport.c authunix_prot.c \ - auth_none.c auth_unix.c xdr.c xdr_array.c xdr_rec.c \ - xdr_reference.c xdr_mem.c svc.c svc_auth.c svc_auth_unix.c \ - rpc_callmsg.c rpc_prot.c rpc_dtablesize.c rpc_commondata.c \ - rpc_thread.c rcmd.c rexec.c sa_len.c ruserpass.c rtime.c \ - getrpcent.c -endif - -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -OBJS=$(COBJS) - -OBJ_LIST=../../obj.inet.rpc - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, inet/rpc/%, $(OBJS)) > $(OBJ_LIST) - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) $(PTINC) -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/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c index b2683a651..e7b7aba53 100644 --- a/libc/inet/rpc/auth_none.c +++ b/libc/inet/rpc/auth_none.c @@ -69,8 +69,8 @@ struct authnone_private_s { static struct authnone_private_s *authnone_private; #endif -AUTH * -authnone_create (void) +AUTH attribute_hidden * +__authnone_create (void) { struct authnone_private_s *ap; XDR xdr_stream; @@ -98,6 +98,7 @@ authnone_create (void) } return (&ap->no_client); } +strong_alias(__authnone_create,authnone_create) /*ARGSUSED */ static bool_t diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c index 3e14ba2a5..c02cc309b 100644 --- a/libc/inet/rpc/auth_unix.c +++ b/libc/inet/rpc/auth_unix.c @@ -38,6 +38,9 @@ * for the credentials. */ +#define sysconf __sysconf +#define getegid __getegid + #define __FORCE_GLIBC #include <features.h> @@ -92,8 +95,8 @@ static bool_t marshal_new_auth (AUTH *) internal_function; * Create a unix style authenticator. * Returns an auth handle with the given stuff in it. */ -AUTH * -authunix_create (char *machname, uid_t uid, gid_t gid, int len, +AUTH attribute_hidden * +__authunix_create (char *machname, uid_t uid, gid_t gid, int len, gid_t *aup_gids) { struct authunix_parms aup; @@ -149,7 +152,7 @@ no_memory: au->au_origcred.oa_base = mem_alloc ((u_int) len); if (au->au_origcred.oa_base == NULL) goto no_memory; - memcpy(au->au_origcred.oa_base, mymem, (u_int) len); + __memcpy(au->au_origcred.oa_base, mymem, (u_int) len); /* * set auth handle to reflect new cred. @@ -158,13 +161,14 @@ no_memory: marshal_new_auth (auth); return auth; } +strong_alias(__authunix_create,authunix_create) /* * Returns an auth handle with parameters determined by doing lots of * syscalls. */ -AUTH * -authunix_create_default (void) +AUTH attribute_hidden * +__authunix_create_default (void) { int len; char machname[MAX_MACHINE_NAME + 1]; @@ -184,8 +188,9 @@ authunix_create_default (void) /* This braindamaged Sun code forces us here to truncate the list of groups to NGRPS members since the code in authuxprot.c transforms a fixed array. Grrr. */ - return authunix_create (machname, uid, gid, MIN (NGRPS, len), gids); + return __authunix_create (machname, uid, gid, MIN (NGRPS, len), gids); } +strong_alias(__authunix_create_default,authunix_create_default) /* * authunix operations diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c index 1234f0682..98ce691ee 100644 --- a/libc/inet/rpc/bindresvport.c +++ b/libc/inet/rpc/bindresvport.c @@ -58,7 +58,7 @@ bindresvport (int sd, struct sockaddr_in *sin) if (sin == (struct sockaddr_in *) 0) { sin = &myaddr; - memset (sin, 0, sizeof (*sin)); + __memset (sin, 0, sizeof (*sin)); sin->sin_family = AF_INET; } else if (sin->sin_family != AF_INET) diff --git a/libc/inet/rpc/clnt_generic.c b/libc/inet/rpc/clnt_generic.c index c8fe545c3..3e2998477 100644 --- a/libc/inet/rpc/clnt_generic.c +++ b/libc/inet/rpc/clnt_generic.c @@ -63,11 +63,11 @@ clnt_create (const char *hostname, u_long prog, u_long vers, CLIENT *client; int herr; - if (strcmp (proto, "unix") == 0) + if (__strcmp (proto, "unix") == 0) { - memset ((char *)&sun, 0, sizeof (sun)); + __memset ((char *)&sun, 0, sizeof (sun)); sun.sun_family = AF_UNIX; - strcpy (sun.sun_path, hostname); + __strcpy (sun.sun_path, hostname); sock = RPC_ANYSOCK; client = clntunix_create (&sun, prog, vers, &sock, 0, 0); if (client == NULL) @@ -112,8 +112,8 @@ clnt_create (const char *hostname, u_long prog, u_long vers, } sin.sin_family = h->h_addrtype; sin.sin_port = 0; - memset (sin.sin_zero, 0, sizeof (sin.sin_zero)); - memcpy ((char *) &sin.sin_addr, h->h_addr, h->h_length); + __memset (sin.sin_zero, 0, sizeof (sin.sin_zero)); + __memcpy ((char *) &sin.sin_addr, h->h_addr, h->h_length); prtbuflen = 1024; prttmpbuf = alloca (prtbuflen); diff --git a/libc/inet/rpc/clnt_perror.c b/libc/inet/rpc/clnt_perror.c index 1c9ca88ae..595ddde9a 100644 --- a/libc/inet/rpc/clnt_perror.c +++ b/libc/inet/rpc/clnt_perror.c @@ -91,8 +91,8 @@ clnt_sperror (CLIENT * rpch, const char *msg) len = sprintf (str, "%s: ", msg); str += len; - (void) strcpy(str, clnt_sperrno(e.re_status)); - str += strlen(str); + (void) __strcpy(str, clnt_sperrno(e.re_status)); + str += __strlen(str); switch (e.re_status) { @@ -126,13 +126,13 @@ clnt_sperror (CLIENT * rpch, const char *msg) case RPC_AUTHERROR: err = auth_errmsg (e.re_why); - (void) strcpy(str, _("; why = ")); - str += strlen(str); + (void) __strcpy(str, _("; why = ")); + str += __strlen(str); if (err != NULL) { - (void) strcpy(str, err); - str += strlen(str); + (void) __strcpy(str, err); + str += __strlen(str); } else { @@ -316,27 +316,27 @@ clnt_spcreateerror (const char *msg) ce = &get_rpc_createerr (); len = sprintf (str, "%s: ", msg); cp = str + len; - (void) strcpy(cp, clnt_sperrno (ce->cf_stat)); - cp += strlen(cp); + (void) __strcpy(cp, clnt_sperrno (ce->cf_stat)); + cp += __strlen(cp); switch (ce->cf_stat) { case RPC_PMAPFAILURE: - (void) strcpy(cp, " - "); - cp += strlen(cp); + (void) __strcpy(cp, " - "); + cp += __strlen(cp); - (void) strcpy(cp, clnt_sperrno (ce->cf_error.re_status)); - cp += strlen(cp); + (void) __strcpy(cp, clnt_sperrno (ce->cf_error.re_status)); + cp += __strlen(cp); break; case RPC_SYSTEMERROR: - (void) strcpy(cp, " - "); - cp += strlen(cp); + (void) __strcpy(cp, " - "); + cp += __strlen(cp); strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf); - (void) strcpy(cp, chrbuf); - cp += strlen(cp); + (void) __strcpy(cp, chrbuf); + cp += __strlen(cp); break; default: break; diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c index a1062109f..e21f40252 100644 --- a/libc/inet/rpc/clnt_raw.c +++ b/libc/inet/rpc/clnt_raw.c @@ -42,6 +42,8 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; * any interference from the kernel. */ +#define authnone_create __authnone_create + #define __FORCE_GLIBC #include <features.h> #include "rpc_private.h" diff --git a/libc/inet/rpc/clnt_simple.c b/libc/inet/rpc/clnt_simple.c index b0af24a98..dede4a028 100644 --- a/libc/inet/rpc/clnt_simple.c +++ b/libc/inet/rpc/clnt_simple.c @@ -87,7 +87,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, crp->socket = RPC_ANYSOCK; } if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum - && strcmp (crp->oldhost, host) == 0) + && __strcmp (crp->oldhost, host) == 0) { /* reuse old client */ } @@ -100,7 +100,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, crp->valid = 0; if (crp->socket != RPC_ANYSOCK) { - (void) close (crp->socket); + (void) __close (crp->socket); crp->socket = RPC_ANYSOCK; } if (crp->client) @@ -125,7 +125,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, timeout.tv_usec = 0; timeout.tv_sec = 5; - memcpy ((char *) &server_addr.sin_addr, hp->h_addr, hp->h_length); + __memcpy ((char *) &server_addr.sin_addr, hp->h_addr, hp->h_length); server_addr.sin_family = AF_INET; server_addr.sin_port = 0; if ((crp->client = clntudp_create (&server_addr, (u_long) prognum, @@ -134,7 +134,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, crp->valid = 1; crp->oldprognum = prognum; crp->oldversnum = versnum; - (void) strncpy (crp->oldhost, host, 255); + (void) __strncpy (crp->oldhost, host, 255); crp->oldhost[255] = '\0'; } tottimeout.tv_sec = 25; @@ -150,8 +150,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, } #ifdef __UCLIBC_HAS_THREADS__ -void -__rpc_thread_clnt_cleanup (void) +void attribute_hidden __rpc_thread_clnt_cleanup (void) { struct callrpc_private_s *rcp = RPC_THREAD_VARIABLE(callrpc_private_s); diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c index 804c45b84..ad2797a9e 100644 --- a/libc/inet/rpc/clnt_tcp.c +++ b/libc/inet/rpc/clnt_tcp.c @@ -50,6 +50,9 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; * Now go hang yourself. */ +#define authnone_create __authnone_create +#define xdrrec_create __xdrrec_create + #define __FORCE_GLIBC #include <features.h> @@ -65,7 +68,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; # include <wchar.h> #endif -extern u_long _create_xid (void); +extern u_long _create_xid (void) attribute_hidden; #define MCALL_MSG_SIZE 24 @@ -172,7 +175,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, ce->cf_stat = RPC_SYSTEMERROR; ce->cf_error.re_errno = errno; if (*sockp >= 0) - (void) close (*sockp); + (void) __close (*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -208,7 +211,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, { if (ct->ct_closeit) { - (void) close (*sockp); + (void) __close (*sockp); } goto fooy; } @@ -461,7 +464,7 @@ clnttcp_destroy (CLIENT *h) if (ct->ct_closeit) { - (void) close (ct->ct_sock); + (void) __close (ct->ct_sock); } XDR_DESTROY (&(ct->ct_xdrs)); mem_free ((caddr_t) ct, sizeof (struct ct_data)); @@ -503,7 +506,7 @@ readtcp (char *ctptr, char *buf, int len) } break; } - switch (len = read (ct->ct_sock, buf, len)) + switch (len = __read (ct->ct_sock, buf, len)) { case 0: @@ -529,7 +532,7 @@ writetcp (char *ctptr, char *buf, int len) for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write (ct->ct_sock, buf, cnt)) == -1) + if ((i = __write (ct->ct_sock, buf, cnt)) == -1) { ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTSEND; diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c index 75d72ec13..5a7e35e80 100644 --- a/libc/inet/rpc/clnt_udp.c +++ b/libc/inet/rpc/clnt_udp.c @@ -37,6 +37,11 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +/* CMSG_NXTHDR is using it */ +#define __cmsg_nxthdr __libc_cmsg_nxthdr + +#define authnone_create __authnone_create + #define __FORCE_GLIBC #include <features.h> @@ -62,7 +67,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #endif extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); -extern u_long _create_xid (void); +extern u_long _create_xid (void) attribute_hidden; /* * UDP bases client side rpc operations @@ -400,13 +405,13 @@ send_again: msg.msg_controllen = 256; ret = recvmsg (cu->cu_sock, &msg, MSG_ERRQUEUE); if (ret >= 0 - && memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0 + && __memcmp (cbuf + 256, cu->cu_outbuf, ret) == 0 && (msg.msg_flags & MSG_ERRQUEUE) && ((msg.msg_namelen == 0 && ret >= 12) || (msg.msg_namelen == sizeof (err_addr) && err_addr.sin_family == AF_INET - && memcmp (&err_addr.sin_addr, &cu->cu_raddr.sin_addr, + && __memcmp (&err_addr.sin_addr, &cu->cu_raddr.sin_addr, sizeof (err_addr.sin_addr)) == 0 && err_addr.sin_port == cu->cu_raddr.sin_port))) for (cmsg = CMSG_FIRSTHDR (&msg); cmsg; @@ -601,7 +606,7 @@ clntudp_destroy (CLIENT *cl) if (cu->cu_closeit) { - (void) close (cu->cu_sock); + (void) __close (cu->cu_sock); } XDR_DESTROY (&(cu->cu_outxdrs)); mem_free ((caddr_t) cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz)); diff --git a/libc/inet/rpc/clnt_unix.c b/libc/inet/rpc/clnt_unix.c index 81d8c4686..93ea42afd 100644 --- a/libc/inet/rpc/clnt_unix.c +++ b/libc/inet/rpc/clnt_unix.c @@ -46,6 +46,10 @@ * Now go hang yourself. */ +#define authnone_create __authnone_create +#define xdrrec_create __xdrrec_create +#define getegid __getegid + #define __FORCE_GLIBC #include <features.h> @@ -62,7 +66,7 @@ # include <wchar.h> #endif -extern u_long _create_xid (void); +extern u_long _create_xid (void) attribute_hidden; #define MCALL_MSG_SIZE 24 @@ -145,7 +149,7 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers, if (*sockp < 0) { *sockp = socket (AF_UNIX, SOCK_STREAM, 0); - len = strlen (raddr->sun_path) + sizeof (raddr->sun_family) + 1; + len = __strlen (raddr->sun_path) + sizeof (raddr->sun_family) + 1; if (*sockp < 0 || connect (*sockp, (struct sockaddr *) raddr, len) < 0) { @@ -153,7 +157,7 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers, ce->cf_stat = RPC_SYSTEMERROR; ce->cf_error.re_errno = errno; if (*sockp != -1) - close (*sockp); + __close (*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -187,7 +191,7 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers, if (!xdr_callhdr (&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) - close (*sockp); + __close (*sockp); goto fooy; } ct->ct_mpos = XDR_GETPOS (&(ct->ct_xdrs)); @@ -433,7 +437,7 @@ clntunix_destroy (CLIENT *h) if (ct->ct_closeit) { - (void) close (ct->ct_sock); + (void) __close (ct->ct_sock); } XDR_DESTROY (&(ct->ct_xdrs)); mem_free ((caddr_t) ct, sizeof (struct ct_data)); @@ -506,7 +510,7 @@ __msgwrite (int sock, void *data, size_t cnt) cred.uid = geteuid (); cred.gid = getegid (); - memcpy (CMSG_DATA(cmsg), &cred, sizeof (struct ucred)); + __memcpy (CMSG_DATA(cmsg), &cred, sizeof (struct ucred)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_CREDENTIALS; cmsg->cmsg_len = sizeof(*cmsg) + sizeof(struct ucred); diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c index cbb961e4d..8a6dacad3 100644 --- a/libc/inet/rpc/create_xid.c +++ b/libc/inet/rpc/create_xid.c @@ -40,8 +40,7 @@ static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER; static int is_initialized; static struct drand48_data __rpc_lrand48_data; -unsigned long -_create_xid (void) +u_long attribute_hidden _create_xid (void) { unsigned long res; diff --git a/libc/inet/rpc/get_myaddress.c b/libc/inet/rpc/get_myaddress.c index 7674a7a46..ef2c2f52e 100644 --- a/libc/inet/rpc/get_myaddress.c +++ b/libc/inet/rpc/get_myaddress.c @@ -94,7 +94,7 @@ get_myaddress (struct sockaddr_in *addr) { *addr = *((struct sockaddr_in *) &ifr->ifr_addr); addr->sin_port = htons (PMAPPORT); - close (s); + __close (s); return; } ifr++; @@ -104,5 +104,5 @@ get_myaddress (struct sockaddr_in *addr) loopback = 1; goto again; } - close (s); + __close (s); } diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c index 56fbbbe45..c261dfb3b 100644 --- a/libc/inet/rpc/getrpcent.c +++ b/libc/inet/rpc/getrpcent.c @@ -96,10 +96,10 @@ struct rpcent *getrpcbyname(const char *name) setrpcent(0); while ((rpc = getrpcent())) { - if (strcmp(rpc->r_name, name) == 0) + if (__strcmp(rpc->r_name, name) == 0) return rpc; for (rp = rpc->r_aliases; *rp != NULL; rp++) { - if (strcmp(*rp, name) == 0) + if (__strcmp(*rp, name) == 0) return rpc; } } @@ -166,8 +166,8 @@ static char *firstwhite(char *s) { char *s1, *s2; - s1 = strchr(s, ' '); - s2 = strchr(s, '\t'); + s1 = __strchr(s, ' '); + s2 = __strchr(s, '\t'); if (s1) { if (s2) return (s1 < s2) ? s1 : s2; @@ -184,12 +184,12 @@ static struct rpcent *interpret(register struct rpcdata *d) register char *cp, **q; p = d->line; - d->line[strlen(p)-1] = '\n'; + d->line[__strlen(p)-1] = '\n'; if (*p == '#') return __get_next_rpcent(d); - cp = strchr(p, '#'); + cp = __strchr(p, '#'); if (cp == NULL) { - cp = strchr(p, '\n'); + cp = __strchr(p, '\n'); if (cp == NULL) return __get_next_rpcent(d); } @@ -200,9 +200,9 @@ static struct rpcent *interpret(register struct rpcdata *d) else return __get_next_rpcent(d); #else - cp = strchr(p, ' '); + cp = __strchr(p, ' '); if (cp == NULL) { - cp = strchr(p, '\t'); + cp = __strchr(p, '\t'); if (cp == NULL) return __get_next_rpcent(d); } @@ -218,11 +218,11 @@ static struct rpcent *interpret(register struct rpcdata *d) if ((cp = firstwhite(cp))) *cp++ = '\0'; #else - cp = strchr(p, ' '); + cp = __strchr(p, ' '); if (cp != NULL) *cp++ = '\0'; else { - cp = strchr(p, '\t'); + cp = __strchr(p, '\t'); if (cp != NULL) *cp++ = '\0'; } @@ -238,11 +238,11 @@ static struct rpcent *interpret(register struct rpcdata *d) if ((cp = firstwhite(cp))) *cp++ = '\0'; #else - cp = strchr(p, ' '); + cp = __strchr(p, ' '); if (cp != NULL) *cp++ = '\0'; else { - cp = strchr(p, '\t'); + cp = __strchr(p, '\t'); if (cp != NULL) *cp++ = '\0'; } @@ -275,8 +275,8 @@ static int __copy_rpcent(struct rpcent *r, struct rpcent *result_buf, char *buff return ENOENT; /* copy the struct from the shared mem */ - memset(result_buf, 0x00, sizeof(*result_buf)); - memset(buffer, 0x00, buflen); + __memset(result_buf, 0x00, sizeof(*result_buf)); + __memset(buffer, 0x00, buflen); result_buf->r_number = r->r_number; @@ -293,21 +293,21 @@ static int __copy_rpcent(struct rpcent *r, struct rpcent *result_buf, char *buff buflen -= s; while (i-- > 0) { - s = strlen(r->r_aliases[i]) + 1; + s = __strlen(r->r_aliases[i]) + 1; if (buflen < s) goto err_out; result_buf->r_aliases[i] = buffer; buffer += s; buflen -= s; - memcpy(result_buf->r_aliases[i], r->r_aliases[i], s); + __memcpy(result_buf->r_aliases[i], r->r_aliases[i], s); } /* copy the name */ - i = strlen(r->r_name); + i = __strlen(r->r_name); if (buflen <= i) goto err_out; result_buf->r_name = buffer; - memcpy(result_buf->r_name, r->r_name, i); + __memcpy(result_buf->r_name, r->r_name, i); /* that was a hoot eh ? */ *result = result_buf; diff --git a/libc/inet/rpc/getrpcport.c b/libc/inet/rpc/getrpcport.c index 851a1c487..5470fbff6 100644 --- a/libc/inet/rpc/getrpcport.c +++ b/libc/inet/rpc/getrpcport.c @@ -70,7 +70,7 @@ getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto) buffer = alloca (buflen); } - memcpy ((char *) &addr.sin_addr, hp->h_addr, hp->h_length); + __memcpy ((char *) &addr.sin_addr, hp->h_addr, hp->h_length); addr.sin_family = AF_INET; addr.sin_port = 0; return pmap_getport (&addr, prognum, versnum, proto); diff --git a/libc/inet/rpc/pmap_clnt.c b/libc/inet/rpc/pmap_clnt.c index 2382c153b..5bbc81564 100644 --- a/libc/inet/rpc/pmap_clnt.c +++ b/libc/inet/rpc/pmap_clnt.c @@ -90,7 +90,7 @@ __get_myaddress (struct sockaddr_in *addr) { *addr = *((struct sockaddr_in *) &ifr->ifr_addr); addr->sin_port = htons (PMAPPORT); - close (s); + __close (s); return TRUE; } ifr++; @@ -100,7 +100,7 @@ __get_myaddress (struct sockaddr_in *addr) loopback = 0; goto again; } - close (s); + __close (s); return FALSE; } @@ -139,7 +139,7 @@ pmap_set (u_long program, u_long version, int protocol, u_short port) return FALSE; } CLNT_DESTROY (client); - /* (void)close(socket); CLNT_DESTROY closes it */ + /* (void)__close(socket); CLNT_DESTROY closes it */ return rslt; } @@ -168,6 +168,6 @@ pmap_unset (u_long program, u_long version) CLNT_CALL (client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, (caddr_t)&parms, (xdrproc_t)xdr_bool, (caddr_t)&rslt, tottimeout); CLNT_DESTROY (client); - /* (void)close(socket); CLNT_DESTROY already closed it */ + /* (void)__close(socket); CLNT_DESTROY already closed it */ return rslt; } diff --git a/libc/inet/rpc/pmap_getmaps.c b/libc/inet/rpc/pmap_getmaps.c index c435dea4e..4ec2d40e9 100644 --- a/libc/inet/rpc/pmap_getmaps.c +++ b/libc/inet/rpc/pmap_getmaps.c @@ -74,7 +74,7 @@ pmap_getmaps (struct sockaddr_in *address) } CLNT_DESTROY (client); } - /* (void)close(socket); CLNT_DESTROY already closed it */ + /* (void)__close(socket); CLNT_DESTROY already closed it */ address->sin_port = 0; return head; } diff --git a/libc/inet/rpc/pmap_getport.c b/libc/inet/rpc/pmap_getport.c index 6d68ef01f..45ed4eae8 100644 --- a/libc/inet/rpc/pmap_getport.c +++ b/libc/inet/rpc/pmap_getport.c @@ -88,7 +88,7 @@ pmap_getport (address, program, version, protocol) } CLNT_DESTROY (client); } - /* (void)close(socket); CLNT_DESTROY already closed it */ + /* (void)__close(socket); CLNT_DESTROY already closed it */ address->sin_port = 0; return port; } diff --git a/libc/inet/rpc/pmap_rmt.c b/libc/inet/rpc/pmap_rmt.c index 0bb9dd884..db875e987 100644 --- a/libc/inet/rpc/pmap_rmt.c +++ b/libc/inet/rpc/pmap_rmt.c @@ -39,6 +39,9 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#define authunix_create_default __authunix_create_default +#define inet_makeaddr __inet_makeaddr + #define __FORCE_GLIBC #include <features.h> @@ -59,7 +62,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #include <arpa/inet.h> #define MAX_BROADCAST_SIZE 1400 -extern u_long _create_xid (void); +extern u_long _create_xid (void) attribute_hidden; static const struct timeval timeout = {3, 0}; @@ -279,7 +282,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) fd.fd = sock; fd.events = POLLIN; nets = getbroadcastnets (addrs, sock, inbuf); - memset ((char *) &baddr, 0, sizeof (baddr)); + __memset ((char *) &baddr, 0, sizeof (baddr)); baddr.sin_family = AF_INET; baddr.sin_port = htons (PMAPPORT); baddr.sin_addr.s_addr = htonl (INADDR_ANY); @@ -407,7 +410,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) } } done_broad: - (void) close (sock); + (void) __close (sock); AUTH_DESTROY (unix_auth); return stat; } diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c index af0e2e17a..a51d09fcd 100644 --- a/libc/inet/rpc/rcmd.c +++ b/libc/inet/rpc/rcmd.c @@ -35,6 +35,9 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #endif /* LIBC_SCCS and not lint */ +#define bcopy __bcopy +#define sysconf __sysconf + #define __FORCE_GLIBC #include <features.h> @@ -152,7 +155,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) sin.sin_port = rport; if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) /* __connect */ break; - (void)close(s); /* __close */ + (void)__close(s); if (errno == EADDRINUSE) { lport--; continue; @@ -182,7 +185,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) } lport--; if (fd2p == 0) { - write(s, "", 1); /* __write */ + __write(s, "", 1); lport = 0; } else { char num[8]; @@ -193,10 +196,10 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) goto bad; listen(s2, 1); (void)snprintf(num, sizeof(num), "%d", lport); /* __snprintf */ - if (write(s, num, strlen(num)+1) != strlen(num)+1) { + if (__write(s, num, __strlen(num)+1) != __strlen(num)+1) { (void)fprintf(stderr, "rcmd: write (setting up stderr): %m\n"); - (void)close(s2); /* __close */ + (void)__close(s2); goto bad; } pfd[0].fd = s; @@ -207,11 +210,11 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) (void)fprintf(stderr, "rcmd: poll (setting up stderr): %m\n"); else (void)fprintf(stderr, "poll: protocol failure in circuit setup\n"); - (void)close(s2); + (void)__close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); - (void)close(s2); + (void)__close(s2); if (s3 < 0) { (void)fprintf(stderr, "rcmd: accept: %m\n"); @@ -228,17 +231,17 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) goto bad2; } } - (void)write(s, locuser, strlen(locuser)+1); - (void)write(s, remuser, strlen(remuser)+1); - (void)write(s, cmd, strlen(cmd)+1); - if (read(s, &c, 1) != 1) { + (void)__write(s, locuser, __strlen(locuser)+1); + (void)__write(s, remuser, __strlen(remuser)+1); + (void)__write(s, cmd, __strlen(cmd)+1); + if (__read(s, &c, 1) != 1) { (void)fprintf(stderr, "rcmd: %s: %m\n", *ahost); goto bad2; } if (c != 0) { - while (read(s, &c, 1) == 1) { - (void)write(STDERR_FILENO, &c, 1); + while (__read(s, &c, 1) == 1) { + (void)__write(STDERR_FILENO, &c, 1); if (c == '\n') break; } @@ -248,9 +251,9 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) return s; bad2: if (lport) - (void)close(*fd2p); + (void)__close(*fd2p); bad: - (void)close(s); + (void)__close(s); sigsetmask(oldmask); return -1; } @@ -270,12 +273,12 @@ int rresvport(int *alport) if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return s; if (errno != EADDRINUSE) { - (void)close(s); + (void)__close(s); return -1; } (*alport)--; if (*alport == IPPORT_RESERVED/2) { - (void)close(s); + (void)__close(s); __set_errno (EAGAIN); /* close */ return -1; } @@ -452,10 +455,10 @@ iruserok2 (raddr, superuser, ruser, luser, rhost) return -1; #endif - dirlen = strlen (pwd->pw_dir); + dirlen = __strlen (pwd->pw_dir); pbuf = malloc (dirlen + sizeof "/.rhosts"); - strcpy (pbuf, pwd->pw_dir); - strcat (pbuf, "/.rhosts"); + __strcpy (pbuf, pwd->pw_dir); + __strcat (pbuf, "/.rhosts"); /* Change effective uid while reading .rhosts. If root and reading an NFS mounted file system, can't read files that @@ -520,18 +523,18 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost) #ifdef HAVE_NETGROUP /* Check nis netgroup. */ - if (strncmp ("+@", lhost, 2) == 0) + if (__strncmp ("+@", lhost, 2) == 0) return innetgr (&lhost[2], rhost, NULL, NULL); - if (strncmp ("-@", lhost, 2) == 0) + if (__strncmp ("-@", lhost, 2) == 0) return -innetgr (&lhost[2], rhost, NULL, NULL); #endif /* HAVE_NETGROUP */ /* -host */ - if (strncmp ("-", lhost,1) == 0) { + if (__strncmp ("-", lhost,1) == 0) { negate = -1; lhost++; - } else if (strcmp ("+",lhost) == 0) { + } else if (__strcmp ("+",lhost) == 0) { return 1; /* asking for trouble, but ok.. */ } @@ -561,7 +564,7 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost) /* Spin through ip addresses. */ for (pp = hp->h_addr_list; *pp; ++pp) - if (!memcmp (&raddr, *pp, sizeof (u_int32_t))) + if (!__memcmp (&raddr, *pp, sizeof (u_int32_t))) return negate; /* No match. */ @@ -580,23 +583,23 @@ __icheckuser (const char *luser, const char *ruser) #ifdef HAVE_NETGROUP /* [-+]@netgroup */ - if (strncmp ("+@", luser, 2) == 0) + if (__strncmp ("+@", luser, 2) == 0) return innetgr (&luser[2], NULL, ruser, NULL); - if (strncmp ("-@", luser,2) == 0) + if (__strncmp ("-@", luser,2) == 0) return -innetgr (&luser[2], NULL, ruser, NULL); #endif /* HAVE_NETGROUP */ /* -user */ - if (strncmp ("-", luser, 1) == 0) - return -(strcmp (&luser[1], ruser) == 0); + if (__strncmp ("-", luser, 1) == 0) + return -(__strcmp (&luser[1], ruser) == 0); /* + */ - if (strcmp ("+", luser) == 0) + if (__strcmp ("+", luser) == 0) return 1; /* simple string match */ - return strcmp (ruser, luser) == 0; + return __strcmp (ruser, luser) == 0; } /* @@ -638,7 +641,7 @@ __ivaliduser2(hostf, raddr, luser, ruser, rhost) } /* Skip lines that are too long. */ - if (strchr (p, '\n') == NULL) { + if (__strchr (p, '\n') == NULL) { int ch = getc_unlocked (hostf); while (ch != '\n' && ch != EOF) diff --git a/libc/inet/rpc/rexec.c b/libc/inet/rpc/rexec.c index 2c280d922..00e68ff6b 100644 --- a/libc/inet/rpc/rexec.c +++ b/libc/inet/rpc/rexec.c @@ -70,7 +70,7 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af) snprintf(servbuff, sizeof(servbuff), "%d", ntohs(rport)); servbuff[sizeof(servbuff) - 1] = '\0'; - memset(&hints, 0, sizeof(hints)); + __memset(&hints, 0, sizeof(hints)); hints.ai_family = af; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; @@ -81,7 +81,7 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af) } if (res0->ai_canonname){ - strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf)); + __strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf)); ahostbuf[sizeof(ahostbuf)-1] = '\0'; *ahost = ahostbuf; } @@ -97,7 +97,7 @@ retry: } if (connect(s, res0->ai_addr, res0->ai_addrlen) < 0) { if (errno == ECONNREFUSED && timo <= 16) { - (void) close(s); + (void) __close(s); sleep(timo); timo *= 2; goto retry; @@ -106,7 +106,7 @@ retry: return (-1); } if (fd2p == 0) { - (void) write(s, "", 1); + (void) __write(s, "", 1); port = 0; } else { char num[32]; @@ -114,18 +114,18 @@ retry: s2 = socket(res0->ai_family, res0->ai_socktype, 0); if (s2 < 0) { - (void) close(s); + (void) __close(s); return (-1); } listen(s2, 1); sa2len = sizeof (sa2); if (getsockname(s2, (struct sockaddr *)&sa2, &sa2len) < 0) { perror("getsockname"); - (void) close(s2); + (void) __close(s2); goto bad; } else if (sa2len != SA_LEN((struct sockaddr *)&sa2)) { __set_errno(EINVAL); - (void) close(s2); + (void) __close(s2); goto bad; } port = 0; @@ -134,10 +134,10 @@ retry: NI_NUMERICSERV)) port = atoi(servbuff); (void) sprintf(num, "%u", port); - (void) write(s, num, strlen(num)+1); + (void) __write(s, num, __strlen(num)+1); { socklen_t len = sizeof (from); s3 = accept(s2, (struct sockaddr *)&from, &len); - close(s2); + __close(s2); if (s3 < 0) { perror("accept"); port = 0; @@ -146,10 +146,10 @@ retry: } *fd2p = s3; } - (void) write(s, name, strlen(name) + 1); + (void) __write(s, name, __strlen(name) + 1); /* should public key encypt the password here */ - (void) write(s, pass, strlen(pass) + 1); - (void) write(s, cmd, strlen(cmd) + 1); + (void) __write(s, pass, __strlen(pass) + 1); + (void) __write(s, cmd, __strlen(cmd) + 1); /* We don't need the memory allocated for the name and the password in ruserpass anymore. */ @@ -158,13 +158,13 @@ retry: if (pass != orig_pass) free ((char *) pass); - if (read(s, &c, 1) != 1) { + if (__read(s, &c, 1) != 1) { perror(*ahost); goto bad; } if (c != 0) { - while (read(s, &c, 1) == 1) { - (void) write(2, &c, 1); + while (__read(s, &c, 1) == 1) { + (void) __write(2, &c, 1); if (c == '\n') break; } @@ -174,8 +174,8 @@ retry: return (s); bad: if (port) - (void) close(*fd2p); - (void) close(s); + (void) __close(*fd2p); + (void) __close(s); freeaddrinfo(res0); return (-1); } diff --git a/libc/inet/rpc/rpc_callmsg.c b/libc/inet/rpc/rpc_callmsg.c index 634b1bea5..8934eed91 100644 --- a/libc/inet/rpc/rpc_callmsg.c +++ b/libc/inet/rpc/rpc_callmsg.c @@ -85,7 +85,7 @@ xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) IXDR_PUT_INT32 (buf, oa->oa_length); if (oa->oa_length) { - memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); + __memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); buf = (int32_t *) ((char *) buf + RNDUP (oa->oa_length)); } oa = &cmsg->rm_call.cb_verf; @@ -93,7 +93,7 @@ xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) IXDR_PUT_INT32 (buf, oa->oa_length); if (oa->oa_length) { - memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); + __memcpy ((caddr_t) buf, oa->oa_base, oa->oa_length); /* no real need.... buf = (long *) ((char *) buf + RNDUP(oa->oa_length)); */ @@ -141,7 +141,7 @@ xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) } else { - memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); + __memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); /* no real need.... buf = (long *) ((char *) buf + RNDUP(oa->oa_length)); @@ -181,7 +181,7 @@ xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg) } else { - memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); + __memcpy (oa->oa_base, (caddr_t) buf, oa->oa_length); /* no real need... buf = (long *) ((char *) buf + RNDUP(oa->oa_length)); diff --git a/libc/inet/rpc/rpc_dtablesize.c b/libc/inet/rpc/rpc_dtablesize.c index 8e0fa35be..b520b1b48 100644 --- a/libc/inet/rpc/rpc_dtablesize.c +++ b/libc/inet/rpc/rpc_dtablesize.c @@ -42,8 +42,8 @@ static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro"; * Cache the result of getdtablesize(), so we don't have to do an * expensive system call every time. */ -int -_rpc_dtablesize (void) +int attribute_hidden +__libc__rpc_dtablesize (void) { static int size; @@ -52,3 +52,4 @@ _rpc_dtablesize (void) return size; } +strong_alias(__libc__rpc_dtablesize,_rpc_dtablesize) diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h index 93662669c..69ee1cb53 100644 --- a/libc/inet/rpc/rpc_private.h +++ b/libc/inet/rpc/rpc_private.h @@ -2,7 +2,7 @@ #include <rpc/rpc.h> /* Now define the internal interfaces. */ -extern unsigned long _create_xid (void); +extern u_long _create_xid (void) attribute_hidden; /* * Multi-threaded support @@ -40,10 +40,10 @@ struct rpc_thread_variables { }; extern struct rpc_thread_variables *__rpc_thread_variables(void) - __attribute__ ((const)); -extern void __rpc_thread_svc_cleanup (void); -extern void __rpc_thread_clnt_cleanup (void); -extern void __rpc_thread_key_cleanup (void); + __attribute__ ((const)) attribute_hidden; +extern void __rpc_thread_svc_cleanup (void) attribute_hidden; +extern void __rpc_thread_clnt_cleanup (void) attribute_hidden; +/*extern void __rpc_thread_key_cleanup (void) attribute_hidden;*/ extern void __rpc_thread_destroy (void); diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c index 374aac84c..fa63b1650 100644 --- a/libc/inet/rpc/rpc_thread.c +++ b/libc/inet/rpc/rpc_thread.c @@ -68,7 +68,7 @@ rpc_thread_multi (void) } -struct rpc_thread_variables * +struct rpc_thread_variables attribute_hidden * __rpc_thread_variables (void) { __libc_once_define (static, once); @@ -103,8 +103,8 @@ __rpc_thread_variables (void) #undef svc_pollfd #undef svc_max_pollfd -fd_set * -__rpc_thread_svc_fdset (void) +fd_set attribute_hidden * +__libc_rpc_thread_svc_fdset (void) { struct rpc_thread_variables *tvp; @@ -113,6 +113,7 @@ __rpc_thread_svc_fdset (void) return &svc_fdset; return &tvp->svc_fdset_s; } +strong_alias(__libc_rpc_thread_svc_fdset,__rpc_thread_svc_fdset) struct rpc_createerr * __rpc_thread_createerr (void) @@ -125,8 +126,8 @@ __rpc_thread_createerr (void) return &tvp->rpc_createerr_s; } -struct pollfd ** -__rpc_thread_svc_pollfd (void) +struct pollfd attribute_hidden ** +__libc_rpc_thread_svc_pollfd (void) { struct rpc_thread_variables *tvp; @@ -135,9 +136,10 @@ __rpc_thread_svc_pollfd (void) return &svc_pollfd; return &tvp->svc_pollfd_s; } +strong_alias(__libc_rpc_thread_svc_pollfd,__rpc_thread_svc_pollfd) -int * -__rpc_thread_svc_max_pollfd (void) +int attribute_hidden * +__libc_rpc_thread_svc_max_pollfd (void) { struct rpc_thread_variables *tvp; @@ -146,6 +148,7 @@ __rpc_thread_svc_max_pollfd (void) return &svc_max_pollfd; return &tvp->svc_max_pollfd_s; } +strong_alias(__libc_rpc_thread_svc_max_pollfd,__rpc_thread_svc_max_pollfd) #else #undef svc_fdset @@ -153,11 +156,12 @@ __rpc_thread_svc_max_pollfd (void) #undef svc_pollfd #undef svc_max_pollfd -fd_set * __rpc_thread_svc_fdset (void) +fd_set attribute_hidden * __libc_rpc_thread_svc_fdset (void) { extern fd_set svc_fdset; return &(svc_fdset); } +strong_alias(__libc_rpc_thread_svc_fdset,__rpc_thread_svc_fdset) struct rpc_createerr * __rpc_thread_createerr (void) { @@ -165,17 +169,19 @@ struct rpc_createerr * __rpc_thread_createerr (void) return &(rpc_createerr); } -struct pollfd ** __rpc_thread_svc_pollfd (void) +struct pollfd attribute_hidden ** __libc_rpc_thread_svc_pollfd (void) { extern struct pollfd *svc_pollfd; return &(svc_pollfd); } +strong_alias(__libc_rpc_thread_svc_pollfd,__rpc_thread_svc_pollfd) -int * __rpc_thread_svc_max_pollfd (void) +int attribute_hidden * __libc_rpc_thread_svc_max_pollfd (void) { extern int svc_max_pollfd; return &(svc_max_pollfd); } +strong_alias(__libc_rpc_thread_svc_max_pollfd,__rpc_thread_svc_max_pollfd) #endif /* __UCLIBC_HAS_THREADS__ */ diff --git a/libc/inet/rpc/rtime.c b/libc/inet/rpc/rtime.c index bf30cd282..554ad69eb 100644 --- a/libc/inet/rpc/rtime.c +++ b/libc/inet/rpc/rtime.c @@ -68,7 +68,7 @@ do_close (int s) int save; save = errno; - close (s); + __close (s); __set_errno (save); } @@ -132,7 +132,7 @@ rtime (struct sockaddr_in *addrp, struct rpc_timeval *timep, do_close (s); return -1; } - res = read (s, (char *) &thetime, sizeof (thetime)); + res = __read (s, (char *) &thetime, sizeof (thetime)); do_close (s); if (res < 0) return (-1); diff --git a/libc/inet/rpc/ruserpass.c b/libc/inet/rpc/ruserpass.c index 5db3e567c..116a34276 100644 --- a/libc/inet/rpc/ruserpass.c +++ b/libc/inet/rpc/ruserpass.c @@ -27,6 +27,10 @@ * SUCH DAMAGE. */ +#define __fsetlocking __libc_fsetlocking +#define getgid __getgid +#define getegid __getegid + #define __FORCE_GLIBC #include <features.h> #include <sys/types.h> @@ -108,9 +112,9 @@ int ruserpass(const char *host, const char **aname, const char **apass) return -1; } - buf = alloca (strlen(hdir) + 8); - strcpy(buf, hdir); - strcat(buf, "/.netrc"); + buf = alloca (__strlen(hdir) + 8); + __strcpy(buf, hdir); + __strcat(buf, "/.netrc"); cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) @@ -123,9 +127,9 @@ int ruserpass(const char *host, const char **aname, const char **apass) #endif if (gethostname(myname, sizeof(myname)) < 0) myname[0] = '\0'; - mydomain = strchr(myname, '.'); + mydomain = __strchr(myname, '.'); if (mydomain==NULL) { - mydomain=myname + strlen(myname); + mydomain=myname + __strlen(myname); } next: while ((t = token())) switch(t) { @@ -147,12 +151,12 @@ next: goto match; /* if (__strcasecmp(hostname, tokval) == 0) goto match; - if ((tmp = strchr(hostname, '.')) != NULL && + if ((tmp = __strchr(hostname, '.')) != NULL && __strcasecmp(tmp, mydomain) == 0 && __strncasecmp(hostname, tokval, tmp-hostname) == 0 && tokval[tmp - hostname] == '\0') goto match; */ - if ((tmp = strchr(host, '.')) != NULL && + if ((tmp = __strchr(host, '.')) != NULL && strcasecmp(tmp, mydomain) == 0 && strncasecmp(host, tokval, tmp - host) == 0 && tokval[tmp - host] == '\0') @@ -166,21 +170,21 @@ next: if (token()) { if (*aname == 0) { char *newp; - newp = malloc((unsigned) strlen(tokval) + 1); + newp = malloc((unsigned) __strlen(tokval) + 1); if (newp == NULL) { printf(_("out of memory")); goto bad; } - *aname = strcpy(newp, tokval); + *aname = __strcpy(newp, tokval); } else { - if (strcmp(*aname, tokval)) + if (__strcmp(*aname, tokval)) goto next; } } break; case PASSWD: - if (strcmp(*aname, "anonymous") && + if (__strcmp(*aname, "anonymous") && fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { printf(_("Error: .netrc file is readable by others.")); @@ -189,13 +193,13 @@ next: } if (token() && *apass == 0) { char *newp; - newp = malloc((unsigned) strlen(tokval) + 1); + newp = malloc((unsigned) __strlen(tokval) + 1); if (newp == NULL) { printf(_("out of memory")); goto bad; } - *apass = strcpy(newp, tokval); + *apass = __strcpy(newp, tokval); } break; case ACCOUNT: @@ -207,8 +211,8 @@ next: goto bad; } if (token() && *aacct == 0) { - *aacct = malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*aacct, tokval); + *aacct = malloc((unsigned) __strlen(tokval) + 1); + (void) __strcpy(*aacct, tokval); } #endif break; @@ -323,7 +327,7 @@ token() if (tokval[0] == 0) return (0); for (i = 0; i < (int) (sizeof (toktab) / sizeof (toktab[0])); ++i) - if (!strcmp(&tokstr[toktab[i].tokstr_off], tokval)) + if (!__strcmp(&tokstr[toktab[i].tokstr_off], tokval)) return toktab[i].tval; return (ID); } diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c index 6e1d8dc3d..a32c68bbc 100644 --- a/libc/inet/rpc/svc.c +++ b/libc/inet/rpc/svc.c @@ -36,6 +36,16 @@ * Copyright (C) 1984, Sun Microsystems, Inc. */ +#define _authenticate __libc__authenticate +#define _rpc_dtablesize __libc__rpc_dtablesize + +/* used by svc_[max_]pollfd */ +#define __rpc_thread_svc_pollfd __libc_rpc_thread_svc_pollfd +#define __rpc_thread_svc_max_pollfd __libc_rpc_thread_svc_max_pollfd + +/* used by svc_fdset */ +#define __rpc_thread_svc_fdset __libc_rpc_thread_svc_fdset + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -75,8 +85,8 @@ static struct svc_callout *svc_head; /* *************** SVCXPRT related stuff **************** */ /* Activate a transport handle. */ -void -xprt_register (SVCXPRT *xprt) +void attribute_hidden +__xprt_register (SVCXPRT *xprt) { register int sock = xprt->xp_sock; register int i; @@ -115,6 +125,7 @@ xprt_register (SVCXPRT *xprt) POLLRDNORM | POLLRDBAND); } } +strong_alias(__xprt_register,xprt_register) /* De-activate a transport handle. */ void @@ -480,8 +491,7 @@ svc_getreq_common (const int fd) #ifdef __UCLIBC_HAS_THREADS__ -void -__rpc_thread_svc_cleanup (void) +void attribute_hidden __rpc_thread_svc_cleanup (void) { struct svc_callout *svcp; diff --git a/libc/inet/rpc/svc_auth.c b/libc/inet/rpc/svc_auth.c index ebfacce04..80c4f7955 100644 --- a/libc/inet/rpc/svc_auth.c +++ b/libc/inet/rpc/svc_auth.c @@ -101,8 +101,8 @@ svcauthsw[] = * There is an assumption that any flavour less than AUTH_NULL is * invalid. */ -enum auth_stat -_authenticate (register struct svc_req *rqst, struct rpc_msg *msg) +enum auth_stat attribute_hidden +__libc__authenticate (register struct svc_req *rqst, struct rpc_msg *msg) { register int cred_flavor; @@ -115,6 +115,7 @@ _authenticate (register struct svc_req *rqst, struct rpc_msg *msg) return AUTH_REJECTEDCRED; } +strong_alias(__libc__authenticate,_authenticate) static enum auth_stat _svcauth_null (struct svc_req *rqst, struct rpc_msg *msg) diff --git a/libc/inet/rpc/svc_auth_unix.c b/libc/inet/rpc/svc_auth_unix.c index 84c563cdf..256a42154 100644 --- a/libc/inet/rpc/svc_auth_unix.c +++ b/libc/inet/rpc/svc_auth_unix.c @@ -84,7 +84,7 @@ _svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg) stat = AUTH_BADCRED; goto done; } - memcpy (aup->aup_machname, (caddr_t) buf, (u_int) str_len); + __memcpy (aup->aup_machname, (caddr_t) buf, (u_int) str_len); aup->aup_machname[str_len] = 0; str_len = RNDUP (str_len); buf = (int32_t *) ((char *) buf + str_len); diff --git a/libc/inet/rpc/svc_run.c b/libc/inet/rpc/svc_run.c index 3ef9fbd24..218bfd969 100644 --- a/libc/inet/rpc/svc_run.c +++ b/libc/inet/rpc/svc_run.c @@ -31,6 +31,10 @@ * Wait for input, call server program. */ +/* used by svc_[max_]pollfd */ +#define __rpc_thread_svc_pollfd __libc_rpc_thread_svc_pollfd +#define __rpc_thread_svc_max_pollfd __libc_rpc_thread_svc_max_pollfd + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> diff --git a/libc/inet/rpc/svc_simple.c b/libc/inet/rpc/svc_simple.c index afc01bafa..da3c71211 100644 --- a/libc/inet/rpc/svc_simple.c +++ b/libc/inet/rpc/svc_simple.c @@ -96,7 +96,7 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum, transp = svcudp_create (RPC_ANYSOCK); if (transp == NULL) { - buf = strdup (_("couldn't create an rpc server\n")); + buf = __strdup (_("couldn't create an rpc server\n")); goto err_out; } } @@ -111,7 +111,7 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum, pl = (struct proglst_ *) malloc (sizeof (struct proglst_)); if (pl == NULL) { - buf = strdup (_("registerrpc: out of memory\n")); + buf = __strdup (_("registerrpc: out of memory\n")); goto err_out; } pl->p_progname = progname; @@ -150,7 +150,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l) { if (svc_sendreply (transp_l, (xdrproc_t)xdr_void, (char *) NULL) == FALSE) { - write (STDERR_FILENO, "xxx\n", 4); + __write (STDERR_FILENO, "xxx\n", 4); exit (1); } return; @@ -161,7 +161,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l) if (pl->p_prognum == prog && pl->p_procnum == proc) { /* decode arguments into a CLEAN buffer */ - memset (xdrbuf, 0, sizeof (xdrbuf)); /* required ! */ + __memset (xdrbuf, 0, sizeof (xdrbuf)); /* required ! */ if (!svc_getargs (transp_l, pl->p_inproc, xdrbuf)) { svcerr_decode (transp_l); diff --git a/libc/inet/rpc/svc_tcp.c b/libc/inet/rpc/svc_tcp.c index e7ec083c8..20deb8719 100644 --- a/libc/inet/rpc/svc_tcp.c +++ b/libc/inet/rpc/svc_tcp.c @@ -41,6 +41,9 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; * and a record/tcp stream. */ +#define xdrrec_create __xdrrec_create +#define xprt_register __xprt_register + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -161,7 +164,7 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize) } madesock = TRUE; } - memset ((char *) &addr, 0, sizeof (addr)); + __memset ((char *) &addr, 0, sizeof (addr)); addr.sin_family = AF_INET; if (bindresvport (sock, &addr)) { @@ -173,7 +176,7 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize) { perror (_("svc_tcp.c - cannot getsockname or listen")); if (madesock) - (void) close (sock); + (void) __close (sock); return (SVCXPRT *) NULL; } r = (struct tcp_rendezvous *) mem_alloc (sizeof (*r)); @@ -269,7 +272,7 @@ again: * make a new transporter (re-uses xprt) */ xprt = makefd_xprt (sock, r->sendsize, r->recvsize); - memcpy (&xprt->xp_raddr, &addr, sizeof (addr)); + __memcpy (&xprt->xp_raddr, &addr, sizeof (addr)); xprt->xp_addrlen = len; return FALSE; /* there is never an rpc msg to be processed */ } @@ -286,7 +289,7 @@ svctcp_destroy (SVCXPRT *xprt) struct tcp_conn *cd = (struct tcp_conn *) xprt->xp_p1; xprt_unregister (xprt); - (void) close (xprt->xp_sock); + (void) __close (xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ @@ -336,7 +339,7 @@ readtcp (char *xprtptr, char *buf, int len) } while ((pollfd.revents & POLLIN) == 0); - if ((len = read (sock, buf, len)) > 0) + if ((len = __read (sock, buf, len)) > 0) return len; fatal_err: @@ -356,7 +359,7 @@ writetcp (char *xprtptr, char * buf, int len) for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write (xprt->xp_sock, buf, cnt)) < 0) + if ((i = __write (xprt->xp_sock, buf, cnt)) < 0) { ((struct tcp_conn *) (xprt->xp_p1))->strm_stat = XPRT_DIED; return -1; diff --git a/libc/inet/rpc/svc_udp.c b/libc/inet/rpc/svc_udp.c index 5e5dee9a3..a37552a4b 100644 --- a/libc/inet/rpc/svc_udp.c +++ b/libc/inet/rpc/svc_udp.c @@ -39,6 +39,8 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#define xprt_register __xprt_register + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -134,7 +136,7 @@ svcudp_bufcreate (sock, sendsz, recvsz) } madesock = TRUE; } - memset ((char *) &addr, 0, sizeof (addr)); + __memset ((char *) &addr, 0, sizeof (addr)); addr.sin_family = AF_INET; if (bindresvport (sock, &addr)) { @@ -145,7 +147,7 @@ svcudp_bufcreate (sock, sendsz, recvsz) { perror (_("svcudp_create - cannot getsockname")); if (madesock) - (void) close (sock); + (void) __close (sock); return (SVCXPRT *) NULL; } xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT)); @@ -198,7 +200,7 @@ svcudp_bufcreate (sock, sendsz, recvsz) #endif /* Clear the padding. */ pad = 0; - memset (&xprt->xp_pad [0], pad, sizeof (xprt->xp_pad)); + __memset (&xprt->xp_pad [0], pad, sizeof (xprt->xp_pad)); xprt_register (xprt); return xprt; @@ -373,7 +375,7 @@ svcudp_destroy (xprt) struct svcudp_data *su = su_data (xprt); xprt_unregister (xprt); - (void) close (xprt->xp_sock); + (void) __close (xprt->xp_sock); XDR_DESTROY (&(su->su_xdrs)); mem_free (rpc_buffer (xprt), su->su_iosz); mem_free ((caddr_t) su, sizeof (struct svcudp_data)); @@ -406,7 +408,7 @@ svcudp_destroy (xprt) (type *) mem_alloc((unsigned) (sizeof(type) * (size))) #define BZERO(addr, type, size) \ - memset((char *) addr, 0, sizeof(type) * (int) (size)) + __memset((char *) addr, 0, sizeof(type) * (int) (size)) /* * An entry in the cache @@ -584,7 +586,7 @@ cache_get (xprt, msg, replyp, replylenp) struct svcudp_data *su = su_data (xprt); struct udp_cache *uc = (struct udp_cache *) su->su_cache; -#define EQADDR(a1, a2) (memcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) +#define EQADDR(a1, a2) (__memcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) loc = CACHE_LOC (xprt, su->su_xid); for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) @@ -607,6 +609,6 @@ cache_get (xprt, msg, replyp, replylenp) uc->uc_proc = msg->rm_call.cb_proc; uc->uc_vers = msg->rm_call.cb_vers; uc->uc_prog = msg->rm_call.cb_prog; - memcpy (&uc->uc_addr, &xprt->xp_raddr, sizeof (uc->uc_addr)); + __memcpy (&uc->uc_addr, &xprt->xp_raddr, sizeof (uc->uc_addr)); return 0; } diff --git a/libc/inet/rpc/svc_unix.c b/libc/inet/rpc/svc_unix.c index 8e052d8a2..d1568e4a7 100644 --- a/libc/inet/rpc/svc_unix.c +++ b/libc/inet/rpc/svc_unix.c @@ -37,6 +37,10 @@ * and a record/unix stream. */ +#define xdrrec_create __xdrrec_create +#define xprt_register __xprt_register +#define getegid __getegid + #define __FORCE_GLIBC #include <features.h> @@ -154,10 +158,10 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path) } madesock = TRUE; } - memset (&addr, '\0', sizeof (addr)); + __memset (&addr, '\0', sizeof (addr)); addr.sun_family = AF_UNIX; - len = strlen (path) + 1; - memcpy (addr.sun_path, path, len); + len = __strlen (path) + 1; + __memcpy (addr.sun_path, path, len); len += sizeof (addr.sun_family); bind (sock, (struct sockaddr *) &addr, len); @@ -167,7 +171,7 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path) { perror (_("svc_unix.c - cannot getsockname or listen")); if (madesock) - close (sock); + __close (sock); return (SVCXPRT *) NULL; } @@ -264,10 +268,10 @@ again: /* * make a new transporter (re-uses xprt) */ - memset (&in_addr, '\0', sizeof (in_addr)); + __memset (&in_addr, '\0', sizeof (in_addr)); in_addr.sin_family = AF_UNIX; xprt = makefd_xprt (sock, r->sendsize, r->recvsize); - memcpy (&xprt->xp_raddr, &in_addr, sizeof (in_addr)); + __memcpy (&xprt->xp_raddr, &in_addr, sizeof (in_addr)); xprt->xp_addrlen = len; return FALSE; /* there is never an rpc msg to be processed */ } @@ -284,7 +288,7 @@ svcunix_destroy (SVCXPRT *xprt) struct unix_conn *cd = (struct unix_conn *) xprt->xp_p1; xprt_unregister (xprt); - close (xprt->xp_sock); + __close (xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ @@ -376,7 +380,7 @@ __msgwrite (int sock, void *data, size_t cnt) cred.uid = geteuid (); cred.gid = getegid (); - memcpy (CMSG_DATA(cmsg), &cred, sizeof (struct ucred)); + __memcpy (CMSG_DATA(cmsg), &cred, sizeof (struct ucred)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_CREDENTIALS; cmsg->cmsg_len = sizeof(*cmsg) + sizeof(struct ucred); diff --git a/libc/inet/rpc/xdr.c b/libc/inet/rpc/xdr.c index a1d449e19..7d69022dc 100644 --- a/libc/inet/rpc/xdr.c +++ b/libc/inet/rpc/xdr.c @@ -678,7 +678,7 @@ xdr_string (xdrs, cpp, maxsize) case XDR_ENCODE: if (sp == NULL) return FALSE; - size = strlen (sp); + size = __strlen (sp); break; case XDR_DECODE: break; diff --git a/libc/inet/rpc/xdr_array.c b/libc/inet/rpc/xdr_array.c index 450f5b2ea..584174e22 100644 --- a/libc/inet/rpc/xdr_array.c +++ b/libc/inet/rpc/xdr_array.c @@ -117,7 +117,7 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc) (void) fputs (_("xdr_array: out of memory\n"), stderr); return FALSE; } - memset (target, 0, nodesize); + __memset (target, 0, nodesize); break; case XDR_FREE: diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c index e80de7b1a..568d0e54a 100644 --- a/libc/inet/rpc/xdr_mem.c +++ b/libc/inet/rpc/xdr_mem.c @@ -137,7 +137,7 @@ xdrmem_getbytes (XDR *xdrs, caddr_t addr, u_int len) { if ((xdrs->x_handy -= len) < 0) return FALSE; - memcpy (addr, xdrs->x_private, len); + __memcpy (addr, xdrs->x_private, len); xdrs->x_private += len; return TRUE; } @@ -151,7 +151,7 @@ xdrmem_putbytes (XDR *xdrs, const char *addr, u_int len) { if ((xdrs->x_handy -= len) < 0) return FALSE; - memcpy (xdrs->x_private, addr, len); + __memcpy (xdrs->x_private, addr, len); xdrs->x_private += len; return TRUE; } diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c index 9c21f57f4..749955401 100644 --- a/libc/inet/rpc/xdr_rec.c +++ b/libc/inet/rpc/xdr_rec.c @@ -142,8 +142,8 @@ static bool_t get_input_bytes (RECSTREAM *, caddr_t, int) internal_function; * write respectively. They are like the system * calls expect that they take an opaque handle rather than an fd. */ -void -xdrrec_create (XDR *xdrs, u_int sendsize, +void attribute_hidden +__xdrrec_create (XDR *xdrs, u_int sendsize, u_int recvsize, caddr_t tcp_handle, int (*readit) (char *, char *, int), int (*writeit) (char *, char *, int)) @@ -204,6 +204,7 @@ xdrrec_create (XDR *xdrs, u_int sendsize, rstrm->fbtbc = 0; rstrm->last_frag = TRUE; } +strong_alias(__xdrrec_create,xdrrec_create) /* @@ -296,7 +297,7 @@ xdrrec_putbytes (XDR *xdrs, const char *addr, u_int len) { current = rstrm->out_boundry - rstrm->out_finger; current = (len < current) ? len : current; - memcpy (rstrm->out_finger, addr, current); + __memcpy (rstrm->out_finger, addr, current); rstrm->out_finger += current; addr += current; len -= current; @@ -598,7 +599,7 @@ get_input_bytes (RECSTREAM *rstrm, caddr_t addr, int len) continue; } current = (len < current) ? len : current; - memcpy (addr, rstrm->in_finger, current); + __memcpy (addr, rstrm->in_finger, current); rstrm->in_finger += current; addr += current; len -= current; diff --git a/libc/inet/rpc/xdr_reference.c b/libc/inet/rpc/xdr_reference.c index 1569e51b7..177c25059 100644 --- a/libc/inet/rpc/xdr_reference.c +++ b/libc/inet/rpc/xdr_reference.c @@ -95,7 +95,7 @@ xdr_reference (xdrs, pp, size, proc) (void) fputs (_("xdr_reference: out of memory\n"), stderr); return FALSE; } - memset (loc, 0, (int) size); + __memset (loc, 0, (int) size); break; default: break; diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c index 35ab1d7a8..2215d2d99 100644 --- a/libc/inet/socketcalls.c +++ b/libc/inet/socketcalls.c @@ -5,7 +5,7 @@ #include <sys/socket.h> #ifdef __NR_socketcall -extern int __socketcall(int call, unsigned long *args); +extern int __socketcall(int call, unsigned long *args) attribute_hidden; /* Various socketcall numbers */ #define SYS_SOCKET 1 diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 9d2d74a2b..11f362a5e 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -1,70 +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 - - -DIRS = assert ctype dirent file fnmatch internals \ - mntent syslog time utmp sysvipc statfs \ - error ttyent gnu search locale -ifeq ($(strip $(UCLIBC_HAS_REGEX)),y) -DIRS += regex -endif -ifeq ($(strip $(UCLIBC_HAS_WORDEXP)),y) -DIRS += wordexp -endif -ifeq ($(strip $(UCLIBC_HAS_THREADS)),y) -DIRS += pthread -endif -ifeq ($(strip $(UCLIBC_HAS_WCHAR)),y) -DIRS += wctype wchar -endif -ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y) -DIRS += intl -endif -ifeq ($(strip $(UCLIBC_HAS_FTW)),y) -DIRS += ftw -endif -ifeq ($(strip $(UCLIBC_HAS_GLOB)),y) -DIRS += glob -endif - -all: subdirs - -tags: - ctags -R - -clean: subdirs_clean - $(RM) *.[oa] *~ core - -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/misc/assert/Makefile b/libc/misc/assert/Makefile index 57a2c0154..4a8f4a072 100644 --- a/libc/misc/assert/Makefile +++ b/libc/misc/assert/Makefile @@ -1,43 +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 - -CSRC=__assert.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.assert - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/assert/%, $(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/misc/ctype/Makefile b/libc/misc/ctype/Makefile index dd7b799bd..4a8f4a072 100644 --- a/libc/misc/ctype/Makefile +++ b/libc/misc/ctype/Makefile @@ -1,68 +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=ctype.c -MOBJ= isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o \ - isgraph.o islower.o isprint.o ispunct.o isspace.o \ - isupper.o isxdigit.o toascii.o tolower.o toupper.o \ - isblank.o isxlower.o isxupper.o - -ifeq ($(UCLIBC_HAS_CTYPE_TABLES),y) -MOBJ += __C_ctype_b.o __C_ctype_tolower.o __C_ctype_toupper.o \ - __ctype_b_loc.o __ctype_tolower_loc.o __ctype_toupper_loc.o \ - __ctype_assert.o isctype.o -endif - -MOBJx= isalnum_l.o isalpha_l.o isascii_l.o iscntrl_l.o isdigit_l.o \ - isgraph_l.o islower_l.o isprint_l.o ispunct_l.o isspace_l.o \ - isupper_l.o isxdigit_l.o toascii_l.o tolower_l.o toupper_l.o \ - isblank_l.o # isxlower_l.o isxupper_l.o - -OBJS=$(MOBJ) - -ifeq ($(UCLIBC_HAS_XLOCALE),y) - OBJS += $(MOBJx) -endif - -OBJ_LIST=../../obj.misc.ctype - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/ctype/%, $(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 - -$(OBJS): 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/misc/dirent/Makefile b/libc/misc/dirent/Makefile index 1f1032642..4a8f4a072 100644 --- a/libc/misc/dirent/Makefile +++ b/libc/misc/dirent/Makefile @@ -1,45 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2001 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 - -CSRC=alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c scandir.c \ - seekdir.c telldir.c readdir64.c alphasort64.c scandir64.c readdir_r.c \ - readdir64_r.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.dirent - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/dirent/%, $(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/misc/dirent/alphasort.c b/libc/misc/dirent/alphasort.c index dcf970070..feae021e6 100644 --- a/libc/misc/dirent/alphasort.c +++ b/libc/misc/dirent/alphasort.c @@ -4,7 +4,7 @@ int alphasort(const void * a, const void * b) { - return strcmp ((*(const struct dirent **) a)->d_name, + return __strcmp ((*(const struct dirent **) a)->d_name, (*(const struct dirent **) b)->d_name); } diff --git a/libc/misc/dirent/alphasort64.c b/libc/misc/dirent/alphasort64.c index bcae8108f..5801f4940 100644 --- a/libc/misc/dirent/alphasort64.c +++ b/libc/misc/dirent/alphasort64.c @@ -19,7 +19,7 @@ int alphasort64(const void * a, const void * b) { - return strcmp ((*(const struct dirent64 **) a)->d_name, + return __strcmp ((*(const struct dirent64 **) a)->d_name, (*(const struct dirent64 **) b)->d_name); } #endif /* __UCLIBC_HAS_LFS__ */ diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c index 068e2d3e2..57600ab69 100644 --- a/libc/misc/dirent/closedir.c +++ b/libc/misc/dirent/closedir.c @@ -29,5 +29,5 @@ int closedir(DIR * dir) #endif free(dir->dd_buf); free(dir); - return close(fd); + return __close(fd); } diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index 017684b40..9f5f75e3f 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -24,7 +24,7 @@ DIR *opendir(const char *name) __set_errno(ENOTDIR); return NULL; } - if ((fd = open(name, O_RDONLY)) < 0) + if ((fd = __open(name, O_RDONLY)) < 0) return NULL; /* According to POSIX, directory streams should be closed when * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>. @@ -32,7 +32,7 @@ DIR *opendir(const char *name) if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) return NULL; if (!(ptr = malloc(sizeof(*ptr)))) { - close(fd); + __close(fd); __set_errno(ENOMEM); return NULL; } @@ -45,7 +45,7 @@ DIR *opendir(const char *name) ptr->dd_max = 512; if (!(buf = calloc(1, ptr->dd_max))) { - close(fd); + __close(fd); free(ptr); __set_errno(ENOMEM); return NULL; diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c index da3564edb..1daae5116 100644 --- a/libc/misc/dirent/readdir64_r.c +++ b/libc/misc/dirent/readdir64_r.c @@ -62,7 +62,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result) if (de == NULL) { *result = NULL; } else { - *result = memcpy (entry, de, de->d_reclen); + *result = __memcpy (entry, de, de->d_reclen); } ret = 0; diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c index 245dcbdde..1c8eeadce 100644 --- a/libc/misc/dirent/readdir_r.c +++ b/libc/misc/dirent/readdir_r.c @@ -48,7 +48,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) if (de == NULL) { *result = NULL; } else { - *result = memcpy (entry, de, de->d_reclen); + *result = __memcpy (entry, de, de->d_reclen); } ret = 0; diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c index cb3d505db..8b08e4884 100644 --- a/libc/misc/dirent/scandir.c +++ b/libc/misc/dirent/scandir.c @@ -72,7 +72,7 @@ int scandir(const char *dir, struct dirent ***namelist, if (vnew == NULL) break; - names[pos++] = (struct dirent *) memcpy (vnew, current, dsize); + names[pos++] = (struct dirent *) __memcpy (vnew, current, dsize); } if (unlikely(errno != 0)) diff --git a/libc/misc/dirent/scandir64.c b/libc/misc/dirent/scandir64.c index b4cc57a36..2916285eb 100644 --- a/libc/misc/dirent/scandir64.c +++ b/libc/misc/dirent/scandir64.c @@ -87,7 +87,7 @@ int scandir64(const char *dir, struct dirent64 ***namelist, if (vnew == NULL) break; - names[pos++] = (struct dirent64 *) memcpy (vnew, current, dsize); + names[pos++] = (struct dirent64 *) __memcpy (vnew, current, dsize); } if (unlikely(errno != 0)) diff --git a/libc/misc/error/Makefile b/libc/misc/error/Makefile index 1ef71dfa7..4a8f4a072 100644 --- a/libc/misc/error/Makefile +++ b/libc/misc/error/Makefile @@ -1,38 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2002 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=error.c err.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.error - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/error/%, $(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/misc/error/error.c b/libc/misc/error/error.c index eddf24587..0a19e3923 100644 --- a/libc/misc/error/error.c +++ b/libc/misc/error/error.c @@ -22,6 +22,8 @@ /* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ /* Adjusted slightly by Erik Andersen <andersen@uclibc.org> */ +#define strerror __strerror + #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -68,7 +70,7 @@ void __error_at_line (int status, int errnum, const char *file_name, static unsigned int old_line_number; if (old_line_number == line_number && - (file_name == old_file_name || !strcmp (old_file_name, file_name))) + (file_name == old_file_name || !__strcmp (old_file_name, file_name))) /* Simply return and print nothing. */ return; diff --git a/libc/misc/file/Makefile b/libc/misc/file/Makefile index a590f6ab5..4a8f4a072 100644 --- a/libc/misc/file/Makefile +++ b/libc/misc/file/Makefile @@ -1,47 +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 - -ifeq ($(strip $(UCLIBC_HAS_LFS)),y) -CSRC = lockf.c lockf64.c -else -CSRC = lockf.c -endif -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.file - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/file/%, $(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/misc/file/lockf.c b/libc/misc/file/lockf.c index f95b24fac..0962031da 100644 --- a/libc/misc/file/lockf.c +++ b/libc/misc/file/lockf.c @@ -28,7 +28,7 @@ int lockf (int fd, int cmd, off_t len) { struct flock fl; - memset ((char *) &fl, '\0', sizeof (fl)); + __memset ((char *) &fl, '\0', sizeof (fl)); /* lockf is always relative to the current file position. */ fl.l_whence = SEEK_CUR; diff --git a/libc/misc/file/lockf64.c b/libc/misc/file/lockf64.c index 5638d6938..eb70e8ddd 100644 --- a/libc/misc/file/lockf64.c +++ b/libc/misc/file/lockf64.c @@ -62,7 +62,7 @@ int lockf64 (int fd, int cmd, off64_t len64) return -1; } - memset((char *) &fl, '\0', sizeof (fl)); + __memset((char *) &fl, '\0', sizeof (fl)); /* lockf is always relative to the current file position. */ fl.l_whence = SEEK_CUR; diff --git a/libc/misc/fnmatch/Makefile b/libc/misc/fnmatch/Makefile index 535169550..4a8f4a072 100644 --- a/libc/misc/fnmatch/Makefile +++ b/libc/misc/fnmatch/Makefile @@ -1,43 +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 - -CSRC=fnmatch.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.fnmatch - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/fnmatch/%, $(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/misc/ftw/Makefile b/libc/misc/ftw/Makefile index a8d52bf32..4a8f4a072 100644 --- a/libc/misc/ftw/Makefile +++ b/libc/misc/ftw/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 - -CSRC=ftw.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -MSRC=ftw.c -MOBJ=ftw.o ftw64.o -OBJS=$(MOBJ) - -OBJ_LIST=../../obj.misc.ftw - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/ftw/%, $(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/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c index e58c3e6ca..c36ae45b6 100644 --- a/libc/misc/ftw/ftw.c +++ b/libc/misc/ftw/ftw.c @@ -18,6 +18,12 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +/* used by D_EXACT_NAMLEN */ +#define strlen __strlen + +#define mempcpy __mempcpy +#define tsearch __tsearch + #define _GNU_SOURCE #include <features.h> @@ -421,7 +427,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st) /* Next, update the `struct FTW' information. */ ++data->ftw.level; - startp = strchr (data->dirbuf, '\0'); + startp = __strchr (data->dirbuf, '\0'); /* There always must be a directory name. */ assert (startp != data->dirbuf); if (startp[-1] != '/') @@ -457,7 +463,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st) while (result == 0 && *runp != '\0') { - char *endp = strchr (runp, '\0'); + char *endp = __strchr (runp, '\0'); result = process_entry (data, &dir, runp, endp - runp); @@ -498,7 +504,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, int flag __set_errno (ENOENT); return -1; } - if ((strlen(dir)+1) > NAME_MAX) { + if ((__strlen(dir)+1) > NAME_MAX) { __set_errno(ENAMETOOLONG); return -1; } @@ -507,10 +513,10 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, int flag data.actdir = 0; data.dirstreams = (struct dir_data **) alloca (data.maxdir * sizeof (struct dir_data *)); - memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *)); + __memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *)); /* PATH_MAX is always defined when we get here. */ - data.dirbufsize = MAX (2 * strlen (dir), PATH_MAX); + data.dirbufsize = MAX (2 * __strlen (dir), PATH_MAX); data.dirbuf = (char *) malloc (data.dirbufsize); if (data.dirbuf == NULL) return -1; diff --git a/libc/misc/glob/Makefile b/libc/misc/glob/Makefile index e753c936a..4a8f4a072 100644 --- a/libc/misc/glob/Makefile +++ b/libc/misc/glob/Makefile @@ -1,45 +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 - -CSRC=glob.c glob64.c glob-hooks.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.glob - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/glob/%, $(OBJS)) > $(OBJ_LIST) - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -glob64.o: glob64.c glob.c -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/misc/glob/glob.c b/libc/misc/glob/glob.c index 0d788df53..22f1874ab 100644 --- a/libc/misc/glob/glob.c +++ b/libc/misc/glob/glob.c @@ -15,6 +15,9 @@ License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define strrchr __strrchr +#define strcoll __strcoll + #include <features.h> #include <stdlib.h> #include <string.h> @@ -124,7 +127,7 @@ glob (pattern, flags, errfunc, pglob) { dirlen = filename - pattern; dirname = (char *) alloca (dirlen + 1); - memcpy (dirname, pattern, dirlen); + __memcpy (dirname, pattern, dirlen); dirname[dirlen] = '\0'; ++filename; } @@ -216,11 +219,11 @@ glob (pattern, flags, errfunc, pglob) /* No matches. */ if (flags & GLOB_NOCHECK) { - size_t len = strlen (pattern) + 1; + size_t len = __strlen (pattern) + 1; char *patcopy = (char *) malloc (len); if (patcopy == NULL) return GLOB_NOSPACE; - memcpy (patcopy, pattern, len); + __memcpy (patcopy, pattern, len); pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, @@ -278,7 +281,7 @@ glob (pattern, flags, errfunc, pglob) for (i = oldcount; i < pglob->gl_pathc; ++i) if (lstat (pglob->gl_pathv[i], &st) == 0 && S_ISDIR (st.st_mode)) - strcat (pglob->gl_pathv[i], "/"); + __strcat (pglob->gl_pathv[i], "/"); } if (!(flags & GLOB_NOSORT)) @@ -340,7 +343,7 @@ prefix_array (dirname, array, n, add_slash) int add_slash; { register size_t i; - size_t dirlen = strlen (dirname); + size_t dirlen = __strlen (dirname); if (dirlen == 1 && dirname[0] == '/') /* DIRNAME is just "/", so normal prepending would get us "//foo". @@ -349,7 +352,7 @@ prefix_array (dirname, array, n, add_slash) for (i = 0; i < n; ++i) { - size_t eltlen = strlen (array[i]) + 1; + size_t eltlen = __strlen (array[i]) + 1; char *new = (char *) malloc (dirlen + 1 + eltlen + (add_slash ? 1 : 0)); if (new == NULL) { @@ -358,9 +361,9 @@ prefix_array (dirname, array, n, add_slash) return 1; } - memcpy (new, dirname, dirlen); + __memcpy (new, dirname, dirlen); new[dirlen] = '/'; - memcpy (&new[dirlen + 1], array[i], eltlen); + __memcpy (&new[dirlen + 1], array[i], eltlen); free ((__ptr_t) array[i]); array[i] = new; } @@ -433,7 +436,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) #endif } - if ((!meta && strcmp (pattern, name) == 0) + if ((!meta && __strcmp (pattern, name) == 0) || fnmatch (pattern, name, (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0) @@ -441,12 +444,12 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) struct globlink *new = (struct globlink *) alloca (sizeof (struct globlink)); if (len == 0) - len = strlen (name); + len = __strlen (name); new->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); if (new->name == NULL) goto memory_error; - memcpy ((__ptr_t) new->name, name, len); + __memcpy ((__ptr_t) new->name, name, len); new->name[len] = '\0'; new->next = names; names = new; @@ -458,14 +461,14 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) if (nfound == 0 && (flags & GLOB_NOCHECK)) { - size_t len = strlen (pattern); + size_t len = __strlen (pattern); nfound = 1; names = (struct globlink *) alloca (sizeof (struct globlink)); names->next = NULL; names->name = (char *) malloc (len + (flags & GLOB_MARK ? 1 : 0) + 1); if (names->name == NULL) goto memory_error; - memcpy (names->name, pattern, len); + __memcpy (names->name, pattern, len); names->name[len] = '\0'; } diff --git a/libc/misc/gnu/Makefile b/libc/misc/gnu/Makefile index a338b8131..4a8f4a072 100644 --- a/libc/misc/gnu/Makefile +++ b/libc/misc/gnu/Makefile @@ -1,43 +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 - -CSRC=obstack.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.gnu - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/gnu/%, $(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/misc/internals/Makefile b/libc/misc/internals/Makefile index 1df05a934..4a8f4a072 100644 --- a/libc/misc/internals/Makefile +++ b/libc/misc/internals/Makefile @@ -1,58 +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 - -CSRC=__uClibc_main.c tempname.c errno.c __errno_location.c __h_errno_location.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -__uClibc_main.o: CFLAGS += $(SSP_DISABLE_FLAGS) - -OBJS=$(COBJS) - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -OBJ_LIST=../../obj.misc.internals - -all: $(OBJ_LIST) interp.o static.o - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/internals/%, $(OBJS)) > $(OBJ_LIST) - -interp.c: Makefile - echo "/* Force shared libraries to know about the correct library loader */" > interp.c - echo "#include <features.h>" >> interp.c - echo "#ifdef __HAVE_ELF__" >> interp.c - echo "const char __dl_ldso__[] __attribute__ ((section " \ - "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> interp.c - echo "#endif" >> interp.c - -$(COBJS) interp.o static.o: %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o -clean: - $(RM) *.[oa] interp.c *~ core +top_srcdir=../../../ +top_builddir=../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in index 8863aba7b..4c7012d9a 100644 --- a/libc/misc/internals/Makefile.in +++ b/libc/misc/internals/Makefile.in @@ -16,14 +16,6 @@ MISC_INTERNALS_OUT:=$(top_builddir)libc/misc/internals MISC_INTERNALS_SRC:=$(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC)) MISC_INTERNALS_OBJ:=$(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC)) -$(MISC_INTERNALS_OUT)/interp.c: $(top_builddir)include/headers_done - $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@ - $(Q)echo "#include <features.h>" >> $@ - $(Q)echo "#ifdef __HAVE_ELF__" >> $@ - $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \ - "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@ - $(Q)echo "#endif" >> $@ - libc-a-y+=$(MISC_INTERNALS_OBJ) libc-so-y+=$(MISC_INTERNALS_OBJ:.o=.os) libc-shared-y+=$(MISC_INTERNALS_OUT)/__uClibc_main.oS @@ -34,4 +26,4 @@ libc-multi-y+=$(MISC_INTERNALS_SRC) objclean-y+=misc_internals_objclean misc_internals_objclean: - $(RM) $(MISC_INTERNALS_OUT)/{*.{o,os,oS},interp.c} + $(RM) $(MISC_INTERNALS_OUT)/*.{o,os,oS} diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c index cd1f3497b..360c76879 100644 --- a/libc/misc/internals/tempname.c +++ b/libc/misc/internals/tempname.c @@ -31,6 +31,8 @@ * Use brain damaged getpid() if real random fails. */ +#define open64 __open64 + #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -59,7 +61,7 @@ static int direxists (const char *dir) for use with mk[s]temp. Will fail (-1) if DIR is non-null and doesn't exist, none of the searched dirs exists, or there's not enough space in TMPL. */ -int __path_search (char *tmpl, size_t tmpl_len, const char *dir, +int attribute_hidden __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, int try_tmpdir) { //const char *d; @@ -72,7 +74,7 @@ int __path_search (char *tmpl, size_t tmpl_len, const char *dir, } else { - plen = strlen (pfx); + plen = __strlen (pfx); if (plen > 5) plen = 5; } @@ -94,7 +96,7 @@ int __path_search (char *tmpl, size_t tmpl_len, const char *dir, { if (direxists (P_tmpdir)) dir = P_tmpdir; - else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) + else if (__strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) dir = "/tmp"; else { @@ -103,7 +105,7 @@ int __path_search (char *tmpl, size_t tmpl_len, const char *dir, } } - dlen = strlen (dir); + dlen = __strlen (dir); while (dlen > 1 && dir[dlen - 1] == '/') dlen--; /* remove trailing slashes */ @@ -126,13 +128,13 @@ static unsigned int fillrand(unsigned char *buf, unsigned int len) { int fd; unsigned int result = -1; - fd = open("/dev/urandom", O_RDONLY); + fd = __open("/dev/urandom", O_RDONLY); if (fd < 0) { - fd = open("/dev/random", O_RDONLY | O_NONBLOCK); + fd = __open("/dev/random", O_RDONLY | O_NONBLOCK); } if (fd >= 0) { - result = read(fd, buf, len); - close(fd); + result = __read(fd, buf, len); + __close(fd); } return result; } @@ -175,15 +177,15 @@ static void brain_damaged_fillrand(unsigned char *buf, unsigned int len) __GT_DIR: create a directory, which will be mode 0700. */ -int __gen_tempname (char *tmpl, int kind) +int attribute_hidden __gen_tempname (char *tmpl, int kind) { char *XXXXXX; unsigned int k; int len, i, count, fd, save_errno = errno; unsigned char randomness[6]; - len = strlen (tmpl); - if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX")) + len = __strlen (tmpl); + if (len < 6 || __strcmp (&tmpl[len - 6], "XXXXXX")) { __set_errno (EINVAL); return -1; @@ -223,7 +225,7 @@ int __gen_tempname (char *tmpl, int kind) continue; } case __GT_FILE: - fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); break; #if defined __UCLIBC_HAS_LFS__ case __GT_BIGFILE: diff --git a/libc/misc/internals/tempname.h b/libc/misc/internals/tempname.h index f068727a7..dfe9399ca 100644 --- a/libc/misc/internals/tempname.h +++ b/libc/misc/internals/tempname.h @@ -4,8 +4,8 @@ #define __need_size_t #include <stddef.h> extern int __path_search (char *tmpl, size_t tmpl_len, const char *dir, - const char *pfx, int try_tmpdir); -extern int __gen_tempname (char *__tmpl, int __kind); + const char *pfx, int try_tmpdir) attribute_hidden; +extern int __gen_tempname (char *__tmpl, int __kind) attribute_hidden; /* The __kind argument to __gen_tempname may be one of: */ #define __GT_FILE 0 /* create a file */ diff --git a/libc/misc/intl/Makefile b/libc/misc/intl/Makefile index e0eb06493..4a8f4a072 100644 --- a/libc/misc/intl/Makefile +++ b/libc/misc/intl/Makefile @@ -1,49 +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= intl.c -MOBJ= __uClibc_dgettext.o __uClibc_dcgettext.o \ - __uClibc_textdomain.o __uClibc_bindtextdomain.o # for libstd++ - -OBJS=$(MOBJ) - -OBJ_LIST=../../obj.misc.intl - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/intl/%, $(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/misc/intl/intl.c b/libc/misc/intl/intl.c index f3255828c..e882f441c 100644 --- a/libc/misc/intl/intl.c +++ b/libc/misc/intl/intl.c @@ -60,7 +60,7 @@ char *__uClibc_textdomain(const char *domainname) { static const char default_str[] = "messages"; - if (domainname && *domainname && strcmp(domainname, default_str)) { + if (domainname && *domainname && __strcmp(domainname, default_str)) { __set_errno(EINVAL); return NULL; } @@ -82,7 +82,7 @@ char *__uClibc_bindtextdomain(const char *domainname, const char *dirname) #if 1 && ((dirname[0] != '/') || dirname[1]) #else - && strcmp(dirname, dir) + && __strcmp(dirname, dir) #endif ) ) { diff --git a/libc/misc/locale/Makefile b/libc/misc/locale/Makefile index 5ab005538..4a8f4a072 100644 --- a/libc/misc/locale/Makefile +++ b/libc/misc/locale/Makefile @@ -1,71 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000 by Lineo, inc. -# Copyright (C) 2000-2002 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= locale.c -MOBJ= setlocale.o localeconv.o _locale_init.o nl_langinfo.o -MOBJx= - -ifeq ($(UCLIBC_HAS_LOCALE),y) - MOBJ += newlocale.o __locale_mbrtowc_l.o -endif - -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJx += nl_langinfo_l.o duplocale.o freelocale.o uselocale.o __curlocale.o -endif - -DATA= -ifeq ($(UCLIBC_HAS_LOCALE),y) - DATA = locale_data.o -endif - -OBJS= $(MOBJ) $(MOBJx) $(DATA) - -OBJ_LIST=../../obj.misc.locale - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/locale/%, $(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 - -locale_data.o: - $(LN) -sf ../../../extra/locale/locale_data.c - $(CC) $(CFLAGS) -c -D__WCHAR_ENABLED -I../../../extra/locale locale_data.c -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(OBJS): Makefile - -clean: - $(RM) *.[oa] *~ core locale_data.c -.PHONY: data +top_srcdir=../../../ +top_builddir=../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in index 9d0074521..f4439cdf5 100644 --- a/libc/misc/locale/Makefile.in +++ b/libc/misc/locale/Makefile.in @@ -18,11 +18,6 @@ ifeq ($(UCLIBC_HAS_XLOCALE),y) MOBJx:=nl_langinfo_l.o duplocale.o freelocale.o uselocale.o __curlocale.o endif -DATA:= -ifeq ($(UCLIBC_HAS_LOCALE),y) -DATA:=locale_data.o -endif - MISC_LOCALE_NO_MULTI=localeconv.o MISC_LOCALE_DIR:=$(top_srcdir)libc/misc/locale @@ -31,7 +26,6 @@ MISC_LOCALE_OUT:=$(top_builddir)libc/misc/locale MISC_LOCALE_MSRC:=$(MISC_LOCALE_DIR)/$(MSRC) MISC_LOCALE_MOBJ:=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MOBJ)) MISC_LOCALE_MOBJx:=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MOBJx)) -MISC_LOCALE_DATA:=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(DATA)) MISC_LOCALE_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(MISC_LOCALE_NO_MULTI),$(notdir $(MISC_LOCALE_MOBJ))))) @@ -47,26 +41,17 @@ $(MISC_LOCALE_MOBJx): $(MISC_LOCALE_MSRC) $(MISC_LOCALE_MOBJx:.o=.os): $(MISC_LOCALE_MSRC) $(compile.m) -D__UCLIBC_DO_XLOCALE -$(MISC_LOCALE_DATA): $(top_builddir)extra/locale/$(notdir $(MISC_LOCALE_DATA:.o=.c)) - $(compile.c) -D__WCHAR_ENABLED -I$(dir $<) - -$(MISC_LOCALE_DATA:.o=.os): $(top_builddir)extra/locale/$(notdir $(MISC_LOCALE_DATA:.o=.c)) - $(compile.c) -D__WCHAR_ENABLED -I$(dir $<) - libc-a-y+=$(MISC_LOCALE_MOBJ) -libc-a-$(UCLIBC_HAS_LOCALE)+=$(MISC_LOCALE_DATA) libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx) libc-so-y+=$(MISC_LOCALE_MOBJ:.o=.os) -libc-so-$(UCLIBC_HAS_LOCALE)+=$(MISC_LOCALE_DATA:.o=.os) libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx:.o=.os) CFLAGS-multi-y+=$(MISC_LOCALE_DEF) libc-multi-y+=$(MISC_LOCALE_MSRC) libc-nomulti-y+=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MISC_LOCALE_NO_MULTI)) -libc-nomulti-$(UCLIBC_HAS_LOCALE)+=$(MISC_LOCALE_DATA) libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx) objclean-y+=misc_locale_objclean misc_locale_objclean: - $(RM) $(MISC_LOCALE_OUT)/{*.{o,os},locale_data.c} + $(RM) $(MISC_LOCALE_OUT)/{*.{o,os}} diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index 6e5830733..77d3f1e5d 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -46,6 +46,8 @@ * locale support had (8-bit codesets only). */ +#define strtok_r __strtok_r + #define _GNU_SOURCE #define __CTYPE_HAS_8_BIT_LOCALES 1 @@ -153,7 +155,7 @@ char *setlocale(int category, register const char *locale) && ( (!locale) /* Request for locale category string. */ || (!*locale) /* Implementation-defined default is C. */ || ((*locale == 'C') && !locale[1]) - || (!strcmp(locale, "POSIX"))) ) + || (!__strcmp(locale, "POSIX"))) ) ? (char *) C_string /* Always in C/POSIX locale. */ : NULL; } @@ -224,7 +226,7 @@ static void update_hr_locale(const unsigned char *spec) *n = 0; } else { char at = 0; - memcpy(n, LOCALE_NAMES + 5*((*loc)-1), 5); + __memcpy(n, LOCALE_NAMES + 5*((*loc)-1), 5); if (n[2] != '_') { at = n[2]; n[2] = '_'; @@ -453,7 +455,7 @@ static int init_cur_collate(int der_num, __collate_t *cur_collate) + cdd->base_idx * sizeof(coldata_base_t) )/2 ); - memcpy(cur_collate, cdb, offsetof(coldata_base_t,index2weight_offset)); + __memcpy(cur_collate, cdb, offsetof(coldata_base_t,index2weight_offset)); cur_collate->undefined_idx = cdd->undefined_idx; cur_collate->ti_mask = (1 << cur_collate->ti_shift)-1; @@ -505,9 +507,9 @@ static int init_cur_collate(int der_num, __collate_t *cur_collate) cur_collate->index2ruleidx = cur_collate->index2weight + cur_collate->max_col_index + 1; - memcpy(cur_collate->index2weight, cur_collate->index2weight_tbl, + __memcpy(cur_collate->index2weight, cur_collate->index2weight_tbl, cur_collate->num_col_base * sizeof(uint16_t)); - memcpy(cur_collate->index2ruleidx, cur_collate->index2ruleidx_tbl, + __memcpy(cur_collate->index2ruleidx, cur_collate->index2ruleidx_tbl, cur_collate->num_col_base * sizeof(uint16_t)); /* now do the overrides */ @@ -592,7 +594,7 @@ int _locale_set_l(const unsigned char *p, __locale_t base) return 0; /* calloc failed. */ } free(base->collate.index2weight); - memcpy(&base->collate, &newcol, sizeof(__collate_t)); + __memcpy(&base->collate, &newcol, sizeof(__collate_t)); } do { @@ -662,15 +664,15 @@ int _locale_set_l(const unsigned char *p, __locale_t base) * All of this will be replaced in the next generation * of locale support anyway... */ - memcpy(base->__ctype_b_data, + __memcpy(base->__ctype_b_data, __C_ctype_b - __UCLIBC_CTYPE_B_TBL_OFFSET, (256 + __UCLIBC_CTYPE_B_TBL_OFFSET) * sizeof(__ctype_mask_t)); - memcpy(base->__ctype_tolower_data, + __memcpy(base->__ctype_tolower_data, __C_ctype_tolower - __UCLIBC_CTYPE_TO_TBL_OFFSET, (256 + __UCLIBC_CTYPE_TO_TBL_OFFSET) * sizeof(__ctype_touplow_t)); - memcpy(base->__ctype_toupper_data, + __memcpy(base->__ctype_toupper_data, __C_ctype_toupper - __UCLIBC_CTYPE_TO_TBL_OFFSET, (256 + __UCLIBC_CTYPE_TO_TBL_OFFSET) * sizeof(__ctype_touplow_t)); @@ -780,7 +782,7 @@ int _locale_set_l(const unsigned char *p, __locale_t base) d = base->outdigit_length; x = &base->outdigit0_mb; for (c = 0 ; c < 10 ; c++) { - ((unsigned char *)d)[c] = strlen(x[c]); + ((unsigned char *)d)[c] = __strlen(x[c]); assert(d[c] > 0); } } else if (i == LC_NUMERIC) { @@ -845,10 +847,10 @@ static const uint16_t __code2flag[16] = { void _locale_init_l(__locale_t base) { - memset(base->cur_locale, 0, LOCALE_SELECTOR_SIZE); + __memset(base->cur_locale, 0, LOCALE_SELECTOR_SIZE); base->cur_locale[0] = '#'; - memcpy(base->category_item_count, + __memcpy(base->category_item_count, __locale_mmap->lc_common_item_offsets_LEN, LC_ALL); @@ -1070,14 +1072,14 @@ static int find_locale(int category_mask, const char *p, char buf[18]; /* TODO: 7+{max codeset name length} */ const char *q; - if ((q = strchr(p,'@')) != NULL) { + if ((q = __strchr(p,'@')) != NULL) { if ((((size_t)((q-p)-5)) > (sizeof(buf) - 5)) || (p[2] != '_')) { return 0; } /* locale name at least 5 chars long and 3rd char is '_' */ s = LOCALE_AT_MODIFIERS; do { - if (!strcmp(s+2, q+1)) { + if (!__strcmp(s+2, q+1)) { break; } s += 2 + *s; /* TODO - fix this throughout */ @@ -1086,7 +1088,7 @@ static int find_locale(int category_mask, const char *p, return 0; } assert(q - p < sizeof(buf)); - memcpy(buf, p, q-p); + __memcpy(buf, p, q-p); buf[q-p] = 0; buf[2] = s[1]; p = buf; @@ -1094,19 +1096,19 @@ static int find_locale(int category_mask, const char *p, #endif lang_cult = codeset = 0; /* Assume C and default codeset. */ - if (((*p == 'C') && !p[1]) || !strcmp(p, posix)) { + if (((*p == 'C') && !p[1]) || !__strcmp(p, posix)) { goto FIND_LOCALE; } - if ((strlen(p) > 5) && (p[5] == '.')) { /* Codeset in locale name? */ + if ((__strlen(p) > 5) && (p[5] == '.')) { /* Codeset in locale name? */ /* TODO: maybe CODESET_LIST + *s ??? */ /* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */ codeset = 2; - if (strcmp(utf8,p+6) != 0) {/* TODO - fix! */ + if (__strcmp(utf8,p+6) != 0) {/* TODO - fix! */ s = CODESET_LIST; do { ++codeset; /* Increment codeset first. */ - if (!strcmp(CODESET_LIST+*s, p+6)) { + if (!__strcmp(CODESET_LIST+*s, p+6)) { goto FIND_LANG_CULT; } } while (*++s); @@ -1119,7 +1121,7 @@ static int find_locale(int category_mask, const char *p, do { /* TODO -- do a binary search? */ /* TODO -- fix gen_mmap!*/ ++lang_cult; /* Increment first since C/POSIX is 0. */ - if (!strncmp(s,p,5)) { /* Found a matching locale name; */ + if (!__strncmp(s,p,5)) { /* Found a matching locale name; */ goto FIND_LOCALE; } s += 5; @@ -1161,14 +1163,14 @@ static unsigned char *composite_locale(int category_mask, const char *locale, int c; int component_mask; - if (!strchr(locale,'=')) { + if (!__strchr(locale,'=')) { if (!find_locale(category_mask, locale, new_locale)) { return NULL; } return new_locale; } - if (strlen(locale) >= sizeof(buf)) { + if (__strlen(locale) >= sizeof(buf)) { return NULL; } stpcpy(buf, locale); @@ -1177,7 +1179,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale, t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */ do { c = 0; - while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) { + while (__strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) { if (++c == LC_ALL) { /* Unknown category name! */ return NULL; } @@ -1219,7 +1221,7 @@ __locale_t __newlocale(int category_mask, const char *locale, __locale_t base) #ifdef __UCLIBC_MJN3_ONLY__ #warning TODO: Rename cur_locale to locale_selector. #endif - strcpy((char *) new_selector, + __strcpy((char *) new_selector, (base ? (char *) base->cur_locale : C_LOCALE_SELECTOR)); if (!*locale) { /* locale == "", so check environment. */ @@ -1308,9 +1310,9 @@ __locale_t __duplocale(__locale_t dataset) if ((i2w = calloc(n, sizeof(uint16_t))) != NULL ) { - memcpy(r, dataset, sizeof(__uclibc_locale_t)); + __memcpy(r, dataset, sizeof(__uclibc_locale_t)); r->collate.index2weight = i2w; - memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t)); + __memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t)); } else { free(r); r = NULL; @@ -1413,8 +1415,8 @@ __locale_t weak_function __curlocale_set(__locale_t newloc) #define Cc2wc_ROW_LEN __LOCALE_DATA_Cc2wc_ROW_LEN extern size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn, - const char **__restrict src, size_t n, - mbstate_t *ps, int allow_continuation); + const char **__restrict src, size_t n, + mbstate_t *ps, int allow_continuation) attribute_hidden; int __locale_mbrtowc_l(wchar_t *__restrict dst, const char *__restrict src, diff --git a/libc/misc/mntent/Makefile b/libc/misc/mntent/Makefile index 34a3d6f71..4a8f4a072 100644 --- a/libc/misc/mntent/Makefile +++ b/libc/misc/mntent/Makefile @@ -1,43 +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 - -CSRC=mntent.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.mntent - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/mntent/%, $(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/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c index d98a6870f..1af5a6b67 100644 --- a/libc/misc/mntent/mntent.c +++ b/libc/misc/mntent/mntent.c @@ -1,3 +1,6 @@ +#define strtok_r __strtok_r +#define strstr __strstr + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/libc/misc/pthread/Makefile b/libc/misc/pthread/Makefile index e222e1442..4a8f4a072 100644 --- a/libc/misc/pthread/Makefile +++ b/libc/misc/pthread/Makefile @@ -1,38 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2002 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=no-tsd.c weaks.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.pthread - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/pthread/%, $(OBJS)) > $(OBJ_LIST) - -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) $(PTINC) -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/misc/regex/regex.c b/libc/misc/regex/regex.c index 5e09af6d9..d367211c5 100644 --- a/libc/misc/regex/regex.c +++ b/libc/misc/regex/regex.c @@ -44,6 +44,15 @@ extern wctype_t __wctype (__const char *__property) attribute_hidden; extern int __iswctype (wint_t __wc, wctype_t __desc) /*attribute_hidden*/; #endif + +#define memcmp __memcmp +#define memcpy __memcpy +#define memmove __memmove +#define memset __memset +#define strchr __strchr +#define strcmp __strcmp +#define strlen __strlen +#define strncpy __strncpy #endif /* Make sure noone compiles this code with a C++ compiler. */ diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c index 3e9d2eb30..69b77c4c3 100644 --- a/libc/misc/regex/regex_old.c +++ b/libc/misc/regex/regex_old.c @@ -21,7 +21,6 @@ 02111-1307 USA. */ #define HAVE_MEMPCPY -#define __mempcpy __libc_mempcpy #define memset __memset #define memcmp __memcmp #define strcmp __strcmp @@ -40,7 +39,7 @@ #define STDC_HEADERS #define RE_TRANSLATE_TYPE char * -extern void *__libc_mempcpy (void *__restrict __dest, +extern void *__mempcpy (void *__restrict __dest, __const void *__restrict __src, size_t __n) /*attribute_hidden*/; /* AIX requires this to be the first thing in the file. */ diff --git a/libc/misc/search/Makefile b/libc/misc/search/Makefile index 7e67bb4e5..4a8f4a072 100644 --- a/libc/misc/search/Makefile +++ b/libc/misc/search/Makefile @@ -1,72 +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 - -MSRC1=tsearch.c -MOBJ1=tsearch.o tfind.o tdelete.o twalk.o tdestroy.o - -MSRC2=lsearch.c -MOBJ2=lfind.o lsearch.o - -MSRC3=insremque.c -MOBJ3=insque.o remque.o - -MSRC4=hsearch_r.c -MOBJ4=hcreate_r.o hdestroy_r.o hsearch_r.o - -CSRC=hsearch.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(COBJS) $(MOBJ1) $(MOBJ2) $(MOBJ3) $(MOBJ4) - -OBJ_LIST=../../obj.misc.search - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/search/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ1): $(MSRC1) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(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 - -$(MOBJ4): $(MSRC4) - $(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/misc/search/hsearch_r.c b/libc/misc/search/hsearch_r.c index 10efb1a88..0f96180b1 100644 --- a/libc/misc/search/hsearch_r.c +++ b/libc/misc/search/hsearch_r.c @@ -140,7 +140,7 @@ int hsearch_r (ENTRY item, ACTION action, ENTRY **retval, { unsigned int hval; unsigned int count; - unsigned int len = strlen (item.key); + unsigned int len = __strlen (item.key); unsigned int idx; /* Compute an value for the given string. Perhaps use a better method. */ @@ -166,7 +166,7 @@ int hsearch_r (ENTRY item, ACTION action, ENTRY **retval, unsigned hval2; if (htab->table[idx].used == hval - && strcmp (item.key, htab->table[idx].entry.key) == 0) + && __strcmp (item.key, htab->table[idx].entry.key) == 0) { *retval = &htab->table[idx].entry; return 1; @@ -190,7 +190,7 @@ int hsearch_r (ENTRY item, ACTION action, ENTRY **retval, /* If entry is found use it. */ if (htab->table[idx].used == hval - && strcmp (item.key, htab->table[idx].entry.key) == 0) + && __strcmp (item.key, htab->table[idx].entry.key) == 0) { *retval = &htab->table[idx].entry; return 1; diff --git a/libc/misc/search/lsearch.c b/libc/misc/search/lsearch.c index 2a9996d47..4bc45ca36 100644 --- a/libc/misc/search/lsearch.c +++ b/libc/misc/search/lsearch.c @@ -37,7 +37,7 @@ void *lsearch(const void *key, void *base, size_t *nmemb, register char *p; if ((p = lfind(key, base, nmemb, size, compar)) == NULL) { - p = memcpy((base + (size * (*nmemb))), key, size); + p = __memcpy((base + (size * (*nmemb))), key, size); ++(*nmemb); } return (p); diff --git a/libc/misc/search/tsearch.c b/libc/misc/search/tsearch.c index 72abcee7b..1da6b571e 100644 --- a/libc/misc/search/tsearch.c +++ b/libc/misc/search/tsearch.c @@ -51,7 +51,7 @@ register node **rootp; address of tree root int (*compar)(); ordering function */ -void *tsearch(__const void *key, void **vrootp, __compar_fn_t compar) +void attribute_hidden *__tsearch(__const void *key, void **vrootp, __compar_fn_t compar) { register node *q; register node **rootp = (node **) vrootp; @@ -77,6 +77,7 @@ void *tsearch(__const void *key, void **vrootp, __compar_fn_t compar) } return (q); } +strong_alias(__tsearch,tsearch) #endif #ifdef L_tfind diff --git a/libc/misc/statfs/Makefile b/libc/misc/statfs/Makefile index bbb9dd0bc..4a8f4a072 100644 --- a/libc/misc/statfs/Makefile +++ b/libc/misc/statfs/Makefile @@ -1,45 +1,13 @@ # Makefile for uClibc -# Copyright (C) 2001,2002 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. +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # -# 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. +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# 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 - -ifeq ($(strip $(UCLIBC_HAS_LFS)),y) -CSRC = fstatfs64.c statfs64.c statvfs.c statvfs64.c fstatvfs.c fstatvfs64.c -else -CSRC = statvfs.c fstatvfs.c -endif -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.statfs - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/statfs/%, $(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/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c index 1040e1fe1..b793002fb 100644 --- a/libc/misc/statfs/fstatfs64.c +++ b/libc/misc/statfs/fstatfs64.c @@ -57,7 +57,7 @@ int fstatfs64 (int fd, struct statfs64 *buf) buf->f_ffree = buf32.f_ffree; buf->f_fsid = buf32.f_fsid; buf->f_namelen = buf32.f_namelen; - memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare)); + __memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare)); return 0; } diff --git a/libc/misc/statfs/fstatvfs.c b/libc/misc/statfs/fstatvfs.c index 5e08f51ad..b79195e73 100644 --- a/libc/misc/statfs/fstatvfs.c +++ b/libc/misc/statfs/fstatvfs.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define strsep __strsep + #include <features.h> #define __USE_GNU diff --git a/libc/misc/statfs/fstatvfs64.c b/libc/misc/statfs/fstatvfs64.c index ed4b63234..0d7416df3 100644 --- a/libc/misc/statfs/fstatvfs64.c +++ b/libc/misc/statfs/fstatvfs64.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define strsep __strsep + #include <features.h> #ifdef __UCLIBC_HAS_LFS__ diff --git a/libc/misc/statfs/internal_statvfs.c b/libc/misc/statfs/internal_statvfs.c index aa7af44f5..8f7e386c4 100644 --- a/libc/misc/statfs/internal_statvfs.c +++ b/libc/misc/statfs/internal_statvfs.c @@ -39,7 +39,7 @@ buf->__f_unused = 0; #endif buf->f_namemax = fsbuf.f_namelen; - memset (buf->__f_spare, '\0', 6 * sizeof (int)); + __memset (buf->__f_spare, '\0', 6 * sizeof (int)); /* What remains to do is to fill the fields f_favail and f_flag. */ @@ -79,21 +79,21 @@ char *opt; while ((opt = strsep (&cp, ",")) != NULL) - if (strcmp (opt, "ro") == 0) + if (__strcmp (opt, "ro") == 0) buf->f_flag |= ST_RDONLY; - else if (strcmp (opt, "nosuid") == 0) + else if (__strcmp (opt, "nosuid") == 0) buf->f_flag |= ST_NOSUID; - else if (strcmp (opt, "noexec") == 0) + else if (__strcmp (opt, "noexec") == 0) buf->f_flag |= ST_NOEXEC; - else if (strcmp (opt, "nodev") == 0) + else if (__strcmp (opt, "nodev") == 0) buf->f_flag |= ST_NODEV; - else if (strcmp (opt, "sync") == 0) + else if (__strcmp (opt, "sync") == 0) buf->f_flag |= ST_SYNCHRONOUS; - else if (strcmp (opt, "mand") == 0) + else if (__strcmp (opt, "mand") == 0) buf->f_flag |= ST_MANDLOCK; - else if (strcmp (opt, "noatime") == 0) + else if (__strcmp (opt, "noatime") == 0) buf->f_flag |= ST_NOATIME; - else if (strcmp (opt, "nodiratime") == 0) + else if (__strcmp (opt, "nodiratime") == 0) buf->f_flag |= ST_NODIRATIME; /* We can stop looking for more entries. */ diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c index 0b954c675..7144cce71 100644 --- a/libc/misc/statfs/statfs64.c +++ b/libc/misc/statfs/statfs64.c @@ -55,7 +55,7 @@ int statfs64 (const char *file, struct statfs64 *buf) buf->f_ffree = buf32.f_ffree; buf->f_fsid = buf32.f_fsid; buf->f_namelen = buf32.f_namelen; - memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare)); + __memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare)); return 0; } diff --git a/libc/misc/statfs/statvfs.c b/libc/misc/statfs/statvfs.c index 02a95fcde..0fe239573 100644 --- a/libc/misc/statfs/statvfs.c +++ b/libc/misc/statfs/statvfs.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define strsep __strsep + #include <features.h> #define __USE_GNU diff --git a/libc/misc/statfs/statvfs64.c b/libc/misc/statfs/statvfs64.c index 78d1a4c3f..8bacbba70 100644 --- a/libc/misc/statfs/statvfs64.c +++ b/libc/misc/statfs/statvfs64.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define strsep __strsep + #include <features.h> #ifdef __UCLIBC_HAS_LFS__ diff --git a/libc/misc/syslog/Makefile b/libc/misc/syslog/Makefile index 26239ab7b..4a8f4a072 100644 --- a/libc/misc/syslog/Makefile +++ b/libc/misc/syslog/Makefile @@ -1,47 +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 - -CSRC=syslog.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -ifeq ($(UCLIBC_HAS_THREADS),y) -CFLAGS += $(PTINC) -endif - -OBJ_LIST=../../obj.misc.syslog - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/syslog/%, $(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/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c index 704336006..69ff0b38b 100644 --- a/libc/misc/syslog/syslog.c +++ b/libc/misc/syslog/syslog.c @@ -112,7 +112,7 @@ closelog_intern(int to_default) { LOCK; if (LogFile != -1) { - (void) close(LogFile); + (void) __close(LogFile); } LogFile = -1; connected = 0; @@ -158,7 +158,7 @@ vsyslog( int pri, const char *fmt, va_list ap ) struct sigaction action, oldaction; int sigpipe; - memset (&action, 0, sizeof (action)); + __memset (&action, 0, sizeof (action)); action.sa_handler = sigpipe_handler; sigemptyset (&action.sa_mask); sigpipe = sigaction (SIGPIPE, &action, &oldaction); @@ -184,7 +184,7 @@ vsyslog( int pri, const char *fmt, va_list ap ) (void)time(&now); stdp = p = tbuf + sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4); if (LogTag) { - if (strlen(LogTag) < sizeof(tbuf) - 64) + if (__strlen(LogTag) < sizeof(tbuf) - 64) p += sprintf(p, "%s", LogTag); else p += sprintf(p, "<BUFFER OVERRUN ATTEMPT>"); @@ -207,9 +207,9 @@ vsyslog( int pri, const char *fmt, va_list ap ) p += vsnprintf(p, end - p, fmt, ap); if (p >= end || p < head_end) { /* Returned -1 in case of error... */ static const char truncate_msg[12] = "[truncated] "; - memmove(head_end + sizeof(truncate_msg), head_end, + __memmove(head_end + sizeof(truncate_msg), head_end, end - head_end - sizeof(truncate_msg)); - memcpy(head_end, truncate_msg, sizeof(truncate_msg)); + __memcpy(head_end, truncate_msg, sizeof(truncate_msg)); if (p < head_end) { while (p < end && *p) { p++; @@ -225,14 +225,14 @@ vsyslog( int pri, const char *fmt, va_list ap ) /* Output to stderr if requested. */ if (LogStat & LOG_PERROR) { *last_chr = '\n'; - (void)write(STDERR_FILENO, stdp, last_chr - stdp + 1); + (void)__write(STDERR_FILENO, stdp, last_chr - stdp + 1); } /* Output the message to the local logger using NUL as a message delimiter. */ p = tbuf; *last_chr = 0; do { - rc = write(LogFile, p, last_chr + 1 - p); + rc = __write(LogFile, p, last_chr + 1 - p); if (rc < 0) { if ((errno==EAGAIN) || (errno==EINTR)) rc=0; @@ -253,12 +253,12 @@ vsyslog( int pri, const char *fmt, va_list ap ) */ /* should mode be `O_WRONLY | O_NOCTTY' ? -- Uli */ if (LogStat & LOG_CONS && - (fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { - p = strchr(tbuf, '>') + 1; + (fd = __open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { + p = __strchr(tbuf, '>') + 1; last_chr[0] = '\r'; last_chr[1] = '\n'; - (void)write(fd, p, last_chr - p + 2); - (void)close(fd); + (void)__write(fd, p, last_chr - p + 2); + (void)__close(fd); } getout: @@ -285,7 +285,7 @@ openlog( const char *ident, int logstat, int logfac ) LogFacility = logfac; if (LogFile == -1) { SyslogAddr.sa_family = AF_UNIX; - (void)strncpy(SyslogAddr.sa_data, _PATH_LOG, + (void)__strncpy(SyslogAddr.sa_data, _PATH_LOG, sizeof(SyslogAddr.sa_data)); retry: if (LogStat & LOG_NDELAY) { @@ -299,19 +299,19 @@ retry: if (LogFile != -1 && !connected) { if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - - sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data)) != -1) + sizeof(SyslogAddr.sa_data) + __strlen(SyslogAddr.sa_data)) != -1) { connected = 1; } else if (logType == SOCK_DGRAM) { logType = SOCK_STREAM; if (LogFile != -1) { - close(LogFile); + __close(LogFile); LogFile = -1; } goto retry; } else { if (LogFile != -1) { - close(LogFile); + __close(LogFile); LogFile = -1; } } diff --git a/libc/misc/sysvipc/Makefile b/libc/misc/sysvipc/Makefile index 11aba5758..4a8f4a072 100644 --- a/libc/misc/sysvipc/Makefile +++ b/libc/misc/sysvipc/Makefile @@ -1,78 +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 - -DIRS= - -MSRC=sem.c -MOBJ=semget.o semctl.o semop.o - -MSRC2=shm.c -MOBJ2=shmat.o shmctl.o shmdt.o shmget.o - -MSRC3=msgq.c -MOBJ3=msgctl.o msgget.o msgrcv.o msgsnd.o - -CSRC = ftok.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(MOBJ) $(MOBJ2) $(MOBJ3) $(COBJS) - -OBJ_LIST=../../obj.misc.sysvipc - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/sysvipc/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(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 - -$(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_%, $(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/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c index 29f3178d6..9c6f019bf 100644 --- a/libc/misc/sysvipc/shm.c +++ b/libc/misc/sysvipc/shm.c @@ -17,6 +17,9 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* SHMLBA is using it */ +#define __getpagesize __libc_getpagesize + #include <stdlib.h> #include <errno.h> #include <sys/shm.h> diff --git a/libc/misc/time/Makefile b/libc/misc/time/Makefile index ebeea09e6..4a8f4a072 100644 --- a/libc/misc/time/Makefile +++ b/libc/misc/time/Makefile @@ -1,73 +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= time.c -MOBJ= asctime.o asctime_r.o clock.o ctime.o ctime_r.o gmtime.o gmtime_r.o \ - localtime.o localtime_r.o mktime.o strftime.o strptime.o tzset.o \ - _time_t2tm.o __time_tm.o _time_mktime.o dysize.o timegm.o \ - _time_mktime_tzi.o _time_localtime_tzi.o -MOBJx= - -ifeq ($(UCLIBC_HAS_FLOATS),y) - MOBJ += difftime.o -endif -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJx += strftime_l.o strptime_l.o -endif - -ifeq ($(UCLIBC_HAS_WCHAR),y) - MOBJ += wcsftime.o -ifeq ($(UCLIBC_HAS_XLOCALE),y) - MOBJx += wcsftime_l.o -endif -endif - -CSRC= adjtime.c ftime.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) - -OBJS=$(COBJS) $(MOBJ) $(MOBJx) - -OBJ_LIST=../../obj.misc.time - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/time/%, $(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 - -$(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/misc/time/time.c b/libc/misc/time/time.c index 21c4bb96b..4d3c43492 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -129,6 +129,9 @@ * differs (intentionally) from glibc's behavior. */ +#define _uintmaxtostr __libc__uintmaxtostr +#define strnlen __strnlen + #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> @@ -210,26 +213,32 @@ extern pthread_mutex_t _time_tzlock; extern rule_struct _time_tzinfo[2]; extern struct tm *_time_t2tm(const time_t *__restrict timer, - int offset, struct tm *__restrict result); + int offset, struct tm *__restrict result) attribute_hidden; -extern time_t _time_mktime(struct tm *timeptr, int store_on_success); +extern time_t _time_mktime(struct tm *timeptr, int store_on_success) attribute_hidden; extern struct tm *__time_localtime_tzi(const time_t *__restrict timer, - struct tm *__restrict result, - rule_struct *tzi); + struct tm *__restrict result, + rule_struct *tzi) attribute_hidden; extern time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success, - rule_struct *tzi); + rule_struct *tzi) attribute_hidden; + +extern char *__asctime (__const struct tm *__tp) attribute_hidden; + +extern char *__asctime_r (__const struct tm *__restrict __tp, + char *__restrict __buf) attribute_hidden; /**********************************************************************/ #ifdef L_asctime static char __time_str[26]; -char *asctime(const struct tm *__restrict ptm) +char attribute_hidden *__asctime(const struct tm *ptm) { - return asctime_r(ptm, __time_str); + return __asctime_r(ptm, __time_str); } +strong_alias(__asctime,asctime) #endif /**********************************************************************/ @@ -297,7 +306,7 @@ static const unsigned char at_data[] = { ' ', '?', '?', '?', '?', '\n', 0 }; -char *asctime_r(register const struct tm *__restrict ptm, +char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm, register char *__restrict buffer) { int tmp; @@ -306,23 +315,23 @@ char *asctime_r(register const struct tm *__restrict ptm, assert(buffer); #ifdef SAFE_ASCTIME_R - memcpy(buffer, at_data + 3*(7 + 12), sizeof(at_data) - 3*(7 + 12)); + __memcpy(buffer, at_data + 3*(7 + 12), sizeof(at_data) - 3*(7 + 12)); if (((unsigned int)(ptm->tm_wday)) <= 6) { - memcpy(buffer, at_data + 3 * ptm->tm_wday, 3); + __memcpy(buffer, at_data + 3 * ptm->tm_wday, 3); } if (((unsigned int)(ptm->tm_mon)) <= 11) { - memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3); + __memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3); } #else assert(((unsigned int)(ptm->tm_wday)) <= 6); assert(((unsigned int)(ptm->tm_mon)) <= 11); - memcpy(buffer, at_data + 3*(7 + 12) - 3, sizeof(at_data) + 3 - 3*(7 + 12)); + __memcpy(buffer, at_data + 3*(7 + 12) - 3, sizeof(at_data) + 3 - 3*(7 + 12)); - memcpy(buffer, at_data + 3 * ptm->tm_wday, 3); - memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3); + __memcpy(buffer, at_data + 3 * ptm->tm_wday, 3); + __memcpy(buffer + 4, at_data + 3*7 + 3 * ptm->tm_mon, 3); #endif #ifdef SAFE_ASCTIME_R @@ -371,6 +380,7 @@ char *asctime_r(register const struct tm *__restrict ptm, return buffer - 8; } +strong_alias(__asctime_r,asctime_r) #endif /**********************************************************************/ @@ -445,7 +455,7 @@ clock_t clock(void) char *ctime(const time_t *clock) { /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */ - return asctime(localtime(clock)); + return __asctime(localtime(clock)); } #endif @@ -456,7 +466,7 @@ char *ctime_r(const time_t *clock, char *buf) { struct tm xtm; - return asctime_r(localtime_r(clock, &xtm), buf); + return __asctime_r(localtime_r(clock, &xtm), buf); } #endif @@ -576,7 +586,7 @@ static const char *lookup_tzname(const char *key) ll_tzname_item_t *p; for (p=ll_tzname ; p ; p=p->next) { - if (!strcmp(p->tzname, key)) { + if (!__strcmp(p->tzname, key)) { return p->tzname; } } @@ -587,7 +597,7 @@ static const char *lookup_tzname(const char *key) /* Insert as 3rd item in the list. */ p->next = ll_tzname[1].next; ll_tzname[1].next = p; - strcpy(p->tzname, key); + __strcpy(p->tzname, key); return p->tzname; } } @@ -679,7 +689,7 @@ static int tm_isdst(register const struct tm *__restrict ptm, return (isdst & 1); } -struct tm *__time_localtime_tzi(register const time_t *__restrict timer, +struct tm attribute_hidden *__time_localtime_tzi(register const time_t *__restrict timer, register struct tm *__restrict result, rule_struct *tzi) { @@ -731,8 +741,8 @@ time_t timegm(struct tm *timeptr) { rule_struct gmt_tzinfo[2]; - memset(gmt_tzinfo, 0, sizeof(gmt_tzinfo)); - strcpy(gmt_tzinfo[0].tzname, "GMT"); /* Match glibc behavior here. */ + __memset(gmt_tzinfo, 0, sizeof(gmt_tzinfo)); + __strcpy(gmt_tzinfo[0].tzname, "GMT"); /* Match glibc behavior here. */ return _time_mktime_tzi(timeptr, 1, gmt_tzinfo); } @@ -1492,7 +1502,7 @@ char *__XL(strptime)(const char *__restrict buf, const char *__restrict format, do { --j; o = __XL(nl_langinfo)(i+j __LOCALE_ARG); - if (!__XL(strncasecmp)(buf,o,strlen(o) __LOCALE_ARG) && *o) { + if (!__XL(strncasecmp)(buf,o,__strlen(o) __LOCALE_ARG) && *o) { do { /* Found a match. */ ++buf; } while (*++o); @@ -1747,11 +1757,11 @@ static char *read_TZ_file(char *buf) size_t todo; char *p = NULL; - if ((fd = open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY)) >= 0) { + if ((fd = __open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY)) >= 0) { todo = TZ_BUFLEN; p = buf; do { - if ((r = read(fd, p, todo)) < 0) { + if ((r = __read(fd, p, todo)) < 0) { goto ERROR; } if (r == 0) { @@ -1771,7 +1781,7 @@ static char *read_TZ_file(char *buf) ERROR: p = NULL; } - close(fd); + __close(fd); } return p; } @@ -1823,8 +1833,8 @@ void tzset(void) #ifdef __UCLIBC_HAS_TZ_CACHING__ *oldval = 0; /* Set oldval to an empty string. */ #endif /* __UCLIBC_HAS_TZ_CACHING__ */ - memset(_time_tzinfo, 0, 2*sizeof(rule_struct)); - strcpy(_time_tzinfo[0].tzname, UTC); + __memset(_time_tzinfo, 0, 2*sizeof(rule_struct)); + __strcpy(_time_tzinfo[0].tzname, UTC); goto DONE; } @@ -1833,13 +1843,13 @@ void tzset(void) } #ifdef __UCLIBC_HAS_TZ_CACHING__ - if (strcmp(e, oldval) == 0) { /* Same string as last time... */ + if (__strcmp(e, oldval) == 0) { /* Same string as last time... */ goto FAST_DONE; /* So nothing to do. */ } /* Make a copy of the TZ env string. It won't be nul-terminated if * it is too long, but it that case it will be illegal and will be reset * to the empty string anyway. */ - strncpy(oldval, e, TZ_BUFLEN); + __strncpy(oldval, e, TZ_BUFLEN); #endif /* __UCLIBC_HAS_TZ_CACHING__ */ count = 0; @@ -1953,7 +1963,7 @@ void tzset(void) } } - memcpy(_time_tzinfo, new_rules, sizeof(new_rules)); + __memcpy(_time_tzinfo, new_rules, sizeof(new_rules)); DONE: tzname[0] = _time_tzinfo[0].tzname; tzname[1] = _time_tzinfo[1].tzname; @@ -2023,7 +2033,7 @@ static const char utc_string[] = "UTC"; /* Note: offset is the correction in _days_ to *timer! */ -struct tm *_time_t2tm(const time_t *__restrict timer, +struct tm attribute_hidden *_time_t2tm(const time_t *__restrict timer, int offset, struct tm *__restrict result) { register int *p; @@ -2161,7 +2171,7 @@ struct tm __time_tm; /* Global shared by gmtime() and localtime(). */ /**********************************************************************/ #ifdef L__time_mktime -time_t _time_mktime(struct tm *timeptr, int store_on_success) +time_t attribute_hidden _time_mktime(struct tm *timeptr, int store_on_success) { time_t t; @@ -2185,7 +2195,7 @@ static const unsigned char __vals[] = { 29, }; -time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success, +time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_success, rule_struct *tzi) { #ifdef __BCC__ @@ -2200,7 +2210,7 @@ time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success, register const unsigned char *s; int d, default_dst; - memcpy(p, timeptr, sizeof(struct tm)); + __memcpy(p, timeptr, sizeof(struct tm)); if (!tzi[1].tzname[0]) { /* No dst in this timezone, */ p[8] = 0; /* so set tm_isdst to 0. */ @@ -2290,7 +2300,7 @@ time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success, if (store_on_success) { - memcpy(timeptr, p, sizeof(struct tm)); + __memcpy(timeptr, p, sizeof(struct tm)); } diff --git a/libc/misc/ttyent/Makefile b/libc/misc/ttyent/Makefile index 8aaf8e8e8..4a8f4a072 100644 --- a/libc/misc/ttyent/Makefile +++ b/libc/misc/ttyent/Makefile @@ -1,38 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2002 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=getttyent.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.ttyent - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/ttyent/%, $(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/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c index d7d77c1ba..c15228a24 100644 --- a/libc/misc/ttyent/getttyent.c +++ b/libc/misc/ttyent/getttyent.c @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#define __fsetlocking __libc_fsetlocking + #define _GNU_SOURCE #include <features.h> #include <ttyent.h> @@ -50,7 +52,7 @@ struct ttyent * getttynam(const char *tty) setttyent(); while ((t = getttyent())) - if (!strcmp(tty, t->ty_name)) + if (!__strcmp(tty, t->ty_name)) break; endttyent(); return (t); @@ -96,7 +98,7 @@ static char * skip(register char *p) static char * value(register char *p) { - return ((p = strchr(p, '=')) ? ++p : NULL); + return ((p = __strchr(p, '=')) ? ++p : NULL); } struct ttyent * getttyent(void) @@ -122,7 +124,7 @@ struct ttyent * getttyent(void) return (NULL); } /* skip lines that are too big */ - if (!strchr(p, '\n')) { + if (!__strchr(p, '\n')) { while ((c = getc_unlocked(tf)) != '\n' && c != EOF) ; continue; @@ -148,8 +150,8 @@ struct ttyent * getttyent(void) tty.ty_status = 0; tty.ty_window = NULL; -#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1]) -#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '=' +#define scmp(e) !__strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1]) +#define vcmp(e) !__strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '=' for (; *p; p = skip(p)) { if (scmp(_TTYS_OFF)) tty.ty_status &= ~TTY_ON; @@ -171,7 +173,7 @@ struct ttyent * getttyent(void) tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; - if ((p = strchr(p, '\n'))) + if ((p = __strchr(p, '\n'))) *p = '\0'; return (&tty); } diff --git a/libc/misc/utmp/Makefile b/libc/misc/utmp/Makefile index c4cab9e9b..4a8f4a072 100644 --- a/libc/misc/utmp/Makefile +++ b/libc/misc/utmp/Makefile @@ -1,43 +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 - -CSRC=utent.c wtent.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.utmp - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/utmp/%, $(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/misc/utmp/utent.c b/libc/misc/utmp/utent.c index aa74cb544..c3d9ab620 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -53,7 +53,7 @@ static struct utmp *__getutent(int utmp_fd) } LOCK; - if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp)) + if (__read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp)) { return NULL; } @@ -68,8 +68,8 @@ void setutent(void) LOCK; if (static_fd == -1) { - if ((static_fd = open(static_ut_name, O_RDWR)) < 0) { - if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) { + if ((static_fd = __open(static_ut_name, O_RDWR)) < 0) { + if ((static_fd = __open(static_ut_name, O_RDONLY)) < 0) { goto bummer; } } @@ -82,7 +82,7 @@ void setutent(void) bummer: UNLOCK; static_fd = -1; - close(static_fd); + __close(static_fd); return; } } @@ -95,7 +95,7 @@ void endutent(void) { LOCK; if (static_fd != -1) { - close(static_fd); + __close(static_fd); } static_fd = -1; UNLOCK; @@ -125,7 +125,7 @@ struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry) utmp_entry->ut_type == DEAD_PROCESS || utmp_entry->ut_type == LOGIN_PROCESS || utmp_entry->ut_type == USER_PROCESS) && - !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id))) + !__strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id))) { return lutmp; } @@ -142,7 +142,7 @@ struct utmp *getutline(const struct utmp *utmp_entry) while ((lutmp = __getutent(static_fd)) != NULL) { if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) && - !strcmp(lutmp->ut_line, utmp_entry->ut_line)) + !__strcmp(lutmp->ut_line, utmp_entry->ut_line)) { return lutmp; } @@ -162,11 +162,11 @@ struct utmp *pututline (const struct utmp *utmp_entry) if (__getutid(utmp_entry) != NULL) { lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); - if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) + if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) return NULL; } else { lseek(static_fd, (off_t) 0, SEEK_END); - if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) + if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) return NULL; } @@ -180,7 +180,7 @@ int utmpname (const char *new_ut_name) if (new_ut_name != NULL) { if (static_ut_name != default_file_name) free((char *)static_ut_name); - static_ut_name = strdup(new_ut_name); + static_ut_name = __strdup(new_ut_name); if (static_ut_name == NULL) { /* We should probably whine about out-of-memory * errors here... Instead just reset to the default */ @@ -189,7 +189,7 @@ int utmpname (const char *new_ut_name) } if (static_fd != -1) - close(static_fd); + __close(static_fd); UNLOCK; return 0; } diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c index ef5663feb..bb5244878 100644 --- a/libc/misc/utmp/wtent.c +++ b/libc/misc/utmp/wtent.c @@ -31,13 +31,13 @@ void logwtmp (const char *line, const char *name, const char *host) { struct utmp lutmp; - memset (&(lutmp), 0, sizeof (struct utmp)); + __memset (&(lutmp), 0, sizeof (struct utmp)); lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS; lutmp.ut_pid = getpid(); - strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1); - strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1); - strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1); + __strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1); + __strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1); + __strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1); gettimeofday(&(lutmp.ut_tv), NULL); updwtmp(_PATH_WTMP, &(lutmp)); @@ -48,12 +48,12 @@ extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp) { int fd; - fd = open(wtmp_file, O_APPEND | O_WRONLY, 0); + fd = __open(wtmp_file, O_APPEND | O_WRONLY, 0); if (fd >= 0) { if (lockf(fd, F_LOCK, 0)==0) { - write(fd, (const char *) lutmp, sizeof(struct utmp)); + __write(fd, (const char *) lutmp, sizeof(struct utmp)); lockf(fd, F_ULOCK, 0); - close(fd); + __close(fd); } } } diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index 055900827..1691e00e0 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -98,8 +98,6 @@ * Manuel */ -#define memmove __memmove - #define _GNU_SOURCE #define _ISOC99_SOURCE #include <errno.h> @@ -1620,7 +1618,7 @@ int main(int argc, char **argv) break; } do { - if ((s = strchr(opt_chars,*p)) == NULL) { + if ((s = __strchr(opt_chars,*p)) == NULL) { USAGE: s = basename(progname); fprintf(stderr, @@ -1697,7 +1695,7 @@ int main(int argc, char **argv) } } if (ni) { /* still bytes in buffer! */ - memmove(ibuf, pi, ni); + __memmove(ibuf, pi, ni); } } diff --git a/libc/misc/wctype/wctype.c b/libc/misc/wctype/wctype.c index ba902ba74..aa2b97d60 100644 --- a/libc/misc/wctype/wctype.c +++ b/libc/misc/wctype/wctype.c @@ -490,7 +490,7 @@ wctype_t attribute_hidden __wctype(const char *property) p = typestring; i = 1; do { - if (!strcmp(property, ++p)) { + if (!__strcmp(property, ++p)) { return i; } ++i; @@ -886,7 +886,7 @@ wctrans_t wctrans(const char *property) p = transstring; i = 1; do { - if (!strcmp(property, ++p)) { + if (!__strcmp(property, ++p)) { return i; } ++i; diff --git a/libc/misc/wordexp/Makefile b/libc/misc/wordexp/Makefile index 6126be8bf..4a8f4a072 100644 --- a/libc/misc/wordexp/Makefile +++ b/libc/misc/wordexp/Makefile @@ -1,38 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 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=wordexp.c -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) - -OBJ_LIST=../../obj.misc.wordexp - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, misc/wordexp/%, $(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/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c index 628b8f3fe..5e9133c83 100644 --- a/libc/misc/wordexp/wordexp.c +++ b/libc/misc/wordexp/wordexp.c @@ -19,6 +19,11 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define mempcpy __mempcpy +#define strndup __strndup +#define strspn __strspn +#define unsetenv __unsetenv + #define _GNU_SOURCE #include <sys/cdefs.h> #include <sys/types.h> @@ -130,7 +135,7 @@ static char *w_addstr(char *buffer, size_t * actlen, size_t * maxlen, { size_t len; assert(str != NULL); /* w_addstr only called from this file */ - len = strlen(str); + len = __strlen(str); return w_addmem(buffer, actlen, maxlen, str, len); } @@ -145,7 +150,7 @@ static int w_addword(wordexp_t * pwordexp, char *word) * the caller sees them. */ if (word == NULL) { - word = strdup(""); + word = __strdup(""); if (word == NULL) goto no_space; } @@ -247,7 +252,7 @@ parse_tilde(char **word, size_t * word_length, size_t * max_length, if (*word_length != 0) { if (!((*word)[*word_length - 1] == '=' && wordc == 0)) { if (!((*word)[*word_length - 1] == ':' - && strchr(*word, '=') && wordc == 0)) { + && __strchr(*word, '=') && wordc == 0)) { *word = w_addchar(*word, word_length, max_length, '~'); return *word ? 0 : WRDE_NOSPACE; } @@ -372,7 +377,7 @@ do_parse_glob(const char *glob_word, char **word, size_t * word_length, } for (match = 0; match < globbuf.gl_pathc; ++match) { - char *matching_word = strdup(globbuf.gl_pathv[match]); + char *matching_word = __strdup(globbuf.gl_pathv[match]); if (matching_word == NULL || w_addword(pwordexp, matching_word)) { globfree(&globbuf); @@ -399,8 +404,8 @@ parse_glob(char **word, size_t * word_length, size_t * max_length, glob_list.we_wordv = NULL; glob_list.we_offs = 0; for (; words[*offset] != '\0'; ++*offset) { - if ((ifs && strchr(ifs, words[*offset])) || - (!ifs && strchr(" \t\n", words[*offset]))) + if ((ifs && __strchr(ifs, words[*offset])) || + (!ifs && __strchr(" \t\n", words[*offset]))) /* Reached IFS */ break; @@ -757,24 +762,24 @@ exec_comm_child(char *comm, int *fildes, int showerr, int noexec) /* Redirect output. */ dup2(fildes[1], 1); - close(fildes[1]); + __close(fildes[1]); /* Redirect stderr to /dev/null if we have to. */ if (showerr == 0) { int fd; - close(2); - fd = open(_PATH_DEVNULL, O_WRONLY); + __close(2); + fd = __open(_PATH_DEVNULL, O_WRONLY); if (fd >= 0 && fd != 2) { dup2(fd, 2); - close(fd); + __close(fd); } } /* Make sure the subshell doesn't field-split on our behalf. */ unsetenv("IFS"); - close(fildes[0]); + __close(fildes[0]); execve(_PATH_BSHELL, (char *const *) args, __environ); /* Bad. What now? */ @@ -807,8 +812,8 @@ exec_comm(char *comm, char **word, size_t * word_length, if ((pid = fork()) < 0) { /* Bad */ - close(fildes[0]); - close(fildes[1]); + __close(fildes[0]); + __close(fildes[1]); return WRDE_NOSPACE; } @@ -817,17 +822,17 @@ exec_comm(char *comm, char **word, size_t * word_length, /* Parent */ - close(fildes[1]); + __close(fildes[1]); buffer = alloca(bufsize); if (!pwordexp) /* Quoted - no field splitting */ { while (1) { - if ((buflen = read(fildes[0], buffer, bufsize)) < 1) { + if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) { if (waitpid(pid, &status, WNOHANG) == 0) continue; - if ((buflen = read(fildes[0], buffer, bufsize)) < 1) + if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) break; } @@ -850,17 +855,17 @@ exec_comm(char *comm, char **word, size_t * word_length, */ while (1) { - if ((buflen = read(fildes[0], buffer, bufsize)) < 1) { + if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) { if (waitpid(pid, &status, WNOHANG) == 0) continue; - if ((buflen = read(fildes[0], buffer, bufsize)) < 1) + if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) break; } for (i = 0; i < buflen; ++i) { - if (strchr(ifs, buffer[i]) != NULL) { + if (__strchr(ifs, buffer[i]) != NULL) { /* Current character is IFS */ - if (strchr(ifs_white, buffer[i]) == NULL) { + if (__strchr(ifs_white, buffer[i]) == NULL) { /* Current character is IFS but not whitespace */ if (copying == 2) { /* current character @@ -954,7 +959,7 @@ exec_comm(char *comm, char **word, size_t * word_length, } } - close(fildes[0]); + __close(fildes[0]); /* Check for syntax error (re-execute but with "-n" flag) */ if (buflen < 1 && status != 0) { @@ -977,7 +982,7 @@ exec_comm(char *comm, char **word, size_t * word_length, no_space: kill(pid, SIGKILL); waitpid(pid, NULL, 0); - close(fildes[0]); + __close(fildes[0]); return WRDE_NOSPACE; } @@ -1176,7 +1181,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, goto envsubst; } while (isdigit(words[++*offset])); - } else if (strchr("*@$", words[*offset]) != NULL) { + } else if (__strchr("*@$", words[*offset]) != NULL) { /* Special parameter. */ special = 1; env = w_addchar(env, &env_length, &env_maxlen, words[*offset]); @@ -1212,7 +1217,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, break; case ':': - if (strchr("-=?+", words[1 + *offset]) == NULL) + if (__strchr("-=?+", words[1 + *offset]) == NULL) goto syntax; colon_seen = 1; @@ -1344,7 +1349,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, /* Build up value parameter by parameter (copy them) */ for (p = 1; __libc_argv[p]; ++p) - plist_len += strlen(__libc_argv[p]) + 1; /* for space */ + plist_len += __strlen(__libc_argv[p]) + 1; /* for space */ value = malloc(plist_len); if (value == NULL) goto no_space; @@ -1374,7 +1379,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, goto no_space; for (p = 2; __libc_argv[p + 1]; p++) { - char *newword = strdup(__libc_argv[p]); + char *newword = __strdup(__libc_argv[p]); if (newword == NULL || w_addword(pwordexp, newword)) goto no_space; @@ -1554,7 +1559,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, if (value == NULL || pattern == NULL || *pattern == '\0') break; - end = value + strlen(value); + end = value + __strlen(value); switch (action) { case ACT_RP_SHORT_LEFT: @@ -1564,7 +1569,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, if (fnmatch(pattern, value, 0) != FNM_NOMATCH) { *p = c; if (free_value) { - char *newval = strdup(p); + char *newval = __strdup(p); if (newval == NULL) { free(value); @@ -1588,7 +1593,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, if (fnmatch(pattern, value, 0) != FNM_NOMATCH) { *p = c; if (free_value) { - char *newval = strdup(p); + char *newval = __strdup(p); if (newval == NULL) { free(value); @@ -1692,7 +1697,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, /* Substitute NULL */ goto success; - value = pattern ? strdup(pattern) : pattern; + value = pattern ? __strdup(pattern) : pattern; free_value = 1; if (pattern && !value) @@ -1705,7 +1710,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, if (free_value && value) free(value); - value = pattern ? strdup(pattern) : pattern; + value = pattern ? __strdup(pattern) : pattern; free_value = 1; if (pattern && !value) @@ -1734,7 +1739,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, if (free_value && value) free(value); - value = pattern ? strdup(pattern) : pattern; + value = pattern ? __strdup(pattern) : pattern; free_value = 1; if (pattern && !value) @@ -1758,7 +1763,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, param_length[20] = '\0'; *word = w_addstr(*word, word_length, max_length, - _itoa(value ? strlen(value) : 0, + _itoa(value ? __strlen(value) : 0, ¶m_length[20])); if (free_value) { assert(value != NULL); @@ -1780,7 +1785,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, return *word ? 0 : WRDE_NOSPACE; } else { /* Need to field-split */ - char *value_copy = strdup(value); /* Don't modify value */ + char *value_copy = __strdup(value); /* Don't modify value */ char *field_begin = value_copy; int seen_nonws_ifs = 0; @@ -1820,7 +1825,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, /* Skip at most one non-whitespace IFS character after the field */ seen_nonws_ifs = 0; - if (*next_field && strchr(ifs, *next_field)) { + if (*next_field && __strchr(ifs, *next_field)) { seen_nonws_ifs = 1; next_field++; } @@ -2066,7 +2071,7 @@ int wordexp(const char *words, wordexp_t * we, int flags) if (!ifs) /* IFS unset - use <space><tab><newline>. */ - ifs = strcpy(ifs_white, " \t\n"); + ifs = __strcpy(ifs_white, " \t\n"); else { char *ifsch = ifs; char *whch = ifs_white; @@ -2185,11 +2190,11 @@ int wordexp(const char *words, wordexp_t * we, int flags) default: /* Is it a word separator? */ - if (strchr(" \t", words[words_offset]) == NULL) { + if (__strchr(" \t", words[words_offset]) == NULL) { char ch = words[words_offset]; /* Not a word separator -- but is it a valid word char? */ - if (strchr("\n|&;<>(){}", ch)) { + if (__strchr("\n|&;<>(){}", ch)) { /* Fail */ error = WRDE_BADCHAR; goto do_error; diff --git a/libc/pwd_grp/Makefile b/libc/pwd_grp/Makefile index 3b37e0052..11f362a5e 100644 --- a/libc/pwd_grp/Makefile +++ b/libc/pwd_grp/Makefile @@ -1,67 +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=pwd_grp.c -MOBJ= fgetpwent_r.o fgetgrent_r.o fgetpwent.o fgetgrent.o \ - getpwnam_r.o getgrnam_r.o getpwuid_r.o getgrgid_r.o \ - getpwuid.o getgrgid.o getpwnam.o getgrnam.o getpw.o \ - getpwent_r.o getgrent_r.o getpwent.o getgrent.o \ - initgroups.o putpwent.o putgrent.o \ - __parsepwent.o __parsegrent.o __pgsreader.o - -ifeq ($(HAS_SHADOW),y) -MOBJ+= fgetspent_r.o fgetspent.o sgetspent_r.o getspnam_r.o \ - getspnam.o getspent_r.o getspent.o sgetspent.o \ - putspent.o __parsespent.o # getspuid_r.o getspuid.o -endif - -CSRC= -ifeq ($(HAS_SHADOW),y) -CSRC+= lckpwdf.c -endif - -COBJ=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(MOBJ) $(COBJ) - -OBJ_LIST=../obj.pwd_grp - -all: $(OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, pwd_grp/%, $(OBJS)) > $(OBJ_LIST) - -$(MOBJ): $(MSRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(STRIPTOOL) -x -R .note -R .comment $*.o - -$(COBJ): %.o : %.c - $(CC) $(CFLAGS) -c $< -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/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c index 6b9c2519b..bac807e6f 100644 --- a/libc/pwd_grp/lckpwdf.c +++ b/libc/pwd_grp/lckpwdf.c @@ -64,7 +64,7 @@ int lckpwdf (void) LOCK; - lock_fd = open (_PATH_PASSWD, O_WRONLY); + lock_fd = __open (_PATH_PASSWD, O_WRONLY); if (lock_fd == -1) { /* Cannot create lock file. */ UNLOCK; @@ -75,7 +75,7 @@ int lckpwdf (void) flags = fcntl (lock_fd, F_GETFD, 0); if (flags == -1) { /* Cannot get file flags. */ - close(lock_fd); + __close(lock_fd); lock_fd = -1; UNLOCK; return -1; @@ -83,7 +83,7 @@ int lckpwdf (void) flags |= FD_CLOEXEC; /* Close on exit. */ if (fcntl (lock_fd, F_SETFD, flags) < 0) { /* Cannot set new flags. */ - close(lock_fd); + __close(lock_fd); lock_fd = -1; UNLOCK; return -1; @@ -97,7 +97,7 @@ int lckpwdf (void) It is important that we don't change the signal state. We must restore the old signal behaviour. */ - memset (&new_act, '\0', sizeof (struct sigaction)); + __memset (&new_act, '\0', sizeof (struct sigaction)); new_act.sa_handler = noop_handler; sigfillset (&new_act.sa_mask); new_act.sa_flags = 0ul; @@ -105,7 +105,7 @@ int lckpwdf (void) /* Install new action handler for alarm and save old. */ if (sigaction (SIGALRM, &new_act, &saved_act) < 0) { /* Cannot install signal handler. */ - close(lock_fd); + __close(lock_fd); lock_fd = -1; UNLOCK; return -1; @@ -114,9 +114,9 @@ int lckpwdf (void) /* Now make sure the alarm signal is not blocked. */ sigemptyset (&new_set); sigaddset (&new_set, SIGALRM); - if (sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0) { + if (__sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0) { sigaction (SIGALRM, &saved_act, NULL); - close(lock_fd); + __close(lock_fd); lock_fd = -1; UNLOCK; return -1; @@ -127,7 +127,7 @@ int lckpwdf (void) alarm (TIMEOUT); /* Try to get the lock. */ - memset (&fl, '\0', sizeof (struct flock)); + __memset (&fl, '\0', sizeof (struct flock)); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; result = fcntl (lock_fd, F_SETLKW, &fl); @@ -137,14 +137,14 @@ int lckpwdf (void) /* Restore old set of handled signals. We don't need to know about the current one.*/ - sigprocmask (SIG_SETMASK, &saved_set, NULL); + __sigprocmask (SIG_SETMASK, &saved_set, NULL); /* Restore old action handler for alarm. We don't need to know about the current one. */ sigaction (SIGALRM, &saved_act, NULL); if (result < 0) { - close(lock_fd); + __close(lock_fd); lock_fd = -1; UNLOCK; return -1; @@ -165,7 +165,7 @@ int ulckpwdf (void) } else { LOCK; - result = close (lock_fd); + result = __close (lock_fd); /* Mark descriptor as unused. */ lock_fd = -1; UNLOCK; diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c index 0225c6c7e..3baa0ad33 100644 --- a/libc/pwd_grp/pwd_grp.c +++ b/libc/pwd_grp/pwd_grp.c @@ -49,12 +49,12 @@ /**********************************************************************/ /* Prototypes for internal functions. */ -extern int __parsepwent(void *pw, char *line); -extern int __parsegrent(void *gr, char *line); -extern int __parsespent(void *sp, char *line); +extern int __parsepwent(void *pw, char *line) attribute_hidden; +extern int __parsegrent(void *gr, char *line) attribute_hidden; +extern int __parsespent(void *sp, char *line) attribute_hidden; extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, - char *__restrict line_buff, size_t buflen, FILE *f); + char *__restrict line_buff, size_t buflen, FILE *f) attribute_hidden; /**********************************************************************/ /* For the various fget??ent_r funcs, return @@ -190,10 +190,10 @@ int sgetspent_r(const char *string, struct spwd *result_buf, } if (string != buffer) { - if (strlen(string) >= buflen) { + if (__strlen(string) >= buflen) { goto DO_ERANGE; } - strcpy(buffer, string); + __strcpy(buffer, string); } if (!(rv = __parsespent(result_buf, buffer))) { @@ -215,7 +215,7 @@ int sgetspent_r(const char *string, struct spwd *result_buf, #define GETXXKEY_R_FUNC getpwnam_r #define GETXXKEY_R_PARSER __parsepwent #define GETXXKEY_R_ENTTYPE struct passwd -#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key)) +#define GETXXKEY_R_TEST(ENT) (!__strcmp((ENT)->pw_name, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD #include "pwd_grp_internal.c" @@ -225,7 +225,7 @@ int sgetspent_r(const char *string, struct spwd *result_buf, #define GETXXKEY_R_FUNC getgrnam_r #define GETXXKEY_R_PARSER __parsegrent #define GETXXKEY_R_ENTTYPE struct group -#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key)) +#define GETXXKEY_R_TEST(ENT) (!__strcmp((ENT)->gr_name, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_GROUP #include "pwd_grp_internal.c" @@ -235,7 +235,7 @@ int sgetspent_r(const char *string, struct spwd *result_buf, #define GETXXKEY_R_FUNC getspnam_r #define GETXXKEY_R_PARSER __parsespent #define GETXXKEY_R_ENTTYPE struct spwd -#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key)) +#define GETXXKEY_R_TEST(ENT) (!__strcmp((ENT)->sp_namp, key)) #define DO_GETXXKEY_R_KEYTYPE const char *__restrict #define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW #include "pwd_grp_internal.c" @@ -658,7 +658,7 @@ int initgroups(const char *user, gid_t gid) assert(group.gr_mem); /* Must have at least a NULL terminator. */ if (group.gr_gid != gid) { for (m=group.gr_mem ; *m ; m++) { - if (!strcmp(*m, user)) { + if (!__strcmp(*m, user)) { if (!(num_groups & 7)) { gid_t *tmp = (gid_t *) realloc(group_list, @@ -833,7 +833,7 @@ static const unsigned char pw_off[] = { offsetof(struct passwd, pw_shell) /* 6 */ }; -int __parsepwent(void *data, char *line) +int attribute_hidden __parsepwent(void *data, char *line) { char *endptr; char *p; @@ -851,7 +851,7 @@ int __parsepwent(void *data, char *line) /* NOTE: glibc difference - glibc allows omission of * ':' seperators after the gid field if all remaining * entries are empty. We require all separators. */ - if (!(line = strchr(line, ':'))) { + if (!(line = __strchr(line, ':'))) { break; } } else { @@ -888,7 +888,7 @@ static const unsigned char gr_off[] = { offsetof(struct group, gr_gid) /* 2 - not a char ptr */ }; -int __parsegrent(void *data, char *line) +int attribute_hidden __parsegrent(void *data, char *line) { char *endptr; char *p; @@ -903,7 +903,7 @@ int __parsegrent(void *data, char *line) if (i < 2) { *((char **) p) = line; - if (!(line = strchr(line, ':'))) { + if (!(line = __strchr(line, ':'))) { break; } *line++ = 0; @@ -992,7 +992,7 @@ static const unsigned char sp_off[] = { offsetof(struct spwd, sp_flag) /* 8 - not a char ptr */ }; -int __parsespent(void *data, char * line) +int attribute_hidden __parsespent(void *data, char * line) { char *endptr; char *p; @@ -1003,7 +1003,7 @@ int __parsespent(void *data, char * line) p = ((char *) ((struct spwd *) data)) + sp_off[i]; if (i < 2) { *((char **) p) = line; - if (!(line = strchr(line, ':'))) { + if (!(line = __strchr(line, ':'))) { break; } } else { @@ -1058,7 +1058,7 @@ int __parsespent(void *data, char * line) * Returns 0 on success and ENOENT for end-of-file (glibc concession). */ -int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, +int attribute_hidden __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, char *__restrict line_buff, size_t buflen, FILE *f) { int line_len; @@ -1080,7 +1080,7 @@ int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, break; } - line_len = strlen(line_buff) - 1; /* strlen() must be > 0. */ + line_len = __strlen(line_buff) - 1; /* strlen() must be > 0. */ if (line_buff[line_len] == '\n') { line_buff[line_len] = 0; } else if (line_len + 2 == buflen) { /* line too long */ diff --git a/libc/pwd_grp/pwd_grp_internal.c b/libc/pwd_grp/pwd_grp_internal.c index 33cf0a313..0552c680b 100644 --- a/libc/pwd_grp/pwd_grp_internal.c +++ b/libc/pwd_grp/pwd_grp_internal.c @@ -49,13 +49,6 @@ /**********************************************************************/ /* Prototypes for internal functions. */ -extern int __parsepwent(void *pw, char *line); -extern int __parsegrent(void *gr, char *line); -extern int __parsespent(void *sp, char *line); - -extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data, - char *__restrict line_buff, size_t buflen, FILE *f); - #ifndef GETXXKEY_R_FUNC #error GETXXKEY_R_FUNC is not defined! #endif diff --git a/libc/string/x86_64/string.c b/libc/string/x86_64/string.c deleted file mode 100644 index 60caddf99..000000000 --- a/libc/string/x86_64/string.c +++ /dev/null @@ -1,1454 +0,0 @@ -/* Tester for string functions. - Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -/* Make sure we don't test the optimized inline functions if we want to - test the real implementation. */ -#if !defined DO_STRING_INLINES -#undef __USE_STRING_INLINES -#endif - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <fcntl.h> - -#define STREQ(a, b) (strcmp((a), (b)) == 0) - -const char *it = "<UNSET>"; /* Routine name for message routines. */ -size_t errors = 0; - -/* Complain if condition is not true. */ -static void -check (int thing, int number) -{ - if (!thing) - { - printf("%s flunked test %d\n", it, number); - ++errors; - } -} - -/* Complain if first two args don't strcmp as equal. */ -static void -equal (const char *a, const char *b, int number) -{ - check(a != NULL && b != NULL && STREQ (a, b), number); -} - -char one[50]; -char two[50]; -char *cp; - -static void -test_strcmp (void) -{ - it = "strcmp"; - check (strcmp ("", "") == 0, 1); /* Trivial case. */ - check (strcmp ("a", "a") == 0, 2); /* Identity. */ - check (strcmp ("abc", "abc") == 0, 3); /* Multicharacter. */ - check (strcmp ("abc", "abcd") < 0, 4); /* Length mismatches. */ - check (strcmp ("abcd", "abc") > 0, 5); - check (strcmp ("abcd", "abce") < 0, 6); /* Honest miscompares. */ - check (strcmp ("abce", "abcd") > 0, 7); - check (strcmp ("a\203", "a") > 0, 8); /* Tricky if char signed. */ - check (strcmp ("a\203", "a\003") > 0, 9); - - { - char buf1[0x40], buf2[0x40]; - int i, j; - for (i=0; i < 0x10; i++) - for (j = 0; j < 0x10; j++) - { - int k; - for (k = 0; k < 0x3f; k++) - { - buf1[j] = '0' ^ (k & 4); - buf2[j] = '4' ^ (k & 4); - } - buf1[i] = buf1[0x3f] = 0; - buf2[j] = buf2[0x3f] = 0; - for (k = 0; k < 0xf; k++) - { - int cnum = 0x10+0x10*k+0x100*j+0x1000*i; - check (strcmp (buf1+i,buf2+j) == 0, cnum); - buf1[i+k] = 'A' + i + k; - buf1[i+k+1] = 0; - check (strcmp (buf1+i,buf2+j) > 0, cnum+1); - check (strcmp (buf2+j,buf1+i) < 0, cnum+2); - buf2[j+k] = 'B' + i + k; - buf2[j+k+1] = 0; - check (strcmp (buf1+i,buf2+j) < 0, cnum+3); - check (strcmp (buf2+j,buf1+i) > 0, cnum+4); - buf2[j+k] = 'A' + i + k; - buf1[i] = 'A' + i + 0x80; - check (strcmp (buf1+i,buf2+j) > 0, cnum+5); - check (strcmp (buf2+j,buf1+i) < 0, cnum+6); - buf1[i] = 'A' + i; - } - } - } -} - -#define SIMPLE_COPY(fn, n, str, ntest) \ - do { \ - int __n; \ - char *cp; \ - for (__n = 0; __n < (int) sizeof (one); ++__n) \ - one[__n] = 'Z'; \ - fn (one, str); \ - for (cp = one, __n = 0; __n < n; ++__n, ++cp) \ - check (*cp == '0' + (n % 10), ntest); \ - check (*cp == '\0', ntest); \ - } while (0) - -static void -test_strcpy (void) -{ - int i; - it = "strcpy"; - check (strcpy (one, "abcd") == one, 1); /* Returned value. */ - equal (one, "abcd", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - equal (one, "x", 3); /* Writeover. */ - equal (one+2, "cd", 4); /* Wrote too much? */ - - (void) strcpy (two, "hi there"); - (void) strcpy (one, two); - equal (one, "hi there", 5); /* Basic test encore. */ - equal (two, "hi there", 6); /* Stomped on source? */ - - (void) strcpy (one, ""); - equal (one, "", 7); /* Boundary condition. */ - - for (i = 0; i < 16; i++) - { - (void) strcpy (one + i, "hi there"); /* Unaligned destination. */ - equal (one + i, "hi there", 8 + (i * 2)); - (void) strcpy (two, one + i); /* Unaligned source. */ - equal (two, "hi there", 9 + (i * 2)); - } - - SIMPLE_COPY(strcpy, 0, "", 41); - SIMPLE_COPY(strcpy, 1, "1", 42); - SIMPLE_COPY(strcpy, 2, "22", 43); - SIMPLE_COPY(strcpy, 3, "333", 44); - SIMPLE_COPY(strcpy, 4, "4444", 45); - SIMPLE_COPY(strcpy, 5, "55555", 46); - SIMPLE_COPY(strcpy, 6, "666666", 47); - SIMPLE_COPY(strcpy, 7, "7777777", 48); - SIMPLE_COPY(strcpy, 8, "88888888", 49); - SIMPLE_COPY(strcpy, 9, "999999999", 50); - SIMPLE_COPY(strcpy, 10, "0000000000", 51); - SIMPLE_COPY(strcpy, 11, "11111111111", 52); - SIMPLE_COPY(strcpy, 12, "222222222222", 53); - SIMPLE_COPY(strcpy, 13, "3333333333333", 54); - SIMPLE_COPY(strcpy, 14, "44444444444444", 55); - SIMPLE_COPY(strcpy, 15, "555555555555555", 56); - SIMPLE_COPY(strcpy, 16, "6666666666666666", 57); -} - -static void -test_stpcpy (void) -{ - it = "stpcpy"; - check ((stpcpy (one, "a") - one) == 1, 1); - equal (one, "a", 2); - - check ((stpcpy (one, "ab") - one) == 2, 3); - equal (one, "ab", 4); - - check ((stpcpy (one, "abc") - one) == 3, 5); - equal (one, "abc", 6); - - check ((stpcpy (one, "abcd") - one) == 4, 7); - equal (one, "abcd", 8); - - check ((stpcpy (one, "abcde") - one) == 5, 9); - equal (one, "abcde", 10); - - check ((stpcpy (one, "abcdef") - one) == 6, 11); - equal (one, "abcdef", 12); - - check ((stpcpy (one, "abcdefg") - one) == 7, 13); - equal (one, "abcdefg", 14); - - check ((stpcpy (one, "abcdefgh") - one) == 8, 15); - equal (one, "abcdefgh", 16); - - check ((stpcpy (one, "abcdefghi") - one) == 9, 17); - equal (one, "abcdefghi", 18); - - check ((stpcpy (one, "x") - one) == 1, 19); - equal (one, "x", 20); /* Writeover. */ - equal (one+2, "cdefghi", 21); /* Wrote too much? */ - - check ((stpcpy (one, "xx") - one) == 2, 22); - equal (one, "xx", 23); /* Writeover. */ - equal (one+3, "defghi", 24); /* Wrote too much? */ - - check ((stpcpy (one, "xxx") - one) == 3, 25); - equal (one, "xxx", 26); /* Writeover. */ - equal (one+4, "efghi", 27); /* Wrote too much? */ - - check ((stpcpy (one, "xxxx") - one) == 4, 28); - equal (one, "xxxx", 29); /* Writeover. */ - equal (one+5, "fghi", 30); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxx") - one) == 5, 31); - equal (one, "xxxxx", 32); /* Writeover. */ - equal (one+6, "ghi", 33); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxxx") - one) == 6, 34); - equal (one, "xxxxxx", 35); /* Writeover. */ - equal (one+7, "hi", 36); /* Wrote too much? */ - - check ((stpcpy (one, "xxxxxxx") - one) == 7, 37); - equal (one, "xxxxxxx", 38); /* Writeover. */ - equal (one+8, "i", 39); /* Wrote too much? */ - - check ((stpcpy (stpcpy (stpcpy (one, "a"), "b"), "c") - one) == 3, 40); - equal (one, "abc", 41); - equal (one + 4, "xxx", 42); - - SIMPLE_COPY(stpcpy, 0, "", 43); - SIMPLE_COPY(stpcpy, 1, "1", 44); - SIMPLE_COPY(stpcpy, 2, "22", 45); - SIMPLE_COPY(stpcpy, 3, "333", 46); - SIMPLE_COPY(stpcpy, 4, "4444", 47); - SIMPLE_COPY(stpcpy, 5, "55555", 48); - SIMPLE_COPY(stpcpy, 6, "666666", 49); - SIMPLE_COPY(stpcpy, 7, "7777777", 50); - SIMPLE_COPY(stpcpy, 8, "88888888", 51); - SIMPLE_COPY(stpcpy, 9, "999999999", 52); - SIMPLE_COPY(stpcpy, 10, "0000000000", 53); - SIMPLE_COPY(stpcpy, 11, "11111111111", 54); - SIMPLE_COPY(stpcpy, 12, "222222222222", 55); - SIMPLE_COPY(stpcpy, 13, "3333333333333", 56); - SIMPLE_COPY(stpcpy, 14, "44444444444444", 57); - SIMPLE_COPY(stpcpy, 15, "555555555555555", 58); - SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59); -} - -static void -test_stpncpy (void) -{ - it = "stpncpy"; - memset (one, 'x', sizeof (one)); - check (stpncpy (one, "abc", 2) == one + 2, 1); - check (stpncpy (one, "abc", 3) == one + 3, 2); - check (stpncpy (one, "abc", 4) == one + 3, 3); - check (one[3] == '\0' && one[4] == 'x', 4); - check (stpncpy (one, "abcd", 5) == one + 4, 5); - check (one[4] == '\0' && one[5] == 'x', 6); - check (stpncpy (one, "abcd", 6) == one + 4, 7); - check (one[4] == '\0' && one[5] == '\0' && one[6] == 'x', 8); -} - -static void -test_strcat (void) -{ - it = "strcat"; - (void) strcpy (one, "ijk"); - check (strcat (one, "lmn") == one, 1); /* Returned value. */ - equal (one, "ijklmn", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - (void) strcat (one, "yz"); - equal (one, "xyz", 3); /* Writeover. */ - equal (one+4, "mn", 4); /* Wrote too much? */ - - (void) strcpy (one, "gh"); - (void) strcpy (two, "ef"); - (void) strcat (one, two); - equal (one, "ghef", 5); /* Basic test encore. */ - equal (two, "ef", 6); /* Stomped on source? */ - - (void) strcpy (one, ""); - (void) strcat (one, ""); - equal (one, "", 7); /* Boundary conditions. */ - (void) strcpy (one, "ab"); - (void) strcat (one, ""); - equal (one, "ab", 8); - (void) strcpy (one, ""); - (void) strcat (one, "cd"); - equal (one, "cd", 9); -} - -static void -test_strncat (void) -{ - /* First test it as strcat, with big counts, then test the count - mechanism. */ - it = "strncat"; - (void) strcpy (one, "ijk"); - check (strncat (one, "lmn", 99) == one, 1); /* Returned value. */ - equal (one, "ijklmn", 2); /* Basic test. */ - - (void) strcpy (one, "x"); - (void) strncat (one, "yz", 99); - equal (one, "xyz", 3); /* Writeover. */ - equal (one+4, "mn", 4); /* Wrote too much? */ - - (void) strcpy (one, "gh"); - (void) strcpy (two, "ef"); - (void) strncat (one, two, 99); - equal (one, "ghef", 5); /* Basic test encore. */ - equal (two, "ef", 6); /* Stomped on source? */ - - (void) strcpy (one, ""); - (void) strncat (one, "", 99); - equal (one, "", 7); /* Boundary conditions. */ - (void) strcpy (one, "ab"); - (void) strncat (one, "", 99); - equal (one, "ab", 8); - (void) strcpy (one, ""); - (void) strncat (one, "cd", 99); - equal (one, "cd", 9); - - (void) strcpy (one, "ab"); - (void) strncat (one, "cdef", 2); - equal (one, "abcd", 10); /* Count-limited. */ - - (void) strncat (one, "gh", 0); - equal (one, "abcd", 11); /* Zero count. */ - - (void) strncat (one, "gh", 2); - equal (one, "abcdgh", 12); /* Count and length equal. */ - - (void) strncat (one, "ij", (size_t)-1); /* set sign bit in count */ - equal (one, "abcdghij", 13); -} - -static void -test_strncmp (void) -{ - /* First test as strcmp with big counts, then test count code. */ - it = "strncmp"; - check (strncmp ("", "", 99) == 0, 1); /* Trivial case. */ - check (strncmp ("a", "a", 99) == 0, 2); /* Identity. */ - check (strncmp ("abc", "abc", 99) == 0, 3); /* Multicharacter. */ - check (strncmp ("abc", "abcd", 99) < 0, 4); /* Length unequal. */ - check (strncmp ("abcd", "abc", 99) > 0, 5); - check (strncmp ("abcd", "abce", 99) < 0, 6); /* Honestly unequal. */ - check (strncmp ("abce", "abcd", 99) > 0, 7); - check (strncmp ("a\203", "a", 2) > 0, 8); /* Tricky if '\203' < 0 */ - check (strncmp ("a\203", "a\003", 2) > 0, 9); - check (strncmp ("abce", "abcd", 3) == 0, 10); /* Count limited. */ - check (strncmp ("abce", "abc", 3) == 0, 11); /* Count == length. */ - check (strncmp ("abcd", "abce", 4) < 0, 12); /* Nudging limit. */ - check (strncmp ("abc", "def", 0) == 0, 13); /* Zero count. */ - check (strncmp ("abc", "", (size_t)-1) > 0, 14); /* set sign bit in count */ - check (strncmp ("abc", "abc", (size_t)-2) == 0, 15); -} - -static void -test_strncpy (void) -{ - /* Testing is a bit different because of odd semantics. */ - it = "strncpy"; - check (strncpy (one, "abc", 4) == one, 1); /* Returned value. */ - equal (one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy (one, "abcdefgh"); - (void) strncpy (one, "xyz", 2); - equal (one, "xycdefgh", 3); /* Copy cut by count. */ - - (void) strcpy (one, "abcdefgh"); - (void) strncpy (one, "xyz", 3); /* Copy cut just before NUL. */ - equal (one, "xyzdefgh", 4); - - (void) strcpy (one, "abcdefgh"); - (void) strncpy (one, "xyz", 4); /* Copy just includes NUL. */ - equal (one, "xyz", 5); - equal (one+4, "efgh", 6); /* Wrote too much? */ - - (void) strcpy (one, "abcdefgh"); - (void) strncpy (one, "xyz", 5); /* Copy includes padding. */ - equal (one, "xyz", 7); - equal (one+4, "", 8); - equal (one+5, "fgh", 9); - - (void) strcpy (one, "abc"); - (void) strncpy (one, "xyz", 0); /* Zero-length copy. */ - equal (one, "abc", 10); - - (void) strncpy (one, "", 2); /* Zero-length source. */ - equal (one, "", 11); - equal (one+1, "", 12); - equal (one+2, "c", 13); - - (void) strcpy (one, "hi there"); - (void) strncpy (two, one, 9); - equal (two, "hi there", 14); /* Just paranoia. */ - equal (one, "hi there", 15); /* Stomped on source? */ -} - -static void -test_strlen (void) -{ - it = "strlen"; - check (strlen ("") == 0, 1); /* Empty. */ - check (strlen ("a") == 1, 2); /* Single char. */ - check (strlen ("abcd") == 4, 3); /* Multiple chars. */ - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - check (strlen (p) == 2, 4+i); - } - } -} - -static void -test_strnlen (void) -{ - it = "strnlen"; - check (strnlen ("", 10) == 0, 1); /* Empty. */ - check (strnlen ("a", 10) == 1, 2); /* Single char. */ - check (strnlen ("abcd", 10) == 4, 3); /* Multiple chars. */ - check (strnlen ("foo", (size_t)-1) == 3, 4); /* limits of n. */ - - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - check (strnlen (p, 100) == 2, 5+i); - } - } -} - -static void -test_strchr (void) -{ - it = "strchr"; - check (strchr ("abcd", 'z') == NULL, 1); /* Not found. */ - (void) strcpy (one, "abcd"); - check (strchr (one, 'c') == one+2, 2); /* Basic test. */ - check (strchr (one, 'd') == one+3, 3); /* End of string. */ - check (strchr (one, 'a') == one, 4); /* Beginning. */ - check (strchr (one, '\0') == one+4, 5); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (strchr (one, 'b') == one+1, 6); /* Finding first. */ - (void) strcpy (one, ""); - check (strchr (one, 'b') == NULL, 7); /* Empty string. */ - check (strchr (one, '\0') == one, 8); /* NUL in empty string. */ - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - check (strchr (p, '/') == NULL, 9+i); - } - } -} - -static void -test_strchrnul (void) -{ - const char *os; - it = "strchrnul"; - cp = strchrnul ((os = "abcd"), 'z'); - check (*cp == '\0', 1); /* Not found. */ - check (cp == os + 4, 2); - (void) strcpy (one, "abcd"); - check (strchrnul (one, 'c') == one+2, 3); /* Basic test. */ - check (strchrnul (one, 'd') == one+3, 4); /* End of string. */ - check (strchrnul (one, 'a') == one, 5); /* Beginning. */ - check (strchrnul (one, '\0') == one+4, 6); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (strchrnul (one, 'b') == one+1, 7); /* Finding first. */ - (void) strcpy (one, ""); - check (strchrnul (one, 'b') == one, 8); /* Empty string. */ - check (strchrnul (one, '\0') == one, 9); /* NUL in empty string. */ - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - cp = strchrnul (p, '/'); - check (*cp == '\0', 9+2*i); - check (cp == p+2, 10+2*i); - } - } -} - -static void -test_rawmemchr (void) -{ - it = "rawmemchr"; - (void) strcpy (one, "abcd"); - check (rawmemchr (one, 'c') == one+2, 1); /* Basic test. */ - check (rawmemchr (one, 'd') == one+3, 2); /* End of string. */ - check (rawmemchr (one, 'a') == one, 3); /* Beginning. */ - check (rawmemchr (one, '\0') == one+4, 4); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (rawmemchr (one, 'b') == one+1, 5); /* Finding first. */ - (void) strcpy (one, ""); - check (rawmemchr (one, '\0') == one, 6); /* NUL in empty string. */ - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - check (rawmemchr (p, 'R') == p+8, 6+i); - } - } -} - -static void -test_index (void) -{ - it = "index"; - check (index ("abcd", 'z') == NULL, 1); /* Not found. */ - (void) strcpy (one, "abcd"); - check (index (one, 'c') == one+2, 2); /* Basic test. */ - check (index (one, 'd') == one+3, 3); /* End of string. */ - check (index (one, 'a') == one, 4); /* Beginning. */ - check (index (one, '\0') == one+4, 5); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (index (one, 'b') == one+1, 6); /* Finding first. */ - (void) strcpy (one, ""); - check (index (one, 'b') == NULL, 7); /* Empty string. */ - check (index (one, '\0') == one, 8); /* NUL in empty string. */ -} - -static void -test_strrchr (void) -{ - it = "strrchr"; - check (strrchr ("abcd", 'z') == NULL, 1); /* Not found. */ - (void) strcpy (one, "abcd"); - check (strrchr (one, 'c') == one+2, 2); /* Basic test. */ - check (strrchr (one, 'd') == one+3, 3); /* End of string. */ - check (strrchr (one, 'a') == one, 4); /* Beginning. */ - check (strrchr (one, '\0') == one+4, 5); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (strrchr (one, 'b') == one+3, 6); /* Finding last. */ - (void) strcpy (one, ""); - check (strrchr (one, 'b') == NULL, 7); /* Empty string. */ - check (strrchr (one, '\0') == one, 8); /* NUL in empty string. */ - { - char buf[4096]; - int i; - char *p; - for (i=0; i < 0x100; i++) - { - p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i; - strcpy (p, "OK"); - strcpy (p+3, "BAD/WRONG"); - check (strrchr (p, '/') == NULL, 9+i); - } - } -} - -static void -test_memrchr (void) -{ - size_t l; - it = "memrchr"; - check (memrchr ("abcd", 'z', 5) == NULL, 1); /* Not found. */ - (void) strcpy (one, "abcd"); - l = strlen (one) + 1; - check (memrchr (one, 'c', l) == one+2, 2); /* Basic test. */ - check (memrchr (one, 'd', l) == one+3, 3); /* End of string. */ - check (memrchr (one, 'a', l) == one, 4); /* Beginning. */ - check (memrchr (one, '\0', l) == one+4, 5); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - l = strlen (one) + 1; - check (memrchr (one, 'b', l) == one+3, 6); /* Finding last. */ - (void) strcpy (one, ""); - l = strlen (one) + 1; - check (memrchr (one, 'b', l) == NULL, 7); /* Empty string. */ - check (memrchr (one, '\0', l) == one, 8); /* NUL in empty string. */ - - /* now test all possible alignment and length combinations to catch - bugs due to unrolled loops (assuming unrolling is limited to no - more than 128 byte chunks: */ - { - char buf[128 + sizeof(long)]; - long align, len, i, pos; - - for (align = 0; align < (long) sizeof(long); ++align) { - for (len = 0; len < (long) (sizeof(buf) - align); ++len) { - for (i = 0; i < len; ++i) - buf[align + i] = 'x'; /* don't depend on memset... */ - - for (pos = len - 1; pos >= 0; --pos) { -#if 0 - printf("align %d, len %d, pos %d\n", align, len, pos); -#endif - check(memrchr(buf + align, 'x', len) == buf + align + pos, 9); - check(memrchr(buf + align + pos + 1, 'x', len - (pos + 1)) == NULL, - 10); - buf[align + pos] = '-'; - } - } - } - } -} - -static void -test_rindex (void) -{ - it = "rindex"; - check (rindex ("abcd", 'z') == NULL, 1); /* Not found. */ - (void) strcpy (one, "abcd"); - check (rindex (one, 'c') == one+2, 2); /* Basic test. */ - check (rindex (one, 'd') == one+3, 3); /* End of string. */ - check (rindex (one, 'a') == one, 4); /* Beginning. */ - check (rindex (one, '\0') == one+4, 5); /* Finding NUL. */ - (void) strcpy (one, "ababa"); - check (rindex (one, 'b') == one+3, 6); /* Finding last. */ - (void) strcpy (one, ""); - check (rindex (one, 'b') == NULL, 7); /* Empty string. */ - check (rindex (one, '\0') == one, 8); /* NUL in empty string. */ -} - -static void -test_strpbrk (void) -{ - it = "strpbrk"; - check(strpbrk("abcd", "z") == NULL, 1); /* Not found. */ - (void) strcpy(one, "abcd"); - check(strpbrk(one, "c") == one+2, 2); /* Basic test. */ - check(strpbrk(one, "d") == one+3, 3); /* End of string. */ - check(strpbrk(one, "a") == one, 4); /* Beginning. */ - check(strpbrk(one, "") == NULL, 5); /* Empty search list. */ - check(strpbrk(one, "cb") == one+1, 6); /* Multiple search. */ - (void) strcpy(one, "abcabdea"); - check(strpbrk(one, "b") == one+1, 7); /* Finding first. */ - check(strpbrk(one, "cb") == one+1, 8); /* With multiple search. */ - check(strpbrk(one, "db") == one+1, 9); /* Another variant. */ - (void) strcpy(one, ""); - check(strpbrk(one, "bc") == NULL, 10); /* Empty string. */ - (void) strcpy(one, ""); - check(strpbrk(one, "bcd") == NULL, 11); /* Empty string. */ - (void) strcpy(one, ""); - check(strpbrk(one, "bcde") == NULL, 12); /* Empty string. */ - check(strpbrk(one, "") == NULL, 13); /* Both strings empty. */ - (void) strcpy(one, "abcabdea"); - check(strpbrk(one, "befg") == one+1, 14); /* Finding first. */ - check(strpbrk(one, "cbr") == one+1, 15); /* With multiple search. */ - check(strpbrk(one, "db") == one+1, 16); /* Another variant. */ - check(strpbrk(one, "efgh") == one+6, 17); /* And yet another. */ -} - -static void -test_strstr (void) -{ - it = "strstr"; - check(strstr("abcd", "z") == NULL, 1); /* Not found. */ - check(strstr("abcd", "abx") == NULL, 2); /* Dead end. */ - (void) strcpy(one, "abcd"); - check(strstr(one, "c") == one+2, 3); /* Basic test. */ - check(strstr(one, "bc") == one+1, 4); /* Multichar. */ - check(strstr(one, "d") == one+3, 5); /* End of string. */ - check(strstr(one, "cd") == one+2, 6); /* Tail of string. */ - check(strstr(one, "abc") == one, 7); /* Beginning. */ - check(strstr(one, "abcd") == one, 8); /* Exact match. */ - check(strstr(one, "abcde") == NULL, 9); /* Too long. */ - check(strstr(one, "de") == NULL, 10); /* Past end. */ - check(strstr(one, "") == one, 11); /* Finding empty. */ - (void) strcpy(one, "ababa"); - check(strstr(one, "ba") == one+1, 12); /* Finding first. */ - (void) strcpy(one, ""); - check(strstr(one, "b") == NULL, 13); /* Empty string. */ - check(strstr(one, "") == one, 14); /* Empty in empty string. */ - (void) strcpy(one, "bcbca"); - check(strstr(one, "bca") == one+2, 15); /* False start. */ - (void) strcpy(one, "bbbcabbca"); - check(strstr(one, "bbca") == one+1, 16); /* With overlap. */ -} - -static void -test_strspn (void) -{ - it = "strspn"; - check(strspn("abcba", "abc") == 5, 1); /* Whole string. */ - check(strspn("abcba", "ab") == 2, 2); /* Partial. */ - check(strspn("abc", "qx") == 0, 3); /* None. */ - check(strspn("", "ab") == 0, 4); /* Null string. */ - check(strspn("abc", "") == 0, 5); /* Null search list. */ -} - -static void -test_strcspn (void) -{ - it = "strcspn"; - check(strcspn("abcba", "qx") == 5, 1); /* Whole string. */ - check(strcspn("abcba", "cx") == 2, 2); /* Partial. */ - check(strcspn("abc", "abc") == 0, 3); /* None. */ - check(strcspn("", "ab") == 0, 4); /* Null string. */ - check(strcspn("abc", "") == 3, 5); /* Null search list. */ -} - -static void -test_strtok (void) -{ - it = "strtok"; - (void) strcpy(one, "first, second, third"); - equal(strtok(one, ", "), "first", 1); /* Basic test. */ - equal(one, "first", 2); - equal(strtok((char *)NULL, ", "), "second", 3); - equal(strtok((char *)NULL, ", "), "third", 4); - check(strtok((char *)NULL, ", ") == NULL, 5); - (void) strcpy(one, ", first, "); - equal(strtok(one, ", "), "first", 6); /* Extra delims, 1 tok. */ - check(strtok((char *)NULL, ", ") == NULL, 7); - (void) strcpy(one, "1a, 1b; 2a, 2b"); - equal(strtok(one, ", "), "1a", 8); /* Changing delim lists. */ - equal(strtok((char *)NULL, "; "), "1b", 9); - equal(strtok((char *)NULL, ", "), "2a", 10); - (void) strcpy(two, "x-y"); - equal(strtok(two, "-"), "x", 11); /* New string before done. */ - equal(strtok((char *)NULL, "-"), "y", 12); - check(strtok((char *)NULL, "-") == NULL, 13); - (void) strcpy(one, "a,b, c,, ,d"); - equal(strtok(one, ", "), "a", 14); /* Different separators. */ - equal(strtok((char *)NULL, ", "), "b", 15); - equal(strtok((char *)NULL, " ,"), "c", 16); /* Permute list too. */ - equal(strtok((char *)NULL, " ,"), "d", 17); - check(strtok((char *)NULL, ", ") == NULL, 18); - check(strtok((char *)NULL, ", ") == NULL, 19); /* Persistence. */ - (void) strcpy(one, ", "); - check(strtok(one, ", ") == NULL, 20); /* No tokens. */ - (void) strcpy(one, ""); - check(strtok(one, ", ") == NULL, 21); /* Empty string. */ - (void) strcpy(one, "abc"); - equal(strtok(one, ", "), "abc", 22); /* No delimiters. */ - check(strtok((char *)NULL, ", ") == NULL, 23); - (void) strcpy(one, "abc"); - equal(strtok(one, ""), "abc", 24); /* Empty delimiter list. */ - check(strtok((char *)NULL, "") == NULL, 25); - (void) strcpy(one, "abcdefgh"); - (void) strcpy(one, "a,b,c"); - equal(strtok(one, ","), "a", 26); /* Basics again... */ - equal(strtok((char *)NULL, ","), "b", 27); - equal(strtok((char *)NULL, ","), "c", 28); - check(strtok((char *)NULL, ",") == NULL, 29); - equal(one+6, "gh", 30); /* Stomped past end? */ - equal(one, "a", 31); /* Stomped old tokens? */ - equal(one+2, "b", 32); - equal(one+4, "c", 33); -} - -static void -test_strtok_r (void) -{ - it = "strtok_r"; - (void) strcpy(one, "first, second, third"); - cp = NULL; /* Always initialize cp to make sure it doesn't point to some old data. */ - equal(strtok_r(one, ", ", &cp), "first", 1); /* Basic test. */ - equal(one, "first", 2); - equal(strtok_r((char *)NULL, ", ", &cp), "second", 3); - equal(strtok_r((char *)NULL, ", ", &cp), "third", 4); - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 5); - (void) strcpy(one, ", first, "); - cp = NULL; - equal(strtok_r(one, ", ", &cp), "first", 6); /* Extra delims, 1 tok. */ - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 7); - (void) strcpy(one, "1a, 1b; 2a, 2b"); - cp = NULL; - equal(strtok_r(one, ", ", &cp), "1a", 8); /* Changing delim lists. */ - equal(strtok_r((char *)NULL, "; ", &cp), "1b", 9); - equal(strtok_r((char *)NULL, ", ", &cp), "2a", 10); - (void) strcpy(two, "x-y"); - cp = NULL; - equal(strtok_r(two, "-", &cp), "x", 11); /* New string before done. */ - equal(strtok_r((char *)NULL, "-", &cp), "y", 12); - check(strtok_r((char *)NULL, "-", &cp) == NULL, 13); - (void) strcpy(one, "a,b, c,, ,d"); - cp = NULL; - equal(strtok_r(one, ", ", &cp), "a", 14); /* Different separators. */ - equal(strtok_r((char *)NULL, ", ", &cp), "b", 15); - equal(strtok_r((char *)NULL, " ,", &cp), "c", 16); /* Permute list too. */ - equal(strtok_r((char *)NULL, " ,", &cp), "d", 17); - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 18); - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 19); /* Persistence. */ - (void) strcpy(one, ", "); - cp = NULL; - check(strtok_r(one, ", ", &cp) == NULL, 20); /* No tokens. */ - (void) strcpy(one, ""); - cp = NULL; - check(strtok_r(one, ", ", &cp) == NULL, 21); /* Empty string. */ - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 22); /* Persistence. */ - (void) strcpy(one, "abc"); - cp = NULL; - equal(strtok_r(one, ", ", &cp), "abc", 23); /* No delimiters. */ - check(strtok_r((char *)NULL, ", ", &cp) == NULL, 24); - (void) strcpy(one, "abc"); - cp = NULL; - equal(strtok_r(one, "", &cp), "abc", 25); /* Empty delimiter list. */ - check(strtok_r((char *)NULL, "", &cp) == NULL, 26); - (void) strcpy(one, "abcdefgh"); - (void) strcpy(one, "a,b,c"); - cp = NULL; - equal(strtok_r(one, ",", &cp), "a", 27); /* Basics again... */ - equal(strtok_r((char *)NULL, ",", &cp), "b", 28); - equal(strtok_r((char *)NULL, ",", &cp), "c", 29); - check(strtok_r((char *)NULL, ",", &cp) == NULL, 30); - equal(one+6, "gh", 31); /* Stomped past end? */ - equal(one, "a", 32); /* Stomped old tokens? */ - equal(one+2, "b", 33); - equal(one+4, "c", 34); -} - -static void -test_strsep (void) -{ - char *ptr; - it = "strsep"; - cp = strcpy(one, "first, second, third"); - equal(strsep(&cp, ", "), "first", 1); /* Basic test. */ - equal(one, "first", 2); - equal(strsep(&cp, ", "), "", 3); - equal(strsep(&cp, ", "), "second", 4); - equal(strsep(&cp, ", "), "", 5); - equal(strsep(&cp, ", "), "third", 6); - check(strsep(&cp, ", ") == NULL, 7); - cp = strcpy(one, ", first, "); - equal(strsep(&cp, ", "), "", 8); - equal(strsep(&cp, ", "), "", 9); - equal(strsep(&cp, ", "), "first", 10); /* Extra delims, 1 tok. */ - equal(strsep(&cp, ", "), "", 11); - equal(strsep(&cp, ", "), "", 12); - check(strsep(&cp, ", ") == NULL, 13); - cp = strcpy(one, "1a, 1b; 2a, 2b"); - equal(strsep(&cp, ", "), "1a", 14); /* Changing delim lists. */ - equal(strsep(&cp, ", "), "", 15); - equal(strsep(&cp, "; "), "1b", 16); - equal(strsep(&cp, ", "), "", 17); - equal(strsep(&cp, ", "), "2a", 18); - cp = strcpy(two, "x-y"); - equal(strsep(&cp, "-"), "x", 19); /* New string before done. */ - equal(strsep(&cp, "-"), "y", 20); - check(strsep(&cp, "-") == NULL, 21); - cp = strcpy(one, "a,b, c,, ,d "); - equal(strsep(&cp, ", "), "a", 22); /* Different separators. */ - equal(strsep(&cp, ", "), "b", 23); - equal(strsep(&cp, " ,"), "", 24); - equal(strsep(&cp, " ,"), "c", 25); /* Permute list too. */ - equal(strsep(&cp, " ,"), "", 26); - equal(strsep(&cp, " ,"), "", 27); - equal(strsep(&cp, " ,"), "", 28); - equal(strsep(&cp, " ,"), "d", 29); - equal(strsep(&cp, " ,"), "", 30); - check(strsep(&cp, ", ") == NULL, 31); - check(strsep(&cp, ", ") == NULL, 32); /* Persistence. */ - cp = strcpy(one, ", "); - equal(strsep(&cp, ", "), "", 33); - equal(strsep(&cp, ", "), "", 34); - equal(strsep(&cp, ", "), "", 35); - check(strsep(&cp, ", ") == NULL, 36); /* No tokens. */ - cp = strcpy(one, ""); - equal(strsep(&cp, ", "), "", 37); - check(strsep(&cp, ", ") == NULL, 38); /* Empty string. */ - cp = strcpy(one, "abc"); - equal(strsep(&cp, ", "), "abc", 39); /* No delimiters. */ - check(strsep(&cp, ", ") == NULL, 40); - cp = strcpy(one, "abc"); - equal(strsep(&cp, ""), "abc", 41); /* Empty delimiter list. */ - check(strsep(&cp, "") == NULL, 42); - (void) strcpy(one, "abcdefgh"); - cp = strcpy(one, "a,b,c"); - equal(strsep(&cp, ","), "a", 43); /* Basics again... */ - equal(strsep(&cp, ","), "b", 44); - equal(strsep(&cp, ","), "c", 45); - check(strsep(&cp, ",") == NULL, 46); - equal(one+6, "gh", 47); /* Stomped past end? */ - equal(one, "a", 48); /* Stomped old tokens? */ - equal(one+2, "b", 49); - equal(one+4, "c", 50); - - { - char text[] = "This,is,a,test"; - char *list = strdupa (text); - equal (strsep (&list, ","), "This", 51); - equal (strsep (&list, ","), "is", 52); - equal (strsep (&list, ","), "a", 53); - equal (strsep (&list, ","), "test", 54); - check (strsep (&list, ",") == NULL, 55); - } - - cp = strcpy(one, "a,b, c,, ,d,"); - equal(strsep(&cp, ","), "a", 56); /* Different separators. */ - equal(strsep(&cp, ","), "b", 57); - equal(strsep(&cp, ","), " c", 58); /* Permute list too. */ - equal(strsep(&cp, ","), "", 59); - equal(strsep(&cp, ","), " ", 60); - equal(strsep(&cp, ","), "d", 61); - equal(strsep(&cp, ","), "", 62); - check(strsep(&cp, ",") == NULL, 63); - check(strsep(&cp, ",") == NULL, 64); /* Persistence. */ - - cp = strcpy(one, "a,b, c,, ,d,"); - equal(strsep(&cp, "xy,"), "a", 65); /* Different separators. */ - equal(strsep(&cp, "x,y"), "b", 66); - equal(strsep(&cp, ",xy"), " c", 67); /* Permute list too. */ - equal(strsep(&cp, "xy,"), "", 68); - equal(strsep(&cp, "x,y"), " ", 69); - equal(strsep(&cp, ",xy"), "d", 70); - equal(strsep(&cp, "xy,"), "", 71); - check(strsep(&cp, "x,y") == NULL, 72); - check(strsep(&cp, ",xy") == NULL, 73); /* Persistence. */ - - cp = strcpy(one, "ABC"); - one[4] = ':'; - equal(strsep(&cp, "C"), "AB", 74); /* Access beyond NUL. */ - ptr = strsep(&cp, ":"); - equal(ptr, "", 75); - check(ptr == one + 3, 76); - check(cp == NULL, 77); - - cp = strcpy(one, "ABC"); - one[4] = ':'; - equal(strsep(&cp, "CD"), "AB", 78); /* Access beyond NUL. */ - ptr = strsep(&cp, ":."); - equal(ptr, "", 79); - check(ptr == one + 3, 80); - - cp = strcpy(one, "ABC"); /* No token in string. */ - equal(strsep(&cp, ","), "ABC", 81); - check(cp == NULL, 82); - - *one = '\0'; /* Empty string. */ - cp = one; - ptr = strsep(&cp, ","); - equal(ptr, "", 83); - check(ptr == one, 84); - check(cp == NULL, 85); - - *one = '\0'; /* Empty string and no token. */ - cp = one; - ptr = strsep(&cp, ""); - equal(ptr, "", 86); - check(ptr == one , 87); - check(cp == NULL, 88); -} - -static void -test_memcmp (void) -{ - it = "memcmp"; - check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ - check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ - check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ - check(memcmp("abce", "abcd", 4) > 0, 4); - check(memcmp("alph", "beta", 4) < 0, 5); - check(memcmp("a\203", "a\003", 2) > 0, 6); - check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ - check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ -} - -static void -test_memchr (void) -{ - it = "memchr"; - check(memchr("abcd", 'z', 4) == NULL, 1); /* Not found. */ - (void) strcpy(one, "abcd"); - check(memchr(one, 'c', 4) == one+2, 2); /* Basic test. */ - check(memchr(one, ~0xff|'c', 4) == one+2, 2); /* ignore highorder bits. */ - check(memchr(one, 'd', 4) == one+3, 3); /* End of string. */ - check(memchr(one, 'a', 4) == one, 4); /* Beginning. */ - check(memchr(one, '\0', 5) == one+4, 5); /* Finding NUL. */ - (void) strcpy(one, "ababa"); - check(memchr(one, 'b', 5) == one+1, 6); /* Finding first. */ - check(memchr(one, 'b', 0) == NULL, 7); /* Zero count. */ - check(memchr(one, 'a', 1) == one, 8); /* Singleton case. */ - (void) strcpy(one, "a\203b"); - check(memchr(one, 0203, 3) == one+1, 9); /* Unsignedness. */ - - /* now test all possible alignment and length combinations to catch - bugs due to unrolled loops (assuming unrolling is limited to no - more than 128 byte chunks: */ - { - char buf[128 + sizeof(long)]; - long align, len, i, pos; - - for (align = 0; align < (long) sizeof(long); ++align) { - for (len = 0; len < (long) (sizeof(buf) - align); ++len) { - for (i = 0; i < len; ++i) { - buf[align + i] = 'x'; /* don't depend on memset... */ - } - for (pos = 0; pos < len; ++pos) { -#if 0 - printf("align %d, len %d, pos %d\n", align, len, pos); -#endif - check(memchr(buf + align, 'x', len) == buf + align + pos, 10); - check(memchr(buf + align, 'x', pos) == NULL, 11); - buf[align + pos] = '-'; - } - } - } - } -} - -static void -test_memcpy (void) -{ - int i; - it = "memcpy"; - check(memcpy(one, "abc", 4) == one, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) memcpy(one+1, "xyz", 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) memcpy(one, "xyz", 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) memcpy(two, one, 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - for (i = 0; i < 16; i++) - { - const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - strcpy (one, x); - check (memcpy (one + i, "hi there", 9) == one + i, - 7 + (i * 6)); /* Unaligned destination. */ - check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */ - equal (one + i, "hi there", 9 + (i * 6)); - check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */ - check (memcpy (two, one + i, 9) == two, - 11 + (i * 6)); /* Unaligned source. */ - equal (two, "hi there", 12 + (i * 6)); - } -} - -static void -test_mempcpy (void) -{ - int i; - it = "mempcpy"; - check(mempcpy(one, "abc", 4) == one + 4, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) mempcpy(one+1, "xyz", 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) mempcpy(one, "xyz", 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) mempcpy(two, one, 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - for (i = 0; i < 16; i++) - { - const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - strcpy (one, x); - check (mempcpy (one + i, "hi there", 9) == one + i + 9, - 7 + (i * 6)); /* Unaligned destination. */ - check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */ - equal (one + i, "hi there", 9 + (i * 6)); - check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */ - check (mempcpy (two, one + i, 9) == two + 9, - 11 + (i * 6)); /* Unaligned source. */ - equal (two, "hi there", 12 + (i * 6)); - } -} - -static void -test_memmove (void) -{ - it = "memmove"; - check(memmove(one, "abc", 4) == one, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one+1, "xyz", 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) memmove(one, "xyz", 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) memmove(two, one, 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one+1, one, 9); - equal(one, "aabcdefgh", 7); /* Overlap, right-to-left. */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one+1, one+2, 7); - equal(one, "acdefgh", 8); /* Overlap, left-to-right. */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one, one, 9); - equal(one, "abcdefgh", 9); /* 100% overlap. */ -} - -static void -test_memccpy (void) -{ - /* First test like memcpy, then the search part The SVID, the only - place where memccpy is mentioned, says overlap might fail, so we - don't try it. Besides, it's hard to see the rationale for a - non-left-to-right memccpy. */ - it = "memccpy"; - check(memccpy(one, "abc", 'q', 4) == NULL, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) memccpy(one+1, "xyz", 'q', 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) memccpy(one, "xyz", 'q', 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) memccpy(two, one, 'q', 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - (void) strcpy(one, "abcdefgh"); - (void) strcpy(two, "horsefeathers"); - check(memccpy(two, one, 'f', 9) == two+6, 7); /* Returned value. */ - equal(one, "abcdefgh", 8); /* Source intact? */ - equal(two, "abcdefeathers", 9); /* Copy correct? */ - - (void) strcpy(one, "abcd"); - (void) strcpy(two, "bumblebee"); - check(memccpy(two, one, 'a', 4) == two+1, 10); /* First char. */ - equal(two, "aumblebee", 11); - check(memccpy(two, one, 'd', 4) == two+4, 12); /* Last char. */ - equal(two, "abcdlebee", 13); - (void) strcpy(one, "xyz"); - check(memccpy(two, one, 'x', 1) == two+1, 14); /* Singleton. */ - equal(two, "xbcdlebee", 15); -} - -static void -test_memset (void) -{ - int i; - - it = "memset"; - (void) strcpy(one, "abcdefgh"); - check(memset(one+1, 'x', 3) == one+1, 1); /* Return value. */ - equal(one, "axxxefgh", 2); /* Basic test. */ - - (void) memset(one+2, 'y', 0); - equal(one, "axxxefgh", 3); /* Zero-length set. */ - - (void) memset(one+5, 0, 1); - equal(one, "axxxe", 4); /* Zero fill. */ - equal(one+6, "gh", 5); /* And the leftover. */ - - (void) memset(one+2, 010045, 1); - equal(one, "ax\045xe", 6); /* Unsigned char convert. */ - - /* Non-8bit fill character. */ - memset (one, 0x101, sizeof (one)); - for (i = 0; i < (int) sizeof (one); ++i) - check (one[i] == '\01', 7); - - /* Test for more complex versions of memset, for all alignments and - lengths up to 256. This test takes a little while, perhaps it should - be made weaker? */ - { - char data[512]; - int j; - int k; - int c; - - for (i = 0; i < 512; i++) - data[i] = 'x'; - for (c = 0; c <= 'y'; c += 'y') /* check for memset(,0,) and - memset(,'y',) */ - for (j = 0; j < 256; j++) - for (i = 0; i < 256; i++) - { - memset (data + i, c, j); - for (k = 0; k < i; k++) - if (data[k] != 'x') - goto fail; - for (k = i; k < i+j; k++) - { - if (data[k] != c) - goto fail; - data[k] = 'x'; - } - for (k = i+j; k < 512; k++) - if (data[k] != 'x') - goto fail; - continue; - - fail: - check (0, 8 + i + j * 256 + (c != 0) * 256 * 256); - } - } -} - -static void -test_bcopy (void) -{ - /* Much like memcpy. Berklix manual is silent about overlap, so - don't test it. */ - it = "bcopy"; - (void) bcopy("abc", one, 4); - equal(one, "abc", 1); /* Simple copy. */ - - (void) strcpy(one, "abcdefgh"); - (void) bcopy("xyz", one+1, 2); - equal(one, "axydefgh", 2); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) bcopy("xyz", one, 0); - equal(one, "abc", 3); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) bcopy(one, two, 9); - equal(two, "hi there", 4); /* Just paranoia. */ - equal(one, "hi there", 5); /* Stomped on source? */ -} - -static void -test_bzero (void) -{ - it = "bzero"; - (void) strcpy(one, "abcdef"); - bzero(one+2, 2); - equal(one, "ab", 1); /* Basic test. */ - equal(one+3, "", 2); - equal(one+4, "ef", 3); - - (void) strcpy(one, "abcdef"); - bzero(one+2, 0); - equal(one, "abcdef", 4); /* Zero-length copy. */ -} - -static void -test_strndup (void) -{ - char *p, *q; - it = "strndup"; - p = strndup("abcdef", 12); - check(p != NULL, 1); - if (p != NULL) - { - equal(p, "abcdef", 2); - q = strndup(p + 1, 2); - check(q != NULL, 3); - if (q != NULL) - equal(q, "bc", 4); - free (q); - } - free (p); - p = strndup("abc def", 3); - check(p != NULL, 5); - if (p != NULL) - equal(p, "abc", 6); - free (p); -} - -static void -test_bcmp (void) -{ - it = "bcmp"; - check(bcmp("a", "a", 1) == 0, 1); /* Identity. */ - check(bcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ - check(bcmp("abcd", "abce", 4) != 0, 3); /* Honestly unequal. */ - check(bcmp("abce", "abcd", 4) != 0, 4); - check(bcmp("alph", "beta", 4) != 0, 5); - check(bcmp("abce", "abcd", 3) == 0, 6); /* Count limited. */ - check(bcmp("abc", "def", 0) == 0, 8); /* Zero count. */ -} - -static void -test_strerror (void) -{ - it = "strerror"; - check(strerror(EDOM) != 0, 1); - check(strerror(ERANGE) != 0, 2); - check(strerror(ENOENT) != 0, 3); -} - -int -main (void) -{ - int status; - - /* Test strcmp first because we use it to test other things. */ - test_strcmp (); - - /* Test strcpy next because we need it to set up other tests. */ - test_strcpy (); - - /* A closely related function is stpcpy. */ - test_stpcpy (); - - /* stpncpy. */ - test_stpncpy (); - - /* strcat. */ - test_strcat (); - - /* strncat. */ - test_strncat (); - - /* strncmp. */ - test_strncmp (); - - /* strncpy. */ - test_strncpy (); - - /* strlen. */ - test_strlen (); - - /* strnlen. */ - test_strnlen (); - - /* strchr. */ - test_strchr (); - - /* strchrnul. */ - test_strchrnul (); - - /* rawmemchr. */ - test_rawmemchr (); - - /* index - just like strchr. */ - test_index (); - - /* strrchr. */ - test_strrchr (); - - /* memrchr. */ - test_memrchr (); - - /* rindex - just like strrchr. */ - test_rindex (); - - /* strpbrk - somewhat like strchr. */ - test_strpbrk (); - - /* strstr - somewhat like strchr. */ - test_strstr (); - - /* strspn. */ - test_strspn (); - - /* strcspn. */ - test_strcspn (); - - /* strtok - the hard one. */ - test_strtok (); - - /* strtok_r. */ - test_strtok_r (); - - /* strsep. */ - test_strsep (); - - /* memcmp. */ - test_memcmp (); - - /* memchr. */ - test_memchr (); - - /* memcpy - need not work for overlap. */ - test_memcpy (); - - /* memmove - must work on overlap. */ - test_memmove (); - - /* mempcpy */ - test_mempcpy (); - - /* memccpy. */ - test_memccpy (); - - /* memset. */ - test_memset (); - - /* bcopy. */ - test_bcopy (); - - /* bzero. */ - test_bzero (); - - /* bcmp - somewhat like memcmp. */ - test_bcmp (); - - /* strndup. */ - test_strndup (); - - /* strerror - VERY system-dependent. */ - test_strerror (); - - - if (errors == 0) - { - status = EXIT_SUCCESS; - puts("No errors."); - } - else - { - status = EXIT_FAILURE; - printf("%lu errors.\n", (unsigned long)errors); - } - - return status; -} diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index 87791724a..3ed177ae2 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -1,60 +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 - -SRCS = $(wildcard *.c) - -ifeq ($(strip $(EXCLUDE_BRK)),y) -SRCS := $(filter-out sbrk.c,$(SRCS)) -endif - -SRCS := $(filter-out ssp-local.c,$(SRCS)) -ifneq ($(strip $(UCLIBC_HAS_SSP)),y) -SRCS := $(filter-out ssp.c,$(SRCS)) -NONSHARED_OBJ_LIST= -else -NONSHARED_OBJ_LIST=../../../nonshared_obj.sysdeps.common -endif -ssp.o: CFLAGS += $(SSP_DISABLE_FLAGS) -ssp-local.o: CFLAGS += $(SSP_DISABLE_FLAGS) - -OBJS = $(patsubst %.c,%.o, $(SRCS)) - -NONSHARED_OBJS = ssp-local.o - -OBJ_LIST=../../../obj.sysdeps.common - -all: $(OBJ_LIST) $(NONSHARED_OBJ_LIST) - -$(OBJ_LIST): $(OBJS) - echo $(patsubst %, sysdeps/linux/common/%, $(OBJS)) > $(OBJ_LIST) - -$(NONSHARED_OBJ_LIST): $(NONSHARED_OBJS) - echo $(patsubst %, sysdeps/linux/common/%, $(NONSHARED_OBJS)) > $(NONSHARED_OBJ_LIST) - -$(OBJS) $(NONSHARED_OBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - $(STRIPTOOL) -x -R .note -R .comment $*.o - -headers: - $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h $(TOPDIR)/include/ -clean: - $(RM) *.o *~ core +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c index 0165acfc1..88f7f9999 100644 --- a/libc/sysdeps/linux/common/gettimeofday.c +++ b/libc/sysdeps/linux/common/gettimeofday.c @@ -9,4 +9,8 @@ #include "syscalls.h" #include <sys/time.h> -_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz); +#undef gettimeofday +#define __NR___gettimeofday __NR_gettimeofday +attribute_hidden _syscall2(int, __gettimeofday, struct timeval *, tv, struct timezone *, tz); +strong_alias(__gettimeofday,gettimeofday) +weak_alias(__gettimeofday,__libc_gettimeofday) diff --git a/libc/sysdeps/linux/mips/bits/types.h b/libc/sysdeps/linux/mips/bits/types.h deleted file mode 100644 index d5f2d3651..000000000 --- a/libc/sysdeps/linux/mips/bits/types.h +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright (C) 1991,92,1994-1999,2000,2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* - * Never include this file directly; use <sys/types.h> instead. - */ - -#ifndef _BITS_TYPES_H -#define _BITS_TYPES_H 1 - -#include <features.h> - -#define __need_size_t -#include <stddef.h> -#include <bits/kernel_types.h> - -/* Convenience types. */ -typedef unsigned char __u_char; -typedef unsigned short __u_short; -typedef unsigned int __u_int; -typedef unsigned long __u_long; -#ifdef __GNUC__ -__extension__ typedef unsigned long long int __u_quad_t; -__extension__ typedef long long int __quad_t; -#else -typedef struct - { - long int __val[2]; - } __quad_t; -typedef struct - { - __u_long __val[2]; - } __u_quad_t; -#endif -typedef signed char __int8_t; -typedef unsigned char __uint8_t; -typedef signed short int __int16_t; -typedef unsigned short int __uint16_t; -typedef signed int __int32_t; -typedef unsigned int __uint32_t; -#ifdef __GNUC__ -__extension__ typedef signed long long int __int64_t; -__extension__ typedef unsigned long long int __uint64_t; -#endif -typedef __quad_t *__qaddr_t; - -typedef __u_quad_t __dev_t; /* Type of device numbers. */ -typedef __u_int __uid_t; /* Type of user identifications. */ -typedef __u_int __gid_t; /* Type of group identifications. */ -typedef __u_long __ino_t; /* Type of file serial numbers. */ -typedef __u_int __mode_t; /* Type of file attribute bitmasks. */ -typedef __u_int __nlink_t; /* Type of file link counts. */ -typedef long int __off_t; /* Type of file sizes and offsets. */ -typedef __quad_t __loff_t; /* Type of file sizes and offsets. */ -typedef int __pid_t; /* Type of process identifications. */ -typedef int __ssize_t; /* Type of a byte count, or error. */ -typedef __u_long __rlim_t; /* Type of resource counts. */ -typedef __u_quad_t __rlim64_t; /* Type of resource counts (LFS). */ -typedef __u_int __id_t; /* General type for ID. */ - -typedef struct - { - int __val[2]; - } __fsid_t; /* Type of file system IDs. */ - -/* Everythin' else. */ -typedef int __daddr_t; /* The type of a disk address. */ -typedef char *__caddr_t; -typedef long int __time_t; -typedef unsigned int __useconds_t; -typedef long int __suseconds_t; -typedef long int __swblk_t; /* Type of a swap block maybe? */ - -typedef long int __clock_t; - -/* Clock ID used in clock and timer functions. */ -typedef int __clockid_t; - -/* Timer ID returned by `timer_create'. */ -typedef int __timer_t; - -/* Number of descriptors that can fit in an `fd_set'. */ -#define __FD_SETSIZE 1024 - - -typedef int __key_t; - -/* Used in `struct shmid_ds'. */ -typedef long int __ipc_pid_t; - - -/* Type to represent block size. */ -typedef long int __blksize_t; - -/* Types from the Large File Support interface. */ - -/* Type to count number os disk blocks. */ -typedef long int __blkcnt_t; -typedef __quad_t __blkcnt64_t; - -/* Type to count file system blocks. */ -typedef __u_long __fsblkcnt_t; -typedef __u_quad_t __fsblkcnt64_t; - -/* Type to count file system inodes. */ -typedef __u_long __fsfilcnt_t; -typedef __u_quad_t __fsfilcnt64_t; - -/* Type of file serial numbers. */ -typedef __u_quad_t __ino64_t; - -/* Type of file sizes and offsets. */ -typedef __loff_t __off64_t; - -/* Used in XTI. */ -typedef long int __t_scalar_t; -typedef unsigned long int __t_uscalar_t; - -/* Duplicates info from stdint.h but this is used in unistd.h. */ -typedef int __intptr_t; - -/* Duplicate info from sys/socket.h. */ -typedef unsigned int __socklen_t; - - -/* Now add the thread types. */ -#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98) -# include <bits/pthreadtypes.h> -#endif - -#endif /* bits/types.h */ diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c index fed3d8c72..a5ad27c15 100644 --- a/libpthread/linuxthreads.old/pthread.c +++ b/libpthread/linuxthreads.old/pthread.c @@ -894,7 +894,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime) struct timespec reltime; /* Compute a time offset relative to now. */ - __gettimeofday (&now, NULL); + gettimeofday (&now, NULL); reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000; reltime.tv_sec = abstime->tv_sec - now.tv_sec; if (reltime.tv_nsec < 0) { diff --git a/utils/bswap.h b/utils/bswap.h index 7ca267bdd..6e7f7d336 100644 --- a/utils/bswap.h +++ b/utils/bswap.h @@ -32,23 +32,19 @@ #ifdef __linux__ #include <byteswap.h> #else -#include <string.h> -static __inline__ uint32_t bswap_32(uint32_t x) - { - uint32_t res; - swab((void*)&x, (void*)&res, sizeof(uint32_t)); - - return res; - } - -static __inline__ uint16_t bswap_16(uint16_t x) - { - uint16_t res; - - swab((void*)&x, (void*)&res, sizeof(uint16_t)); - return res; - } +static inline uint32_t bswap_32(uint32_t x) +{ + return ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8)); +} +static inline uint16_t bswap_16(uint16_t x) +{ + return ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)); +} #endif #endif diff --git a/utils/chroot_realpath.c b/utils/chroot_realpath.c index 43ce9a528..dd33c3fc0 100644 --- a/utils/chroot_realpath.c +++ b/utils/chroot_realpath.c @@ -2,15 +2,20 @@ * chroot_realpath.c -- reslove pathname as if inside chroot * Based on realpath.c Copyright (C) 1993 Rick Sladkey <jrs@world.std.com> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. * * 2005/09/12: Dan Howell (modified from realpath.c to emulate chroot) */ diff --git a/utils/ldd.c b/utils/ldd.c index a857127a8..319f0bfdc 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -26,8 +26,6 @@ * */ - -#define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> #include <fcntl.h> |