diff options
Diffstat (limited to 'libc')
82 files changed, 360 insertions, 291 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index 56954385d..1d1be7eb9 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -9,8 +9,8 @@ include $(top_srcdir)libc/inet/rpc/Makefile.in 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 + inet_net.c ntop.c herror.c if_index.c gai_strerror.c getaddrinfo.c \ + in6_addr.c ether_addr.c ntohl.c opensock.c ifaddrs.c MSRC1:= addr.c MOBJ1:= inet_aton.o inet_addr.o inet_ntoa.o inet_makeaddr.o inet_lnaof.o \ diff --git a/libc/inet/addr.c b/libc/inet/addr.c index da40dea0c..6be41f81d 100644 --- a/libc/inet/addr.c +++ b/libc/inet/addr.c @@ -16,9 +16,6 @@ * Changed to use _int10tostr. */ -/* for some reason this does not work here */ -#define memmove __memmove - #define _GNU_SOURCE #define __FORCE_GLIBC #include <features.h> diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index a85e2ff5e..ee5fdc5f7 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -51,6 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define inet_pton __inet_pton #define inet_ntop __inet_ntop #define strtoul __strtoul +#define if_nametoindex __if_nametoindex #if 0 #define uname __uname #define stpcpy __stpcpy diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c index edbae55b0..cd5f63ad5 100644 --- a/libc/inet/getnetent.c +++ b/libc/inet/getnetent.c @@ -17,6 +17,7 @@ #define inet_network __inet_network #define rewind __rewind +#define fgets __fgets #define __FORCE_GLIBC #include <features.h> diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c index 0c0e2c468..008b0d606 100644 --- a/libc/inet/getproto.c +++ b/libc/inet/getproto.c @@ -54,6 +54,7 @@ #define strpbrk __strpbrk #define atoi __atoi #define rewind __rewind +#define fgets __fgets #define __FORCE_GLIBC #define _GNU_SOURCE diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c index 79cdf7434..f3916de86 100644 --- a/libc/inet/getservice.c +++ b/libc/inet/getservice.c @@ -54,6 +54,7 @@ #define strpbrk __strpbrk #define atoi __atoi #define rewind __rewind +#define fgets __fgets #define __FORCE_GLIBC #define _GNU_SOURCE diff --git a/libc/inet/in6_addr.c b/libc/inet/in6_addr.c index de90555c9..7e52d2e39 100644 --- a/libc/inet/in6_addr.c +++ b/libc/inet/in6_addr.c @@ -27,7 +27,7 @@ const struct in6_addr __in6addr_any = weak_alias (__in6addr_any, in6addr_any) const struct in6_addr __in6addr_loopback = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }; -weak_alias(__in6addr_loopback, in6addr_loopback); +weak_alias(__in6addr_loopback, in6addr_loopback) #endif /* __UCLIBC_HAS_IPV6__ */ diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c index 91fa2b899..6f3a8ccec 100644 --- a/libc/inet/ntop.c +++ b/libc/inet/ntop.c @@ -246,10 +246,10 @@ inet_pton4(const char *src, u_char *dst) /* We cannot use the macro version of tolower() or very bad * things happen when '*src++' gets evaluated multiple times. - * So * undef it here so we get the function version of tolower + * So undef it here so we get the function version of tolower * instead. */ -#undef tolower +#undef __tolower static int inet_pton6(const char *src, u_char *dst) @@ -271,7 +271,7 @@ inet_pton6(const char *src, u_char *dst) curtok = src; saw_xdigit = 0; val = 0; - while ((ch = tolower (*src++)) != '\0') { + while ((ch = __tolower (*src++)) != '\0') { const char *pch; pch = __strchr(xdigits, ch); diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index f983229a4..0f6cd3532 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -149,6 +149,7 @@ #define recv __recv #define send __send #define snprintf __snprintf +#define fgets __fgets #define __FORCE_GLIBC #include <features.h> @@ -1136,7 +1137,7 @@ struct hostent *gethostbyname2(const char *name, int family) #ifdef L_res_init -int res_init(void) +int attribute_hidden __res_init_internal(void) { __close_nameservers(); __open_nameservers(); @@ -1180,6 +1181,7 @@ int res_init(void) return(0); } +strong_alias(__res_init_internal,res_init) void res_close( void ) { @@ -1231,7 +1233,6 @@ __res_state (void) return __resp; } # endif -hidden_def (__res_state) #endif @@ -1241,7 +1242,11 @@ hidden_def (__res_state) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif -int res_query(const char *dname, int class, int type, +int __res_init_internal (void) __THROW attribute_hidden; +int __res_querydomain_internal (const char *, const char *, int, int, + u_char *, int) __THROW attribute_hidden; + +int attribute_hidden __res_query_internal(const char *dname, int class, int type, unsigned char *answer, int anslen) { int i; @@ -1282,6 +1287,7 @@ int res_query(const char *dname, int class, int type, free(packet); return i; } +strong_alias(__res_query_internal,res_query) /* * Formulate a normal query, send, and retrieve answer in supplied buffer. @@ -1301,7 +1307,7 @@ int res_search(name, class, type, answer, anslen) int trailing_dot, ret, saved_herrno; int got_nodata = 0, got_servfail = 0, tried_as_is = 0; - if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && res_init() == -1)) { + if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && __res_init_internal() == -1)) { h_errno = NETDB_INTERNAL; return (-1); } @@ -1321,7 +1327,7 @@ int res_search(name, class, type, answer, anslen) */ saved_herrno = -1; if (dots >= _res.ndots) { - ret = res_querydomain(name, NULL, class, type, answer, anslen); + ret = __res_querydomain_internal(name, NULL, class, type, answer, anslen); if (ret > 0) return (ret); saved_herrno = h_errno; @@ -1342,7 +1348,7 @@ int res_search(name, class, type, answer, anslen) *domain && !done; domain++) { - ret = res_querydomain(name, *domain, class, type, + ret = __res_querydomain_internal(name, *domain, class, type, answer, anslen); if (ret > 0) return (ret); @@ -1398,7 +1404,7 @@ int res_search(name, class, type, answer, anslen) * name or whether it ends with a dot. */ if (!tried_as_is) { - ret = res_querydomain(name, NULL, class, type, answer, anslen); + ret = __res_querydomain_internal(name, NULL, class, type, answer, anslen); if (ret > 0) return (ret); } @@ -1424,7 +1430,7 @@ int res_search(name, class, type, answer, anslen) * Perform a call on res_query on the concatenation of name and domain, * removing a trailing dot from name if domain is NULL. */ -int res_querydomain(name, domain, class, type, answer, anslen) +int attribute_hidden __res_querydomain_internal(name, domain, class, type, answer, anslen) const char *name, *domain; int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ @@ -1434,7 +1440,7 @@ int res_querydomain(name, domain, class, type, answer, anslen) const char *longname = nbuf; size_t n, d; - if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && res_init() == -1)) { + if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && __res_init_internal() == -1)) { h_errno = NETDB_INTERNAL; return (-1); } @@ -1468,8 +1474,9 @@ int res_querydomain(name, domain, class, type, answer, anslen) } snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain); } - return (res_query(longname, class, type, answer, anslen)); + return (__res_query_internal(longname, class, type, answer, anslen)); } +strong_alias(__res_querydomain_internal,res_querydomain) /* res_mkquery */ /* res_send */ diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c index b2e23924c..cb30c40a7 100644 --- a/libc/inet/rpc/auth_none.c +++ b/libc/inet/rpc/auth_none.c @@ -105,7 +105,7 @@ strong_alias(__authnone_create,authnone_create) /*ARGSUSED */ static bool_t -authnone_marshal (AUTH *client, XDR *xdrs) +authnone_marshal (AUTH *client attribute_unused, XDR *xdrs) { struct authnone_private_s *ap; @@ -116,23 +116,23 @@ authnone_marshal (AUTH *client, XDR *xdrs) } static void -authnone_verf (AUTH *auth) +authnone_verf (AUTH *auth attribute_unused) { } static bool_t -authnone_validate (AUTH *auth, struct opaque_auth *oa) +authnone_validate (AUTH *auth attribute_unused, struct opaque_auth *oa attribute_unused) { return TRUE; } static bool_t -authnone_refresh (AUTH *auth) +authnone_refresh (AUTH *auth attribute_unused) { return FALSE; } static void -authnone_destroy (AUTH *auth) +authnone_destroy (AUTH *auth attribute_unused) { } diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c index 85fb98a63..bb14df068 100644 --- a/libc/inet/rpc/auth_unix.c +++ b/libc/inet/rpc/auth_unix.c @@ -47,6 +47,7 @@ #define xdr_authunix_parms __xdr_authunix_parms #define xdr_opaque_auth __xdr_opaque_auth #define gettimeofday __gettimeofday +#define fputs __fputs #define __FORCE_GLIBC #include <features.h> @@ -182,7 +183,14 @@ __authunix_create_default (void) uid_t uid; gid_t gid; int max_nr_groups = sysconf (_SC_NGROUPS_MAX); - gid_t gids[max_nr_groups]; + gid_t *gids = NULL; + AUTH *ret_auth; + + if (max_nr_groups) { + gids = (gid_t*)malloc(sizeof(*gids) * max_nr_groups); + if (gids == NULL) + abort (); + } if (gethostname (machname, MAX_MACHINE_NAME) == -1) abort (); @@ -195,7 +203,10 @@ __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); + ret_auth = __authunix_create (machname, uid, gid, MIN (NGRPS, len), gids); + if (gids) + free (gids); + return ret_auth; } strong_alias(__authunix_create_default,authunix_create_default) @@ -204,7 +215,7 @@ strong_alias(__authunix_create_default,authunix_create_default) */ static void -authunix_nextverf (AUTH *auth) +authunix_nextverf (AUTH *auth attribute_unused) { /* no action necessary */ } diff --git a/libc/inet/rpc/clnt_perror.c b/libc/inet/rpc/clnt_perror.c index 611ca998c..eba539c95 100644 --- a/libc/inet/rpc/clnt_perror.c +++ b/libc/inet/rpc/clnt_perror.c @@ -37,6 +37,9 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; * Copyright (C) 1984, Sun Microsystems, Inc. * */ + +#define fputs __fputs + #define __FORCE_GLIBC #include <features.h> @@ -245,7 +248,7 @@ __clnt_sperror (CLIENT * rpch, const char *msg) case RPC_CANTSEND: case RPC_CANTRECV: - strerror_r (e.re_errno, chrbuf, sizeof chrbuf); + __glibc_strerror_r_internal (e.re_errno, chrbuf, sizeof chrbuf); len = __sprintf (str, "; errno = %s", chrbuf); str += len; break; @@ -335,7 +338,7 @@ __clnt_spcreateerror (const char *msg) (void) __strcpy(cp, " - "); cp += __strlen(cp); - strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf); + __glibc_strerror_r_internal (ce->cf_error.re_errno, chrbuf, sizeof chrbuf); (void) __strcpy(cp, chrbuf); cp += __strlen(cp); break; diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c index aa7b44bb4..37b99ecb1 100644 --- a/libc/inet/rpc/clnt_raw.c +++ b/libc/inet/rpc/clnt_raw.c @@ -147,7 +147,7 @@ clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout) caddr_t argsp; xdrproc_t xresults; caddr_t resultsp; - struct timeval timeout; + struct timeval timeout attribute_unused; { struct clntraw_private_s *clp = clntraw_private; XDR *xdrs = &clp->xdr_stream; @@ -222,16 +222,13 @@ call_again: } static void -clntraw_geterr (CLIENT *cl, struct rpc_err *err) +clntraw_geterr (CLIENT *cl attribute_unused, struct rpc_err *err attribute_unused) { } static bool_t -clntraw_freeres (cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; +clntraw_freeres (CLIENT *cl attribute_unused, xdrproc_t xdr_res, caddr_t res_ptr) { struct clntraw_private_s *clp = clntraw_private; XDR *xdrs = &clp->xdr_stream; @@ -252,12 +249,12 @@ clntraw_abort (void) } static bool_t -clntraw_control (CLIENT *cl, int i, char *c) +clntraw_control (CLIENT *cl attribute_unused, int i attribute_unused, char *c attribute_unused) { return FALSE; } static void -clntraw_destroy (CLIENT *cl) +clntraw_destroy (CLIENT *cl attribute_unused) { } diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c index c415a447d..8dcb4682a 100644 --- a/libc/inet/rpc/clnt_tcp.c +++ b/libc/inet/rpc/clnt_tcp.c @@ -63,6 +63,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #define connect __connect #define bindresvport __bindresvport #define poll __poll +#define fputs __fputs #define __FORCE_GLIBC #include <features.h> @@ -81,6 +82,11 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; extern u_long _create_xid (void) attribute_hidden; +#undef get_rpc_createerr +extern struct rpc_createerr *__rpc_thread_createerr_internal (void) + __attribute__ ((__const__)) attribute_hidden; +#define get_rpc_createerr() (*__rpc_thread_createerr_internal ()) + #define MCALL_MSG_SIZE 24 struct ct_data diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c index 2a9f7b135..bd93fd022 100644 --- a/libc/inet/rpc/clnt_udp.c +++ b/libc/inet/rpc/clnt_udp.c @@ -53,6 +53,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #define sendto __sendto #define recvmsg __recvmsg #define poll __poll +#define fputs __fputs #define __FORCE_GLIBC #include <features.h> @@ -80,6 +81,11 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; extern u_long _create_xid (void) attribute_hidden; +#undef get_rpc_createerr +extern struct rpc_createerr *__rpc_thread_createerr_internal (void) + __attribute__ ((__const__)) attribute_hidden; +#define get_rpc_createerr() (*__rpc_thread_createerr_internal ()) + /* * UDP bases client side rpc operations */ diff --git a/libc/inet/rpc/clnt_unix.c b/libc/inet/rpc/clnt_unix.c index c97edba42..e0483b4e2 100644 --- a/libc/inet/rpc/clnt_unix.c +++ b/libc/inet/rpc/clnt_unix.c @@ -62,6 +62,7 @@ #define recvmsg __recvmsg #define sendmsg __sendmsg #define poll __poll +#define fputs __fputs #define __FORCE_GLIBC #include <features.h> @@ -81,6 +82,11 @@ extern u_long _create_xid (void) attribute_hidden; +#undef get_rpc_createerr +extern struct rpc_createerr *__rpc_thread_createerr_internal (void) + __attribute__ ((__const__)) attribute_hidden; +#define get_rpc_createerr() (*__rpc_thread_createerr_internal ()) + #define MCALL_MSG_SIZE 24 struct ct_data diff --git a/libc/inet/rpc/get_myaddress.c b/libc/inet/rpc/get_myaddress.c index bdbafa44d..45fbe359f 100644 --- a/libc/inet/rpc/get_myaddress.c +++ b/libc/inet/rpc/get_myaddress.c @@ -68,14 +68,14 @@ get_myaddress (struct sockaddr_in *addr) if ((s = __socket (AF_INET, SOCK_DGRAM, 0)) < 0) { __perror ("get_myaddress: socket"); - exit (1); + __exit (1); } ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; if (__ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0) { __perror (_("get_myaddress: ioctl (get interface configuration)")); - exit (1); + __exit (1); } again: @@ -86,7 +86,7 @@ get_myaddress (struct sockaddr_in *addr) if (__ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0) { __perror ("get_myaddress: ioctl"); - exit (1); + __exit (1); } if ((ifreq.ifr_flags & IFF_UP) && (ifr->ifr_addr.sa_family == AF_INET) && (!(ifreq.ifr_flags & IFF_LOOPBACK) || diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c index c2e101510..100469879 100644 --- a/libc/inet/rpc/getrpcent.c +++ b/libc/inet/rpc/getrpcent.c @@ -35,6 +35,7 @@ #define atoi __atoi #define rewind __rewind +#define fgets __fgets #define __FORCE_GLIBC #include <features.h> diff --git a/libc/inet/rpc/pmap_clnt.c b/libc/inet/rpc/pmap_clnt.c index 49cd93f4b..0c233dd19 100644 --- a/libc/inet/rpc/pmap_clnt.c +++ b/libc/inet/rpc/pmap_clnt.c @@ -69,14 +69,14 @@ __get_myaddress (struct sockaddr_in *addr) if ((s = __socket (AF_INET, SOCK_DGRAM, 0)) < 0) { __perror ("__get_myaddress: socket"); - exit (1); + __exit (1); } ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; if (__ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0) { __perror (_("__get_myaddress: ioctl (get interface configuration)")); - exit (1); + __exit (1); } again: @@ -87,7 +87,7 @@ __get_myaddress (struct sockaddr_in *addr) if (__ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0) { __perror ("__get_myaddress: ioctl"); - exit (1); + __exit (1); } if ((ifreq.ifr_flags & IFF_UP) && (ifr->ifr_addr.sa_family == AF_INET) && ((ifreq.ifr_flags & IFF_LOOPBACK) || (loopback == 0))) diff --git a/libc/inet/rpc/pmap_getport.c b/libc/inet/rpc/pmap_getport.c index 1981cfaa1..b47baf35c 100644 --- a/libc/inet/rpc/pmap_getport.c +++ b/libc/inet/rpc/pmap_getport.c @@ -45,6 +45,11 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/pmap_clnt.h> #include <sys/socket.h> +#undef get_rpc_createerr +extern struct rpc_createerr *__rpc_thread_createerr_internal (void) + __attribute__ ((__const__)) attribute_hidden; +#define get_rpc_createerr() (*__rpc_thread_createerr_internal ()) + static const struct timeval timeout = {5, 0}; static const struct timeval tottimeout = diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c index c2eed87d4..c7a5be0db 100644 --- a/libc/inet/rpc/rcmd.c +++ b/libc/inet/rpc/rcmd.c @@ -81,6 +81,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; extern int __rresvport(int *alport) attribute_hidden; +extern int __getc_unlocked (FILE *__stream) attribute_hidden; /* some forward declarations */ static int __ivaliduser2(FILE *hostf, u_int32_t raddr, @@ -169,7 +170,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) sigsetmask(oldmask); /* sigsetmask */ return -1; } - fcntl(s, F_SETOWN, pid); /* __fcntl */ + __fcntl(s, F_SETOWN, pid); /* __fcntl */ sin.sin_family = hp->h_addrtype; bcopy(hp->h_addr_list[0], &sin.sin_addr, MIN (sizeof (sin.sin_addr), hp->h_length)); @@ -385,7 +386,7 @@ iruserfopen (char *file, uid_t okuser) root, if writeable by anyone but the owner, or if hardlinked anywhere, quit. */ cp = NULL; - if (lstat (file, &st)) + if (__lstat (file, &st)) cp = "lstat failed"; else if (!S_ISREG (st.st_mode)) cp = "not regular file"; @@ -394,7 +395,7 @@ iruserfopen (char *file, uid_t okuser) res = fopen (file, "r"); if (!res) cp = "cannot open"; - else if (fstat (fileno (res), &st) < 0) + else if (__fstat (fileno (res), &st) < 0) cp = "fstat failed"; else if (st.st_uid && st.st_uid != okuser) cp = "bad owner"; @@ -664,15 +665,15 @@ __ivaliduser2(hostf, raddr, luser, ruser, rhost) /* Skip lines that are too long. */ if (__strchr (p, '\n') == NULL) { - int ch = getc_unlocked (hostf); + int ch = __getc_unlocked (hostf); while (ch != '\n' && ch != EOF) - ch = getc_unlocked (hostf); + ch = __getc_unlocked (hostf); continue; } for (;*p && !isspace(*p); ++p) { - *p = tolower (*p); + *p = __tolower (*p); } /* Next we want to find the permitted name for the remote user. */ diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h index 69ee1cb53..d899b401d 100644 --- a/libc/inet/rpc/rpc_private.h +++ b/libc/inet/rpc/rpc_private.h @@ -4,6 +4,11 @@ /* Now define the internal interfaces. */ extern u_long _create_xid (void) attribute_hidden; +#undef get_rpc_createerr +extern struct rpc_createerr *__rpc_thread_createerr_internal (void) + __attribute__ ((__const__)) attribute_hidden; +#define get_rpc_createerr() (*__rpc_thread_createerr_internal ()) + /* * Multi-threaded support * Group all global and static variables into a single spot. diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c index 02c9c76fa..12b7f2216 100644 --- a/libc/inet/rpc/rpc_thread.c +++ b/libc/inet/rpc/rpc_thread.c @@ -7,6 +7,7 @@ #ifdef __UCLIBC_HAS_THREADS__ #include <bits/libc-tsd.h> +#include <bits/libc-lock.h> /* Variable used in non-threaded applications or for the first thread. */ static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem; @@ -40,25 +41,6 @@ __rpc_thread_destroy (void) } } - -/* XXX: maybe turn this into a normal __pthread_once() via pthreads/weaks.c ? */ -extern int weak_function __pthread_once (pthread_once_t *__once_control, - void (*__init_routine) (void)); - -# define __libc_once_define(CLASS, NAME) \ - CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT - -/* Call handler iff the first call. */ -#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ - do { \ - if (__pthread_once != NULL) \ - __pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \ - else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \ - INIT_FUNCTION (); \ - (ONCE_CONTROL) = !PTHREAD_ONCE_INIT; \ - } \ - } while (0) - /* * Initialize RPC multi-threaded operation */ @@ -116,8 +98,8 @@ __rpc_thread_svc_fdset_internal (void) } strong_alias(__rpc_thread_svc_fdset_internal,__rpc_thread_svc_fdset) -struct rpc_createerr * -__rpc_thread_createerr (void) +struct rpc_createerr attribute_hidden * +__rpc_thread_createerr_internal (void) { struct rpc_thread_variables *tvp; @@ -126,6 +108,8 @@ __rpc_thread_createerr (void) return &rpc_createerr; return &tvp->rpc_createerr_s; } +#undef __rpc_thread_createerr +strong_alias(__rpc_thread_createerr_internal,__rpc_thread_createerr) struct pollfd attribute_hidden ** __rpc_thread_svc_pollfd_internal (void) @@ -164,11 +148,13 @@ fd_set attribute_hidden * __rpc_thread_svc_fdset_internal (void) } strong_alias(__rpc_thread_svc_fdset_internal,__rpc_thread_svc_fdset) -struct rpc_createerr * __rpc_thread_createerr (void) +struct rpc_createerr attribute_hidden * __rpc_thread_createerr_internal (void) { extern struct rpc_createerr rpc_createerr; return &(rpc_createerr); } +#undef __rpc_thread_createerr +strong_alias(__rpc_thread_createerr_internal,__rpc_thread_createerr) struct pollfd attribute_hidden ** __rpc_thread_svc_pollfd_internal (void) { diff --git a/libc/inet/rpc/ruserpass.c b/libc/inet/rpc/ruserpass.c index b7bc36864..728ea5bb7 100644 --- a/libc/inet/rpc/ruserpass.c +++ b/libc/inet/rpc/ruserpass.c @@ -50,6 +50,8 @@ #include <string.h> #include <unistd.h> +extern int __getc_unlocked (FILE *__stream) attribute_hidden; + #define _(X) (X) /* #include "ftp_var.h" */ @@ -182,7 +184,7 @@ next: break; case PASSWD: if (__strcmp(*aname, "anonymous") && - fstat(fileno(cfile), &stb) >= 0 && + __fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { __printf(_("Error: .netrc file is readable by others.")); __printf(_("Remove password or make file unreadable by others.")); @@ -201,7 +203,7 @@ next: break; case ACCOUNT: #if 0 - if (fstat(fileno(cfile), &stb) >= 0 + if (__fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { __printf("Error: .netrc file is readable by others."); __printf("Remove account or make file unreadable by others."); @@ -219,7 +221,7 @@ next: (void) fclose(cfile); return (0); } - while ((c=getc_unlocked(cfile)) != EOF && c == ' ' + while ((c=__getc_unlocked(cfile)) != EOF && c == ' ' || c == '\t'); if (c == EOF || c == '\n') { __printf("Missing macdef name argument.\n"); @@ -231,7 +233,7 @@ next: } tmp = macros[macnum].mac_name; *tmp++ = c; - for (i=0; i < 8 && (c=getc_unlocked(cfile)) != EOF && + for (i=0; i < 8 && (c=__getc_unlocked(cfile)) != EOF && !isspace(c); ++i) { *tmp++ = c; } @@ -241,7 +243,7 @@ next: } *tmp = '\0'; if (c != '\n') { - while ((c=getc_unlocked(cfile)) != EOF + while ((c=__getc_unlocked(cfile)) != EOF && c != '\n'); } if (c == EOF) { @@ -256,7 +258,7 @@ next: } tmp = macros[macnum].mac_start; while (tmp != macbuf + 4096) { - if ((c=getc_unlocked(cfile)) == EOF) { + if ((c=__getc_unlocked(cfile)) == EOF) { __printf("Macro definition missing null line terminator.\n"); goto bad; } @@ -300,24 +302,24 @@ token() if (feof_unlocked(cfile) || ferror_unlocked(cfile)) return (0); - while ((c = getc_unlocked(cfile)) != EOF && + while ((c = __getc_unlocked(cfile)) != EOF && (c == '\n' || c == '\t' || c == ' ' || c == ',')) continue; if (c == EOF) return (0); cp = tokval; if (c == '"') { - while ((c = getc_unlocked(cfile)) != EOF && c != '"') { + while ((c = __getc_unlocked(cfile)) != EOF && c != '"') { if (c == '\\') - c = getc_unlocked(cfile); + c = __getc_unlocked(cfile); *cp++ = c; } } else { *cp++ = c; - while ((c = getc_unlocked(cfile)) != EOF + while ((c = __getc_unlocked(cfile)) != EOF && c != '\n' && c != '\t' && c != ' ' && c != ',') { if (c == '\\') - c = getc_unlocked(cfile); + c = __getc_unlocked(cfile); *cp++ = c; } } diff --git a/libc/inet/rpc/svc_auth.c b/libc/inet/rpc/svc_auth.c index bcead0608..812463396 100644 --- a/libc/inet/rpc/svc_auth.c +++ b/libc/inet/rpc/svc_auth.c @@ -118,7 +118,7 @@ _authenticate_internal (register struct svc_req *rqst, struct rpc_msg *msg) strong_alias(_authenticate_internal,_authenticate) static enum auth_stat -_svcauth_null (struct svc_req *rqst, struct rpc_msg *msg) +_svcauth_null (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused) { return AUTH_OK; } diff --git a/libc/inet/rpc/svc_auth_unix.c b/libc/inet/rpc/svc_auth_unix.c index 0562a42fe..abddc6ea8 100644 --- a/libc/inet/rpc/svc_auth_unix.c +++ b/libc/inet/rpc/svc_auth_unix.c @@ -152,7 +152,7 @@ done: */ /*ARGSUSED */ enum auth_stat -_svcauth_short (struct svc_req *rqst, struct rpc_msg *msg) +_svcauth_short (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused) { return AUTH_REJECTEDCRED; } diff --git a/libc/inet/rpc/svc_raw.c b/libc/inet/rpc/svc_raw.c index 8a4cc5981..986350882 100644 --- a/libc/inet/rpc/svc_raw.c +++ b/libc/inet/rpc/svc_raw.c @@ -102,14 +102,14 @@ svcraw_create (void) } static enum xprt_stat -svcraw_stat (SVCXPRT *xprt) +svcraw_stat (SVCXPRT *xprt attribute_unused) { return XPRT_IDLE; } static bool_t svcraw_recv (xprt, msg) - SVCXPRT *xprt; + SVCXPRT *xprt attribute_unused; struct rpc_msg *msg; { struct svcraw_private_s *srp = svcraw_private; @@ -126,7 +126,7 @@ svcraw_recv (xprt, msg) } static bool_t -svcraw_reply (SVCXPRT *xprt, struct rpc_msg *msg) +svcraw_reply (SVCXPRT *xprt attribute_unused, struct rpc_msg *msg) { struct svcraw_private_s *srp = svcraw_private; XDR *xdrs; @@ -143,7 +143,7 @@ svcraw_reply (SVCXPRT *xprt, struct rpc_msg *msg) } static bool_t -svcraw_getargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr) +svcraw_getargs (SVCXPRT *xprt attribute_unused, xdrproc_t xdr_args, caddr_t args_ptr) { struct svcraw_private_s *srp = svcraw_private; @@ -153,7 +153,7 @@ svcraw_getargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr) } static bool_t -svcraw_freeargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr) +svcraw_freeargs (SVCXPRT *xprt attribute_unused, xdrproc_t xdr_args, caddr_t args_ptr) { struct svcraw_private_s *srp = svcraw_private; XDR *xdrs; @@ -166,6 +166,6 @@ svcraw_freeargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr) } static void -svcraw_destroy (SVCXPRT *xprt) +svcraw_destroy (SVCXPRT *xprt attribute_unused) { } diff --git a/libc/inet/rpc/svc_simple.c b/libc/inet/rpc/svc_simple.c index 6b8fe7103..825235450 100644 --- a/libc/inet/rpc/svc_simple.c +++ b/libc/inet/rpc/svc_simple.c @@ -44,6 +44,7 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro"; #define svcudp_create __svcudp_create #define pmap_unset __pmap_unset #define asprintf __asprintf +#define fputs __fputs #define __FORCE_GLIBC #define _GNU_SOURCE @@ -159,7 +160,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); - exit (1); + __exit (1); } return; } @@ -184,7 +185,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l) (void) asprintf (&buf, _("trouble replying to prog %d\n"), pl->p_prognum); - exit (1); + __exit (1); } /* free the decoded arguments */ (void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf); @@ -198,5 +199,5 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l) #endif fputs (buf, stderr); free (buf); - exit (1); + __exit (1); } diff --git a/libc/inet/rpc/svc_tcp.c b/libc/inet/rpc/svc_tcp.c index 1972bcf99..4a2556159 100644 --- a/libc/inet/rpc/svc_tcp.c +++ b/libc/inet/rpc/svc_tcp.c @@ -55,6 +55,7 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; #define poll __poll #define accept __accept #define listen __listen +#define fputs __fputs #define __FORCE_GLIBC #define _GNU_SOURCE @@ -264,7 +265,7 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize) } static bool_t -rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg) +rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg attribute_unused) { int sock; struct tcp_rendezvous *r; @@ -290,7 +291,7 @@ again: } static enum xprt_stat -rendezvous_stat (SVCXPRT *xprt) +rendezvous_stat (SVCXPRT *xprt attribute_unused) { return XPRT_IDLE; } diff --git a/libc/inet/rpc/svc_udp.c b/libc/inet/rpc/svc_udp.c index 62719ee33..82f279814 100644 --- a/libc/inet/rpc/svc_udp.c +++ b/libc/inet/rpc/svc_udp.c @@ -52,6 +52,7 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; #define sendto __sendto #define recvmsg __recvmsg #define sendmsg __sendmsg +#define fputs __fputs #define __FORCE_GLIBC #define _GNU_SOURCE @@ -227,7 +228,7 @@ strong_alias(__svcudp_create,svcudp_create) static enum xprt_stat svcudp_stat (xprt) - SVCXPRT *xprt; + SVCXPRT *xprt attribute_unused; { return XPRT_IDLE; diff --git a/libc/inet/rpc/svc_unix.c b/libc/inet/rpc/svc_unix.c index 95a65ad1f..d71485f0a 100644 --- a/libc/inet/rpc/svc_unix.c +++ b/libc/inet/rpc/svc_unix.c @@ -55,6 +55,7 @@ #define poll __poll #define accept __accept #define listen __listen +#define fputs __fputs #define __FORCE_GLIBC #include <features.h> @@ -263,7 +264,7 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize) } static bool_t -rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg) +rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg attribute_unused) { int sock; struct unix_rendezvous *r; @@ -292,7 +293,7 @@ again: } static enum xprt_stat -rendezvous_stat (SVCXPRT *xprt) +rendezvous_stat (SVCXPRT *xprt attribute_unused) { return XPRT_IDLE; } diff --git a/libc/inet/rpc/xdr.c b/libc/inet/rpc/xdr.c index 12315fdb5..1474c1e08 100644 --- a/libc/inet/rpc/xdr.c +++ b/libc/inet/rpc/xdr.c @@ -41,6 +41,8 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; * xdr. */ +#define fputs __fputs + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> diff --git a/libc/inet/rpc/xdr_array.c b/libc/inet/rpc/xdr_array.c index a4e50fa8d..5432a5d01 100644 --- a/libc/inet/rpc/xdr_array.c +++ b/libc/inet/rpc/xdr_array.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; */ #define xdr_u_int __xdr_u_int +#define fputs __fputs #define __FORCE_GLIBC #define _GNU_SOURCE diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c index 56908c434..4b6a4817e 100644 --- a/libc/inet/rpc/xdr_mem.c +++ b/libc/inet/rpc/xdr_mem.c @@ -93,7 +93,7 @@ strong_alias(__xdrmem_create,xdrmem_create) */ static void -xdrmem_destroy (XDR *xdrs) +xdrmem_destroy (XDR *xdrs attribute_unused) { } diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c index a8d95e162..15381a6cc 100644 --- a/libc/inet/rpc/xdr_rec.c +++ b/libc/inet/rpc/xdr_rec.c @@ -44,6 +44,8 @@ * The other 31 bits encode the byte length of the fragment. */ +#define fputs __fputs + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -317,7 +319,7 @@ xdrrec_getpos (const XDR *xdrs) RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; long pos; - pos = lseek ((int) (long) rstrm->tcp_handle, (long) 0, 1); + pos = __lseek ((int) (long) rstrm->tcp_handle, (long) 0, 1); if (pos != -1) switch (xdrs->x_op) { diff --git a/libc/inet/rpc/xdr_reference.c b/libc/inet/rpc/xdr_reference.c index 478c8e906..de310b08a 100644 --- a/libc/inet/rpc/xdr_reference.c +++ b/libc/inet/rpc/xdr_reference.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; */ #define xdr_bool __xdr_bool +#define fputs __fputs #define __FORCE_GLIBC #define _GNU_SOURCE diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c index bd9ee4f1b..5c8aec6f9 100644 --- a/libc/inet/rpc/xdr_stdio.c +++ b/libc/inet/rpc/xdr_stdio.c @@ -39,6 +39,9 @@ #define fread __fread #define fwrite __fwrite +#define fseek __fseek +#define fflush __fflush +#define ftell __ftell #include <rpc/types.h> #include <stdio.h> @@ -160,7 +163,7 @@ xdrstdio_setpos (XDR *xdrs, u_int pos) } static int32_t * -xdrstdio_inline (XDR *xdrs, int len) +xdrstdio_inline (XDR *xdrs attribute_unused, int len attribute_unused) { /* * Must do some work to implement this: must insure diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c index d6ec86e94..db2da8c5b 100644 --- a/libc/inet/socketcalls.c +++ b/libc/inet/socketcalls.c @@ -158,7 +158,6 @@ strong_alias(__listen,listen) #ifdef __NR_recv #define __NR___libc_recv __NR_recv _syscall4(ssize_t, __libc_recv, int, sockfd, __ptr_t, buffer, size_t, len, int, flags); -weak_alias(__libc_recv, recv); #elif defined(__NR_socketcall) /* recv, recvfrom added by bir7@leland.stanford.edu */ ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags) diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index ee11899e7..d4efbaaad 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -14,6 +14,10 @@ ifeq ($(EXCLUDE_BRK),y) CSRC:=$(filter-out sbrk.c,$(CSRC)) endif +ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) +CSRC:=$(filter-out fork.c,$(CSRC)) +endif + COMMON_SSP:=ssp.c ssp-local.c # full list diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c index 701877c06..ca9aff5e7 100644 --- a/libc/sysdeps/linux/common/__syscall_fcntl.c +++ b/libc/sysdeps/linux/common/__syscall_fcntl.c @@ -11,15 +11,18 @@ #include <stdarg.h> #include <fcntl.h> +#undef __fcntl + #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64 -extern int __libc_fcntl64(int fd, int cmd, ...); +extern int __fcntl64(int fd, int cmd, ...) attribute_hidden; #endif +#undef fcntl #define __NR___syscall_fcntl __NR_fcntl static inline _syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg); -int __libc_fcntl(int fd, int cmd, ...) +int attribute_hidden __fcntl(int fd, int cmd, ...) { long arg; va_list list; @@ -30,7 +33,7 @@ int __libc_fcntl(int fd, int cmd, ...) if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) { #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64 - return __libc_fcntl64(fd, cmd, arg); + return __fcntl64(fd, cmd, arg); #else __set_errno(ENOSYS); return -1; @@ -38,8 +41,10 @@ int __libc_fcntl(int fd, int cmd, ...) } return (__syscall_fcntl(fd, cmd, arg)); } - -weak_alias(__libc_fcntl, fcntl) +strong_alias(__fcntl,fcntl) +weak_alias(__fcntl,__libc_fcntl) #if ! defined __NR_fcntl64 && defined __UCLIBC_HAS_LFS__ -weak_alias(__libc_fcntl, fcntl64) +hidden_strong_alias(__fcntl,__fcntl64) +weak_alias(__fcntl,fcntl64) +weak_alias(__fcntl,__libc_fcntl64) #endif diff --git a/libc/sysdeps/linux/common/__syscall_fcntl64.c b/libc/sysdeps/linux/common/__syscall_fcntl64.c index 7f9164b52..9231808e3 100644 --- a/libc/sysdeps/linux/common/__syscall_fcntl64.c +++ b/libc/sysdeps/linux/common/__syscall_fcntl64.c @@ -12,9 +12,10 @@ #include <fcntl.h> #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64 +#undef fcntl64 #define __NR___syscall_fcntl64 __NR_fcntl64 static inline _syscall3(int, __syscall_fcntl64, int, fd, int, cmd, long, arg); -int __libc_fcntl64(int fd, int cmd, ...) +int attribute_hidden __fcntl64(int fd, int cmd, ...) { long arg; va_list list; @@ -25,6 +26,6 @@ int __libc_fcntl64(int fd, int cmd, ...) va_end(list); return (__syscall_fcntl64(fd, cmd, arg)); } - -weak_alias(__libc_fcntl64, fcntl64) +strong_alias(__fcntl64,fcntl64) +weak_alias(__fcntl64,__libc_fcntl64) #endif diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c index d0a4ee1d6..4e450bbc5 100644 --- a/libc/sysdeps/linux/common/_exit.c +++ b/libc/sysdeps/linux/common/_exit.c @@ -32,10 +32,12 @@ static inline _syscall1(void, __syscall_exit, int, status); #endif -void attribute_noreturn _exit(int status) +#undef _exit +#undef _exit_internal +void attribute_noreturn attribute_hidden _exit_internal(int status) { /* The loop is added only to keep gcc happy. */ while(1) INLINE_SYSCALL(exit, 1, status); } - +strong_alias(_exit_internal,_exit) diff --git a/libc/sysdeps/linux/common/bits/nan.h b/libc/sysdeps/linux/common/bits/nan.h index 6d88b551b..bae97f216 100644 --- a/libc/sysdeps/linux/common/bits/nan.h +++ b/libc/sysdeps/linux/common/bits/nan.h @@ -1,5 +1,5 @@ /* `NAN' constant for IEEE 754 machines. - Copyright (C) 1992, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992,1996,1997,1999,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,11 +24,15 @@ /* IEEE Not A Number. */ -#ifdef __GNUC__ +#if __GNUC_PREREQ(3,3) + +# define NAN (__builtin_nanf ("")) + +#elif defined __GNUC__ # define NAN \ - (__extension__ \ - ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + (__extension__ \ + ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \ { __l: 0x7fc00000UL }).__d) #else @@ -42,7 +46,8 @@ # define __nan_bytes { 0, 0, 0xc0, 0x7f } # endif -static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes }; +static union { unsigned char __c[4]; float __d; } __nan_union + __attribute_used__ = { __nan_bytes }; # define NAN (__nan_union.__d) #endif /* GCC. */ diff --git a/libc/sysdeps/linux/common/bits/statfs.h b/libc/sysdeps/linux/common/bits/statfs.h index 78c9bdbbc..e115c4d75 100644 --- a/libc/sysdeps/linux/common/bits/statfs.h +++ b/libc/sysdeps/linux/common/bits/statfs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,12 +20,12 @@ # error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead." #endif -#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t*/ +#include <bits/types.h> struct statfs { - int f_type; - int f_bsize; + __SWORD_TYPE f_type; + __SWORD_TYPE f_bsize; #ifndef __USE_FILE_OFFSET64 __fsblkcnt_t f_blocks; __fsblkcnt_t f_bfree; @@ -40,25 +40,25 @@ struct statfs __fsfilcnt64_t f_ffree; #endif __fsid_t f_fsid; - int f_namelen; - int f_spare[6]; + __SWORD_TYPE f_namelen; + __SWORD_TYPE f_spare[5]; }; #ifdef __USE_LARGEFILE64 struct statfs64 { - int f_type; - int f_bsize; + __SWORD_TYPE f_type; + __SWORD_TYPE f_bsize; __fsblkcnt64_t f_blocks; __fsblkcnt64_t f_bfree; __fsblkcnt64_t f_bavail; __fsfilcnt64_t f_files; __fsfilcnt64_t f_ffree; __fsid_t f_fsid; - int f_namelen; - int f_spare[6]; + __SWORD_TYPE f_namelen; + __SWORD_TYPE f_spare[5]; }; #endif -/* Tell code we have this member. */ +/* Tell code we have these members. */ #define _STATFS_F_NAMELEN diff --git a/libc/sysdeps/linux/common/bits/uClibc_ctype.h b/libc/sysdeps/linux/common/bits/uClibc_ctype.h index 7c2d412cf..dd723c77c 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_ctype.h +++ b/libc/sysdeps/linux/common/bits/uClibc_ctype.h @@ -134,17 +134,6 @@ enum { #define __C_tolower(c) (__C_isupper(c) ? ((c) | 0x20) : (c)) #define __C_toupper(c) (__C_islower(c) ? ((c) ^ 0x20) : (c)) -#define __C_isxlower(c) \ - (__C_isdigit(c) \ - || ((sizeof(c) == sizeof(char)) \ - ? (((unsigned char)(((c)) - 'a')) < 6) \ - : (((unsigned int)(((c)) - 'a')) < 6))) -#define __C_isxupper(c) \ - (__C_isdigit(c) \ - || ((sizeof(c) == sizeof(char)) \ - ? (((unsigned char)(((c)) - 'A')) < 6) \ - : (((unsigned int)(((c)) - 'A')) < 6))) - /**********************************************************************/ __BEGIN_DECLS @@ -171,14 +160,7 @@ extern int isascii(int c) __THROW; extern int toascii(int c) __THROW; #endif -/* The following are included for compatibility with older versions of - * uClibc; but now they're only visible if MISC funcctionality is requested. - * However, as they are locale-independent, the hidden macro versions are - * always present. */ -#ifdef __USE_MISC -extern int isxlower(int c) __THROW; /* uClibc-specific. */ -extern int isxupper(int c) __THROW; /* uClibc-specific. */ - +#if defined _LIBC && (defined NOT_IN_libc || defined IS_IN_libc) /* isdigit() is really locale-invariant, so provide some small fast macros. * These are uClibc-specific. */ #define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) @@ -202,20 +184,6 @@ extern int isxupper(int c) __THROW; /* uClibc-specific. */ #define _toupper(c) ((c) ^ 0x20) #define _tolower(c) ((c) | 0x20) - -/* For compatibility with older versions of uClibc. Are these ever used? */ -#if 0 -#define __isxlower(c) __C_isxlower(c) /* uClibc-specific. */ -#define __isxupper(c) __C_isxupper(c) /* uClibc-specific. */ -#endif - -/* Apparently, glibc implements things as macros if __NO_CTYPE isn't defined. - * If we don't have locale support, we'll do the same. Otherwise, we'll - * only use macros for the supported-locale-invariant cases. */ -#ifndef __UCLIBC_HAS_LOCALE__ - -#endif /* __UCLIBC_HAS_LOCALE__ */ - __END_DECLS /**********************************************************************/ @@ -264,9 +232,6 @@ __END_DECLS #define __ispunct(c) __body(ispunct,c) #define __isgraph(c) __body(isgraph,c) -#define __isxlower(c) __body(isxlower,c) -#define __isxupper(c) __body(isxupper,c) - #define __tolower(c) __body(tolower,c) #define __toupper(c) __body(toupper,c) @@ -285,9 +250,6 @@ __END_DECLS #define ispunct(c) __ispunct(c) #define isgraph(c) __isgraph(c) -#define isxlower(c) __isxlower(c) -#define isxupper(c) __isxupper(c) - #define tolower(c) __tolower(c) #define toupper(c) __toupper(c) diff --git a/libc/sysdeps/linux/common/bits/uClibc_fpmax.h b/libc/sysdeps/linux/common/bits/uClibc_fpmax.h index 690f7b23b..27432a03e 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_fpmax.h +++ b/libc/sysdeps/linux/common/bits/uClibc_fpmax.h @@ -98,21 +98,23 @@ typedef float __fpmax_t; #endif /* DECIMAL_DIG */ -extern __fpmax_t __strtofpmax(const char *str, char **endptr, int exp_adjust); +#if defined _LIBC && defined IS_IN_libc +extern __fpmax_t __strtofpmax(const char *str, char **endptr, int exp_adjust) attribute_hidden; #ifdef __UCLIBC_HAS_XLOCALE__ extern __fpmax_t __strtofpmax_l(const char *str, char **endptr, int exp_adjust, - __locale_t locale_arg); + __locale_t locale_arg) attribute_hidden; #endif #ifdef __UCLIBC_HAS_WCHAR__ extern __fpmax_t __wcstofpmax(const wchar_t *wcs, wchar_t **endptr, - int exp_adjust); + int exp_adjust) attribute_hidden; #ifdef __UCLIBC_HAS_XLOCALE__ extern __fpmax_t __wcstofpmax_l(const wchar_t *wcs, wchar_t **endptr, - int exp_adjust, __locale_t locale_arg); + int exp_adjust, __locale_t locale_arg) attribute_hidden; #endif +#endif /* _LIBC */ #endif /* __UCLIBC_HAS_WCHAR__ */ /* The following checks in an __fpmax_t is either 0 or +/- infinity. diff --git a/libc/sysdeps/linux/common/bits/uClibc_locale.h b/libc/sysdeps/linux/common/bits/uClibc_locale.h index a6191a32d..fe574170f 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_locale.h +++ b/libc/sysdeps/linux/common/bits/uClibc_locale.h @@ -65,21 +65,20 @@ #define __LC_ALL 6 /**********************************************************************/ -/* #if defined(_LIBC) && !defined(__LOCALE_C_ONLY) */ #ifndef __LOCALE_C_ONLY -#ifdef _LIBC +#if defined _LIBC /* && (defined IS_IN_libc || defined NOT_IN_libc) */ #include <stddef.h> #include <stdint.h> #include <bits/uClibc_touplow.h> -#endif -#if defined(_LIBC) && !defined(__UCLIBC_GEN_LOCALE) +#ifndef __UCLIBC_GEN_LOCALE #include <bits/uClibc_locale_data.h> #endif +#endif -extern void _locale_set(const unsigned char *p); -extern void _locale_init(void); +/* extern void _locale_set(const unsigned char *p); */ +/* extern void _locale_init(void); */ enum { __ctype_encoding_7_bit, /* C/POSIX */ @@ -101,7 +100,7 @@ enum { * In particular, C/POSIX locale is '#' + "\x80\x01"}*LC_ALL + nul. */ -#if defined(_LIBC) && !defined(__UCLIBC_GEN_LOCALE) +#if defined _LIBC && !defined __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */ typedef struct { uint16_t num_weights; uint16_t num_starters; @@ -319,14 +318,15 @@ typedef struct __uclibc_locale_struct { extern __uclibc_locale_t __global_locale_data; extern struct __uclibc_locale_struct * __global_locale; -#endif +#endif /* _LIBC */ typedef struct __uclibc_locale_struct *__locale_t; -#ifdef _LIBC +/* if we need to leave only _LIBC, then attribute_hidden is not usable */ +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) extern int __locale_mbrtowc_l(wchar_t *__restrict dst, const char *__restrict src, - __locale_t loc ); + __locale_t loc ) attribute_hidden; #endif #ifdef L_setlocale @@ -368,7 +368,7 @@ extern __locale_t __curlocale_set(__locale_t newloc); #define __LOCALE_ARG , locale_arg #define __LOCALE_PTR locale_arg -#else /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__STDLIB_DO_XLOCALE) */ +#else /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */ #define __XL(N) N #define __XL_NPP(N) N @@ -377,10 +377,10 @@ extern __locale_t __curlocale_set(__locale_t newloc); #define __LOCALE_ARG #define __LOCALE_PTR __UCLIBC_CURLOCALE -#endif /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__STDLIB_DO_XLOCALE) */ +#endif /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */ /**********************************************************************/ -#endif /* defined(_LIBC) && !defined(__LOCALE_C_ONLY) */ +#endif /* !defined(__LOCALE_C_ONLY) */ /**********************************************************************/ #endif /* _UCLIBC_LOCALE_H */ diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h index b757ef439..a3be2ca35 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_pthread.h +++ b/libc/sysdeps/linux/common/bits/uClibc_pthread.h @@ -16,7 +16,7 @@ * 02111-1307 USA. */ -/* Supply prototypes for the (weak) thread functions used by the +/* Supply prototypes for the internal thread functions used by the * uClibc library code. */ @@ -24,17 +24,14 @@ #define _UCLIBC_PTHREAD_H #ifndef _PTHREAD_H -#error Always include <pthread.h> rather than <bits/uClibc_pthread.h> +# error "Always include <pthread.h> rather than <bits/uClibc_pthread.h>" #endif extern int __pthread_mutex_init (pthread_mutex_t *__restrict __mutex, __const pthread_mutexattr_t *__restrict - __mutex_attr) __THROW; - -extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW; - -extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW; - -extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW; + __mutex_attr) attribute_hidden; +extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) attribute_hidden; +extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) attribute_hidden; +extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) attribute_hidden; #endif diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h index 04844ac6a..d73da9de7 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h +++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h @@ -397,8 +397,8 @@ struct __STDIO_FILE_STRUCT { **********************************************************************/ #if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) -extern void _stdio_init(void); -extern void _stdio_term(void); +extern void _stdio_init(void) attribute_hidden; +extern void _stdio_term(void) attribute_hidden; #ifdef __STDIO_HAS_OPENLIST @@ -440,7 +440,7 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden; extern int __fgetc_unlocked(FILE *__stream); extern int __fputc_unlocked(int __c, FILE *__stream); -/* First define the default definitions. They overriden below as necessary. */ +/* First define the default definitions. They will be overwritten below as necessary. */ #define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) #define __FGETC(__stream) (fgetc)((__stream)) #define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) diff --git a/libc/sysdeps/linux/common/chmod.c b/libc/sysdeps/linux/common/chmod.c index 631706672..bf368cf5e 100644 --- a/libc/sysdeps/linux/common/chmod.c +++ b/libc/sysdeps/linux/common/chmod.c @@ -13,7 +13,8 @@ #define __NR___syscall_chmod __NR_chmod static inline _syscall2(int, __syscall_chmod, const char *, path, __kernel_mode_t, mode); -int chmod(const char *path, mode_t mode) +int attribute_hidden __chmod(const char *path, mode_t mode) { return __syscall_chmod(path, mode); } +strong_alias(__chmod,chmod) diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c index a54f13be5..5a604d0dc 100644 --- a/libc/sysdeps/linux/common/create_module.c +++ b/libc/sysdeps/linux/common/create_module.c @@ -65,7 +65,7 @@ _syscall2(unsigned long, create_module, const char *, name, size_t, size); #endif #else /* !__NR_create_module */ -caddr_t create_module(const char *name, size_t size) +caddr_t create_module(const char *name attribute_unused, size_t size attribute_unused) { __set_errno(ENOSYS); return (caddr_t)-1; diff --git a/libc/sysdeps/linux/common/fork.c b/libc/sysdeps/linux/common/fork.c index e766799c0..899cbaf63 100644 --- a/libc/sysdeps/linux/common/fork.c +++ b/libc/sysdeps/linux/common/fork.c @@ -12,8 +12,9 @@ #ifdef __ARCH_HAS_MMU__ #ifdef __NR_fork -#define __NR___libc_fork __NR_fork -_syscall0(pid_t, __libc_fork); -weak_alias(__libc_fork, fork); +#define __NR___fork __NR_fork +attribute_hidden _syscall0(pid_t, __fork); +strong_alias(__fork,fork) +weak_alias(__fork,__libc_fork) #endif #endif diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c index 208227a7e..979a0db1d 100644 --- a/libc/sysdeps/linux/common/fstat.c +++ b/libc/sysdeps/linux/common/fstat.c @@ -15,6 +15,8 @@ #include "xstatconv.h" #define __NR___syscall_fstat __NR_fstat +#undef __fstat +#undef fstat static inline _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf); int attribute_hidden __fstat(int fd, struct stat *buf) @@ -31,5 +33,6 @@ int attribute_hidden __fstat(int fd, struct stat *buf) strong_alias(__fstat,fstat) #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__ -weak_alias(fstat,fstat64) +hidden_strong_alias(__fstat,__fstat64) +weak_alias(__fstat,fstat64) #endif diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c index 87621beab..e1e9dff5c 100644 --- a/libc/sysdeps/linux/common/fstat64.c +++ b/libc/sysdeps/linux/common/fstat64.c @@ -19,6 +19,7 @@ static inline _syscall2(int, __syscall_fstat64, int, filedes, struct kernel_stat64 *, buf); +#undef fstat64 int attribute_hidden __fstat64(int fd, struct stat64 *buf) { int result; diff --git a/libc/sysdeps/linux/common/fsync.c b/libc/sysdeps/linux/common/fsync.c index 96764dbe2..e6f610751 100644 --- a/libc/sysdeps/linux/common/fsync.c +++ b/libc/sysdeps/linux/common/fsync.c @@ -12,4 +12,4 @@ #define __NR___libc_fsync __NR_fsync _syscall1(int, __libc_fsync, int, fd); -weak_alias(__libc_fsync, fsync); +weak_alias(__libc_fsync, fsync) diff --git a/libc/sysdeps/linux/common/get_kernel_syms.c b/libc/sysdeps/linux/common/get_kernel_syms.c index 92a105ebd..a1ab3a552 100644 --- a/libc/sysdeps/linux/common/get_kernel_syms.c +++ b/libc/sysdeps/linux/common/get_kernel_syms.c @@ -13,7 +13,7 @@ struct kernel_sym; #ifdef __NR_get_kernel_syms _syscall1(int, get_kernel_syms, struct kernel_sym *, table); #else -int get_kernel_syms(struct kernel_sym *table) +int get_kernel_syms(struct kernel_sym *table attribute_unused) { __set_errno(ENOSYS); return -1; diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index 71134af09..a44647d67 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -2,6 +2,7 @@ #define opendir __opendir #define closedir __closedir +#define readdir __readdir #include <stdlib.h> #include <errno.h> @@ -42,7 +43,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path int slow_search = (sizeof(ino_t) != sizeof(d->d_ino)); #endif - if (stat(path_buf, &st) < 0) { + if (__stat(path_buf, &st) < 0) { goto oops; } #ifdef FAST_DIR_SEARCH_POSSIBLE @@ -74,7 +75,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path goto oops; } __strcpy(ptr + 1, d->d_name); - if (stat(path_buf, &st) < 0) + if (__stat(path_buf, &st) < 0) continue; if (st.st_ino == this_ino && st.st_dev == this_dev) { closedir(dp); @@ -100,7 +101,7 @@ static char *recurser(char *path_buf, int path_size, dev_t root_dev, ino_t root_ dev_t this_dev; ino_t this_ino; - if (stat(path_buf, &st) < 0) { + if (__stat(path_buf, &st) < 0) { if (errno != EFAULT) goto oops; return 0; @@ -139,7 +140,7 @@ int __syscall_getcwd(char * buf, unsigned long size) len = -1; /* get stat for root to have a valid parameters for the terminating condition */ - if (stat("/", &st) < 0) { + if (__stat("/", &st) < 0) { /* root dir not found! */ return -1; } diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c index 25b77fe39..4db513a62 100644 --- a/libc/sysdeps/linux/common/getdents.c +++ b/libc/sysdeps/linux/common/getdents.c @@ -75,7 +75,7 @@ ssize_t attribute_hidden __getdents (int fd, char *buf, size_t nbytes) /* Our heuristic failed. We read too many entries. Reset the stream. */ assert (last_offset != -1); - lseek(fd, last_offset, SEEK_SET); + __lseek(fd, last_offset, SEEK_SET); if ((char *) dp == buf) { /* The buffer the user passed in is too small to hold even diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c index d6410262d..f65e9e70b 100644 --- a/libc/sysdeps/linux/common/getdents64.c +++ b/libc/sysdeps/linux/common/getdents64.c @@ -80,7 +80,7 @@ ssize_t attribute_hidden __getdents64 (int fd, char *buf, size_t nbytes) /* Our heuristic failed. We read too many entries. Reset the stream. */ assert (last_offset != -1); - lseek64(fd, last_offset, SEEK_SET); + __lseek64(fd, last_offset, SEEK_SET); if ((char *) dp == buf) { /* The buffer the user passed in is too small to hold even diff --git a/libc/sysdeps/linux/common/getdirname.c b/libc/sysdeps/linux/common/getdirname.c index d791f34a3..a4285322b 100644 --- a/libc/sysdeps/linux/common/getdirname.c +++ b/libc/sysdeps/linux/common/getdirname.c @@ -42,11 +42,11 @@ get_current_dir_name (void) pwd = __getenv ("PWD"); if (pwd != NULL #if defined __UCLIBC_HAS_LFS__ - && stat64 (".", &dotstat) == 0 - && stat64 (pwd, &pwdstat) == 0 + && __stat64 (".", &dotstat) == 0 + && __stat64 (pwd, &pwdstat) == 0 #else - && stat (".", &dotstat) == 0 - && stat (pwd, &pwdstat) == 0 + && __stat (".", &dotstat) == 0 + && __stat (pwd, &pwdstat) == 0 #endif && pwdstat.st_dev == dotstat.st_dev && pwdstat.st_ino == dotstat.st_ino) diff --git a/libc/sysdeps/linux/common/getgroups.c b/libc/sysdeps/linux/common/getgroups.c index c863489b9..83d92627e 100644 --- a/libc/sysdeps/linux/common/getgroups.c +++ b/libc/sysdeps/linux/common/getgroups.c @@ -10,7 +10,9 @@ #define sysconf __sysconf #include "syscalls.h" +#include <stdlib.h> #include <unistd.h> +#include <grp.h> #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -18,21 +20,30 @@ static inline _syscall2(int, __syscall_getgroups, int, size, __kernel_gid_t *, list); -int attribute_hidden __getgroups(int n, gid_t * groups) +int attribute_hidden __getgroups(int size, gid_t groups[]) { - if (unlikely(n < 0)) { + if (unlikely(size < 0)) { +ret_error: __set_errno(EINVAL); return -1; } else { int i, ngids; - __kernel_gid_t kernel_groups[n = MIN(n, sysconf(_SC_NGROUPS_MAX))]; + __kernel_gid_t *kernel_groups; - ngids = __syscall_getgroups(n, kernel_groups); - if (n != 0 && ngids > 0) { + size = MIN(size, sysconf(_SC_NGROUPS_MAX)); + kernel_groups = (__kernel_gid_t *)malloc(sizeof(*kernel_groups) * size); + if (size && kernel_groups == NULL) + goto ret_error; + + ngids = __syscall_getgroups(size, kernel_groups); + if (size != 0 && ngids > 0) { for (i = 0; i < ngids; i++) { groups[i] = kernel_groups[i]; } } + + if (kernel_groups) + free(kernel_groups); return ngids; } } diff --git a/libc/sysdeps/linux/common/getpgid.c b/libc/sysdeps/linux/common/getpgid.c index e8057b132..8de8516dc 100644 --- a/libc/sysdeps/linux/common/getpgid.c +++ b/libc/sysdeps/linux/common/getpgid.c @@ -16,4 +16,4 @@ pid_t __getpgid(pid_t pid) { return (__syscall_getpgid(pid)); } -weak_alias(__getpgid, getpgid); +weak_alias(__getpgid, getpgid) diff --git a/libc/sysdeps/linux/common/llseek.c b/libc/sysdeps/linux/common/llseek.c index 046f2a8c2..55200d369 100644 --- a/libc/sysdeps/linux/common/llseek.c +++ b/libc/sysdeps/linux/common/llseek.c @@ -25,7 +25,7 @@ #include <features.h> #undef __OPTIMIZE__ /* We absolutely do _NOT_ want interfaces silently - * * * renamed under us or very bad things will happen... */ + * renamed under us or very bad things will happen... */ #ifdef __USE_FILE_OFFSET64 # undef __USE_FILE_OFFSET64 #endif @@ -33,7 +33,7 @@ #include <sys/types.h> #include <sys/syscall.h> - +#undef lseek64 #if defined __NR__llseek && defined __UCLIBC_HAS_LFS__ #ifndef INLINE_SYSCALL @@ -43,20 +43,20 @@ static inline _syscall5(int, __syscall_llseek, int, fd, off_t, offset_hi, off_t, offset_lo, loff_t *, result, int, whence); #endif -loff_t __libc_lseek64(int fd, loff_t offset, int whence) +loff_t attribute_hidden __lseek64(int fd, loff_t offset, int whence) { loff_t result; return(loff_t)(INLINE_SYSCALL (_llseek, 5, fd, (off_t) (offset >> 32), (off_t) (offset & 0xffffffff), &result, whence) ?: result); } #else -extern __off_t __libc_lseek(int fildes, off_t offset, int whence); -loff_t __libc_lseek64(int fd, loff_t offset, int whence) +extern __off_t __lseek(int fildes, off_t offset, int whence) attribute_hidden; +loff_t __lseek64(int fd, loff_t offset, int whence) { - return(loff_t)(__libc_lseek(fd, (off_t) (offset & 0xffffffff), whence)); + return(loff_t)(__lseek(fd, (off_t) (offset & 0xffffffff), whence)); } #endif -weak_alias(__libc_lseek64, _llseek); -weak_alias(__libc_lseek64, llseek); -weak_alias(__libc_lseek64, lseek64); - +strong_alias(__lseek64,lseek64) +//strong_alias(__lseek64,_llseek) +//strong_alias(__lseek64,llseek) +weak_alias(__lseek64,__libc_lseek64) diff --git a/libc/sysdeps/linux/common/lseek.c b/libc/sysdeps/linux/common/lseek.c index 03288c706..4eb51d322 100644 --- a/libc/sysdeps/linux/common/lseek.c +++ b/libc/sysdeps/linux/common/lseek.c @@ -10,6 +10,9 @@ #include "syscalls.h" #include <unistd.h> -#define __NR___libc_lseek __NR_lseek -_syscall3(__off_t, __libc_lseek, int, fildes, __off_t, offset, int, whence); -weak_alias(__libc_lseek, lseek); +#define __NR___lseek __NR_lseek +#undef __lseek +#undef lseek +attribute_hidden _syscall3(__off_t, __lseek, int, fildes, __off_t, offset, int, whence); +strong_alias(__lseek,lseek) +weak_alias(__lseek,__libc_lseek) diff --git a/libc/sysdeps/linux/common/lstat.c b/libc/sysdeps/linux/common/lstat.c index 8cacd4e78..69d663d51 100644 --- a/libc/sysdeps/linux/common/lstat.c +++ b/libc/sysdeps/linux/common/lstat.c @@ -15,6 +15,8 @@ #include "xstatconv.h" #define __NR___syscall_lstat __NR_lstat +#undef __lstat +#undef lstat static inline _syscall2(int, __syscall_lstat, const char *, file_name, struct kernel_stat *, buf); diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c index f3ae083f1..80268d2a1 100644 --- a/libc/sysdeps/linux/common/lstat64.c +++ b/libc/sysdeps/linux/common/lstat64.c @@ -16,6 +16,7 @@ #include "xstatconv.h" #define __NR___syscall_lstat64 __NR_lstat64 +#undef lstat64 static inline _syscall2(int, __syscall_lstat64, const char *, file_name, struct kernel_stat64 *, buf); diff --git a/libc/sysdeps/linux/common/mmap64.c b/libc/sysdeps/linux/common/mmap64.c index 804d6af50..f0380b1ad 100644 --- a/libc/sysdeps/linux/common/mmap64.c +++ b/libc/sysdeps/linux/common/mmap64.c @@ -55,13 +55,12 @@ __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset) { - if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len)) - { - __set_errno (EINVAL); - return MAP_FAILED; - } + if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len)) { + __set_errno (EINVAL); + return MAP_FAILED; + } - return mmap (addr, len, prot, flags, fd, (off_t) offset); + return mmap (addr, len, prot, flags, fd, (off_t) offset); } #else @@ -77,11 +76,11 @@ static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset) { - if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) { - __set_errno (EINVAL); - return MAP_FAILED; - } - return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT))); + if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) { + __set_errno (EINVAL); + return MAP_FAILED; + } + return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT))); } #endif diff --git a/libc/sysdeps/linux/common/modify_ldt.c b/libc/sysdeps/linux/common/modify_ldt.c index 16df10c98..618681ad3 100644 --- a/libc/sysdeps/linux/common/modify_ldt.c +++ b/libc/sysdeps/linux/common/modify_ldt.c @@ -11,5 +11,5 @@ #ifdef __NR_modify_ldt _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount); -weak_alias(modify_ldt, __modify_ldt); +weak_alias(modify_ldt, __modify_ldt) #endif diff --git a/libc/sysdeps/linux/common/msync.c b/libc/sysdeps/linux/common/msync.c index a821a936a..8de9f346e 100644 --- a/libc/sysdeps/linux/common/msync.c +++ b/libc/sysdeps/linux/common/msync.c @@ -13,4 +13,4 @@ #define __NR___libc_msync __NR_msync _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags); -weak_alias(__libc_msync, msync); +weak_alias(__libc_msync, msync) diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c index 90e990a4f..648f7d053 100644 --- a/libc/sysdeps/linux/common/open.c +++ b/libc/sysdeps/linux/common/open.c @@ -14,6 +14,8 @@ #include <string.h> #include <sys/param.h> +#undef __open +#undef open #define __NR___syscall_open __NR_open static inline _syscall3(int, __syscall_open, const char *, file, int, flags, __kernel_mode_t, mode); diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c index c1cd47141..f577d9507 100644 --- a/libc/sysdeps/linux/common/open64.c +++ b/libc/sysdeps/linux/common/open64.c @@ -28,6 +28,7 @@ #ifdef __UCLIBC_HAS_LFS__ /* Open FILE with access OFLAG. If OFLAG includes O_CREAT, a third argument is the file protection. */ +#undef open64 int attribute_hidden __open64 (const char *file, int oflag, ...) { int mode = 0; diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c index 52fc35700..5662a440c 100644 --- a/libc/sysdeps/linux/common/posix_fadvise.c +++ b/libc/sysdeps/linux/common/posix_fadvise.c @@ -20,12 +20,12 @@ _syscall4(int, posix_fadvise, int, fd, off_t, offset, off_t, len, int, advice); -#if defined __UCLIBC_HAS_LFS__ && !defined __NR_fadvise64_64 -weak_alias(posix_fadvise, posix_fadvise64); +#if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || !defined _syscall6) +weak_alias(posix_fadvise, posix_fadvise64) #endif #else -int posix_fadvise(int fd, off_t offset, off_t len, int advice) +int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused) { __set_errno(ENOSYS); return -1; diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c index 05eff4bc9..7183ac9a7 100644 --- a/libc/sysdeps/linux/common/pread_write.c +++ b/libc/sysdeps/linux/common/pread_write.c @@ -100,25 +100,25 @@ static ssize_t __fake_pread_write(int fd, void *buf, /* Since we must not change the file pointer preserve the * value so that we can restore it later. */ - if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1) + if ((old_offset=__lseek(fd, 0, SEEK_CUR)) == (off_t) -1) return -1; /* Set to wanted position. */ - if (lseek (fd, offset, SEEK_SET) == (off_t) -1) + if (__lseek (fd, offset, SEEK_SET) == (off_t) -1) return -1; if (do_pwrite==1) { /* Write the data. */ - result = write(fd, buf, count); + result = __write(fd, buf, count); } else { /* Read the data. */ - result = read(fd, buf, count); + result = __read(fd, buf, count); } /* Now we have to restore the position. If this fails we * have to return this as an error. */ save_errno = errno; - if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1) + if (__lseek(fd, old_offset, SEEK_SET) == (off_t) -1) { if (result == -1) __set_errno(save_errno); @@ -138,24 +138,24 @@ static ssize_t __fake_pread_write64(int fd, void *buf, /* Since we must not change the file pointer preserve the * value so that we can restore it later. */ - if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1) + if ((old_offset=__lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1) return -1; /* Set to wanted position. */ - if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1) + if (__lseek64(fd, offset, SEEK_SET) == (off64_t) -1) return -1; if (do_pwrite==1) { /* Write the data. */ - result = write(fd, buf, count); + result = __write(fd, buf, count); } else { /* Read the data. */ - result = read(fd, buf, count); + result = __read(fd, buf, count); } /* Now we have to restore the position. */ save_errno = errno; - if (lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1) { + if (__lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1) { if (result == -1) __set_errno (save_errno); return -1; diff --git a/libc/sysdeps/linux/common/query_module.c b/libc/sysdeps/linux/common/query_module.c index 09c1a56e8..853b9ed94 100644 --- a/libc/sysdeps/linux/common/query_module.c +++ b/libc/sysdeps/linux/common/query_module.c @@ -12,8 +12,8 @@ _syscall5(int, query_module, const char *, name, int, which, void *, buf, size_t, bufsize, size_t *, ret); #else -int query_module(const char *name, int which, - void *buf, size_t bufsize, size_t * ret) +int query_module(const char *name attribute_unused, int which attribute_unused, + void *buf attribute_unused, size_t bufsize attribute_unused, size_t * ret attribute_unused) { __set_errno(ENOSYS); return -1; diff --git a/libc/sysdeps/linux/common/sbrk.c b/libc/sysdeps/linux/common/sbrk.c index 028370e99..d8507335b 100644 --- a/libc/sysdeps/linux/common/sbrk.c +++ b/libc/sysdeps/linux/common/sbrk.c @@ -21,27 +21,27 @@ /* Defined in brk.c. */ extern void *__curbrk; -extern int brk (void *addr); +extern int __brk (void *addr) attribute_hidden; /* Extend the process's data space by INCREMENT. If INCREMENT is negative, shrink data space by - INCREMENT. Return start of new space allocated, or -1 for errors. */ -void * sbrk (intptr_t increment) +void attribute_hidden * __sbrk (intptr_t increment) { void *oldbrk; if (__curbrk == NULL) - if (brk (0) < 0) /* Initialize the break. */ + if (__brk (0) < 0) /* Initialize the break. */ return (void *) -1; if (increment == 0) return __curbrk; oldbrk = __curbrk; - if (brk (oldbrk + increment) < 0) + if (__brk (oldbrk + increment) < 0) return (void *) -1; return oldbrk; } - +strong_alias(__sbrk,sbrk) diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c index 96428edb3..49d85156f 100644 --- a/libc/sysdeps/linux/common/setgroups.c +++ b/libc/sysdeps/linux/common/setgroups.c @@ -10,6 +10,7 @@ #define sysconf __sysconf #include "syscalls.h" +#include <stdlib.h> #include <unistd.h> #include <grp.h> @@ -17,23 +18,33 @@ static inline _syscall2(int, __syscall_setgroups, size_t, size, const __kernel_gid_t *, list); -int attribute_hidden __setgroups(size_t n, const gid_t * groups) +int attribute_hidden __setgroups(size_t size, const gid_t *groups) { - if (n > (size_t) sysconf(_SC_NGROUPS_MAX)) { + if (size > (size_t) sysconf(_SC_NGROUPS_MAX)) { +ret_error: __set_errno(EINVAL); return -1; } else { size_t i; - __kernel_gid_t kernel_groups[n]; + __kernel_gid_t *kernel_groups = NULL; - for (i = 0; i < n; i++) { + if (size) { + kernel_groups = (__kernel_gid_t *)malloc(sizeof(*kernel_groups) * size); + if (kernel_groups == NULL) + goto ret_error; + } + + for (i = 0; i < size; i++) { kernel_groups[i] = (groups)[i]; if (groups[i] != (gid_t) ((__kernel_gid_t) groups[i])) { - __set_errno(EINVAL); - return -1; + goto ret_error; } } - return (__syscall_setgroups(n, kernel_groups)); + + i = __syscall_setgroups(size, kernel_groups); + if (kernel_groups) + free(kernel_groups); + return i; } } strong_alias(__setgroups,setgroups) diff --git a/libc/sysdeps/linux/common/ssp-local.c b/libc/sysdeps/linux/common/ssp-local.c index 091c34c5d..11ae654c8 100644 --- a/libc/sysdeps/linux/common/ssp-local.c +++ b/libc/sysdeps/linux/common/ssp-local.c @@ -23,7 +23,7 @@ #include <features.h> -extern void __stack_chk_fail (void) attribute_noreturn; +extern void __stack_chk_fail_internal (void) attribute_noreturn; /* On some architectures, this helps needless PIC pointer setup that would be needed just for the __stack_chk_fail call. */ @@ -31,5 +31,5 @@ extern void __stack_chk_fail (void) attribute_noreturn; void attribute_noreturn attribute_hidden __stack_chk_fail_local (void) { - __stack_chk_fail (); + __stack_chk_fail_internal (); } diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 05e53c29d..9efcd1a89 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -39,7 +39,7 @@ #include <signal.h> #include <sys/syslog.h> -static __always_inline void block_signals(void) +static void block_signals(void) { struct sigaction sa; sigset_t mask; @@ -57,7 +57,7 @@ static __always_inline void block_signals(void) sigaction(SSP_SIGTYPE, &sa, NULL); } -static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) +static void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) { __write(fd, msg1, __strlen(msg1)); __write(fd, msg2, __strlen(msg2)); @@ -68,52 +68,50 @@ static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2 closelog(); } -static __always_inline attribute_noreturn void terminate(void) +static attribute_noreturn void terminate(void) { (void) kill(__getpid(), SSP_SIGTYPE); - _exit(127); + _exit_internal(127); } void attribute_noreturn __stack_smash_handler(char func[], int damaged __attribute__ ((unused))); void attribute_noreturn __stack_smash_handler(char func[], int damaged) { - extern char *__progname; static const char message[] = ": stack smashing attack in function "; block_signals(); - ssp_write(STDERR_FILENO, __progname, message, func); + ssp_write(STDERR_FILENO, __uclibc_progname, message, func); /* The loop is added only to keep gcc happy. */ while(1) terminate(); } -void attribute_noreturn __stack_chk_fail(void) +void attribute_noreturn attribute_hidden __stack_chk_fail_internal(void) { - extern char *__progname; static const char msg1[] = "stack smashing detected: "; static const char msg3[] = " terminated"; block_signals(); - ssp_write(STDERR_FILENO, msg1, __progname, msg3); + ssp_write(STDERR_FILENO, msg1, __uclibc_progname, msg3); /* The loop is added only to keep gcc happy. */ while(1) terminate(); } +strong_alias(__stack_chk_fail_internal,__stack_chk_fail) #if 0 void attribute_noreturn __chk_fail(void) { - extern char *__progname; static const char msg1[] = "buffer overflow detected: "; static const char msg3[] = " terminated"; block_signals(); - ssp_write(STDERR_FILENO, msg1, __progname, msg3); + ssp_write(STDERR_FILENO, msg1, __uclibc_progname, msg3); /* The loop is added only to keep gcc happy. */ while(1) diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c index cefbd5f8e..7e7fe6bec 100644 --- a/libc/sysdeps/linux/common/stat.c +++ b/libc/sysdeps/linux/common/stat.c @@ -14,6 +14,8 @@ #include "xstatconv.h" #define __NR___syscall_stat __NR_stat +#undef __stat +#undef stat static inline _syscall2(int, __syscall_stat, const char *, file_name, struct kernel_stat *, buf); @@ -31,5 +33,6 @@ int attribute_hidden __stat(const char *file_name, struct stat *buf) strong_alias(__stat,stat) #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__ -weak_alias(stat,stat64) +hidden_strong_alias(__stat,__stat64) +weak_alias(__stat,stat64) #endif diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c index d539906dd..f46e52e98 100644 --- a/libc/sysdeps/linux/common/stat64.c +++ b/libc/sysdeps/linux/common/stat64.c @@ -19,6 +19,7 @@ static inline _syscall2(int, __syscall_stat64, const char *, file_name, struct kernel_stat64 *, buf); +#undef stat64 int attribute_hidden __stat64(const char *file_name, struct stat64 *buf) { int result; diff --git a/libc/sysdeps/linux/common/vfork.c b/libc/sysdeps/linux/common/vfork.c index ba4f042ca..d0a4d9a0e 100644 --- a/libc/sysdeps/linux/common/vfork.c +++ b/libc/sysdeps/linux/common/vfork.c @@ -2,7 +2,10 @@ #include <unistd.h> #include <sys/types.h> -pid_t vfork(void) +extern __pid_t __fork (void) __THROW attribute_hidden; + +pid_t attribute_hidden __vfork(void) { - return fork(); + return __fork(); } +strong_alias(__vfork,vfork) diff --git a/libc/sysdeps/linux/common/write.c b/libc/sysdeps/linux/common/write.c index d3b5fab93..8a1d57a82 100644 --- a/libc/sysdeps/linux/common/write.c +++ b/libc/sysdeps/linux/common/write.c @@ -17,5 +17,5 @@ weak_alias(__write,__libc_write) #if 0 /* Stupid libgcc.a from gcc 2.95.x uses __write in pure.o * which is a blatent GNU libc-ism... */ -weak_alias(__libc_write, __write); +weak_alias(__libc_write, __write) #endif |