summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/Makefile.in83
-rw-r--r--libc/inet/accept.c8
-rw-r--r--libc/inet/addr.c53
-rw-r--r--libc/inet/bind.c8
-rw-r--r--libc/inet/closenameservers.c8
-rw-r--r--libc/inet/connect.c8
-rw-r--r--libc/inet/decodea.c8
-rw-r--r--libc/inet/decoded.c8
-rw-r--r--libc/inet/decodeh.c8
-rw-r--r--libc/inet/decodep.c8
-rw-r--r--libc/inet/decodeq.c8
-rw-r--r--libc/inet/dnslookup.c8
-rw-r--r--libc/inet/encodea.c8
-rw-r--r--libc/inet/encoded.c8
-rw-r--r--libc/inet/encodeh.c8
-rw-r--r--libc/inet/encodep.c8
-rw-r--r--libc/inet/encodeq.c8
-rw-r--r--libc/inet/ether_addr.c26
-rw-r--r--libc/inet/formquery.c8
-rw-r--r--libc/inet/gai_strerror.c1
-rw-r--r--libc/inet/get_hosts_byaddr_r.c8
-rw-r--r--libc/inet/get_hosts_byname_r.c8
-rw-r--r--libc/inet/getaddrinfo.c116
-rw-r--r--libc/inet/gethostbyaddr.c8
-rw-r--r--libc/inet/gethostbyaddr_r.c8
-rw-r--r--libc/inet/gethostbyname.c8
-rw-r--r--libc/inet/gethostbyname2.c8
-rw-r--r--libc/inet/gethostbyname2_r.c8
-rw-r--r--libc/inet/gethostbyname_r.c8
-rw-r--r--libc/inet/gethostent.c8
-rw-r--r--libc/inet/getnameinfo.c8
-rw-r--r--libc/inet/getnetbyad.c10
-rw-r--r--libc/inet/getnetbynm.c15
-rw-r--r--libc/inet/getnetent.c27
-rw-r--r--libc/inet/getpeername.c8
-rw-r--r--libc/inet/getproto.c61
-rw-r--r--libc/inet/getservice.c70
-rw-r--r--libc/inet/getsockname.c8
-rw-r--r--libc/inet/getsockopt.c8
-rw-r--r--libc/inet/herror.c9
-rw-r--r--libc/inet/hostid.c54
-rw-r--r--libc/inet/if_index.c93
-rw-r--r--libc/inet/ifaddrs.c32
-rw-r--r--libc/inet/in6_addr.c8
-rw-r--r--libc/inet/inet_addr.c8
-rw-r--r--libc/inet/inet_aton.c8
-rw-r--r--libc/inet/inet_lnaof.c8
-rw-r--r--libc/inet/inet_makeaddr.c8
-rw-r--r--libc/inet/inet_net.c13
-rw-r--r--libc/inet/inet_netof.c8
-rw-r--r--libc/inet/inet_ntoa.c8
-rw-r--r--libc/inet/lengthd.c8
-rw-r--r--libc/inet/lengthq.c8
-rw-r--r--libc/inet/listen.c8
-rw-r--r--libc/inet/netlinkaccess.h11
-rw-r--r--libc/inet/ns_name.c8
-rw-r--r--libc/inet/ntohl.c21
-rw-r--r--libc/inet/ntop.c45
-rw-r--r--libc/inet/opennameservers.c8
-rw-r--r--libc/inet/opensock.c9
-rw-r--r--libc/inet/read_etc_hosts_r.c8
-rw-r--r--libc/inet/recv.c8
-rw-r--r--libc/inet/recvfrom.c8
-rw-r--r--libc/inet/recvmsg.c8
-rw-r--r--libc/inet/res_comp.c8
-rw-r--r--libc/inet/res_init.c8
-rw-r--r--libc/inet/res_query.c8
-rw-r--r--libc/inet/resolv.c331
-rw-r--r--libc/inet/resolveaddress.c8
-rw-r--r--libc/inet/resolvename.c8
-rw-r--r--libc/inet/rpc/Makefile.in54
-rw-r--r--libc/inet/rpc/auth_none.c26
-rw-r--r--libc/inet/rpc/auth_unix.c51
-rw-r--r--libc/inet/rpc/authunix_prot.c18
-rw-r--r--libc/inet/rpc/bindresvport.c17
-rw-r--r--libc/inet/rpc/clnt_generic.c27
-rw-r--r--libc/inet/rpc/clnt_perror.c101
-rw-r--r--libc/inet/rpc/clnt_raw.c19
-rw-r--r--libc/inet/rpc/clnt_simple.c18
-rw-r--r--libc/inet/rpc/clnt_tcp.c66
-rw-r--r--libc/inet/rpc/clnt_udp.c80
-rw-r--r--libc/inet/rpc/clnt_unix.c73
-rw-r--r--libc/inet/rpc/create_xid.c11
-rw-r--r--libc/inet/rpc/get_myaddress.c28
-rw-r--r--libc/inet/rpc/getrpcent.c96
-rw-r--r--libc/inet/rpc/getrpcport.c9
-rw-r--r--libc/inet/rpc/pm_getmaps.c (renamed from libc/inet/rpc/pmap_getmaps.c)14
-rw-r--r--libc/inet/rpc/pm_getport.c (renamed from libc/inet/rpc/pmap_getport.c)24
-rw-r--r--libc/inet/rpc/pmap_clnt.c64
-rw-r--r--libc/inet/rpc/pmap_prot.c5
-rw-r--r--libc/inet/rpc/pmap_prot2.c8
-rw-r--r--libc/inet/rpc/pmap_rmt.c138
-rw-r--r--libc/inet/rpc/rcmd.c270
-rw-r--r--libc/inet/rpc/rexec.c97
-rw-r--r--libc/inet/rpc/rpc_cmsg.c (renamed from libc/inet/rpc/rpc_callmsg.c)28
-rw-r--r--libc/inet/rpc/rpc_dtablesize.c11
-rw-r--r--libc/inet/rpc/rpc_private.h6
-rw-r--r--libc/inet/rpc/rpc_prot.c48
-rw-r--r--libc/inet/rpc/rpc_thread.c49
-rw-r--r--libc/inet/rpc/rtime.c19
-rw-r--r--libc/inet/rpc/ruserpass.c124
-rw-r--r--libc/inet/rpc/sa_len.c3
-rw-r--r--libc/inet/rpc/svc.c132
-rw-r--r--libc/inet/rpc/svc_auth.c7
-rw-r--r--libc/inet/rpc/svc_authux.c (renamed from libc/inet/rpc/svc_auth_unix.c)17
-rw-r--r--libc/inet/rpc/svc_raw.c8
-rw-r--r--libc/inet/rpc/svc_run.c17
-rw-r--r--libc/inet/rpc/svc_simple.c38
-rw-r--r--libc/inet/rpc/svc_tcp.c65
-rw-r--r--libc/inet/rpc/svc_udp.c81
-rw-r--r--libc/inet/rpc/svc_unix.c77
-rw-r--r--libc/inet/rpc/xdr.c143
-rw-r--r--libc/inet/rpc/xdr_array.c21
-rw-r--r--libc/inet/rpc/xdr_float.c1
-rw-r--r--libc/inet/rpc/xdr_mem.c44
-rw-r--r--libc/inet/rpc/xdr_rec.c49
-rw-r--r--libc/inet/rpc/xdr_reference.c23
-rw-r--r--libc/inet/rpc/xdr_stdio.c28
-rw-r--r--libc/inet/send.c8
-rw-r--r--libc/inet/sendmsg.c8
-rw-r--r--libc/inet/sendto.c8
-rw-r--r--libc/inet/setsockopt.c8
-rw-r--r--libc/inet/shutdown.c8
-rw-r--r--libc/inet/socket.c8
-rw-r--r--libc/inet/socketcalls.c88
-rw-r--r--libc/inet/socketpair.c8
-rw-r--r--libc/misc/time/Makefile.in67
-rw-r--r--libc/misc/time/__time_tm.c8
-rw-r--r--libc/misc/time/_time_localtime_tzi.c8
-rw-r--r--libc/misc/time/_time_mktime.c8
-rw-r--r--libc/misc/time/_time_mktime_tzi.c8
-rw-r--r--libc/misc/time/_time_t2tm.c8
-rw-r--r--libc/misc/time/adjtime.c8
-rw-r--r--libc/misc/time/asctime.c8
-rw-r--r--libc/misc/time/asctime_r.c8
-rw-r--r--libc/misc/time/clock.c8
-rw-r--r--libc/misc/time/ctime.c8
-rw-r--r--libc/misc/time/ctime_r.c8
-rw-r--r--libc/misc/time/difftime.c8
-rw-r--r--libc/misc/time/dysize.c8
-rw-r--r--libc/misc/time/ftime.c4
-rw-r--r--libc/misc/time/gmtime.c8
-rw-r--r--libc/misc/time/gmtime_r.c8
-rw-r--r--libc/misc/time/localtime.c8
-rw-r--r--libc/misc/time/localtime_r.c8
-rw-r--r--libc/misc/time/mktime.c8
-rw-r--r--libc/misc/time/strftime.c8
-rw-r--r--libc/misc/time/strftime_l.c9
-rw-r--r--libc/misc/time/strptime.c8
-rw-r--r--libc/misc/time/strptime_l.c9
-rw-r--r--libc/misc/time/time.c253
-rw-r--r--libc/misc/time/timegm.c8
-rw-r--r--libc/misc/time/tzset.c8
-rw-r--r--libc/misc/time/wcsftime.c8
-rw-r--r--libc/misc/time/wcsftime_l.c9
-rw-r--r--libc/stdlib/Makefile.in157
-rw-r--r--libc/stdlib/__cxa_atexit.c8
-rw-r--r--libc/stdlib/__cxa_finalize.c8
-rw-r--r--libc/stdlib/__exit_handler.c8
-rw-r--r--libc/stdlib/__fp_range_check.c8
-rw-r--r--libc/stdlib/__strtofpmax.c8
-rw-r--r--libc/stdlib/__strtofpmax_l.c9
-rw-r--r--libc/stdlib/__wcstofpmax.c8
-rw-r--r--libc/stdlib/__wcstofpmax_l.c9
-rw-r--r--libc/stdlib/_atexit.c348
-rw-r--r--libc/stdlib/_stdlib_mb_cur_max.c7
-rw-r--r--libc/stdlib/_stdlib_strto_l.c7
-rw-r--r--libc/stdlib/_stdlib_strto_l_l.c8
-rw-r--r--libc/stdlib/_stdlib_strto_ll.c7
-rw-r--r--libc/stdlib/_stdlib_strto_ll_l.c8
-rw-r--r--libc/stdlib/_stdlib_wcsto_l.c7
-rw-r--r--libc/stdlib/_stdlib_wcsto_l_l.c8
-rw-r--r--libc/stdlib/_stdlib_wcsto_ll.c7
-rw-r--r--libc/stdlib/_stdlib_wcsto_ll_l.c8
-rw-r--r--libc/stdlib/_strtod.c623
-rw-r--r--libc/stdlib/abort.c70
-rw-r--r--libc/stdlib/abs.c7
-rw-r--r--libc/stdlib/arc4random.c56
-rw-r--r--libc/stdlib/atexit.c351
-rw-r--r--libc/stdlib/atof.c7
-rw-r--r--libc/stdlib/atoi.c7
-rw-r--r--libc/stdlib/atol.c7
-rw-r--r--libc/stdlib/atoll.c7
-rw-r--r--libc/stdlib/bsd_getpt.c6
-rw-r--r--libc/stdlib/bsearch.c7
-rw-r--r--libc/stdlib/drand48-iter.c12
-rw-r--r--libc/stdlib/drand48.c19
-rw-r--r--libc/stdlib/drand48_r.c8
-rw-r--r--libc/stdlib/erand48.c5
-rw-r--r--libc/stdlib/erand48_r.c5
-rw-r--r--libc/stdlib/exit.c8
-rw-r--r--libc/stdlib/gcvt.c4
-rw-r--r--libc/stdlib/getenv.c36
-rw-r--r--libc/stdlib/getpt.c7
-rw-r--r--libc/stdlib/jrand48.c6
-rw-r--r--libc/stdlib/jrand48_r.c5
-rw-r--r--libc/stdlib/labs.c7
-rw-r--r--libc/stdlib/ldiv.c2
-rw-r--r--libc/stdlib/llabs.c7
-rw-r--r--libc/stdlib/lldiv.c3
-rw-r--r--libc/stdlib/lrand48.c6
-rw-r--r--libc/stdlib/lrand48_r.c9
-rw-r--r--libc/stdlib/malloc-simple/Makefile.in29
-rw-r--r--libc/stdlib/malloc-simple/alloc.c20
-rw-r--r--libc/stdlib/malloc-simple/calloc.c8
-rw-r--r--libc/stdlib/malloc-simple/free.c8
-rw-r--r--libc/stdlib/malloc-simple/malloc.c8
-rw-r--r--libc/stdlib/malloc-simple/memalign.c8
-rw-r--r--libc/stdlib/malloc-simple/realloc.c8
-rw-r--r--libc/stdlib/malloc-standard/Makefile.in21
-rw-r--r--libc/stdlib/malloc-standard/calloc.c5
-rw-r--r--libc/stdlib/malloc-standard/free.c8
-rw-r--r--libc/stdlib/malloc-standard/mallinfo.c9
-rw-r--r--libc/stdlib/malloc-standard/malloc.c2
-rw-r--r--libc/stdlib/malloc-standard/malloc.h12
-rw-r--r--libc/stdlib/malloc-standard/memalign.c12
-rw-r--r--libc/stdlib/malloc-standard/realloc.c9
-rw-r--r--libc/stdlib/malloc/Makefile.in25
-rw-r--r--libc/stdlib/malloc/calloc.c4
-rw-r--r--libc/stdlib/malloc/free.c7
-rw-r--r--libc/stdlib/malloc/heap_debug.c5
-rw-r--r--libc/stdlib/malloc/malloc.c8
-rw-r--r--libc/stdlib/malloc/malloc.h3
-rw-r--r--libc/stdlib/malloc/malloc_debug.c14
-rw-r--r--libc/stdlib/malloc/memalign.c1
-rw-r--r--libc/stdlib/malloc/realloc.c8
-rw-r--r--libc/stdlib/mblen.c7
-rw-r--r--libc/stdlib/mbstowcs.c7
-rw-r--r--libc/stdlib/mbtowc.c7
-rw-r--r--libc/stdlib/mrand48.c6
-rw-r--r--libc/stdlib/mrand48_r.c4
-rw-r--r--libc/stdlib/nrand48.c6
-rw-r--r--libc/stdlib/nrand48_r.c5
-rw-r--r--libc/stdlib/old_atexit.c8
-rw-r--r--libc/stdlib/on_exit.c8
-rw-r--r--libc/stdlib/ptsname.c34
-rw-r--r--libc/stdlib/qsort.c7
-rw-r--r--libc/stdlib/rand.c4
-rw-r--r--libc/stdlib/random.c18
-rw-r--r--libc/stdlib/random_r.c25
-rw-r--r--libc/stdlib/realpath.c37
-rw-r--r--libc/stdlib/seed48.c6
-rw-r--r--libc/stdlib/seed48_r.c9
-rw-r--r--libc/stdlib/setenv.c52
-rw-r--r--libc/stdlib/srand48.c6
-rw-r--r--libc/stdlib/srand48_r.c5
-rw-r--r--libc/stdlib/stdlib.c278
-rw-r--r--libc/stdlib/strtod.c620
-rw-r--r--libc/stdlib/strtod_l.c9
-rw-r--r--libc/stdlib/strtof.c36
-rw-r--r--libc/stdlib/strtof_l.c9
-rw-r--r--libc/stdlib/strtol.c7
-rw-r--r--libc/stdlib/strtol_l.c8
-rw-r--r--libc/stdlib/strtold.c36
-rw-r--r--libc/stdlib/strtold_l.c9
-rw-r--r--libc/stdlib/strtoll.c7
-rw-r--r--libc/stdlib/strtoll_l.c8
-rw-r--r--libc/stdlib/strtoul.c7
-rw-r--r--libc/stdlib/strtoul_l.c8
-rw-r--r--libc/stdlib/strtoull.c7
-rw-r--r--libc/stdlib/strtoull_l.c8
-rw-r--r--libc/stdlib/system.c228
-rw-r--r--libc/stdlib/unix_grantpt.c34
-rw-r--r--libc/stdlib/unlockpt.c3
-rw-r--r--libc/stdlib/valloc.c4
-rw-r--r--libc/stdlib/wcstod.c8
-rw-r--r--libc/stdlib/wcstod_l.c9
-rw-r--r--libc/stdlib/wcstof.c8
-rw-r--r--libc/stdlib/wcstof_l.c9
-rw-r--r--libc/stdlib/wcstol.c7
-rw-r--r--libc/stdlib/wcstol_l.c8
-rw-r--r--libc/stdlib/wcstold.c8
-rw-r--r--libc/stdlib/wcstold_l.c9
-rw-r--r--libc/stdlib/wcstoll.c7
-rw-r--r--libc/stdlib/wcstoll_l.c8
-rw-r--r--libc/stdlib/wcstombs.c7
-rw-r--r--libc/stdlib/wcstoul.c7
-rw-r--r--libc/stdlib/wcstoul_l.c8
-rw-r--r--libc/stdlib/wcstoull.c7
-rw-r--r--libc/stdlib/wcstoull_l.c8
-rw-r--r--libc/stdlib/wctomb.c7
-rw-r--r--libc/string/Makefile.in90
-rw-r--r--libc/string/__glibc_strerror_r.c11
-rw-r--r--libc/string/__xpg_basename.c1
-rw-r--r--libc/string/__xpg_strerror_r.c41
-rw-r--r--libc/string/_collate.c74
-rw-r--r--libc/string/_string.h1
-rw-r--r--libc/string/_string_syserrmsgs.c1
-rw-r--r--libc/string/_string_syssigmsgs.c3
-rw-r--r--libc/string/arm/Makefile6
-rw-r--r--libc/string/arm/Makefile.arch27
-rw-r--r--libc/string/arm/_memcpy.S19
-rw-r--r--libc/string/arm/bcopy.S13
-rw-r--r--libc/string/arm/bzero.S13
-rw-r--r--libc/string/arm/memcmp.S24
-rw-r--r--libc/string/arm/memcpy.S11
-rw-r--r--libc/string/arm/memmove.S11
-rw-r--r--libc/string/arm/memset.S23
-rw-r--r--libc/string/arm/strcmp.S21
-rw-r--r--libc/string/arm/strlen.S17
-rw-r--r--libc/string/arm/strncmp.S21
-rw-r--r--libc/string/basename.c7
-rw-r--r--libc/string/bcopy.c8
-rw-r--r--libc/string/bzero.c8
-rw-r--r--libc/string/dirname.c1
-rw-r--r--libc/string/ffs.c7
-rw-r--r--libc/string/frv/Makefile6
-rw-r--r--libc/string/frv/Makefile.arch27
-rw-r--r--libc/string/frv/memcpy.S11
-rw-r--r--libc/string/frv/memset.S11
-rw-r--r--libc/string/generic/Makefile6
-rw-r--r--libc/string/generic/Makefile.in29
-rw-r--r--libc/string/generic/memchr.c8
-rw-r--r--libc/string/generic/memcmp.c11
-rw-r--r--libc/string/generic/memcpy.c7
-rw-r--r--libc/string/generic/memmem.c10
-rw-r--r--libc/string/generic/memmove.c10
-rw-r--r--libc/string/generic/mempcpy.c10
-rw-r--r--libc/string/generic/memrchr.c8
-rw-r--r--libc/string/generic/memset.c6
-rw-r--r--libc/string/generic/rawmemchr.c8
-rw-r--r--libc/string/generic/strcat.c6
-rw-r--r--libc/string/generic/strchr.c11
-rw-r--r--libc/string/generic/strchrnul.c8
-rw-r--r--libc/string/generic/strcmp.c11
-rw-r--r--libc/string/generic/strcpy.c6
-rw-r--r--libc/string/generic/strcspn.c10
-rw-r--r--libc/string/generic/strlen.c8
-rw-r--r--libc/string/generic/strncat.c6
-rw-r--r--libc/string/generic/strncmp.c6
-rw-r--r--libc/string/generic/strncpy.c6
-rw-r--r--libc/string/generic/strnlen.c8
-rw-r--r--libc/string/generic/strrchr.c15
-rw-r--r--libc/string/generic/strsep.c13
-rw-r--r--libc/string/generic/strspn.c6
-rw-r--r--libc/string/generic/strstr.c7
-rw-r--r--libc/string/generic/strtok_r.c17
-rw-r--r--libc/string/i386/Makefile6
-rw-r--r--libc/string/i386/Makefile.arch24
-rw-r--r--libc/string/i386/memchr.c6
-rw-r--r--libc/string/i386/memcpy.c6
-rw-r--r--libc/string/i386/memmove.c6
-rw-r--r--libc/string/i386/memset.c6
-rw-r--r--libc/string/i386/strcat.c6
-rw-r--r--libc/string/i386/strchr.c9
-rw-r--r--libc/string/i386/strcmp.c11
-rw-r--r--libc/string/i386/strcpy.c6
-rw-r--r--libc/string/i386/strlen.c6
-rw-r--r--libc/string/i386/strncat.c6
-rw-r--r--libc/string/i386/strncmp.c6
-rw-r--r--libc/string/i386/strncpy.c6
-rw-r--r--libc/string/i386/strnlen.c7
-rw-r--r--libc/string/i386/strrchr.c9
-rw-r--r--libc/string/ia64/Makefile13
-rw-r--r--libc/string/ia64/bcopy.S10
-rw-r--r--libc/string/ia64/bzero.S315
-rw-r--r--libc/string/ia64/memccpy.S213
-rw-r--r--libc/string/ia64/memchr.S133
-rw-r--r--libc/string/ia64/memcmp.S165
-rw-r--r--libc/string/ia64/memcpy.S436
-rw-r--r--libc/string/ia64/memmove.S251
-rw-r--r--libc/string/ia64/memset.S400
-rw-r--r--libc/string/ia64/softpipe.h29
-rw-r--r--libc/string/ia64/strchr.S112
-rw-r--r--libc/string/ia64/strcmp.S59
-rw-r--r--libc/string/ia64/strcpy.S145
-rw-r--r--libc/string/ia64/strlen.S98
-rw-r--r--libc/string/ia64/strncmp.S62
-rw-r--r--libc/string/ia64/strncpy.S232
-rw-r--r--libc/string/ia64/sysdep.h168
-rw-r--r--libc/string/memccpy.c4
-rw-r--r--libc/string/memchr.c8
-rw-r--r--libc/string/memcmp.c9
-rw-r--r--libc/string/memcpy.c9
-rw-r--r--libc/string/memmem.c4
-rw-r--r--libc/string/memmove.c9
-rw-r--r--libc/string/mempcpy.c8
-rw-r--r--libc/string/memrchr.c6
-rw-r--r--libc/string/memset.c9
-rw-r--r--libc/string/mips/Makefile6
-rw-r--r--libc/string/mips/Makefile.arch26
-rw-r--r--libc/string/mips/memcpy.S10
-rw-r--r--libc/string/mips/memset.S10
-rw-r--r--libc/string/mips/sysdep.h45
-rw-r--r--libc/string/powerpc/Makefile6
-rw-r--r--libc/string/powerpc/Makefile.arch24
-rw-r--r--libc/string/powerpc/memcpy.c6
-rw-r--r--libc/string/powerpc/memmove.c10
-rw-r--r--libc/string/powerpc/memset.c7
-rw-r--r--libc/string/psignal.c7
-rw-r--r--libc/string/rawmemchr.c7
-rw-r--r--libc/string/sh64/Makefile6
-rw-r--r--libc/string/sh64/Makefile.arch27
-rw-r--r--libc/string/sh64/memcpy.S11
-rw-r--r--libc/string/sh64/memset.S11
-rw-r--r--libc/string/sh64/strcpy.S11
-rw-r--r--libc/string/sh64/strlen.S11
-rw-r--r--libc/string/sparc/Makefile6
-rw-r--r--libc/string/sparc/Makefile.arch28
-rw-r--r--libc/string/sparc/_glibc_inc.h1
-rw-r--r--libc/string/sparc/sparc32/memchr.S8
-rw-r--r--libc/string/sparc/sparc32/memcpy.S17
-rw-r--r--libc/string/sparc/sparc32/memset.S11
-rw-r--r--libc/string/sparc/sparc32/stpcpy.S6
-rw-r--r--libc/string/sparc/sparc32/strcat.S6
-rw-r--r--libc/string/sparc/sparc32/strchr.S16
-rw-r--r--libc/string/sparc/sparc32/strcmp.S7
-rw-r--r--libc/string/sparc/sparc32/strcpy.S7
-rw-r--r--libc/string/sparc/sparc32/strlen.S7
-rw-r--r--libc/string/sparc/sparc64/memchr.S8
-rw-r--r--libc/string/sparc/sparc64/memcpy.S21
-rw-r--r--libc/string/sparc/sparc64/memset.S11
-rw-r--r--libc/string/sparc/sparc64/sparcv9b/memcpy.S17
-rw-r--r--libc/string/sparc/sparc64/stpcpy.S7
-rw-r--r--libc/string/sparc/sparc64/strcat.S7
-rw-r--r--libc/string/sparc/sparc64/strchr.S16
-rw-r--r--libc/string/sparc/sparc64/strcmp.S7
-rw-r--r--libc/string/sparc/sparc64/strcpy.S6
-rw-r--r--libc/string/sparc/sparc64/strlen.S7
-rw-r--r--libc/string/sparc/strcmp.S5
-rw-r--r--libc/string/stpcpy.c9
-rw-r--r--libc/string/stpncpy.c9
-rw-r--r--libc/string/strcasecmp.c40
-rw-r--r--libc/string/strcasestr.c15
-rw-r--r--libc/string/strcat.c9
-rw-r--r--libc/string/strchr.c11
-rw-r--r--libc/string/strchrnul.c9
-rw-r--r--libc/string/strcmp.c21
-rw-r--r--libc/string/strcpy.c9
-rw-r--r--libc/string/strcspn.c9
-rw-r--r--libc/string/strdup.c21
-rw-r--r--libc/string/strerror.c10
-rw-r--r--libc/string/strlcpy.c33
-rw-r--r--libc/string/strlen.c9
-rw-r--r--libc/string/strncasecmp.c40
-rw-r--r--libc/string/strncat.c9
-rw-r--r--libc/string/strncmp.c10
-rw-r--r--libc/string/strncpy.c10
-rw-r--r--libc/string/strndup.c13
-rw-r--r--libc/string/strnlen.c8
-rw-r--r--libc/string/strpbrk.c9
-rw-r--r--libc/string/strrchr.c10
-rw-r--r--libc/string/strsep.c13
-rw-r--r--libc/string/strsignal.c24
-rw-r--r--libc/string/strspn.c9
-rw-r--r--libc/string/strstr.c13
-rw-r--r--libc/string/strtok.c6
-rw-r--r--libc/string/strtok_r.c21
-rw-r--r--libc/string/sys_errlist.c2
-rw-r--r--libc/string/sys_siglist.c6
-rw-r--r--libc/string/x86_64/Makefile6
-rw-r--r--libc/string/x86_64/Makefile.arch28
-rw-r--r--libc/string/x86_64/_glibc_inc.h1
-rw-r--r--libc/string/x86_64/bzero.S3
-rw-r--r--libc/string/x86_64/memcpy.S8
-rw-r--r--libc/string/x86_64/mempcpy.S4
-rw-r--r--libc/string/x86_64/memset.S8
-rw-r--r--libc/string/x86_64/stpcpy.S4
-rw-r--r--libc/string/x86_64/strcat.S6
-rw-r--r--libc/string/x86_64/strchr.S8
-rw-r--r--libc/string/x86_64/strcmp.S10
-rw-r--r--libc/string/x86_64/strcpy.S4
-rw-r--r--libc/string/x86_64/strcspn.S8
-rw-r--r--libc/string/x86_64/strlen.S6
-rw-r--r--libc/string/x86_64/strpbrk.S4
-rw-r--r--libc/string/x86_64/strspn.S6
466 files changed, 8877 insertions, 4332 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in
index 1d1be7eb9..89374f98d 100644
--- a/libc/inet/Makefile.in
+++ b/libc/inet/Makefile.in
@@ -1,80 +1,45 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
include $(top_srcdir)libc/inet/rpc/Makefile.in
-CSRC:= getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
+CSRC := getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.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 \
- inet_netof.o
+# multi source addr.c
+CSRC += inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c inet_lnaof.c \
+ inet_netof.c
-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 res_state.o
+# multi source resolv.c
+CSRC += encodeh.c decodeh.c encoded.c decoded.c lengthd.c encodeq.c \
+ decodeq.c lengthq.c encodea.c decodea.c encodep.c decodep.c \
+ formquery.c dnslookup.c resolveaddress.c opennameservers.c \
+ closenameservers.c resolvename.c gethostbyname.c res_init.c \
+ res_query.c gethostbyaddr.c read_etc_hosts_r.c get_hosts_byname_r.c \
+ get_hosts_byaddr_r.c gethostbyname2.c getnameinfo.c gethostent.c \
+ gethostbyname_r.c gethostbyname2_r.c gethostbyaddr_r.c \
+ res_comp.c ns_name.c
-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
+# multi source socketcalls.c
+CSRC += accept.c bind.c connect.c getpeername.c getsockname.c getsockopt.c \
+ listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c sendto.c \
+ setsockopt.c shutdown.c socket.c socketpair.c
-INET_DIR:=$(top_srcdir)libc/inet
-INET_OUT:=$(top_builddir)libc/inet
+INET_DIR := $(top_srcdir)libc/inet
+INET_OUT := $(top_builddir)libc/inet
-INET_SRC:=$(patsubst %.c,$(INET_DIR)/%.c,$(CSRC))
-INET_OBJ:=$(patsubst %.c,$(INET_OUT)/%.o,$(CSRC))
+INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC))
+INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC))
-INET_MSRC1:=$(INET_DIR)/$(MSRC1)
-INET_MSRC2:=$(INET_DIR)/$(MSRC2)
-INET_MSRC3:=$(INET_DIR)/$(MSRC3)
-INET_MOBJ1:=$(patsubst %.o,$(INET_OUT)/%.o,$(MOBJ1))
-INET_MOBJ2:=$(patsubst %.o,$(INET_OUT)/%.o,$(MOBJ2))
-INET_MOBJ3:=$(patsubst %.o,$(INET_OUT)/%.o,$(MOBJ3))
+libc-y += $(INET_OBJ)
-INET_MSRC:=$(INET_MSRC1) $(INET_MSRC2) $(INET_MSRC3)
-INET_MOBJ:=$(INET_MOBJ1) $(INET_MOBJ2) $(INET_MOBJ3)
-INET_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(INET_MOBJ))))
-
-INET_OBJS:=$(INET_OBJ) $(INET_MOBJ)
-
-$(INET_MOBJ1): $(INET_MSRC1)
- $(compile.m)
-
-$(INET_MOBJ1:.o=.os): $(INET_MSRC1)
- $(compile.m)
-
-$(INET_MOBJ2): $(INET_MSRC2)
- $(compile.m)
-
-$(INET_MOBJ2:.o=.os): $(INET_MSRC2)
- $(compile.m)
-
-$(INET_MOBJ3): $(INET_MSRC3)
- $(compile.m)
-
-$(INET_MOBJ3:.o=.os): $(INET_MSRC3)
- $(compile.m)
-
-libc-a-y+=$(INET_OBJS)
-libc-so-y+=$(INET_OBJS:.o=.os)
-
-CFLAGS-multi-y+=$(INET_DEF)
-libc-multi-y+=$(INET_SRC) $(INET_MSRC)
-
-objclean-y+=inet_objclean
+objclean-y += inet_objclean
inet_objclean:
$(RM) $(INET_OUT)/*.{o,os}
diff --git a/libc/inet/accept.c b/libc/inet/accept.c
new file mode 100644
index 000000000..0217a6876
--- /dev/null
+++ b/libc/inet/accept.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_accept
+#include "socketcalls.c"
diff --git a/libc/inet/addr.c b/libc/inet/addr.c
index 6be41f81d..6434466c4 100644
--- a/libc/inet/addr.c
+++ b/libc/inet/addr.c
@@ -16,13 +16,13 @@
* Changed to use _int10tostr.
*/
-#define _GNU_SOURCE
#define __FORCE_GLIBC
#include <features.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <bits/uClibc_uintmaxtostr.h>
#ifdef L_inet_aton
@@ -42,7 +42,13 @@
* leading 0 -> octal
* all else -> decimal
*/
-int attribute_hidden __inet_aton(const char *cp, struct in_addr *addrptr)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
+libc_hidden_proto(inet_aton)
+int inet_aton(const char *cp, struct in_addr *addrptr)
{
in_addr_t addr;
int value;
@@ -88,29 +94,33 @@ int attribute_hidden __inet_aton(const char *cp, struct in_addr *addrptr)
return 1;
}
-strong_alias(__inet_aton,inet_aton)
+libc_hidden_def(inet_aton)
#endif
#ifdef L_inet_addr
-extern int __inet_aton (__const char *__cp, struct in_addr *__inp) __THROW attribute_hidden;
+#include <arpa/inet.h>
+libc_hidden_proto(inet_aton)
-in_addr_t attribute_hidden __inet_addr(const char *cp)
+libc_hidden_proto(inet_addr)
+in_addr_t inet_addr(const char *cp)
{
struct in_addr a;
- if (!__inet_aton(cp, &a))
+ if (!inet_aton(cp, &a))
return INADDR_NONE;
else
return a.s_addr;
}
-strong_alias(__inet_addr,inet_addr)
+libc_hidden_def(inet_addr)
#endif
#ifdef L_inet_ntoa
#define INET_NTOA_MAX_LEN 16 /* max 12 digits + 3 '.'s + 1 nul */
-char attribute_hidden *__inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN])
+extern char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN]);
+libc_hidden_proto(inet_ntoa_r)
+char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN])
{
in_addr_t addr = ntohl(in.s_addr);
int i;
@@ -129,22 +139,28 @@ char attribute_hidden *__inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_L
return p+1;
}
-strong_alias(__inet_ntoa_r,inet_ntoa_r)
+libc_hidden_def(inet_ntoa_r)
-char attribute_hidden *__inet_ntoa(struct in_addr in)
+libc_hidden_proto(inet_ntoa)
+char *inet_ntoa(struct in_addr in)
{
static char buf[INET_NTOA_MAX_LEN];
- return(__inet_ntoa_r(in, buf));
+ return(inet_ntoa_r(in, buf));
}
-strong_alias(__inet_ntoa,inet_ntoa)
+libc_hidden_def(inet_ntoa)
#endif
#ifdef L_inet_makeaddr
+
+/* for some reason it does not remove the jump relocation */
+libc_hidden_proto(memmove)
+
/*
* Formulate an Internet address from network + host. Used in
* building addresses stored in the ifnet structure.
*/
-struct in_addr attribute_hidden __inet_makeaddr(in_addr_t net, in_addr_t host)
+libc_hidden_proto(inet_makeaddr)
+struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host)
{
in_addr_t addr;
@@ -159,8 +175,7 @@ struct in_addr attribute_hidden __inet_makeaddr(in_addr_t net, in_addr_t host)
addr = htonl(addr);
return (*(struct in_addr *)&addr);
}
-strong_alias(__inet_makeaddr,inet_makeaddr)
-
+libc_hidden_def(inet_makeaddr)
#endif
#ifdef L_inet_lnaof
@@ -188,8 +203,9 @@ in_addr_t inet_lnaof(struct in_addr in)
* Return the network number from an internet
* address; handles class a/b/c network #'s.
*/
-in_addr_t attribute_hidden
-__inet_netof(struct in_addr in)
+libc_hidden_proto(inet_netof)
+in_addr_t
+inet_netof(struct in_addr in)
{
in_addr_t i = ntohl(in.s_addr);
@@ -200,6 +216,5 @@ __inet_netof(struct in_addr in)
else
return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
}
-strong_alias(__inet_netof,inet_netof)
-
+libc_hidden_def(inet_netof)
#endif
diff --git a/libc/inet/bind.c b/libc/inet/bind.c
new file mode 100644
index 000000000..d13e2262e
--- /dev/null
+++ b/libc/inet/bind.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_bind
+#include "socketcalls.c"
diff --git a/libc/inet/closenameservers.c b/libc/inet/closenameservers.c
new file mode 100644
index 000000000..ca4dae3fb
--- /dev/null
+++ b/libc/inet/closenameservers.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_closenameservers
+#include "resolv.c"
diff --git a/libc/inet/connect.c b/libc/inet/connect.c
new file mode 100644
index 000000000..bddbe16e6
--- /dev/null
+++ b/libc/inet/connect.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_connect
+#include "socketcalls.c"
diff --git a/libc/inet/decodea.c b/libc/inet/decodea.c
new file mode 100644
index 000000000..409a97843
--- /dev/null
+++ b/libc/inet/decodea.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_decodea
+#include "resolv.c"
diff --git a/libc/inet/decoded.c b/libc/inet/decoded.c
new file mode 100644
index 000000000..73849ef5f
--- /dev/null
+++ b/libc/inet/decoded.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_decoded
+#include "resolv.c"
diff --git a/libc/inet/decodeh.c b/libc/inet/decodeh.c
new file mode 100644
index 000000000..86681fa88
--- /dev/null
+++ b/libc/inet/decodeh.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_decodeh
+#include "resolv.c"
diff --git a/libc/inet/decodep.c b/libc/inet/decodep.c
new file mode 100644
index 000000000..40b0bda0d
--- /dev/null
+++ b/libc/inet/decodep.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_decodep
+#include "resolv.c"
diff --git a/libc/inet/decodeq.c b/libc/inet/decodeq.c
new file mode 100644
index 000000000..a6109677e
--- /dev/null
+++ b/libc/inet/decodeq.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_decodeq
+#include "resolv.c"
diff --git a/libc/inet/dnslookup.c b/libc/inet/dnslookup.c
new file mode 100644
index 000000000..4ffc34f0a
--- /dev/null
+++ b/libc/inet/dnslookup.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_dnslookup
+#include "resolv.c"
diff --git a/libc/inet/encodea.c b/libc/inet/encodea.c
new file mode 100644
index 000000000..628f9bad5
--- /dev/null
+++ b/libc/inet/encodea.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_encodea
+#include "resolv.c"
diff --git a/libc/inet/encoded.c b/libc/inet/encoded.c
new file mode 100644
index 000000000..d60618771
--- /dev/null
+++ b/libc/inet/encoded.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_encoded
+#include "resolv.c"
diff --git a/libc/inet/encodeh.c b/libc/inet/encodeh.c
new file mode 100644
index 000000000..1d5488017
--- /dev/null
+++ b/libc/inet/encodeh.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_encodeh
+#include "resolv.c"
diff --git a/libc/inet/encodep.c b/libc/inet/encodep.c
new file mode 100644
index 000000000..d2f248b40
--- /dev/null
+++ b/libc/inet/encodep.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_encodep
+#include "resolv.c"
diff --git a/libc/inet/encodeq.c b/libc/inet/encodeq.c
new file mode 100644
index 000000000..be1a3123b
--- /dev/null
+++ b/libc/inet/encodeq.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_encodeq
+#include "resolv.c"
diff --git a/libc/inet/ether_addr.c b/libc/inet/ether_addr.c
index 0a1e2aede..13414826e 100644
--- a/libc/inet/ether_addr.c
+++ b/libc/inet/ether_addr.c
@@ -23,7 +23,6 @@
* - initial uClibc port
*/
-
#define __FORCE_GLIBC
#include <features.h>
#include <ctype.h>
@@ -32,7 +31,18 @@
#include <netinet/ether.h>
#include <netinet/if_ether.h>
-struct ether_addr attribute_hidden *__ether_aton_r(const char *asc, struct ether_addr *addr)
+libc_hidden_proto(ether_aton_r)
+libc_hidden_proto(ether_ntoa_r)
+libc_hidden_proto(sprintf)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+libc_hidden_proto(__ctype_tolower_loc)
+#else
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_tolower)
+#endif
+
+struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
{
size_t cnt;
@@ -68,28 +78,28 @@ struct ether_addr attribute_hidden *__ether_aton_r(const char *asc, struct ether
return addr;
}
-strong_alias(__ether_aton_r,ether_aton_r)
+libc_hidden_def(ether_aton_r)
struct ether_addr *ether_aton(const char *asc)
{
static struct ether_addr result;
- return __ether_aton_r(asc, &result);
+ return ether_aton_r(asc, &result);
}
-char attribute_hidden *__ether_ntoa_r(const struct ether_addr *addr, char *buf)
+char *ether_ntoa_r(const struct ether_addr *addr, char *buf)
{
- __sprintf(buf, "%x:%x:%x:%x:%x:%x",
+ sprintf(buf, "%x:%x:%x:%x:%x:%x",
addr->ether_addr_octet[0], addr->ether_addr_octet[1],
addr->ether_addr_octet[2], addr->ether_addr_octet[3],
addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
return buf;
}
-strong_alias(__ether_ntoa_r,ether_ntoa_r)
+libc_hidden_def(ether_ntoa_r)
char *ether_ntoa(const struct ether_addr *addr)
{
static char asc[18];
- return __ether_ntoa_r(addr, asc);
+ return ether_ntoa_r(addr, asc);
}
diff --git a/libc/inet/formquery.c b/libc/inet/formquery.c
new file mode 100644
index 000000000..2c53e33de
--- /dev/null
+++ b/libc/inet/formquery.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_formquery
+#include "resolv.c"
diff --git a/libc/inet/gai_strerror.c b/libc/inet/gai_strerror.c
index 56fb57684..c1c7b767f 100644
--- a/libc/inet/gai_strerror.c
+++ b/libc/inet/gai_strerror.c
@@ -17,7 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define _GNU_SOURCE
#define __FORCE_GLIBC
#include <features.h>
#include <stdio.h>
diff --git a/libc/inet/get_hosts_byaddr_r.c b/libc/inet/get_hosts_byaddr_r.c
new file mode 100644
index 000000000..c377aec13
--- /dev/null
+++ b/libc/inet/get_hosts_byaddr_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_get_hosts_byaddr_r
+#include "resolv.c"
diff --git a/libc/inet/get_hosts_byname_r.c b/libc/inet/get_hosts_byname_r.c
new file mode 100644
index 000000000..7ad1e3fa5
--- /dev/null
+++ b/libc/inet/get_hosts_byname_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_get_hosts_byname_r
+#include "resolv.c"
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index ee5fdc5f7..1c593fc4f 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -1,3 +1,10 @@
+/*
+ * Copyright 1996 by Craig Metz
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
/* $USAGI: getaddrinfo.c,v 1.16 2001/10/04 09:52:03 sekiya Exp $ */
/* The Inner Net License, Version 2.00
@@ -42,25 +49,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If these license terms cause you a real problem, contact the author. */
-/* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */
-
-#define getservbyname_r __getservbyname_r
-#define gethostbyname_r __gethostbyname_r
-#define gethostbyname2_r __gethostbyname2_r
-#define gethostbyaddr_r __gethostbyaddr_r
-#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
-/* strdupa is using these */
-#define memcpy __memcpy
-#define strlen __strlen
-#endif
-
-#define _GNU_SOURCE
#define __FORCE_GLIBC
#include <features.h>
#include <assert.h>
@@ -79,6 +67,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/utsname.h>
#include <net/if.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+/* libc_hidden_proto(strcmp) */
+/* libc_hidden_proto(stpcpy) */
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(getservbyname_r)
+libc_hidden_proto(gethostbyname_r)
+libc_hidden_proto(gethostbyname2_r)
+libc_hidden_proto(gethostbyaddr_r)
+libc_hidden_proto(inet_pton)
+libc_hidden_proto(inet_ntop)
+libc_hidden_proto(strtoul)
+libc_hidden_proto(if_nametoindex)
+libc_hidden_proto(__h_errno_location)
+/* libc_hidden_proto(uname) */
+#ifdef __UCLIBC_HAS_IPV6__
+libc_hidden_proto(in6addr_loopback)
+#endif
+
/* The following declarations and definitions have been removed from
* the public header since we don't want people to use them. */
#define AI_V4MAPPED 0x0008 /* IPv4-mapped addresses are acceptable. */
@@ -160,12 +171,12 @@ static int addrconfig (sa_family_t af)
int s;
int ret;
int saved_errno = errno;
- s = __socket(af, SOCK_DGRAM, 0);
+ s = socket(af, SOCK_DGRAM, 0);
if (s < 0)
ret = (errno == EMFILE) ? 1 : 0;
else
{
- __close(s);
+ close(s);
ret = 1;
}
__set_errno (saved_errno);
@@ -189,10 +200,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;
}
@@ -219,7 +230,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;
@@ -237,22 +248,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;
@@ -274,7 +285,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
@@ -354,7 +365,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); \
} \
@@ -505,7 +516,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';
@@ -588,21 +599,20 @@ 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__
if (req->ai_family == 0 || req->ai_family == AF_INET6)
{
- 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
@@ -674,7 +684,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;
@@ -718,7 +728,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
@@ -726,7 +736,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;
@@ -738,17 +748,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;
@@ -775,8 +785,9 @@ static struct gaih gaih[] =
{ PF_UNSPEC, NULL }
};
-void attribute_hidden
-__freeaddrinfo (struct addrinfo *ai)
+libc_hidden_proto(freeaddrinfo)
+void
+freeaddrinfo (struct addrinfo *ai)
{
struct addrinfo *p;
@@ -787,10 +798,11 @@ __freeaddrinfo (struct addrinfo *ai)
free (p);
}
}
-strong_alias(__freeaddrinfo,freeaddrinfo)
+libc_hidden_def(freeaddrinfo)
-int attribute_hidden
-__getaddrinfo (const char *name, const char *service,
+libc_hidden_proto(getaddrinfo)
+int
+getaddrinfo (const char *name, const char *service,
const struct addrinfo *hints, struct addrinfo **pai)
{
int i = 0, j = 0, last_i = 0;
@@ -860,7 +872,7 @@ __getaddrinfo (const char *name, const char *service,
continue;
if (p)
- __freeaddrinfo (p);
+ freeaddrinfo (p);
return -(i & GAIH_EAI);
}
@@ -884,8 +896,8 @@ __getaddrinfo (const char *name, const char *service,
return 0;
if (p)
- __freeaddrinfo (p);
+ freeaddrinfo (p);
return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
}
-strong_alias(__getaddrinfo,getaddrinfo)
+libc_hidden_def(getaddrinfo)
diff --git a/libc/inet/gethostbyaddr.c b/libc/inet/gethostbyaddr.c
new file mode 100644
index 000000000..ae8a543e5
--- /dev/null
+++ b/libc/inet/gethostbyaddr.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyaddr
+#include "resolv.c"
diff --git a/libc/inet/gethostbyaddr_r.c b/libc/inet/gethostbyaddr_r.c
new file mode 100644
index 000000000..6235c82e1
--- /dev/null
+++ b/libc/inet/gethostbyaddr_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyaddr_r
+#include "resolv.c"
diff --git a/libc/inet/gethostbyname.c b/libc/inet/gethostbyname.c
new file mode 100644
index 000000000..3d46ab015
--- /dev/null
+++ b/libc/inet/gethostbyname.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyname
+#include "resolv.c"
diff --git a/libc/inet/gethostbyname2.c b/libc/inet/gethostbyname2.c
new file mode 100644
index 000000000..685801642
--- /dev/null
+++ b/libc/inet/gethostbyname2.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyname2
+#include "resolv.c"
diff --git a/libc/inet/gethostbyname2_r.c b/libc/inet/gethostbyname2_r.c
new file mode 100644
index 000000000..06d058ae7
--- /dev/null
+++ b/libc/inet/gethostbyname2_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyname2_r
+#include "resolv.c"
diff --git a/libc/inet/gethostbyname_r.c b/libc/inet/gethostbyname_r.c
new file mode 100644
index 000000000..fc9e56da5
--- /dev/null
+++ b/libc/inet/gethostbyname_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostbyname_r
+#include "resolv.c"
diff --git a/libc/inet/gethostent.c b/libc/inet/gethostent.c
new file mode 100644
index 000000000..16133c0e4
--- /dev/null
+++ b/libc/inet/gethostent.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostent
+#include "resolv.c"
diff --git a/libc/inet/getnameinfo.c b/libc/inet/getnameinfo.c
new file mode 100644
index 000000000..fbfd3ede1
--- /dev/null
+++ b/libc/inet/getnameinfo.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_getnameinfo
+#include "resolv.c"
diff --git a/libc/inet/getnetbyad.c b/libc/inet/getnetbyad.c
index a257a1bd7..e353f245b 100644
--- a/libc/inet/getnetbyad.c
+++ b/libc/inet/getnetbyad.c
@@ -15,15 +15,15 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define setnetent __setnetent
-#define getnetent __getnetent
-#define endnetent __endnetent
-
#define __FORCE_GLIBC
#include <features.h>
#include <netdb.h>
-extern int _net_stayopen;
+libc_hidden_proto(setnetent)
+libc_hidden_proto(getnetent)
+libc_hidden_proto(endnetent)
+
+extern int _net_stayopen attribute_hidden;
struct netent *getnetbyaddr (uint32_t net, int type)
{
diff --git a/libc/inet/getnetbynm.c b/libc/inet/getnetbynm.c
index f4e9b817e..97d5cb85f 100644
--- a/libc/inet/getnetbynm.c
+++ b/libc/inet/getnetbynm.c
@@ -15,16 +15,17 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define setnetent __setnetent
-#define getnetent __getnetent
-#define endnetent __endnetent
-
#define __FORCE_GLIBC
#include <features.h>
#include <netdb.h>
#include <string.h>
-extern int _net_stayopen;
+libc_hidden_proto(strcmp)
+libc_hidden_proto(setnetent)
+libc_hidden_proto(getnetent)
+libc_hidden_proto(endnetent)
+
+extern int _net_stayopen attribute_hidden;
struct netent *
getnetbyname(const char *name)
@@ -34,10 +35,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/getnetent.c b/libc/inet/getnetent.c
index cd5f63ad5..d3fdb988a 100644
--- a/libc/inet/getnetent.c
+++ b/libc/inet/getnetent.c
@@ -15,10 +15,6 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define inet_network __inet_network
-#define rewind __rewind
-#define fgets __fgets
-
#define __FORCE_GLIBC
#include <features.h>
#include <stdio.h>
@@ -26,6 +22,12 @@
#include <netdb.h>
#include <arpa/inet.h>
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(inet_network)
+libc_hidden_proto(rewind)
+libc_hidden_proto(fgets)
+libc_hidden_proto(abort)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -43,9 +45,10 @@ static char *line = NULL;
static struct netent net;
static char *net_aliases[MAXALIASES];
-int _net_stayopen;
+int _net_stayopen attribute_hidden;
-void attribute_hidden __setnetent(int f)
+libc_hidden_proto(setnetent)
+void setnetent(int f)
{
LOCK;
if (netf == NULL)
@@ -56,9 +59,10 @@ void attribute_hidden __setnetent(int f)
UNLOCK;
return;
}
-strong_alias(__setnetent,setnetent)
+libc_hidden_def(setnetent)
-void attribute_hidden __endnetent(void)
+libc_hidden_proto(endnetent)
+void endnetent(void)
{
LOCK;
if (netf) {
@@ -68,7 +72,7 @@ void attribute_hidden __endnetent(void)
_net_stayopen = 0;
UNLOCK;
}
-strong_alias(__endnetent,endnetent)
+libc_hidden_def(endnetent)
static char * any(register char *cp, char *match)
{
@@ -83,7 +87,8 @@ static char * any(register char *cp, char *match)
return ((char *)0);
}
-struct netent attribute_hidden * __getnetent(void)
+libc_hidden_proto(getnetent)
+struct netent *getnetent(void)
{
char *p;
register char *cp, **q;
@@ -142,4 +147,4 @@ again:
UNLOCK;
return (&net);
}
-strong_alias(__getnetent,getnetent)
+libc_hidden_def(getnetent)
diff --git a/libc/inet/getpeername.c b/libc/inet/getpeername.c
new file mode 100644
index 000000000..74825a7b2
--- /dev/null
+++ b/libc/inet/getpeername.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_getpeername
+#include "socketcalls.c"
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index 008b0d606..a54532ede 100644
--- a/libc/inet/getproto.c
+++ b/libc/inet/getproto.c
@@ -51,13 +51,7 @@
** SUCH DAMAGE.
*/
-#define strpbrk __strpbrk
-#define atoi __atoi
-#define rewind __rewind
-#define fgets __fgets
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -67,6 +61,14 @@
#include <string.h>
#include <errno.h>
+libc_hidden_proto(fopen)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strpbrk)
+libc_hidden_proto(atoi)
+libc_hidden_proto(rewind)
+libc_hidden_proto(fgets)
+libc_hidden_proto(fclose)
+libc_hidden_proto(abort)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -94,7 +96,8 @@ static void __initbuf(void)
}
}
-void attribute_hidden __setprotoent(int f)
+libc_hidden_proto(setprotoent)
+void setprotoent(int f)
{
LOCK;
if (protof == NULL)
@@ -104,9 +107,10 @@ void attribute_hidden __setprotoent(int f)
proto_stayopen |= f;
UNLOCK;
}
-strong_alias(__setprotoent,setprotoent)
+libc_hidden_def(setprotoent)
-void attribute_hidden __endprotoent(void)
+libc_hidden_proto(endprotoent)
+void endprotoent(void)
{
LOCK;
if (protof) {
@@ -116,9 +120,10 @@ void attribute_hidden __endprotoent(void)
proto_stayopen = 0;
UNLOCK;
}
-strong_alias(__endprotoent,endprotoent)
+libc_hidden_def(endprotoent)
-int attribute_hidden __getprotoent_r(struct protoent *result_buf,
+libc_hidden_proto(getprotoent_r)
+int getprotoent_r(struct protoent *result_buf,
char *buf, size_t buflen,
struct protoent **result)
{
@@ -194,19 +199,20 @@ again:
UNLOCK;
return 0;
}
-strong_alias(__getprotoent_r,getprotoent_r)
+libc_hidden_def(getprotoent_r)
struct protoent * getprotoent(void)
{
struct protoent *result;
__initbuf();
- __getprotoent_r(&proto, static_aliases, SBUFSIZE, &result);
+ getprotoent_r(&proto, static_aliases, SBUFSIZE, &result);
return result;
}
-int attribute_hidden __getprotobyname_r(const char *name,
+libc_hidden_proto(getprotobyname_r)
+int getprotobyname_r(const char *name,
struct protoent *result_buf,
char *buf, size_t buflen,
struct protoent **result)
@@ -215,21 +221,21 @@ int attribute_hidden __getprotobyname_r(const char *name,
int ret;
LOCK;
- __setprotoent(proto_stayopen);
- while (!(ret=__getprotoent_r(result_buf, buf, buflen, result))) {
- if (__strcmp(result_buf->p_name, name) == 0)
+ setprotoent(proto_stayopen);
+ while (!(ret=getprotoent_r(result_buf, buf, buflen, result))) {
+ 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:
if (!proto_stayopen)
- __endprotoent();
+ endprotoent();
UNLOCK;
return *result?0:ret;
}
-strong_alias(__getprotobyname_r,getprotobyname_r)
+libc_hidden_def(getprotobyname_r)
struct protoent * getprotobyname(const char *name)
@@ -237,12 +243,13 @@ struct protoent * getprotobyname(const char *name)
struct protoent *result;
__initbuf();
- __getprotobyname_r(name, &proto, static_aliases, SBUFSIZE, &result);
+ getprotobyname_r(name, &proto, static_aliases, SBUFSIZE, &result);
return result;
}
-int attribute_hidden __getprotobynumber_r (int proto_num,
+libc_hidden_proto(getprotobynumber_r)
+int getprotobynumber_r (int proto_num,
struct protoent *result_buf,
char *buf, size_t buflen,
struct protoent **result)
@@ -250,23 +257,23 @@ int attribute_hidden __getprotobynumber_r (int proto_num,
int ret;
LOCK;
- __setprotoent(proto_stayopen);
- while (!(ret=__getprotoent_r(result_buf, buf, buflen, result)))
+ setprotoent(proto_stayopen);
+ while (!(ret=getprotoent_r(result_buf, buf, buflen, result)))
if (result_buf->p_proto == proto_num)
break;
if (!proto_stayopen)
- __endprotoent();
+ endprotoent();
UNLOCK;
return *result?0:ret;
}
-strong_alias(__getprotobynumber_r,getprotobynumber_r)
+libc_hidden_def(getprotobynumber_r)
struct protoent * getprotobynumber(int proto_num)
{
struct protoent *result;
__initbuf();
- __getprotobynumber_r(proto_num, &proto, static_aliases,
+ getprotobynumber_r(proto_num, &proto, static_aliases,
SBUFSIZE, &result);
return result;
}
diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c
index f3916de86..7f4939bbd 100644
--- a/libc/inet/getservice.c
+++ b/libc/inet/getservice.c
@@ -51,13 +51,7 @@
** SUCH DAMAGE.
*/
-#define strpbrk __strpbrk
-#define atoi __atoi
-#define rewind __rewind
-#define fgets __fgets
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -69,6 +63,14 @@
#include <arpa/inet.h>
#include <errno.h>
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strpbrk)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(atoi)
+libc_hidden_proto(rewind)
+libc_hidden_proto(fgets)
+libc_hidden_proto(abort)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -97,7 +99,8 @@ static void __initbuf(void)
}
}
-extern void attribute_hidden __setservent(int f)
+libc_hidden_proto(setservent)
+void setservent(int f)
{
LOCK;
if (servf == NULL)
@@ -107,9 +110,10 @@ extern void attribute_hidden __setservent(int f)
serv_stayopen |= f;
UNLOCK;
}
-strong_alias(__setservent,setservent)
+libc_hidden_def(setservent)
-extern void attribute_hidden __endservent(void)
+libc_hidden_proto(endservent)
+void endservent(void)
{
LOCK;
if (servf) {
@@ -119,9 +123,10 @@ extern void attribute_hidden __endservent(void)
serv_stayopen = 0;
UNLOCK;
}
-strong_alias(__endservent,endservent)
+libc_hidden_def(endservent)
-extern int attribute_hidden __getservent_r(struct servent * result_buf,
+libc_hidden_proto(getservent_r)
+int getservent_r(struct servent * result_buf,
char * buf, size_t buflen,
struct servent ** result)
{
@@ -200,18 +205,19 @@ again:
UNLOCK;
return 0;
}
-strong_alias(__getservent_r,getservent_r)
+libc_hidden_def(getservent_r)
struct servent * getservent(void)
{
struct servent *result;
__initbuf();
- __getservent_r(&serv, servbuf, SBUFSIZE, &result);
+ getservent_r(&serv, servbuf, SBUFSIZE, &result);
return result;
}
-extern int attribute_hidden __getservbyname_r(const char *name, const char *proto,
+libc_hidden_proto(getservbyname_r)
+int getservbyname_r(const char *name, const char *proto,
struct servent * result_buf, char * buf, size_t buflen,
struct servent ** result)
{
@@ -219,62 +225,64 @@ extern int attribute_hidden __getservbyname_r(const char *name, const char *prot
int ret;
LOCK;
- __setservent(serv_stayopen);
- while (!(ret=__getservent_r(result_buf, buf, buflen, result))) {
- if (__strcmp(name, result_buf->s_name) == 0)
+ setservent(serv_stayopen);
+ while (!(ret=getservent_r(result_buf, buf, buflen, result))) {
+ 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)
- __endservent();
+ endservent();
UNLOCK;
return *result?0:ret;
}
-strong_alias(__getservbyname_r,getservbyname_r)
+libc_hidden_def(getservbyname_r)
struct servent *getservbyname(const char *name, const char *proto)
{
struct servent *result;
__initbuf();
- __getservbyname_r(name, proto, &serv, servbuf, SBUFSIZE, &result);
+ getservbyname_r(name, proto, &serv, servbuf, SBUFSIZE, &result);
return result;
}
-extern int attribute_hidden __getservbyport_r(int port, const char *proto,
+libc_hidden_proto(getservbyport_r)
+int getservbyport_r(int port, const char *proto,
struct servent * result_buf, char * buf,
size_t buflen, struct servent ** result)
{
int ret;
LOCK;
- __setservent(serv_stayopen);
- while (!(ret=__getservent_r(result_buf, buf, buflen, result))) {
+ setservent(serv_stayopen);
+ 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)
- __endservent();
+ endservent();
UNLOCK;
return *result?0:ret;
}
-strong_alias(__getservbyport_r,getservbyport_r)
+libc_hidden_def(getservbyport_r)
-struct servent attribute_hidden * __getservbyport(int port, const char *proto)
+libc_hidden_proto(getservbyport)
+struct servent * getservbyport(int port, const char *proto)
{
struct servent *result;
__initbuf();
- __getservbyport_r(port, proto, &serv, servbuf, SBUFSIZE, &result);
+ getservbyport_r(port, proto, &serv, servbuf, SBUFSIZE, &result);
return result;
}
-strong_alias(__getservbyport,getservbyport)
+libc_hidden_def(getservbyport)
diff --git a/libc/inet/getsockname.c b/libc/inet/getsockname.c
new file mode 100644
index 000000000..4a4d6a135
--- /dev/null
+++ b/libc/inet/getsockname.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_getsockname
+#include "socketcalls.c"
diff --git a/libc/inet/getsockopt.c b/libc/inet/getsockopt.c
new file mode 100644
index 000000000..48f72e999
--- /dev/null
+++ b/libc/inet/getsockopt.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_getsockopt
+#include "socketcalls.c"
diff --git a/libc/inet/herror.c b/libc/inet/herror.c
index 2f0797b91..66626c0a8 100644
--- a/libc/inet/herror.c
+++ b/libc/inet/herror.c
@@ -23,6 +23,10 @@
#include <string.h>
#include <netdb.h>
+libc_hidden_proto(fprintf)
+libc_hidden_proto(__h_errno_location)
+libc_hidden_proto(stderr)
+
static const char *error_msg = "Resolver error";
static const char *const h_errlist[] = {
"Error 0",
@@ -36,7 +40,8 @@ static const int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
/*
* herror -- print the error indicated by the h_errno value.
*/
-void attribute_hidden __herror(const char *s)
+libc_hidden_proto(herror)
+void herror(const char *s)
{
static const char colon_space[] = ": ";
const char *p;
@@ -52,7 +57,7 @@ void attribute_hidden __herror(const char *s)
}
fprintf(stderr, "%s%s%s\n", s, c, p);
}
-strong_alias(__herror,herror)
+libc_hidden_def(herror)
const char *hstrerror(int err)
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index bc9576e74..48dc55732 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -1,7 +1,8 @@
-#define geteuid __geteuid
-#define getuid __getuid
-#define gethostbyname __gethostbyname
-#define gethostname __gethostname
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#define __FORCE_GLIBC
#include <features.h>
@@ -13,7 +14,19 @@
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <not-cancel.h>
+#endif
+libc_hidden_proto(memcpy)
+libc_hidden_proto(open)
+libc_hidden_proto(close)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(getuid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(gethostbyname)
+libc_hidden_proto(gethostname)
#define HOSTID "/etc/hostid"
@@ -23,28 +36,45 @@ 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)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if ((fd=open_not_cancel(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1;
+ ret = write_not_cancel(fd,(void *)&new_id,sizeof(new_id)) ==
+ sizeof(new_id) ? 0 : -1;
+ close_not_cancel_no_status (fd);
+#else
+ 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);
+#endif
return ret;
}
long int gethostid(void)
{
- char host[MAXHOSTNAMELEN + 1];
+ char host[MAXHOSTNAMELEN + 1];
int fd, id;
/* If hostid was already set the we can return that value.
* 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)))
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if ((fd =open_not_cancel_2 (HOSTID, O_RDONLY)) >= 0 &&
+ read_not_cancel (fd, (void *) &id, sizeof (id)))
{
- __close (fd);
+ close_not_cancel_no_status (fd);
return id;
}
- if (fd >= 0) __close (fd);
+ if (fd >= 0) close_not_cancel_no_status (fd);
+#else
+ if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,(void *)&id,sizeof(id)))
+ {
+ close (fd);
+ return id;
+ }
+ if (fd >= 0) close (fd);
+#endif
/* Try some methods of returning a unique 32 bit id. Clearly IP
* numbers, if on the internet, will have a unique address. If they
@@ -70,7 +100,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_index.c b/libc/inet/if_index.c
index 40e46d538..239ed6416 100644
--- a/libc/inet/if_index.c
+++ b/libc/inet/if_index.c
@@ -20,11 +20,8 @@
Reworked Dec 2002 by Erik Andersen <andersen@codepoet.org>
*/
-#define strndup __strndup
-
#define __FORCE_GLIBC
#include <features.h>
-#define __USE_GNU
#include <string.h>
#include <alloca.h>
#include <errno.h>
@@ -35,11 +32,21 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <libc-internal.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <not-cancel.h>
+#endif
#include "netlinkaccess.h"
+libc_hidden_proto(strndup)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(strdup)
+libc_hidden_proto(ioctl)
+libc_hidden_proto(close)
+
extern int __opensock(void) attribute_hidden;
+libc_hidden_proto(if_nametoindex)
unsigned int
if_nametoindex(const char* ifname)
{
@@ -53,22 +60,31 @@ if_nametoindex(const char* ifname)
if (fd < 0)
return 0;
- __strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
+ strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
+ if (ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
int saved_errno = errno;
- __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(fd);
+#else
+ close(fd);
+#endif
if (saved_errno == EINVAL)
__set_errno(ENOSYS);
return 0;
}
- __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(fd);
+#else
+ close(fd);
+#endif
return ifr.ifr_ifindex;
#endif
}
-hidden_strong_alias(if_nametoindex,__if_nametoindex)
+libc_hidden_def(if_nametoindex)
+libc_hidden_proto(if_freenameindex)
void
if_freenameindex (struct if_nameindex *ifn)
{
@@ -80,8 +96,9 @@ if_freenameindex (struct if_nameindex *ifn)
}
free (ifn);
}
-hidden_strong_alias(if_freenameindex,__if_freenameindex)
+libc_hidden_def(if_freenameindex)
+libc_hidden_proto(if_nameindex)
#if !__ASSUME_NETLINK_SUPPORT
struct if_nameindex *
if_nameindex (void)
@@ -112,9 +129,13 @@ if_nameindex (void)
ifc.ifc_buf = extend_alloca (ifc.ifc_buf, rq_len, 2 * rq_len);
ifc.ifc_len = rq_len;
- if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0)
+ if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
{
- __close (fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close (fd);
+#endif
return NULL;
}
}
@@ -125,7 +146,11 @@ if_nameindex (void)
idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));
if (idx == NULL)
{
- __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close(fd);
+#endif
__set_errno(ENOBUFS);
return NULL;
}
@@ -133,9 +158,9 @@ if_nameindex (void)
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)
+ || ioctl (fd, SIOCGIFINDEX, ifr) < 0)
{
int saved_errno = errno;
unsigned int j;
@@ -143,7 +168,11 @@ if_nameindex (void)
for (j = 0; j < i; ++j)
free (idx[j].if_name);
free(idx);
- __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close(fd);
+#endif
if (saved_errno == EINVAL)
saved_errno = ENOSYS;
else if (saved_errno == ENOMEM)
@@ -157,7 +186,11 @@ if_nameindex (void)
idx[i].if_index = 0;
idx[i].if_name = NULL;
- __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close(fd);
+#endif
return idx;
#endif
}
@@ -248,11 +281,11 @@ if_nameindex (void)
if (rta->rta_type == IFLA_IFNAME)
{
- idx[nifs].if_name = __strndup (rta_data, rta_payload);
+ idx[nifs].if_name = strndup (rta_data, rta_payload);
if (idx[nifs].if_name == NULL)
{
idx[nifs].if_index = 0;
- __if_freenameindex (idx);
+ if_freenameindex (idx);
idx = NULL;
goto nomem;
}
@@ -277,7 +310,7 @@ if_nameindex (void)
return idx;
}
#endif
-hidden_strong_alias(if_nameindex,__if_nameindex)
+libc_hidden_def(if_nameindex)
#if 0
struct if_nameindex *
@@ -305,36 +338,44 @@ if_indextoname (unsigned int ifindex, char *ifname)
return NULL;
ifr.ifr_ifindex = ifindex;
- if (__ioctl (fd, SIOCGIFNAME, &ifr) < 0)
+ if (ioctl (fd, SIOCGIFNAME, &ifr) < 0)
{
int serrno = errno;
- __close (fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close (fd);
+#endif
if (serrno == ENODEV)
/* POSIX requires ENXIO. */
serrno = ENXIO;
__set_errno (serrno);
return NULL;
}
- __close (fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status (fd);
+#else
+ close (fd);
+#endif
- return __strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+ return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
# else
struct if_nameindex *idx;
struct if_nameindex *p;
char *result = NULL;
- idx = __if_nameindex();
+ idx = if_nameindex();
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;
}
- __if_freenameindex (idx);
+ if_freenameindex (idx);
if (result == NULL)
__set_errno (ENXIO);
diff --git a/libc/inet/ifaddrs.c b/libc/inet/ifaddrs.c
index 74f3622f8..b9f3cbd0e 100644
--- a/libc/inet/ifaddrs.c
+++ b/libc/inet/ifaddrs.c
@@ -17,16 +17,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define time __time
-#define sendto __sendto
-#define recvmsg __recvmsg
-#define bind __bind
-#define mempcpy __mempcpy
-#define getsockname __getsockname
-
#define __FORCE_GLIBC
#include <features.h>
-#define __USE_GNU
#include <alloca.h>
#include <assert.h>
#include <errno.h>
@@ -37,6 +29,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -46,6 +39,17 @@
#include "netlinkaccess.h"
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(time)
+libc_hidden_proto(sendto)
+libc_hidden_proto(recvmsg)
+libc_hidden_proto(bind)
+libc_hidden_proto(memset)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(getsockname)
+libc_hidden_proto(fclose)
+libc_hidden_proto(abort)
#ifndef __libc_use_alloca
# define __libc_use_alloca(x) (x < __MAX_ALLOCA_CUTOFF)
@@ -116,7 +120,7 @@ __netlink_sendreq (struct netlink_handle *h, int type)
memset (&nladdr, '\0', sizeof (nladdr));
nladdr.nl_family = AF_NETLINK;
- return TEMP_FAILURE_RETRY (__sendto (h->fd, (void *) &req, sizeof (req), 0,
+ return TEMP_FAILURE_RETRY (sendto (h->fd, (void *) &req, sizeof (req), 0,
(struct sockaddr *) &nladdr,
sizeof (nladdr)));
}
@@ -167,7 +171,7 @@ __netlink_request (struct netlink_handle *h, int type)
0
};
- read_len = TEMP_FAILURE_RETRY (__recvmsg (h->fd, &msg, 0));
+ read_len = TEMP_FAILURE_RETRY (recvmsg (h->fd, &msg, 0));
if (read_len < 0)
goto out_fail;
@@ -282,7 +286,7 @@ __netlink_close (struct netlink_handle *h)
{
/* Don't modify errno. */
int serrno = errno;
- __close(h->fd);
+ close(h->fd);
__set_errno(serrno);
}
@@ -293,13 +297,13 @@ __netlink_open (struct netlink_handle *h)
{
struct sockaddr_nl nladdr;
- h->fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ h->fd = socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (h->fd < 0)
goto out;
memset (&nladdr, '\0', sizeof (nladdr));
nladdr.nl_family = AF_NETLINK;
- if (__bind (h->fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) < 0)
+ if (bind (h->fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) < 0)
{
close_and_out:
__netlink_close (h);
@@ -313,7 +317,7 @@ __netlink_open (struct netlink_handle *h)
It is not necessarily the PID if there is more than one socket
open. */
socklen_t addr_len = sizeof (nladdr);
- if (__getsockname (h->fd, (struct sockaddr *) &nladdr, &addr_len) < 0)
+ if (getsockname (h->fd, (struct sockaddr *) &nladdr, &addr_len) < 0)
goto close_and_out;
h->pid = nladdr.nl_pid;
return 0;
diff --git a/libc/inet/in6_addr.c b/libc/inet/in6_addr.c
index 7e52d2e39..c2ab375e6 100644
--- a/libc/inet/in6_addr.c
+++ b/libc/inet/in6_addr.c
@@ -22,12 +22,12 @@
#include <netinet/in.h>
#ifdef __UCLIBC_HAS_IPV6__
-const struct in6_addr __in6addr_any =
+const struct in6_addr in6addr_any =
{ { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
-weak_alias (__in6addr_any, in6addr_any)
-const struct in6_addr __in6addr_loopback =
+libc_hidden_proto(in6addr_loopback)
+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)
+libc_hidden_data_def(in6addr_loopback)
#endif /* __UCLIBC_HAS_IPV6__ */
diff --git a/libc/inet/inet_addr.c b/libc/inet/inet_addr.c
new file mode 100644
index 000000000..445f850a1
--- /dev/null
+++ b/libc/inet/inet_addr.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_makeaddr
+#include "addr.c"
diff --git a/libc/inet/inet_aton.c b/libc/inet/inet_aton.c
new file mode 100644
index 000000000..d79ba07b0
--- /dev/null
+++ b/libc/inet/inet_aton.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_aton
+#include "addr.c"
diff --git a/libc/inet/inet_lnaof.c b/libc/inet/inet_lnaof.c
new file mode 100644
index 000000000..9887a4342
--- /dev/null
+++ b/libc/inet/inet_lnaof.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_lnaof
+#include "addr.c"
diff --git a/libc/inet/inet_makeaddr.c b/libc/inet/inet_makeaddr.c
new file mode 100644
index 000000000..9f946967c
--- /dev/null
+++ b/libc/inet/inet_makeaddr.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_addr
+#include "addr.c"
diff --git a/libc/inet/inet_net.c b/libc/inet/inet_net.c
index a7d1844a7..64c6c3e84 100644
--- a/libc/inet/inet_net.c
+++ b/libc/inet/inet_net.c
@@ -36,14 +36,21 @@
#include <features.h>
#include <ctype.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
/*
* Internet network address interpretation routine.
* The library routines call this routine to interpret
* network numbers.
*/
-in_addr_t attribute_hidden
-__inet_network(const char *cp)
+libc_hidden_proto(inet_network)
+in_addr_t
+inet_network(const char *cp)
{
register in_addr_t val, base, n;
register char c;
@@ -98,4 +105,4 @@ again:
}
return (val);
}
-strong_alias(__inet_network,inet_network)
+libc_hidden_def(inet_network)
diff --git a/libc/inet/inet_netof.c b/libc/inet/inet_netof.c
new file mode 100644
index 000000000..045c120c9
--- /dev/null
+++ b/libc/inet/inet_netof.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_netof
+#include "addr.c"
diff --git a/libc/inet/inet_ntoa.c b/libc/inet/inet_ntoa.c
new file mode 100644
index 000000000..83ed13803
--- /dev/null
+++ b/libc/inet/inet_ntoa.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_inet_ntoa
+#include "addr.c"
diff --git a/libc/inet/lengthd.c b/libc/inet/lengthd.c
new file mode 100644
index 000000000..07c7fc6f1
--- /dev/null
+++ b/libc/inet/lengthd.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_lengthd
+#include "resolv.c"
diff --git a/libc/inet/lengthq.c b/libc/inet/lengthq.c
new file mode 100644
index 000000000..e62e6f25a
--- /dev/null
+++ b/libc/inet/lengthq.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_lengthq
+#include "resolv.c"
diff --git a/libc/inet/listen.c b/libc/inet/listen.c
new file mode 100644
index 000000000..32e347895
--- /dev/null
+++ b/libc/inet/listen.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_listen
+#include "socketcalls.c"
diff --git a/libc/inet/netlinkaccess.h b/libc/inet/netlinkaccess.h
index 715a896e3..a47d8901c 100644
--- a/libc/inet/netlinkaccess.h
+++ b/libc/inet/netlinkaccess.h
@@ -21,9 +21,16 @@
#include <features.h>
#include <stdint.h>
-#include <linux/types.h>
-#include <linux/netlink.h>
+#include <sys/types.h>
+
+#define _LINUX_TYPES_H
+typedef uint8_t __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
+typedef uint64_t __u64;
+typedef int32_t __s32;
#include <linux/rtnetlink.h>
+#include <linux/netlink.h>
/* Should prob be a configure option or something */
#ifdef __UCLIBC_USE_NETLINK__
diff --git a/libc/inet/ns_name.c b/libc/inet/ns_name.c
new file mode 100644
index 000000000..158a1a331
--- /dev/null
+++ b/libc/inet/ns_name.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ns_name
+#include "resolv.c"
diff --git a/libc/inet/ntohl.c b/libc/inet/ntohl.c
index 4fbdf7096..87a034bf0 100644
--- a/libc/inet/ntohl.c
+++ b/libc/inet/ntohl.c
@@ -22,43 +22,48 @@
#include <endian.h>
#include <byteswap.h>
+uint32_t ntohl (uint32_t x);
+uint16_t ntohs (uint16_t x);
+uint32_t htonl (uint32_t x);
+uint16_t htons (uint16_t x);
+
#if __BYTE_ORDER == __BIG_ENDIAN
-extern uint32_t ntohl (uint32_t x)
+uint32_t ntohl (uint32_t x)
{
return x;
}
-extern uint16_t ntohs (uint16_t x)
+uint16_t ntohs (uint16_t x)
{
return x;
}
-extern uint32_t htonl (uint32_t x)
+uint32_t htonl (uint32_t x)
{
return x;
}
-extern uint16_t htons (uint16_t x)
+uint16_t htons (uint16_t x)
{
return x;
}
#elif __BYTE_ORDER == __LITTLE_ENDIAN
-extern uint32_t ntohl (uint32_t x)
+uint32_t ntohl (uint32_t x)
{
return __bswap_32(x);
}
-extern uint16_t ntohs (uint16_t x)
+uint16_t ntohs (uint16_t x)
{
return __bswap_16(x);
}
-extern uint32_t htonl (uint32_t x)
+uint32_t htonl (uint32_t x)
{
return __bswap_32(x);
}
-extern uint16_t htons (uint16_t x)
+uint16_t htons (uint16_t x)
{
return __bswap_16(x);
}
diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c
index 6f3a8ccec..88ff6a150 100644
--- a/libc/inet/ntop.c
+++ b/libc/inet/ntop.c
@@ -30,6 +30,13 @@
#include <string.h>
#include <ctype.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(tolower)
/*
* WARNING: Don't even consider trying to compile this on a system where
@@ -76,12 +83,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 +121,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,10 +167,10 @@ 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]);
+ tp += sprintf(tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == 8)
@@ -177,7 +184,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 +231,7 @@ inet_pton4(const char *src, u_char *dst)
}
if (octets < 4)
return (0);
- __memcpy(dst, tmp, 4);
+ memcpy(dst, tmp, 4);
return (1);
}
@@ -249,7 +256,7 @@ inet_pton4(const char *src, u_char *dst)
* 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)
@@ -261,7 +268,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. */
@@ -271,10 +278,10 @@ 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);
+ pch = strchr(xdigits, ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
@@ -333,7 +340,7 @@ inet_pton6(const char *src, u_char *dst)
}
if (tp != endp)
return (0);
- __memcpy(dst, tmp, 16);
+ memcpy(dst, tmp, 16);
return (1);
}
@@ -349,8 +356,9 @@ inet_pton6(const char *src, u_char *dst)
* author:
* Paul Vixie, 1996.
*/
-const char attribute_hidden *
-__inet_ntop(int af, const void *src, char *dst, socklen_t size)
+libc_hidden_proto(inet_ntop)
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
case AF_INET:
@@ -365,7 +373,7 @@ __inet_ntop(int af, const void *src, char *dst, socklen_t size)
}
/* NOTREACHED */
}
-strong_alias(__inet_ntop,inet_ntop)
+libc_hidden_def(inet_ntop)
/* int
@@ -379,8 +387,9 @@ strong_alias(__inet_ntop,inet_ntop)
* author:
* Paul Vixie, 1996.
*/
-int attribute_hidden
-__inet_pton(int af, const char *src, void *dst)
+libc_hidden_proto(inet_pton)
+int
+inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
@@ -395,4 +404,4 @@ __inet_pton(int af, const char *src, void *dst)
}
/* NOTREACHED */
}
-strong_alias(__inet_pton,inet_pton)
+libc_hidden_def(inet_pton)
diff --git a/libc/inet/opennameservers.c b/libc/inet/opennameservers.c
new file mode 100644
index 000000000..effd10800
--- /dev/null
+++ b/libc/inet/opennameservers.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_opennameservers
+#include "resolv.c"
diff --git a/libc/inet/opensock.c b/libc/inet/opensock.c
index a27141a16..a2c09dcf5 100644
--- a/libc/inet/opensock.c
+++ b/libc/inet/opensock.c
@@ -25,16 +25,19 @@
#include <features.h>
#include <libc-internal.h>
+libc_hidden_proto(socket)
+
/* Return a socket of any type. The socket can be used in subsequent
ioctl calls to talk to the kernel. */
-int attribute_hidden
+int __opensock(void) attribute_hidden;
+int
__opensock (void)
{
int fd;
#ifdef __UCLIBC_HAS_IPV6__
- fd = __socket(AF_INET6, SOCK_DGRAM, 0);
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
if (fd<0)
#endif /* __UCLIBC_HAS_IPV6__ */
- fd = __socket(AF_INET, SOCK_DGRAM, 0);
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
return(fd);
}
diff --git a/libc/inet/read_etc_hosts_r.c b/libc/inet/read_etc_hosts_r.c
new file mode 100644
index 000000000..6504e541f
--- /dev/null
+++ b/libc/inet/read_etc_hosts_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_read_etc_hosts_r
+#include "resolv.c"
diff --git a/libc/inet/recv.c b/libc/inet/recv.c
new file mode 100644
index 000000000..1c77ce323
--- /dev/null
+++ b/libc/inet/recv.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_recv
+#include "socketcalls.c"
diff --git a/libc/inet/recvfrom.c b/libc/inet/recvfrom.c
new file mode 100644
index 000000000..ec683f6c8
--- /dev/null
+++ b/libc/inet/recvfrom.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_recvfrom
+#include "socketcalls.c"
diff --git a/libc/inet/recvmsg.c b/libc/inet/recvmsg.c
new file mode 100644
index 000000000..db51d8b03
--- /dev/null
+++ b/libc/inet/recvmsg.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_recvmsg
+#include "socketcalls.c"
diff --git a/libc/inet/res_comp.c b/libc/inet/res_comp.c
new file mode 100644
index 000000000..8aee6b17c
--- /dev/null
+++ b/libc/inet/res_comp.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_res_comp
+#include "resolv.c"
diff --git a/libc/inet/res_init.c b/libc/inet/res_init.c
new file mode 100644
index 000000000..09caf4927
--- /dev/null
+++ b/libc/inet/res_init.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_res_init
+#include "resolv.c"
diff --git a/libc/inet/res_query.c b/libc/inet/res_query.c
new file mode 100644
index 000000000..c662510e6
--- /dev/null
+++ b/libc/inet/res_query.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_res_query
+#include "resolv.c"
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 28ebfd88b..edd06b9e9 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -133,24 +133,6 @@
*
*/
-#define strnlen __strnlen
-#define strncat __strncat
-#define strstr __strstr
-#define random __random
-#define getservbyport __getservbyport
-#define getdomainname __getdomainname
-#define uname __uname
-#define inet_addr __inet_addr
-#define inet_aton __inet_aton
-#define inet_pton __inet_pton
-#define inet_ntop __inet_ntop
-#define connect __connect
-#define select __select
-#define recv __recv
-#define send __send
-#define snprintf __snprintf
-#define fgets __fgets
-
#define __FORCE_GLIBC
#include <features.h>
#include <string.h>
@@ -171,14 +153,59 @@
#include <sys/utsname.h>
#include <sys/un.h>
-extern int __gethostbyname_r (__const char *__restrict __name,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop) attribute_hidden;
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(memmove)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strdup)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncat)
+libc_hidden_proto(strncpy)
+/* libc_hidden_proto(strnlen) */
+libc_hidden_proto(strstr)
+libc_hidden_proto(strcasecmp)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(random)
+libc_hidden_proto(getservbyport)
+libc_hidden_proto(getdomainname)
+libc_hidden_proto(uname)
+libc_hidden_proto(inet_addr)
+libc_hidden_proto(inet_aton)
+libc_hidden_proto(inet_pton)
+libc_hidden_proto(inet_ntop)
+libc_hidden_proto(connect)
+libc_hidden_proto(select)
+libc_hidden_proto(recv)
+libc_hidden_proto(send)
+libc_hidden_proto(printf)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(snprintf)
+libc_hidden_proto(fgets)
+libc_hidden_proto(gethostbyname)
+libc_hidden_proto(gethostbyname_r)
+libc_hidden_proto(gethostbyname2_r)
+libc_hidden_proto(gethostbyaddr)
+libc_hidden_proto(gethostbyaddr_r)
+libc_hidden_proto(ns_name_uncompress)
+libc_hidden_proto(ns_name_unpack)
+libc_hidden_proto(ns_name_ntop)
+libc_hidden_proto(res_init)
+libc_hidden_proto(res_query)
+libc_hidden_proto(res_querydomain)
+libc_hidden_proto(gethostent_r)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(__h_errno_location)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
-extern struct hostent *__gethostbyaddr (__const void *__addr, __socklen_t __len,
- int __type) attribute_hidden;
#define MAX_RECURSE 5
#define REPLY_TIMEOUT 10
#define MAX_RETRIES 3
@@ -201,15 +228,16 @@ extern struct hostent *__gethostbyaddr (__const void *__addr, __socklen_t __len,
/* Global stuff (stuff needing to be locked to be thread safe)... */
-extern int __nameservers;
-extern char * __nameserver[MAX_SERVERS];
-extern int __searchdomains;
-extern char * __searchdomain[MAX_SEARCH];
+extern int __nameservers attribute_hidden;
+extern char * __nameserver[MAX_SERVERS] attribute_hidden;
+extern int __searchdomains attribute_hidden;
+extern char * __searchdomain[MAX_SEARCH] attribute_hidden;
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
extern pthread_mutex_t __resolv_lock;
+libc_hidden_proto(__resolv_lock)
#endif
#define BIGLOCK __pthread_mutex_lock(&__resolv_lock)
#define BIGUNLOCK __pthread_mutex_unlock(&__resolv_lock)
@@ -281,7 +309,7 @@ extern int __decode_header(unsigned char * data, struct resolv_header * h) attri
extern int __encode_question(struct resolv_question * q,
unsigned char * dest, int maxlen) attribute_hidden;
extern int __decode_question(unsigned char * message, int offset,
- struct resolv_question * q);
+ struct resolv_question * q) attribute_hidden;
extern int __encode_answer(struct resolv_answer * a,
unsigned char * dest, int maxlen) attribute_hidden;
extern int __decode_answer(unsigned char * message, int offset,
@@ -291,17 +319,6 @@ 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_internal(const u_char *, const u_char *,
- const u_char *, char *, size_t) attribute_hidden;
-extern int __ns_name_ntop_internal(const u_char *, char *, size_t) attribute_hidden;
-extern int __ns_name_unpack_internal(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 attribute_hidden __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen)
@@ -360,14 +377,14 @@ int attribute_hidden __encode_dotted(const char *dotted, unsigned char *dest, in
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)
@@ -415,7 +432,7 @@ int attribute_hidden __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)
@@ -439,7 +456,6 @@ int attribute_hidden __decode_dotted(const unsigned char *data, int offset,
#endif
#ifdef L_lengthd
-
int attribute_hidden __length_dotted(const unsigned char *data, int offset)
{
int orig_offset = offset;
@@ -488,7 +504,7 @@ int attribute_hidden __encode_question(struct resolv_question *q,
#endif
#ifdef L_decodeq
-int __decode_question(unsigned char *message, int offset,
+int attribute_hidden __decode_question(unsigned char *message, int offset,
struct resolv_question *q)
{
char temp[256];
@@ -500,7 +516,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];
@@ -546,7 +562,7 @@ int attribute_hidden __encode_answer(struct resolv_answer *a, unsigned char *des
*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;
}
@@ -565,7 +581,7 @@ int attribute_hidden __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];
@@ -590,6 +606,12 @@ int __encode_packet(struct resolv_header *h,
struct resolv_answer **an,
struct resolv_answer **ns,
struct resolv_answer **ar,
+ unsigned char *dest, int maxlen) attribute_hidden;
+int __encode_packet(struct resolv_header *h,
+ struct resolv_question **q,
+ struct resolv_answer **an,
+ struct resolv_answer **ns,
+ struct resolv_answer **ar,
unsigned char *dest, int maxlen)
{
int i, total = 0;
@@ -642,6 +664,7 @@ int __encode_packet(struct resolv_header *h,
#endif
#ifdef L_decodep
+int __decode_packet(unsigned char *data, struct resolv_header *h) attribute_hidden;
int __decode_packet(unsigned char *data, struct resolv_header *h)
{
return __decode_header(data, h);
@@ -649,6 +672,7 @@ int __decode_packet(unsigned char *data, struct resolv_header *h)
#endif
#ifdef L_formquery
+int __form_query(int id, const char *name, int type, unsigned char *packet, int maxlen);
int __form_query(int id, const char *name, int type, unsigned char *packet,
int maxlen)
{
@@ -656,7 +680,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;
@@ -729,11 +753,11 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
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;
@@ -749,7 +773,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
if (i < 0)
goto fail;
- __strncpy(lookup,name,MAXDNAME);
+ strncpy(lookup,name,MAXDNAME);
if (variant >= 0) {
BIGLOCK;
if (variant < __searchdomains) {
@@ -774,9 +798,9 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
#ifdef __UCLIBC_HAS_IPV6__
v6 = inet_pton(AF_INET6, dns, &sa6.sin6_addr) > 0;
- fd = __socket(v6 ? AF_INET6 : AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(v6 ? AF_INET6 : AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#else
- fd = __socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#endif
if (fd < 0) {
retries++;
@@ -880,7 +904,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
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;
@@ -912,7 +936,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
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;
}
}
@@ -920,7 +944,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
DPRINTF("Answer name = |%s|\n", a->dotted);
DPRINTF("Answer type = |%d|\n", a->atype);
- __close(fd);
+ close(fd);
if (outpacket)
*outpacket = packet;
@@ -972,7 +996,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
fail:
if (fd != -1)
- __close(fd);
+ close(fd);
if (lookup)
free(lookup);
if (packet)
@@ -998,6 +1022,7 @@ char * __searchdomain[MAX_SEARCH];
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
pthread_mutex_t __resolv_lock = PTHREAD_MUTEX_INITIALIZER;
+libc_hidden_data_def(__resolv_lock)
#endif
/*
@@ -1038,21 +1063,21 @@ int attribute_hidden __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]);
}
}
@@ -1089,7 +1114,7 @@ void attribute_hidden __close_nameservers(void)
#ifdef L_gethostbyname
-struct hostent attribute_hidden *__gethostbyname(const char *name)
+struct hostent *gethostbyname(const char *name)
{
static struct hostent h;
static char buf[sizeof(struct in_addr) +
@@ -1097,29 +1122,19 @@ struct hostent attribute_hidden *__gethostbyname(const char *name)
sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */];
struct hostent *hp;
- __gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno);
+ gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno);
return hp;
}
-strong_alias(__gethostbyname,gethostbyname)
+libc_hidden_def(gethostbyname)
#endif
#ifdef L_gethostbyname2
-#ifndef __UCLIBC_HAS_IPV6__
-extern struct hostent *__gethostbyname (__const char *__name) attribute_hidden;
-#else
-extern int __gethostbyname2_r (__const char *__restrict __name, int __af,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop) attribute_hidden;
-#endif
-
struct hostent *gethostbyname2(const char *name, int family)
{
#ifndef __UCLIBC_HAS_IPV6__
- return family == AF_INET ? __gethostbyname(name) : (struct hostent*)0;
+ return family == AF_INET ? gethostbyname(name) : (struct hostent*)0;
#else /* __UCLIBC_HAS_IPV6__ */
static struct hostent h;
static char buf[sizeof(struct in6_addr) +
@@ -1127,7 +1142,7 @@ struct hostent *gethostbyname2(const char *name, int family)
sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */];
struct hostent *hp;
- __gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno);
+ gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno);
return hp;
#endif /* __UCLIBC_HAS_IPV6__ */
@@ -1246,11 +1261,7 @@ __res_state (void)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
-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,
+int res_query(const char *dname, int class, int type,
unsigned char *answer, int anslen)
{
int i;
@@ -1265,7 +1276,7 @@ int attribute_hidden __res_query_internal(const char *dname, int class, int type
return(-1);
}
- __memset((char *) &a, '\0', sizeof(a));
+ memset((char *) &a, '\0', sizeof(a));
BIGLOCK;
__nameserversXX=__nameservers;
@@ -1282,7 +1293,7 @@ int attribute_hidden __res_query_internal(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);
@@ -1291,7 +1302,7 @@ int attribute_hidden __res_query_internal(const char *dname, int class, int type
free(packet);
return i;
}
-strong_alias(__res_query_internal,res_query)
+libc_hidden_def(res_query)
/*
* Formulate a normal query, send, and retrieve answer in supplied buffer.
@@ -1311,7 +1322,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_internal() == -1)) {
+ if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && res_init() == -1)) {
h_errno = NETDB_INTERNAL;
return (-1);
}
@@ -1331,7 +1342,7 @@ int res_search(name, class, type, answer, anslen)
*/
saved_herrno = -1;
if (dots >= _res.ndots) {
- ret = __res_querydomain_internal(name, NULL, class, type, answer, anslen);
+ ret = res_querydomain(name, NULL, class, type, answer, anslen);
if (ret > 0)
return (ret);
saved_herrno = h_errno;
@@ -1352,7 +1363,7 @@ int res_search(name, class, type, answer, anslen)
*domain && !done;
domain++) {
- ret = __res_querydomain_internal(name, *domain, class, type,
+ ret = res_querydomain(name, *domain, class, type,
answer, anslen);
if (ret > 0)
return (ret);
@@ -1408,7 +1419,7 @@ int res_search(name, class, type, answer, anslen)
* name or whether it ends with a dot.
*/
if (!tried_as_is) {
- ret = __res_querydomain_internal(name, NULL, class, type, answer, anslen);
+ ret = res_querydomain(name, NULL, class, type, answer, anslen);
if (ret > 0)
return (ret);
}
@@ -1434,7 +1445,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 attribute_hidden __res_querydomain_internal(name, domain, class, type, answer, anslen)
+int res_querydomain(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 */
@@ -1444,14 +1455,14 @@ int attribute_hidden __res_querydomain_internal(name, domain, class, type, answe
const char *longname = nbuf;
size_t n, d;
- if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && __res_init_internal() == -1)) {
+ if ((!name || !answer) || ((_res.options & RES_INIT) == 0 && res_init() == -1)) {
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
- __printf(";; res_querydomain(%s, %s, %d, %d)\n",
+ printf(";; res_querydomain(%s, %s, %d, %d)\n",
name, domain?domain:"<Nil>", class, type);
#endif
if (domain == NULL) {
@@ -1459,28 +1470,28 @@ int attribute_hidden __res_querydomain_internal(name, domain, class, type, answe
* 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);
}
snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain);
}
- return (__res_query_internal(longname, class, type, answer, anslen));
+ return (res_query(longname, class, type, answer, anslen));
}
-strong_alias(__res_querydomain_internal,res_querydomain)
+libc_hidden_def(res_querydomain)
/* res_mkquery */
/* res_send */
@@ -1489,14 +1500,7 @@ strong_alias(__res_querydomain_internal,res_querydomain)
#endif
#ifdef L_gethostbyaddr
-extern int __gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
- int __type,
- struct hostent *__restrict __result_buf,
- char *__restrict __buf, size_t __buflen,
- struct hostent **__restrict __result,
- int *__restrict __h_errnop) attribute_hidden;
-
-struct hostent attribute_hidden *__gethostbyaddr (const void *addr, socklen_t len, int type)
+struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
{
static struct hostent h;
static char buf[
@@ -1508,11 +1512,11 @@ struct hostent attribute_hidden *__gethostbyaddr (const void *addr, socklen_t le
sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */];
struct hostent *hp;
- __gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno);
+ gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno);
return hp;
}
-strong_alias(__gethostbyaddr,gethostbyaddr)
+libc_hidden_def(gethostbyaddr)
#endif
@@ -1597,7 +1601,7 @@ int attribute_hidden __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;
@@ -1622,12 +1626,12 @@ int attribute_hidden __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 */
for (i = 1; i < aliases; i++)
- if (__strcasecmp(name, alias[i]) == 0)
+ if (strcasecmp(name, alias[i]) == 0)
break;
if (i >= aliases)
continue;
@@ -1698,7 +1702,7 @@ void sethostent (int stay_open)
UNLOCK;
}
-int attribute_hidden __gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
+int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
struct hostent **result, int *h_errnop)
{
int ret;
@@ -1721,7 +1725,7 @@ int attribute_hidden __gethostent_r(struct hostent *result_buf, char *buf, size_
UNLOCK;
return(ret);
}
-strong_alias(__gethostent_r,gethostent_r)
+libc_hidden_def(gethostent_r)
struct hostent *gethostent (void)
{
@@ -1737,7 +1741,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);
}
@@ -1798,7 +1802,8 @@ int attribute_hidden __get_hosts_byaddr_r(const char * addr, int len, int type,
# define min(x,y) (((x) > (y)) ? (y) : (x))
#endif /* min */
-int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
+libc_hidden_proto(getnameinfo)
+int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
socklen_t hostlen, char *serv, socklen_t servlen,
unsigned int flags)
{
@@ -1839,12 +1844,12 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
if (!(flags & NI_NUMERICHOST)) {
#ifdef __UCLIBC_HAS_IPV6__
if (sa->sa_family == AF_INET6)
- h = __gethostbyaddr ((const void *)
+ h = gethostbyaddr ((const void *)
&(((const struct sockaddr_in6 *) sa)->sin6_addr),
sizeof(struct in6_addr), AF_INET6);
else
#endif /* __UCLIBC_HAS_IPV6__ */
- h = __gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
+ h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
sizeof(struct in_addr), AF_INET);
if (h) {
@@ -1853,12 +1858,12 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
&& (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;
}
}
@@ -1887,7 +1892,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
char scopebuf[IFNAMSIZ + 1];
char *scopeptr;
int ni_numericscope = 0;
- size_t real_hostlen = __strnlen (host, hostlen);
+ size_t real_hostlen = strnlen (host, hostlen);
size_t scopelen = 0;
scopebuf[0] = SCOPE_DELIMITER;
@@ -1899,7 +1904,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
if (if_indextoname (scopeid, scopeptr) == NULL)
++ni_numericscope;
else
- scopelen = __strlen (scopebuf);
+ scopelen = strlen (scopebuf);
} else {
++ni_numericscope;
}
@@ -1913,7 +1918,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
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
@@ -1936,7 +1941,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
struct utsname utsname;
if (!uname (&utsname)) {
- __strncpy (host, utsname.nodename, hostlen);
+ strncpy (host, utsname.nodename, hostlen);
break;
};
};
@@ -1946,7 +1951,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
return EAI_NONAME;
}
- __strncpy (host, "localhost", hostlen);
+ strncpy (host, "localhost", hostlen);
break;
default:
@@ -1964,7 +1969,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
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;
}
}
@@ -1973,7 +1978,7 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
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;
}
}
@@ -1984,13 +1989,13 @@ int attribute_hidden __getnameinfo (const struct sockaddr *sa, socklen_t addrlen
errno = serrno;
return 0;
}
-strong_alias(__getnameinfo,getnameinfo)
+libc_hidden_def(getnameinfo)
#endif
#ifdef L_gethostbyname_r
-int attribute_hidden __gethostbyname_r(const char * name,
+int gethostbyname_r(const char * name,
struct hostent * result_buf,
char * buf, size_t buflen,
struct hostent ** result,
@@ -2059,7 +2064,7 @@ int attribute_hidden __gethostbyname_r(const char * name,
if (buflen<256)
return ERANGE;
- __strncpy(buf, name, buflen);
+ strncpy(buf, name, buflen);
alias[0] = buf;
alias[1] = NULL;
@@ -2103,7 +2108,7 @@ int attribute_hidden __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)
@@ -2113,11 +2118,11 @@ int attribute_hidden __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);
@@ -2139,19 +2144,19 @@ int attribute_hidden __gethostbyname_r(const char * name,
*h_errnop = NETDB_SUCCESS;
return NETDB_SUCCESS;
}
-strong_alias(__gethostbyname_r,gethostbyname_r)
+libc_hidden_def(gethostbyname_r)
#endif
#ifdef L_gethostbyname2_r
-int attribute_hidden __gethostbyname2_r(const char *name, int family,
+int gethostbyname2_r(const char *name, int family,
struct hostent * result_buf,
char * buf, size_t buflen,
struct hostent ** result,
int * h_errnop)
{
#ifndef __UCLIBC_HAS_IPV6__
- return family == (AF_INET)? __gethostbyname_r(name, result_buf,
+ return family == (AF_INET)? gethostbyname_r(name, result_buf,
buf, buflen, result, h_errnop) : HOST_NOT_FOUND;
#else /* __UCLIBC_HAS_IPV6__ */
struct in6_addr *in;
@@ -2164,7 +2169,7 @@ int attribute_hidden __gethostbyname2_r(const char *name, int family,
char ** __nameserverXX;
if (family == AF_INET)
- return __gethostbyname_r(name, result_buf, buf, buflen, result, h_errnop);
+ return gethostbyname_r(name, result_buf, buf, buflen, result, h_errnop);
if (family != AF_INET6)
return EINVAL;
@@ -2217,7 +2222,7 @@ int attribute_hidden __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)) {
@@ -2230,7 +2235,7 @@ int attribute_hidden __gethostbyname2_r(const char *name, int family,
return NETDB_SUCCESS;
}
- __memset((char *) &a, '\0', sizeof(a));
+ memset((char *) &a, '\0', sizeof(a));
for (;;) {
BIGLOCK;
@@ -2245,7 +2250,7 @@ int attribute_hidden __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 */
@@ -2263,7 +2268,7 @@ int attribute_hidden __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);
@@ -2282,11 +2287,11 @@ int attribute_hidden __gethostbyname2_r(const char *name, int family,
return NETDB_SUCCESS;
#endif /* __UCLIBC_HAS_IPV6__ */
}
-strong_alias(__gethostbyname2_r,gethostbyname2_r)
+libc_hidden_def(gethostbyname2_r)
#endif
#ifdef L_gethostbyaddr_r
-int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int type,
+int gethostbyaddr_r (const void *addr, socklen_t len, int type,
struct hostent * result_buf,
char * buf, size_t buflen,
struct hostent ** result,
@@ -2312,7 +2317,7 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
if (!addr)
return EINVAL;
- __memset((char *) &a, '\0', sizeof(a));
+ memset((char *) &a, '\0', sizeof(a));
switch (type) {
case AF_INET:
@@ -2386,24 +2391,24 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
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;
- __sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
+ sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
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;
for (i = len - 1; i >= 0; i--) {
- qp += __sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf,
+ 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__ */
}
@@ -2422,7 +2427,7 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
return TRY_AGAIN;
}
- __strncpy(buf, a.dotted, buflen);
+ strncpy(buf, a.dotted, buflen);
free(a.dotted);
if (a.atype == T_CNAME) { /* CNAME */
@@ -2467,7 +2472,7 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
*h_errnop = NETDB_SUCCESS;
return NETDB_SUCCESS;
}
-strong_alias(__gethostbyaddr_r,gethostbyaddr_r)
+libc_hidden_def(gethostbyaddr_r)
#endif
#ifdef L_res_comp
@@ -2481,7 +2486,7 @@ strong_alias(__gethostbyaddr_r,gethostbyaddr_r)
int __dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
char *dst, int dstsiz)
{
- int n = __ns_name_uncompress_internal(msg, eom, src, dst, (size_t)dstsiz);
+ int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);
if (n > 0 && dst[0] == '.')
dst[0] = '\0';
@@ -2533,19 +2538,19 @@ static int special(int ch)
* note:
* Root domain returns as "." not "".
*/
-int attribute_hidden __ns_name_uncompress_internal(const u_char *msg, const u_char *eom,
+int 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_internal(msg, eom, src, tmp, sizeof tmp)) == -1)
+ if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
return (-1);
- if (__ns_name_ntop_internal(tmp, dst, dstsiz) == -1)
+ if (ns_name_ntop(tmp, dst, dstsiz) == -1)
return (-1);
return (n);
}
-strong_alias(__ns_name_uncompress_internal,__ns_name_uncompress)
+libc_hidden_def(ns_name_uncompress)
/*
@@ -2557,7 +2562,7 @@ strong_alias(__ns_name_uncompress_internal,__ns_name_uncompress)
* The root is returned as "."
* All other domains are returned in non absolute form
*/
-int attribute_hidden __ns_name_ntop_internal(const u_char *src, char *dst, size_t dstsiz) {
+int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
const u_char *cp;
char *dn, *eom;
u_char c;
@@ -2626,7 +2631,7 @@ int attribute_hidden __ns_name_ntop_internal(const u_char *src, char *dst, size_
*dn++ = '\0';
return (dn - dst);
}
-strong_alias(__ns_name_ntop_internal,__ns_name_ntop)
+libc_hidden_def(ns_name_ntop)
/*
* ns_name_unpack(msg, eom, src, dst, dstsiz)
@@ -2634,7 +2639,7 @@ strong_alias(__ns_name_ntop_internal,__ns_name_ntop)
* return:
* -1 if it fails, or consumed octets if it succeeds.
*/
-int attribute_hidden __ns_name_unpack_internal(const u_char *msg, const u_char *eom, const u_char *src,
+int 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;
@@ -2662,7 +2667,7 @@ int attribute_hidden __ns_name_unpack_internal(const u_char *msg, const u_char *
}
checked += n + 1;
*dstp++ = n;
- __memcpy(dstp, srcp, n);
+ memcpy(dstp, srcp, n);
dstp += n;
srcp += n;
break;
@@ -2701,5 +2706,5 @@ int attribute_hidden __ns_name_unpack_internal(const u_char *msg, const u_char *
len = srcp - src;
return (len);
}
-strong_alias(__ns_name_unpack_internal,__ns_name_unpack)
+libc_hidden_def(ns_name_unpack)
#endif /* L_ns_name */
diff --git a/libc/inet/resolveaddress.c b/libc/inet/resolveaddress.c
new file mode 100644
index 000000000..d57366c98
--- /dev/null
+++ b/libc/inet/resolveaddress.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_resolveaddress
+#include "resolv.c"
diff --git a/libc/inet/resolvename.c b/libc/inet/resolvename.c
new file mode 100644
index 000000000..157878fd1
--- /dev/null
+++ b/libc/inet/resolvename.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_resolvename
+#include "resolv.c"
diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in
index 9bfa781d6..0fd12c3e3 100644
--- a/libc/inet/rpc/Makefile.in
+++ b/libc/inet/rpc/Makefile.in
@@ -1,52 +1,44 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-ifeq ($(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
+ifneq ($(UCLIBC_HAS_FULL_RPC),y)
# 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
+CSRC:= authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
+ clnt_perror.c clnt_simple.c clnt_tcp.c clnt_udp.c \
+ create_xid.c getrpcent.c \
+ pmap_clnt.c pm_getmaps.c pm_getport.c pmap_prot.c pmap_prot2.c \
+ rcmd.c rexec.c rpc_cmsg.c rpc_commondata.c rpc_dtablesize.c \
+ rpc_prot.c rpc_thread.c rtime.c ruserpass.c sa_len.c \
+ svc.c svc_auth.c svc_authux.c \
+ xdr.c xdr_array.c xdr_mem.c xdr_rec.c xdr_reference.c
endif
INET_RPC_DIR:=$(top_srcdir)libc/inet/rpc
INET_RPC_OUT:=$(top_builddir)libc/inet/rpc
-ifneq ($(DOMULTI),n)
-INET_RPC_NO_MULTI:=rpc_commondata.c rpc_thread.c svc.c
-CSRC:=$(filter-out $(INET_RPC_NO_MULTI),$(CSRC))
+ifeq ($(UCLIBC_HAS_FULL_RPC),y)
+INET_RPC_SRC:=$(wildcard $(INET_RPC_DIR)/*.c)
+else
+INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC))
endif
+# rpc_thread.oS is better, because the header adds unneeded references to __pthread_internal_tsd*
+INET_RPC_SRC:=$(filter-out $(INET_RPC_DIR)/rpc_thread.c,$(INET_RPC_SRC))
-INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC))
-INET_RPC_OBJ:=$(patsubst %.c,$(INET_RPC_OUT)/%.o,$(CSRC))
+INET_RPC_OBJ:=$(patsubst $(INET_RPC_DIR)/%.c,$(INET_RPC_OUT)/%.o,$(INET_RPC_SRC))
+
+libc-static-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.o
+libc-shared-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.oS
-libc-a-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ)
-libc-so-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ:.o=.os)
+libc-nomulti-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o
-libc-multi-$(UCLIBC_HAS_RPC)+=$(INET_RPC_SRC)
-libc-nomulti-$(UCLIBC_HAS_RPC)+=$(patsubst %.c,$(INET_RPC_OUT)/%.o,$(INET_RPC_NO_MULTI))
+libc-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ)
objclean-y+=inet_rpc_objclean
inet_rpc_objclean:
- $(RM) $(INET_RPC_OUT)/*.{o,os}
+ $(RM) $(INET_RPC_OUT)/*.{o,os,oS}
diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
index cb30c40a7..05851025f 100644
--- a/libc/inet/rpc/auth_none.c
+++ b/libc/inet/rpc/auth_none.c
@@ -35,14 +35,14 @@
* credentials and verifiers to remote systems.
*/
-#define xdrmem_create __xdrmem_create
-#define xdr_opaque_auth __xdr_opaque_auth
-
#define __FORCE_GLIBC
#include <features.h>
#include "rpc_private.h"
-#define MAX_MARSHEL_SIZE 20
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_opaque_auth)
+
+#define MAX_MARSHAL_SIZE 20
/*
* Authenticator operations routines
@@ -53,7 +53,7 @@ static bool_t authnone_marshal (AUTH *, XDR *);
static bool_t authnone_validate (AUTH *, struct opaque_auth *);
static bool_t authnone_refresh (AUTH *);
-static struct auth_ops ops = {
+static const struct auth_ops ops = {
authnone_verf,
authnone_marshal,
authnone_validate,
@@ -61,9 +61,11 @@ static struct auth_ops ops = {
authnone_destroy
};
+/* Internal data and routines */
+
struct authnone_private_s {
AUTH no_client;
- char marshalled_client[MAX_MARSHEL_SIZE];
+ char marshalled_client[MAX_MARSHAL_SIZE];
u_int mcnt;
};
#ifdef __UCLIBC_HAS_THREADS__
@@ -72,8 +74,9 @@ struct authnone_private_s {
static struct authnone_private_s *authnone_private;
#endif
-AUTH attribute_hidden *
-__authnone_create (void)
+libc_hidden_proto(authnone_create)
+AUTH *
+authnone_create (void)
{
struct authnone_private_s *ap;
XDR xdr_stream;
@@ -90,9 +93,9 @@ __authnone_create (void)
if (!ap->mcnt)
{
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
- ap->no_client.ah_ops = &ops;
+ ap->no_client.ah_ops = (struct auth_ops *)&ops;
xdrs = &xdr_stream;
- xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHEL_SIZE,
+ xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE,
XDR_ENCODE);
(void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
(void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
@@ -101,9 +104,8 @@ __authnone_create (void)
}
return (&ap->no_client);
}
-strong_alias(__authnone_create,authnone_create)
+libc_hidden_def(authnone_create)
-/*ARGSUSED */
static bool_t
authnone_marshal (AUTH *client attribute_unused, XDR *xdrs)
{
diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c
index bb14df068..7644ab276 100644
--- a/libc/inet/rpc/auth_unix.c
+++ b/libc/inet/rpc/auth_unix.c
@@ -38,17 +38,6 @@
* for the credentials.
*/
-#define sysconf __sysconf
-#define getegid __getegid
-#define geteuid __geteuid
-#define getgroups __getgroups
-#define gethostname __gethostname
-#define xdrmem_create __xdrmem_create
-#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>
@@ -67,6 +56,24 @@
# include <wchar.h>
#endif
+libc_hidden_proto(memcpy)
+libc_hidden_proto(sysconf)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(getgroups)
+libc_hidden_proto(gethostname)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_authunix_parms)
+libc_hidden_proto(xdr_opaque_auth)
+libc_hidden_proto(gettimeofday)
+libc_hidden_proto(fputs)
+libc_hidden_proto(perror)
+libc_hidden_proto(abort)
+libc_hidden_proto(stderr)
+#ifdef USE_IN_LIBIO
+libc_hidden_proto(fwprintf)
+#endif
+
/*
* Unix authenticator operations vector
*/
@@ -103,8 +110,9 @@ 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 attribute_hidden *
-__authunix_create (char *machname, uid_t uid, gid_t gid, int len,
+libc_hidden_proto(authunix_create)
+AUTH *
+authunix_create (char *machname, uid_t uid, gid_t gid, int len,
gid_t *aup_gids)
{
struct authunix_parms aup;
@@ -124,7 +132,7 @@ __authunix_create (char *machname, uid_t uid, gid_t gid, int len,
no_memory:
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("authunix_create: out of memory\n"));
else
#endif
@@ -160,7 +168,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.
@@ -169,14 +177,15 @@ no_memory:
marshal_new_auth (auth);
return auth;
}
-strong_alias(__authunix_create,authunix_create)
+libc_hidden_def(authunix_create)
/*
* Returns an auth handle with parameters determined by doing lots of
* syscalls.
*/
-AUTH attribute_hidden *
-__authunix_create_default (void)
+libc_hidden_proto(authunix_create_default)
+AUTH *
+authunix_create_default (void)
{
int len;
char machname[MAX_MACHINE_NAME + 1];
@@ -203,12 +212,12 @@ __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. */
- ret_auth = __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)
+libc_hidden_def(authunix_create_default)
/*
* authunix operations
@@ -338,7 +347,7 @@ marshal_new_auth (AUTH *auth)
xdrmem_create (xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
if ((!xdr_opaque_auth (xdrs, &(auth->ah_cred))) ||
(!xdr_opaque_auth (xdrs, &(auth->ah_verf))))
- __perror (_("auth_none.c - Fatal marshalling problem"));
+ perror (_("auth_none.c - Fatal marshalling problem"));
else
au->au_mpos = XDR_GETPOS (xdrs);
diff --git a/libc/inet/rpc/authunix_prot.c b/libc/inet/rpc/authunix_prot.c
index 32da3256d..62d1cb724 100644
--- a/libc/inet/rpc/authunix_prot.c
+++ b/libc/inet/rpc/authunix_prot.c
@@ -34,22 +34,24 @@
* XDR for UNIX style authentication parameters for RPC
*/
-#define xdr_string __xdr_string
-#define xdr_u_int __xdr_u_int
-#define xdr_array __xdr_array
-#define xdr_u_long __xdr_u_long
-
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
+libc_hidden_proto(xdr_string)
+libc_hidden_proto(xdr_u_int)
+libc_hidden_proto(xdr_array)
+libc_hidden_proto(xdr_u_long)
+libc_hidden_proto(xdr_u_short)
+
/*
* XDR for unix authentication parameters.
* Unfortunately, none of these can be declared const.
*/
-bool_t attribute_hidden
-__xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p)
+libc_hidden_proto(xdr_authunix_parms)
+bool_t
+xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p)
{
if (xdr_u_long (xdrs, &(p->aup_time))
&& xdr_string (xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
@@ -68,4 +70,4 @@ __xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p)
}
return FALSE;
}
-strong_alias(__xdr_authunix_parms,xdr_authunix_parms)
+libc_hidden_def(xdr_authunix_parms)
diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c
index 530df52b3..32055cdf6 100644
--- a/libc/inet/rpc/bindresvport.c
+++ b/libc/inet/rpc/bindresvport.c
@@ -30,8 +30,6 @@
* Copyright (c) 1987 by Sun Microsystems, Inc.
*/
-#define bind __bind
-
#define __FORCE_GLIBC
#include <features.h>
@@ -42,11 +40,16 @@
#include <sys/socket.h>
#include <netinet/in.h>
+libc_hidden_proto(memset)
+libc_hidden_proto(bind)
+libc_hidden_proto(getpid)
+
/*
* Bind a socket to a privileged IP port
*/
-int attribute_hidden
-__bindresvport (int sd, struct sockaddr_in *sin)
+libc_hidden_proto(bindresvport)
+int
+bindresvport (int sd, struct sockaddr_in *sin)
{
int res;
static short port;
@@ -60,7 +63,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)
@@ -71,7 +74,7 @@ __bindresvport (int sd, struct sockaddr_in *sin)
if (port == 0)
{
- port = (__getpid () % NPORTS) + STARTPORT;
+ port = (getpid () % NPORTS) + STARTPORT;
}
res = -1;
__set_errno (EADDRINUSE);
@@ -88,4 +91,4 @@ __bindresvport (int sd, struct sockaddr_in *sin)
return res;
}
-strong_alias(__bindresvport,bindresvport)
+libc_hidden_def(bindresvport)
diff --git a/libc/inet/rpc/clnt_generic.c b/libc/inet/rpc/clnt_generic.c
index d4a74f6d5..899a9dd0e 100644
--- a/libc/inet/rpc/clnt_generic.c
+++ b/libc/inet/rpc/clnt_generic.c
@@ -30,12 +30,6 @@
* Copyright (C) 1987, Sun Microsystems, Inc.
*/
-#define clnttcp_create __clnttcp_create
-#define clntudp_create __clntudp_create
-#define clntunix_create __clntunix_create
-#define getprotobyname_r __getprotobyname_r
-#define gethostbyname_r __gethostbyname_r
-
#define __FORCE_GLIBC
#include <features.h>
@@ -46,6 +40,17 @@
#include <sys/socket.h>
#include <netdb.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(clnttcp_create)
+libc_hidden_proto(clntudp_create)
+libc_hidden_proto(clntunix_create)
+libc_hidden_proto(getprotobyname_r)
+libc_hidden_proto(gethostbyname_r)
+libc_hidden_proto(__rpc_thread_createerr)
+
/*
* Generic client creation: takes (hostname, program-number, protocol) and
* returns client handle. Default options are set, which the user can
@@ -68,11 +73,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)
@@ -117,8 +122,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 eba539c95..ef3ed2d30 100644
--- a/libc/inet/rpc/clnt_perror.c
+++ b/libc/inet/rpc/clnt_perror.c
@@ -38,8 +38,6 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
*
*/
-#define fputs __fputs
-
#define __FORCE_GLIBC
#include <features.h>
@@ -53,6 +51,15 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
# define fputs(s, f) _IO_fputs (s, f)
#endif
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(__glibc_strerror_r)
+libc_hidden_proto(fputs)
+#ifdef USE_IN_LIBIO
+libc_hidden_proto(fwprintf)
+#endif
+
static char *auth_errmsg (enum auth_stat stat) internal_function;
#ifdef __UCLIBC_HAS_THREADS__
@@ -179,8 +186,9 @@ static const struct rpc_errtab rpc_errlist[] =
/*
* This interface for use by clntrpc
*/
-char attribute_hidden *
-__clnt_sperrno (enum clnt_stat stat)
+libc_hidden_proto(clnt_sperrno)
+char *
+clnt_sperrno (enum clnt_stat stat)
{
size_t i;
@@ -193,24 +201,25 @@ __clnt_sperrno (enum clnt_stat stat)
}
return _("RPC: (unknown error code)");
}
-strong_alias(__clnt_sperrno,clnt_sperrno)
+libc_hidden_def(clnt_sperrno)
void
clnt_perrno (enum clnt_stat num)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", __clnt_sperrno (num));
+ (void) fwprintf (stderr, L"%s", clnt_sperrno (num));
else
#endif
- (void) fputs (__clnt_sperrno (num), stderr);
+ (void) fputs (clnt_sperrno (num), stderr);
}
/*
* Print reply error info
*/
-char attribute_hidden *
-__clnt_sperror (CLIENT * rpch, const char *msg)
+libc_hidden_proto(clnt_sperror)
+char *
+clnt_sperror (CLIENT * rpch, const char *msg)
{
char chrbuf[1024];
struct rpc_err e;
@@ -223,11 +232,11 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
return NULL;
CLNT_GETERR (rpch, &e);
- len = __sprintf (str, "%s: ", 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)
{
@@ -248,43 +257,43 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
case RPC_CANTSEND:
case RPC_CANTRECV:
- __glibc_strerror_r_internal (e.re_errno, chrbuf, sizeof chrbuf);
- len = __sprintf (str, "; errno = %s", chrbuf);
+ __glibc_strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
+ len = sprintf (str, "; errno = %s", chrbuf);
str += len;
break;
case RPC_VERSMISMATCH:
- len= __sprintf (str, _("; low version = %lu, high version = %lu"),
+ len= sprintf (str, _("; low version = %lu, high version = %lu"),
e.re_vers.low, e.re_vers.high);
str += len;
break;
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
{
- len = __sprintf (str, _("(unknown authentication error - %d)"),
+ len = sprintf (str, _("(unknown authentication error - %d)"),
(int) e.re_why);
str += len;
}
break;
case RPC_PROGVERSMISMATCH:
- len = __sprintf (str, _("; low version = %lu, high version = %lu"),
+ len = sprintf (str, _("; low version = %lu, high version = %lu"),
e.re_vers.low, e.re_vers.high);
str += len;
break;
default: /* unknown */
- len = __sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
+ len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
str += len;
break;
}
@@ -292,22 +301,24 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
*++str = '\0';
return (strstart);
}
-strong_alias(__clnt_sperror,clnt_sperror)
+libc_hidden_def(clnt_sperror)
-void attribute_hidden
-__clnt_perror (CLIENT * rpch, const char *msg)
+libc_hidden_proto(clnt_perror)
+void
+clnt_perror (CLIENT * rpch, const char *msg)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", __clnt_sperror (rpch, msg));
+ (void) fwprintf (stderr, L"%s", clnt_sperror (rpch, msg));
else
#endif
- (void) fputs (__clnt_sperror (rpch, msg), stderr);
+ (void) fputs (clnt_sperror (rpch, msg), stderr);
}
-strong_alias(__clnt_perror,clnt_perror)
+libc_hidden_def(clnt_perror)
-char attribute_hidden *
-__clnt_spcreateerror (const char *msg)
+libc_hidden_proto(clnt_spcreateerror)
+char *
+clnt_spcreateerror (const char *msg)
{
char chrbuf[1024];
char *str = _buf ();
@@ -318,29 +329,29 @@ __clnt_spcreateerror (const char *msg)
if (str == NULL)
return NULL;
ce = &get_rpc_createerr ();
- len = __sprintf (str, "%s: ", msg);
+ 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);
- __glibc_strerror_r_internal (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
- (void) __strcpy(cp, chrbuf);
- cp += __strlen(cp);
+ __glibc_strerror_r (ce->cf_error.re_errno, chrbuf, sizeof chrbuf);
+ (void) strcpy(cp, chrbuf);
+ cp += strlen(cp);
break;
default:
break;
@@ -349,17 +360,17 @@ __clnt_spcreateerror (const char *msg)
*++cp = '\0';
return str;
}
-strong_alias(__clnt_spcreateerror,clnt_spcreateerror)
+libc_hidden_def(clnt_spcreateerror)
void
clnt_pcreateerror (const char *msg)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", __clnt_spcreateerror (msg));
+ (void) fwprintf (stderr, L"%s", clnt_spcreateerror (msg));
else
#endif
- (void) fputs (__clnt_spcreateerror (msg), stderr);
+ (void) fputs (clnt_spcreateerror (msg), stderr);
}
struct auth_errtab
diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c
index 37b99ecb1..b44bd38b8 100644
--- a/libc/inet/rpc/clnt_raw.c
+++ b/libc/inet/rpc/clnt_raw.c
@@ -42,20 +42,21 @@ 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 xdrmem_create __xdrmem_create
-#define xdr_callhdr __xdr_callhdr
-#define xdr_replymsg __xdr_replymsg
-#define xdr_opaque_auth __xdr_opaque_auth
-#define svc_getreq __svc_getreq
-#define _seterr_reply __seterr_reply
-
#define __FORCE_GLIBC
#include <features.h>
#include "rpc_private.h"
#include <rpc/svc.h>
#include <rpc/xdr.h>
+libc_hidden_proto(perror)
+libc_hidden_proto(authnone_create)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callhdr)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_opaque_auth)
+libc_hidden_proto(svc_getreq)
+libc_hidden_proto(_seterr_reply)
+
#define MCALL_MSG_SIZE 24
/*
@@ -121,7 +122,7 @@ clntraw_create (u_long prog, u_long vers)
xdrmem_create (xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
if (!xdr_callhdr (xdrs, &call_msg))
{
- __perror (_ ("clnt_raw.c - Fatal header serialization error."));
+ perror (_ ("clnt_raw.c - Fatal header serialization error."));
}
clp->mcnt = XDR_GETPOS (xdrs);
XDR_DESTROY (xdrs);
diff --git a/libc/inet/rpc/clnt_simple.c b/libc/inet/rpc/clnt_simple.c
index 7c17dc1f1..f9f18f3d4 100644
--- a/libc/inet/rpc/clnt_simple.c
+++ b/libc/inet/rpc/clnt_simple.c
@@ -38,9 +38,6 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define clntudp_create __clntudp_create
-#define gethostbyname_r __gethostbyname_r
-
#define __FORCE_GLIBC
#include <features.h>
@@ -53,6 +50,13 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
#include <netdb.h>
#include <string.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(close)
+libc_hidden_proto(clntudp_create)
+libc_hidden_proto(gethostbyname_r)
+
struct callrpc_private_s
{
CLIENT *client;
@@ -90,7 +94,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 */
}
@@ -103,7 +107,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)
@@ -128,7 +132,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,
@@ -137,7 +141,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;
diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c
index 8dcb4682a..6d19df31c 100644
--- a/libc/inet/rpc/clnt_tcp.c
+++ b/libc/inet/rpc/clnt_tcp.c
@@ -50,21 +50,6 @@ 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 xdrrec_endofrecord __xdrrec_endofrecord
-#define xdrrec_skiprecord __xdrrec_skiprecord
-#define xdr_callhdr __xdr_callhdr
-#define xdr_replymsg __xdr_replymsg
-#define xdr_opaque_auth __xdr_opaque_auth
-#define xdrmem_create __xdrmem_create
-#define pmap_getport __pmap_getport
-#define _seterr_reply __seterr_reply
-#define connect __connect
-#define bindresvport __bindresvport
-#define poll __poll
-#define fputs __fputs
-
#define __FORCE_GLIBC
#include <features.h>
@@ -80,12 +65,32 @@ 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) attribute_hidden;
+libc_hidden_proto(socket)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(close)
+libc_hidden_proto(authnone_create)
+libc_hidden_proto(xdrrec_create)
+libc_hidden_proto(xdrrec_endofrecord)
+libc_hidden_proto(xdrrec_skiprecord)
+libc_hidden_proto(xdr_callhdr)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_opaque_auth)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_void)
+libc_hidden_proto(pmap_getport)
+libc_hidden_proto(_seterr_reply)
+libc_hidden_proto(connect)
+libc_hidden_proto(bindresvport)
+libc_hidden_proto(poll)
+libc_hidden_proto(fputs)
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(stderr)
+#ifdef USE_IN_LIBIO
+libc_hidden_proto(fwprintf)
+#endif
-#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 ())
+extern u_long _create_xid (void) attribute_hidden;
#define MCALL_MSG_SIZE 24
@@ -137,8 +142,9 @@ static struct clnt_ops tcp_ops =
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
* something more useful.
*/
-CLIENT attribute_hidden *
-__clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
+libc_hidden_proto(clnttcp_create)
+CLIENT *
+clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
int *sockp, u_int sendsz, u_int recvsz)
{
CLIENT *h;
@@ -152,7 +158,7 @@ __clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
struct rpc_createerr *ce = &get_rpc_createerr ();
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("clnttcp_create: out of memory\n"));
else
#endif
@@ -182,7 +188,7 @@ __clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
*/
if (*sockp < 0)
{
- *sockp = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ *sockp = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
(void) bindresvport (*sockp, (struct sockaddr_in *) 0);
if ((*sockp < 0)
|| (connect (*sockp, (struct sockaddr *) raddr,
@@ -192,7 +198,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;
@@ -228,7 +234,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;
}
@@ -254,7 +260,7 @@ fooy:
mem_free ((caddr_t) h, sizeof (CLIENT));
return ((CLIENT *) NULL);
}
-strong_alias(__clnttcp_create,clnttcp_create)
+libc_hidden_def(clnttcp_create)
static enum clnt_stat
clnttcp_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
@@ -482,7 +488,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));
@@ -524,7 +530,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:
@@ -550,7 +556,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 bd93fd022..9b01d2751 100644
--- a/libc/inet/rpc/clnt_udp.c
+++ b/libc/inet/rpc/clnt_udp.c
@@ -37,24 +37,6 @@ 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 __cmsg_nxthdr_internal
-
-#define authnone_create __authnone_create
-#define xdrmem_create __xdrmem_create
-#define xdr_callhdr __xdr_callhdr
-#define xdr_replymsg __xdr_replymsg
-#define xdr_opaque_auth __xdr_opaque_auth
-#define pmap_getport __pmap_getport
-#define _seterr_reply __seterr_reply
-#define setsockopt __setsockopt
-#define bindresvport __bindresvport
-#define recvfrom __recvfrom
-#define sendto __sendto
-#define recvmsg __recvmsg
-#define poll __poll
-#define fputs __fputs
-
#define __FORCE_GLIBC
#include <features.h>
@@ -72,6 +54,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
#include <net/if.h>
#ifdef USE_IN_LIBIO
# include <wchar.h>
+libc_hidden_proto(fwprintf)
#endif
#ifdef IP_RECVERR
@@ -79,12 +62,31 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
#include <sys/uio.h>
#endif
-extern u_long _create_xid (void) attribute_hidden;
+libc_hidden_proto(memcmp)
+libc_hidden_proto(ioctl)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+/* CMSG_NXTHDR is using it */
+libc_hidden_proto(__cmsg_nxthdr)
+
+libc_hidden_proto(authnone_create)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callhdr)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_opaque_auth)
+libc_hidden_proto(pmap_getport)
+libc_hidden_proto(_seterr_reply)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(bindresvport)
+libc_hidden_proto(recvfrom)
+libc_hidden_proto(sendto)
+libc_hidden_proto(recvmsg)
+libc_hidden_proto(poll)
+libc_hidden_proto(fputs)
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(stderr)
-#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 ())
+extern u_long _create_xid (void) attribute_hidden;
/*
* UDP bases client side rpc operations
@@ -143,8 +145,9 @@ struct cu_data
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
-CLIENT attribute_hidden *
-__clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
+libc_hidden_proto(clntudp_bufcreate)
+CLIENT *
+clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp, u_int sendsz,
u_int recvsz)
{
@@ -161,7 +164,7 @@ __clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
struct rpc_createerr *ce = &get_rpc_createerr ();
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("clntudp_create: out of memory\n"));
else
#endif
@@ -207,7 +210,7 @@ __clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
{
int dontblock = 1;
- *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ *sockp = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (*sockp < 0)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
@@ -218,7 +221,7 @@ __clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
/* attempt to bind to prov port */
(void) bindresvport (*sockp, (struct sockaddr_in *) 0);
/* the sockets rpc controls are non-blocking */
- (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
+ (void) ioctl (*sockp, FIONBIO, (char *) &dontblock);
#ifdef IP_RECVERR
{
int on = 1;
@@ -241,16 +244,17 @@ fooy:
mem_free ((caddr_t) cl, sizeof (CLIENT));
return (CLIENT *) NULL;
}
-strong_alias(__clntudp_bufcreate,clntudp_bufcreate)
+libc_hidden_def(clntudp_bufcreate)
-CLIENT attribute_hidden *
-__clntudp_create (struct sockaddr_in *raddr, u_long program, u_long version, struct timeval wait, int *sockp)
+libc_hidden_proto(clntudp_create)
+CLIENT *
+clntudp_create (struct sockaddr_in *raddr, u_long program, u_long version, struct timeval wait, int *sockp)
{
- return __clntudp_bufcreate (raddr, program, version, wait, sockp,
+ return clntudp_bufcreate (raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE);
}
-strong_alias(__clntudp_create,clntudp_create)
+libc_hidden_def(clntudp_create)
static int
is_network_up (int sock)
@@ -262,13 +266,13 @@ is_network_up (int sock)
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
- if (__ioctl(sock, SIOCGIFCONF, (char *) &ifc) == 0)
+ if (ioctl(sock, SIOCGIFCONF, (char *) &ifc) == 0)
{
ifr = ifc.ifc_req;
for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
{
ifreq = *ifr;
- if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+ if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
break;
if ((ifreq.ifr_flags & IFF_UP)
@@ -419,13 +423,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;
@@ -620,7 +624,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 e0483b4e2..c5e949db6 100644
--- a/libc/inet/rpc/clnt_unix.c
+++ b/libc/inet/rpc/clnt_unix.c
@@ -46,24 +46,6 @@
* Now go hang yourself.
*/
-#define authnone_create __authnone_create
-#define xdrrec_create __xdrrec_create
-#define xdrrec_endofrecord __xdrrec_endofrecord
-#define xdrrec_skiprecord __xdrrec_skiprecord
-#define xdr_callhdr __xdr_callhdr
-#define xdr_replymsg __xdr_replymsg
-#define xdr_opaque_auth __xdr_opaque_auth
-#define xdrmem_create __xdrmem_create
-#define getegid __getegid
-#define geteuid __geteuid
-#define _seterr_reply __seterr_reply
-#define setsockopt __setsockopt
-#define connect __connect
-#define recvmsg __recvmsg
-#define sendmsg __sendmsg
-#define poll __poll
-#define fputs __fputs
-
#define __FORCE_GLIBC
#include <features.h>
@@ -78,14 +60,36 @@
#include <rpc/pmap_clnt.h>
#ifdef USE_IN_LIBIO
# include <wchar.h>
+libc_hidden_proto(fwprintf)
#endif
-extern u_long _create_xid (void) attribute_hidden;
+libc_hidden_proto(strlen)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(getpid)
+libc_hidden_proto(authnone_create)
+libc_hidden_proto(xdrrec_create)
+libc_hidden_proto(xdrrec_endofrecord)
+libc_hidden_proto(xdrrec_skiprecord)
+libc_hidden_proto(xdr_callhdr)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_opaque_auth)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_void)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(_seterr_reply)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(connect)
+libc_hidden_proto(recvmsg)
+libc_hidden_proto(sendmsg)
+libc_hidden_proto(poll)
+libc_hidden_proto(fputs)
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(stderr)
-#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 ())
+extern u_long _create_xid (void) attribute_hidden;
#define MCALL_MSG_SIZE 24
@@ -137,8 +141,9 @@ static struct clnt_ops unix_ops =
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
* something more useful.
*/
-CLIENT attribute_hidden *
-__clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
+libc_hidden_proto(clntunix_create)
+CLIENT *
+clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
int *sockp, u_int sendsz, u_int recvsz)
{
CLIENT *h;
@@ -152,7 +157,7 @@ __clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
struct rpc_createerr *ce = &get_rpc_createerr ();
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("clntunix_create: out of memory\n"));
else
#endif
@@ -167,8 +172,8 @@ __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;
+ *sockp = socket (AF_UNIX, SOCK_STREAM, 0);
+ len = strlen (raddr->sun_path) + sizeof (raddr->sun_family) + 1;
if (*sockp < 0
|| connect (*sockp, (struct sockaddr *) raddr, len) < 0)
{
@@ -176,7 +181,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;
@@ -210,7 +215,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));
@@ -235,7 +240,7 @@ fooy:
mem_free ((caddr_t) h, sizeof (CLIENT));
return (CLIENT *) NULL;
}
-strong_alias(__clntunix_create,clntunix_create)
+libc_hidden_def(clntunix_create)
static enum clnt_stat
clntunix_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
@@ -457,7 +462,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));
@@ -526,11 +531,11 @@ __msgwrite (int sock, void *data, size_t cnt)
/* XXX I'm not sure, if gete?id() is always correct, or if we should use
get?id(). But since keyserv needs geteuid(), we have no other chance.
It would be much better, if the kernel could pass both to the server. */
- cred.pid = __getpid ();
+ cred.pid = getpid ();
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 69b83ff59..3b90d7a48 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/libc/inet/rpc/create_xid.c
@@ -17,10 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define lrand48_r __lrand48_r
-#define srand48_r __srand48_r
-#define gettimeofday __gettimeofday
-
#define __FORCE_GLIBC
#include <features.h>
@@ -29,6 +25,10 @@
#include <sys/time.h>
#include <rpc/rpc.h>
+libc_hidden_proto(lrand48_r)
+libc_hidden_proto(srand48_r)
+libc_hidden_proto(gettimeofday)
+
/* The RPC code is not threadsafe, but new code should be threadsafe. */
#ifdef __UCLIBC_HAS_THREADS__
@@ -41,7 +41,8 @@ static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER;
static int is_initialized;
static struct drand48_data __rpc_lrand48_data;
-u_long attribute_hidden _create_xid (void)
+u_long _create_xid (void) attribute_hidden;
+u_long _create_xid (void)
{
unsigned long res;
diff --git a/libc/inet/rpc/get_myaddress.c b/libc/inet/rpc/get_myaddress.c
index 45fbe359f..a6ba07811 100644
--- a/libc/inet/rpc/get_myaddress.c
+++ b/libc/inet/rpc/get_myaddress.c
@@ -50,6 +50,12 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
#include <netinet/in.h>
#include <arpa/inet.h>
+libc_hidden_proto(ioctl)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(perror)
+libc_hidden_proto(exit)
+
/*
* don't use gethostbyname, which would invoke yellow pages
*
@@ -65,17 +71,17 @@ get_myaddress (struct sockaddr_in *addr)
struct ifreq ifreq, *ifr;
int len, loopback = 0;
- if ((s = __socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
{
- __perror ("get_myaddress: socket");
- __exit (1);
+ perror ("get_myaddress: socket");
+ exit (1);
}
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
- if (__ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
+ if (ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
{
- __perror (_("get_myaddress: ioctl (get interface configuration)"));
- __exit (1);
+ perror (_("get_myaddress: ioctl (get interface configuration)"));
+ exit (1);
}
again:
@@ -83,10 +89,10 @@ get_myaddress (struct sockaddr_in *addr)
for (len = ifc.ifc_len; len; len -= sizeof ifreq)
{
ifreq = *ifr;
- if (__ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+ if (ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
{
- __perror ("get_myaddress: ioctl");
- __exit (1);
+ perror ("get_myaddress: ioctl");
+ exit (1);
}
if ((ifreq.ifr_flags & IFF_UP) && (ifr->ifr_addr.sa_family == AF_INET)
&& (!(ifreq.ifr_flags & IFF_LOOPBACK) ||
@@ -94,7 +100,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 +110,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 100469879..428fbcc31 100644
--- a/libc/inet/rpc/getrpcent.c
+++ b/libc/inet/rpc/getrpcent.c
@@ -33,10 +33,6 @@
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
-#define atoi __atoi
-#define rewind __rewind
-#define fgets __fgets
-
#define __FORCE_GLIBC
#include <features.h>
#include <stdio.h>
@@ -48,6 +44,17 @@
#include <arpa/inet.h>
#include <errno.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(atoi)
+libc_hidden_proto(rewind)
+libc_hidden_proto(fgets)
+
/*
* Internet version.
*/
@@ -77,7 +84,8 @@ static struct rpcdata *_rpcdata(void)
return d;
}
-void attribute_hidden __endrpcent(void)
+libc_hidden_proto(endrpcent)
+void endrpcent(void)
{
register struct rpcdata *d = _rpcdata();
@@ -94,9 +102,10 @@ void attribute_hidden __endrpcent(void)
d->rpcf = NULL;
}
}
-strong_alias(__endrpcent,endrpcent)
+libc_hidden_def(endrpcent)
-void attribute_hidden __setrpcent(int f)
+libc_hidden_proto(setrpcent)
+void setrpcent(int f)
{
register struct rpcdata *d = _rpcdata();
@@ -111,7 +120,7 @@ void attribute_hidden __setrpcent(int f)
d->current = NULL;
d->stayopen |= f;
}
-strong_alias(__setrpcent,setrpcent)
+libc_hidden_def(setrpcent)
static struct rpcent *interpret(struct rpcdata *);
@@ -122,7 +131,8 @@ static struct rpcent *__get_next_rpcent(struct rpcdata *d)
return interpret(d);
}
-struct rpcent attribute_hidden *__getrpcent(void)
+libc_hidden_proto(getrpcent)
+struct rpcent *getrpcent(void)
{
register struct rpcdata *d = _rpcdata();
@@ -132,51 +142,53 @@ struct rpcent attribute_hidden *__getrpcent(void)
return NULL;
return __get_next_rpcent(d);
}
-strong_alias(__getrpcent,getrpcent)
+libc_hidden_def(getrpcent)
-struct rpcent attribute_hidden *__getrpcbynumber(register int number)
+libc_hidden_proto(getrpcbynumber)
+struct rpcent *getrpcbynumber(register int number)
{
register struct rpcdata *d = _rpcdata();
register struct rpcent *rpc;
if (d == NULL)
return NULL;
- __setrpcent(0);
- while ((rpc = __getrpcent())) {
+ setrpcent(0);
+ while ((rpc = getrpcent())) {
if (rpc->r_number == number)
break;
}
- __endrpcent();
+ endrpcent();
return rpc;
}
-strong_alias(__getrpcbynumber,getrpcbynumber)
+libc_hidden_def(getrpcbynumber)
-struct rpcent attribute_hidden *__getrpcbyname(const char *name)
+libc_hidden_proto(getrpcbyname)
+struct rpcent *getrpcbyname(const char *name)
{
struct rpcent *rpc;
char **rp;
- __setrpcent(0);
- while ((rpc = __getrpcent())) {
- if (__strcmp(rpc->r_name, name) == 0)
+ setrpcent(0);
+ while ((rpc = getrpcent())) {
+ 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;
}
}
- __endrpcent();
+ endrpcent();
return NULL;
}
-strong_alias(__getrpcbyname,getrpcbyname)
+libc_hidden_def(getrpcbyname)
#ifdef __linux__
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;
@@ -193,12 +205,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);
}
@@ -209,9 +221,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);
}
@@ -227,11 +239,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';
}
@@ -247,11 +259,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';
}
@@ -281,8 +293,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;
@@ -299,21 +311,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;
@@ -328,7 +340,7 @@ int getrpcbynumber_r(int number, struct rpcent *result_buf, char *buffer,
{
int ret;
LOCK;
- ret = __copy_rpcent(__getrpcbynumber(number), result_buf, buffer, buflen, result);
+ ret = __copy_rpcent(getrpcbynumber(number), result_buf, buffer, buflen, result);
UNLOCK;
return ret;
}
@@ -338,7 +350,7 @@ int getrpcbyname_r(const char *name, struct rpcent *result_buf, char *buffer,
{
int ret;
LOCK;
- ret = __copy_rpcent(__getrpcbyname(name), result_buf, buffer, buflen, result);
+ ret = __copy_rpcent(getrpcbyname(name), result_buf, buffer, buflen, result);
UNLOCK;
return ret;
}
@@ -348,7 +360,7 @@ int getrpcent_r(struct rpcent *result_buf, char *buffer,
{
int ret;
LOCK;
- ret = __copy_rpcent(__getrpcent(), result_buf, buffer, buflen, result);
+ ret = __copy_rpcent(getrpcent(), result_buf, buffer, buflen, result);
UNLOCK;
return ret;
}
diff --git a/libc/inet/rpc/getrpcport.c b/libc/inet/rpc/getrpcport.c
index 48e58d9ab..82fa8d17a 100644
--- a/libc/inet/rpc/getrpcport.c
+++ b/libc/inet/rpc/getrpcport.c
@@ -35,9 +35,6 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
-#define pmap_getport __pmap_getport
-#define gethostbyname_r __gethostbyname_r
-
#define __FORCE_GLIBC
#include <features.h>
@@ -51,6 +48,10 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(pmap_getport)
+libc_hidden_proto(gethostbyname_r)
+
int
getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto)
{
@@ -73,7 +74,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_getmaps.c b/libc/inet/rpc/pm_getmaps.c
index 84736e03e..bd740a0ae 100644
--- a/libc/inet/rpc/pmap_getmaps.c
+++ b/libc/inet/rpc/pm_getmaps.c
@@ -39,16 +39,20 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define clnt_perror __clnt_perror
-#define clnttcp_create __clnttcp_create
-
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
-#include <sys/socket.h>
#include <netdb.h>
+#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
+#include <unistd.h>
+
+libc_hidden_proto(clnt_perror)
+libc_hidden_proto(clnttcp_create)
+libc_hidden_proto(xdr_pmap)
+libc_hidden_proto(xdr_pmaplist)
+libc_hidden_proto(xdr_void)
/*
* Get a copy of the current port maps.
@@ -65,6 +69,8 @@ pmap_getmaps (struct sockaddr_in *address)
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons (PMAPPORT);
+
+ /* Don't need a reserved port to get ports from the portmapper. */
client = clnttcp_create (address, PMAPPROG,
PMAPVERS, &socket, 50, 500);
if (client != (CLIENT *) NULL)
diff --git a/libc/inet/rpc/pmap_getport.c b/libc/inet/rpc/pm_getport.c
index b47baf35c..2fca57800 100644
--- a/libc/inet/rpc/pmap_getport.c
+++ b/libc/inet/rpc/pm_getport.c
@@ -38,17 +38,16 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define clntudp_bufcreate __clntudp_bufcreate
-
+#include <stdbool.h>
+#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#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 ())
+libc_hidden_proto(clntudp_bufcreate)
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(xdr_u_short)
+libc_hidden_proto(xdr_pmap)
static const struct timeval timeout =
{5, 0};
@@ -60,8 +59,13 @@ static const struct timeval tottimeout =
* Calls the pmap service remotely to do the lookup.
* Returns 0 if no map exists.
*/
-u_short attribute_hidden
-__pmap_getport (struct sockaddr_in *address, u_long program, u_long version, u_int protocol)
+libc_hidden_proto(pmap_getport)
+u_short
+pmap_getport (address, program, version, protocol)
+ struct sockaddr_in *address;
+ u_long program;
+ u_long version;
+ u_int protocol;
{
u_short port = 0;
int socket = -1;
@@ -95,4 +99,4 @@ __pmap_getport (struct sockaddr_in *address, u_long program, u_long version, u_i
address->sin_port = 0;
return port;
}
-strong_alias(__pmap_getport,pmap_getport)
+libc_hidden_def(pmap_getport)
diff --git a/libc/inet/rpc/pmap_clnt.c b/libc/inet/rpc/pmap_clnt.c
index 0c233dd19..8ac41f281 100644
--- a/libc/inet/rpc/pmap_clnt.c
+++ b/libc/inet/rpc/pmap_clnt.c
@@ -34,10 +34,6 @@
* Client interface to pmap rpc service.
*/
-#define clnt_perror __clnt_perror
-#define clntudp_bufcreate __clntudp_bufcreate
-#define xdr_bool __xdr_bool
-
#define __FORCE_GLIBC
#include <features.h>
@@ -52,6 +48,16 @@
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
+libc_hidden_proto(ioctl)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(perror)
+libc_hidden_proto(exit)
+libc_hidden_proto(clnt_perror)
+libc_hidden_proto(clntudp_bufcreate)
+libc_hidden_proto(xdr_bool)
+libc_hidden_proto(xdr_pmap)
+
/*
* Same as get_myaddress, but we try to use the loopback
* interface. portmap caches interfaces, and on DHCP clients,
@@ -66,17 +72,17 @@ __get_myaddress (struct sockaddr_in *addr)
struct ifreq ifreq, *ifr;
int len, loopback = 1;
- if ((s = __socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
{
- __perror ("__get_myaddress: socket");
- __exit (1);
+ perror ("__get_myaddress: socket");
+ exit (1);
}
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
- if (__ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
+ if (ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
{
- __perror (_("__get_myaddress: ioctl (get interface configuration)"));
- __exit (1);
+ perror (_("__get_myaddress: ioctl (get interface configuration)"));
+ exit (1);
}
again:
@@ -84,17 +90,17 @@ __get_myaddress (struct sockaddr_in *addr)
for (len = ifc.ifc_len; len; len -= sizeof ifreq)
{
ifreq = *ifr;
- if (__ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+ if (ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
{
- __perror ("__get_myaddress: ioctl");
- __exit (1);
+ perror ("__get_myaddress: ioctl");
+ exit (1);
}
if ((ifreq.ifr_flags & IFF_UP) && (ifr->ifr_addr.sa_family == AF_INET)
&& ((ifreq.ifr_flags & IFF_LOOPBACK) || (loopback == 0)))
{
*addr = *((struct sockaddr_in *) &ifr->ifr_addr);
addr->sin_port = htons (PMAPPORT);
- __close (s);
+ close (s);
return TRUE;
}
ifr++;
@@ -104,7 +110,7 @@ __get_myaddress (struct sockaddr_in *addr)
loopback = 0;
goto again;
}
- __close (s);
+ close (s);
return FALSE;
}
@@ -116,11 +122,12 @@ static const struct timeval tottimeout = {60, 0};
* Set a mapping between program,version and port.
* Calls the pmap service remotely to do the mapping.
*/
-bool_t attribute_hidden
-__pmap_set (u_long program, u_long version, int protocol, u_short port)
+libc_hidden_proto(pmap_set)
+bool_t
+pmap_set (u_long program, u_long version, int protocol, u_short port)
{
struct sockaddr_in myaddress;
- int socket = -1;
+ int _socket = -1;
CLIENT *client;
struct pmap parms;
bool_t rslt;
@@ -128,7 +135,7 @@ __pmap_set (u_long program, u_long version, int protocol, u_short port)
if (!__get_myaddress (&myaddress))
return FALSE;
client = clntudp_bufcreate (&myaddress, PMAPPROG, PMAPVERS,
- timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
+ timeout, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
if (client == (CLIENT *) NULL)
return (FALSE);
parms.pm_prog = program;
@@ -140,23 +147,24 @@ __pmap_set (u_long program, u_long version, int protocol, u_short port)
tottimeout) != RPC_SUCCESS)
{
clnt_perror (client, _("Cannot register service"));
- return FALSE;
+ rslt = FALSE;
}
CLNT_DESTROY (client);
- /* (void)__close(socket); CLNT_DESTROY closes it */
+ /* (void)close(_socket); CLNT_DESTROY closes it */
return rslt;
}
-strong_alias(__pmap_set,pmap_set)
+libc_hidden_def (pmap_set)
/*
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
-bool_t attribute_hidden
-__pmap_unset (u_long program, u_long version)
+libc_hidden_proto(pmap_unset)
+bool_t
+pmap_unset (u_long program, u_long version)
{
struct sockaddr_in myaddress;
- int socket = -1;
+ int _socket = -1;
CLIENT *client;
struct pmap parms;
bool_t rslt;
@@ -164,7 +172,7 @@ __pmap_unset (u_long program, u_long version)
if (!__get_myaddress (&myaddress))
return FALSE;
client = clntudp_bufcreate (&myaddress, PMAPPROG, PMAPVERS,
- timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
+ timeout, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
if (client == (CLIENT *) NULL)
return FALSE;
parms.pm_prog = program;
@@ -173,7 +181,7 @@ __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;
}
-strong_alias(__pmap_unset,pmap_unset)
+libc_hidden_def (pmap_unset)
diff --git a/libc/inet/rpc/pmap_prot.c b/libc/inet/rpc/pmap_prot.c
index 388c8aeee..0ae2c88f3 100644
--- a/libc/inet/rpc/pmap_prot.c
+++ b/libc/inet/rpc/pmap_prot.c
@@ -38,13 +38,13 @@ static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define xdr_u_long __xdr_u_long
-
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
+libc_hidden_proto(xdr_u_long)
+libc_hidden_proto(xdr_pmap)
bool_t
xdr_pmap (xdrs, regs)
XDR *xdrs;
@@ -57,3 +57,4 @@ xdr_pmap (xdrs, regs)
return xdr_u_long (xdrs, &regs->pm_port);
return FALSE;
}
+libc_hidden_def(xdr_pmap)
diff --git a/libc/inet/rpc/pmap_prot2.c b/libc/inet/rpc/pmap_prot2.c
index 655400f0c..5adc4ee2e 100644
--- a/libc/inet/rpc/pmap_prot2.c
+++ b/libc/inet/rpc/pmap_prot2.c
@@ -38,13 +38,13 @@ static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define xdr_bool __xdr_bool
-#define xdr_reference __xdr_reference
-
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
+libc_hidden_proto(xdr_bool)
+libc_hidden_proto(xdr_reference)
+libc_hidden_proto(xdr_pmap)
/*
* What is going on with linked lists? (!)
@@ -84,6 +84,7 @@ static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
* the net, yet is the data that the pointer points to which is interesting;
* this sounds like a job for xdr_reference!
*/
+libc_hidden_proto(xdr_pmaplist)
bool_t
xdr_pmaplist (xdrs, rp)
XDR *xdrs;
@@ -119,3 +120,4 @@ xdr_pmaplist (xdrs, rp)
rp = freeing ? next : &((*rp)->pml_next);
}
}
+libc_hidden_def(xdr_pmaplist)
diff --git a/libc/inet/rpc/pmap_rmt.c b/libc/inet/rpc/pmap_rmt.c
index dbba18378..badb6a467 100644
--- a/libc/inet/rpc/pmap_rmt.c
+++ b/libc/inet/rpc/pmap_rmt.c
@@ -39,20 +39,6 @@ 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 xdrmem_create __xdrmem_create
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-#define xdr_reference __xdr_reference
-#define xdr_u_long __xdr_u_long
-#define inet_makeaddr __inet_makeaddr
-#define inet_netof __inet_netof
-#define clntudp_create __clntudp_create
-#define setsockopt __setsockopt
-#define recvfrom __recvfrom
-#define sendto __sendto
-#define poll __poll
-
#define __FORCE_GLIBC
#include <features.h>
@@ -73,40 +59,32 @@ 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) attribute_hidden;
+libc_hidden_proto(memset)
+libc_hidden_proto(ioctl)
+libc_hidden_proto(perror)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(authunix_create_default)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_reference)
+libc_hidden_proto(xdr_u_long)
+libc_hidden_proto(xdr_void)
+libc_hidden_proto(xdr_rmtcallres)
+libc_hidden_proto(inet_makeaddr)
+libc_hidden_proto(inet_netof)
+libc_hidden_proto(clntudp_create)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(recvfrom)
+libc_hidden_proto(sendto)
+libc_hidden_proto(poll)
+libc_hidden_proto(fprintf)
-static const struct timeval timeout = {3, 0};
-/*
- * XDR remote call arguments
- * written for XDR_ENCODE direction only
- */
-bool_t attribute_hidden
-__xdr_rmtcall_args (XDR *xdrs, struct rmtcallargs *cap)
-{
- u_int lenposition, argposition, position;
+extern u_long _create_xid (void) attribute_hidden;
- if (xdr_u_long (xdrs, &(cap->prog)) &&
- xdr_u_long (xdrs, &(cap->vers)) &&
- xdr_u_long (xdrs, &(cap->proc)))
- {
- lenposition = XDR_GETPOS (xdrs);
- if (!xdr_u_long (xdrs, &(cap->arglen)))
- return FALSE;
- argposition = XDR_GETPOS (xdrs);
- if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
- return FALSE;
- position = XDR_GETPOS (xdrs);
- cap->arglen = (u_long) position - (u_long) argposition;
- XDR_SETPOS (xdrs, lenposition);
- if (!xdr_u_long (xdrs, &(cap->arglen)))
- return FALSE;
- XDR_SETPOS (xdrs, position);
- return TRUE;
- }
- return FALSE;
-}
-strong_alias(__xdr_rmtcall_args,xdr_rmtcall_args)
+static const struct timeval timeout = {3, 0};
/*
* pmapper remote-call-service interface.
@@ -124,14 +102,14 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
struct timeval tout;
u_long *port_ptr;
{
- int socket = -1;
+ int _socket = -1;
CLIENT *client;
struct rmtcallargs a;
struct rmtcallres r;
enum clnt_stat stat;
addr->sin_port = htons (PMAPPORT);
- client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &socket);
+ client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &_socket);
if (client != (CLIENT *) NULL)
{
a.prog = prog;
@@ -142,7 +120,7 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
r.port_ptr = port_ptr;
r.results_ptr = resp;
r.xdr_results = xdrres;
- stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)__xdr_rmtcall_args,
+ stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)xdr_rmtcall_args,
(caddr_t)&a, (xdrproc_t)xdr_rmtcallres,
(caddr_t)&r, tout);
CLNT_DESTROY (client);
@@ -151,13 +129,46 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
{
stat = RPC_FAILED;
}
- /* (void)__close(socket); CLNT_DESTROY already closed it */
+ /* (void)close(_socket); CLNT_DESTROY already closed it */
addr->sin_port = 0;
return stat;
}
/*
+ * XDR remote call arguments
+ * written for XDR_ENCODE direction only
+ */
+libc_hidden_proto(xdr_rmtcall_args)
+bool_t
+xdr_rmtcall_args (XDR *xdrs, struct rmtcallargs *cap)
+{
+ u_int lenposition, argposition, position;
+
+ if (xdr_u_long (xdrs, &(cap->prog)) &&
+ xdr_u_long (xdrs, &(cap->vers)) &&
+ xdr_u_long (xdrs, &(cap->proc)))
+ {
+ u_long dummy_arglen = 0;
+ lenposition = XDR_GETPOS (xdrs);
+ if (!xdr_u_long (xdrs, &dummy_arglen))
+ return FALSE;
+ argposition = XDR_GETPOS (xdrs);
+ if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
+ return FALSE;
+ position = XDR_GETPOS (xdrs);
+ cap->arglen = (u_long) position - (u_long) argposition;
+ XDR_SETPOS (xdrs, lenposition);
+ if (!xdr_u_long (xdrs, &(cap->arglen)))
+ return FALSE;
+ XDR_SETPOS (xdrs, position);
+ return TRUE;
+ }
+ return FALSE;
+}
+libc_hidden_def(xdr_rmtcall_args)
+
+/*
* XDR remote call results
* written for XDR_DECODE direction only
*/
@@ -177,6 +188,7 @@ xdr_rmtcallres (xdrs, crp)
}
return FALSE;
}
+libc_hidden_def(xdr_rmtcallres)
/*
@@ -198,18 +210,18 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
ifc.ifc_len = UDPMSGSIZE;
ifc.ifc_buf = buf;
- if (__ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
+ if (ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
{
- __perror (_("broadcast: ioctl (get interface configuration)"));
+ perror (_("broadcast: ioctl (get interface configuration)"));
return (0);
}
ifr = ifc.ifc_req;
for (i = 0, n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
{
ifreq = *ifr;
- if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+ if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
{
- __perror (_("broadcast: ioctl (get interface flags)"));
+ perror (_("broadcast: ioctl (get interface flags)"));
continue;
}
if ((ifreq.ifr_flags & IFF_BROADCAST) &&
@@ -218,7 +230,7 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
{
sin = (struct sockaddr_in *) &ifr->ifr_addr;
#ifdef SIOCGIFBRDADDR /* 4.3BSD */
- if (__ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
+ if (ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
{
addrs[i++] = inet_makeaddr (inet_netof
/* Changed to pass struct instead of s_addr member
@@ -277,16 +289,16 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
* initialization: create a socket, a broadcast address, and
* preserialize the arguments into a send buffer.
*/
- if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
- __perror (_("Cannot create socket for broadcast rpc"));
+ perror (_("Cannot create socket for broadcast rpc"));
stat = RPC_CANTSEND;
goto done_broad;
}
#ifdef SO_BROADCAST
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
{
- __perror (_("Cannot set socket option SO_BROADCAST"));
+ perror (_("Cannot set socket option SO_BROADCAST"));
stat = RPC_CANTSEND;
goto done_broad;
}
@@ -294,7 +306,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);
@@ -317,7 +329,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
r.xdr_results = xresults;
r.results_ptr = resultsp;
xdrmem_create (xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
- if ((!xdr_callmsg (xdrs, &msg)) || (!__xdr_rmtcall_args (xdrs, &a)))
+ if ((!xdr_callmsg (xdrs, &msg)) || (!xdr_rmtcall_args (xdrs, &a)))
{
stat = RPC_CANTENCODEARGS;
goto done_broad;
@@ -337,7 +349,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
(struct sockaddr *) &baddr,
sizeof (struct sockaddr)) != outlen)
{
- __perror (_("Cannot send broadcast packet"));
+ perror (_("Cannot send broadcast packet"));
stat = RPC_CANTSEND;
goto done_broad;
}
@@ -362,7 +374,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
case -1: /* some kind of error */
if (errno == EINTR)
goto recv_again;
- __perror (_("Broadcast poll problem"));
+ perror (_("Broadcast poll problem"));
stat = RPC_CANTRECV;
goto done_broad;
@@ -375,7 +387,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
{
if (errno == EINTR)
goto try_again;
- __perror (_("Cannot receive reply to broadcast"));
+ perror (_("Cannot receive reply to broadcast"));
stat = RPC_CANTRECV;
goto done_broad;
}
@@ -422,7 +434,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 c7a5be0db..b4fe8cfe7 100644
--- a/libc/inet/rpc/rcmd.c
+++ b/libc/inet/rpc/rcmd.c
@@ -1,4 +1,32 @@
/*
+ * Copyright (C) 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
* Copyright (c) 1983, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
@@ -10,10 +38,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@@ -35,53 +59,89 @@
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#endif /* LIBC_SCCS and not lint */
-#define bcopy __bcopy
-#define sysconf __sysconf
-#define getline __getline
-#define geteuid __geteuid
-#define seteuid __seteuid
-#define getpwnam_r __getpwnam_r
-#define gethostbyname __gethostbyname
-#define gethostbyname_r __gethostbyname_r
-#define fileno __fileno
-#define sleep __sleep
-#define inet_addr __inet_addr
-#define inet_ntoa __inet_ntoa
-#define herror __herror
-#define bind __bind
-#define connect __connect
-#define sigblock __sigblock
-#define snprintf __snprintf
-#define poll __poll
-#define accept __accept
-#define listen __listen
-#define sigsetmask __sigsetmask
-
-#define __FORCE_GLIBC
+#define __UCLIBC_HIDE_DEPRECATED__
#include <features.h>
-
-#define __USE_GNU
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <alloca.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pwd.h>
#include <sys/param.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
-#include <netdb.h>
+
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <alloca.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <ctype.h>
+#include <string.h>
+#include <libintl.h>
+#include <stdlib.h>
+#ifdef __UCLIBC_HAS_WCHAR__
+#include <wchar.h>
+#endif
+#include <sys/uio.h>
+
+libc_hidden_proto(memcmp)
+libc_hidden_proto(strcat)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(strnlen)
+libc_hidden_proto(memmove)
+libc_hidden_proto(getpid)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(perror)
+libc_hidden_proto(lstat)
+libc_hidden_proto(fstat)
+libc_hidden_proto(tolower)
+libc_hidden_proto(sysconf)
+libc_hidden_proto(getline)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(seteuid)
+libc_hidden_proto(getpwnam_r)
+libc_hidden_proto(gethostbyname)
+libc_hidden_proto(gethostbyname_r)
+libc_hidden_proto(fileno)
+libc_hidden_proto(sleep)
+libc_hidden_proto(inet_addr)
+libc_hidden_proto(inet_ntoa)
+libc_hidden_proto(herror)
+libc_hidden_proto(bind)
+libc_hidden_proto(connect)
+libc_hidden_proto(sigblock)
+libc_hidden_proto(snprintf)
+libc_hidden_proto(poll)
+libc_hidden_proto(accept)
+libc_hidden_proto(listen)
+libc_hidden_proto(sigsetmask)
+libc_hidden_proto(getc_unlocked)
+libc_hidden_proto(__fgetc_unlocked)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(__h_errno_location)
+libc_hidden_proto(stderr)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+libc_hidden_proto(__ctype_tolower_loc)
+#else
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_tolower)
+#endif
-extern int __rresvport(int *alport) attribute_hidden;
-extern int __getc_unlocked (FILE *__stream) attribute_hidden;
+libc_hidden_proto(rresvport)
/* some forward declarations */
static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
@@ -110,11 +170,11 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
int s, lport, timo;
char c;
- pid = __getpid();
+ pid = getpid();
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
hstbuflen = 1024;
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
tmphstbuf = alloca (hstbuflen);
#else
tmphstbuf = malloc (hstbuflen);
@@ -126,7 +186,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
if (herr != NETDB_INTERNAL || errno != ERANGE)
{
__set_h_errno (herr);
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(tmphstbuf);
#endif
herror(*ahost);
@@ -136,7 +196,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
{
/* Enlarge the buffer. */
hstbuflen *= 2;
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
tmphstbuf = alloca (hstbuflen);
#else
if (tmphstbuf) {
@@ -146,7 +206,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
#endif
}
}
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(tmphstbuf);
#endif
#else /* call the non-reentrant version */
@@ -160,7 +220,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
*ahost = hp->h_name;
oldmask = sigblock(sigmask(SIGURG)); /* __sigblock */
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
- s = __rresvport(&lport);
+ s = rresvport(&lport);
if (s < 0) {
if (errno == EAGAIN)
(void)fprintf(stderr,
@@ -170,14 +230,14 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
sigsetmask(oldmask); /* sigsetmask */
return -1;
}
- __fcntl(s, F_SETOWN, pid); /* __fcntl */
+ fcntl(s, F_SETOWN, pid);
sin.sin_family = hp->h_addrtype;
- bcopy(hp->h_addr_list[0], &sin.sin_addr,
+ memmove(&sin.sin_addr, hp->h_addr_list[0],
MIN (sizeof (sin.sin_addr), hp->h_length));
sin.sin_port = rport;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) /* __connect */
break;
- (void)__close(s);
+ (void)close(s);
if (errno == EADDRINUSE) {
lport--;
continue;
@@ -193,9 +253,9 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
(void)fprintf(stderr, "connect to address %s: ",
inet_ntoa(sin.sin_addr));
__set_errno (oerrno);
- __perror(0);
+ perror(0);
hp->h_addr_list++;
- bcopy(hp->h_addr_list[0], &sin.sin_addr,
+ memmove(&sin.sin_addr, hp->h_addr_list[0],
MIN (sizeof (sin.sin_addr), hp->h_length));
(void)fprintf(stderr, "Trying %s...\n",
inet_ntoa(sin.sin_addr));
@@ -207,21 +267,21 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
}
lport--;
if (fd2p == 0) {
- __write(s, "", 1);
+ write(s, "", 1);
lport = 0;
} else {
char num[8];
- int s2 = __rresvport(&lport), s3;
+ int s2 = rresvport(&lport), s3;
socklen_t len = sizeof(from);
if (s2 < 0)
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);
+ (void)close(s2);
goto bad;
}
pfd[0].fd = s;
@@ -232,11 +292,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");
@@ -253,17 +313,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;
}
@@ -273,21 +333,21 @@ 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;
}
-int attribute_hidden __rresvport(int *alport)
+int rresvport(int *alport)
{
struct sockaddr_in sin;
int s;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
- s = __socket(AF_INET, SOCK_STREAM, 0);
+ s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
return -1;
for (;;) {
@@ -295,12 +355,12 @@ int attribute_hidden __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;
}
@@ -308,10 +368,9 @@ int attribute_hidden __rresvport(int *alport)
return -1;
}
-strong_alias(__rresvport,rresvport)
+libc_hidden_def(rresvport)
-int __check_rhosts_file = 1;
-char *__rcmd_errstr;
+static int __check_rhosts_file = 1;
int ruserok(rhost, superuser, ruser, luser)
const char *rhost, *ruser, *luser;
@@ -329,7 +388,7 @@ int ruserok(rhost, superuser, ruser, luser)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
buflen = 1024;
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
buffer = alloca (buflen);
#else
buffer = malloc (buflen);
@@ -339,7 +398,7 @@ int ruserok(rhost, superuser, ruser, luser)
buflen, &hp, &herr) != 0 || hp == NULL)
{
if (herr != NETDB_INTERNAL || errno != ERANGE) {
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
return -1;
@@ -347,7 +406,7 @@ int ruserok(rhost, superuser, ruser, luser)
{
/* Enlarge the buffer. */
buflen *= 2;
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
buffer = alloca (buflen);
#else
if (buffer) {
@@ -357,7 +416,7 @@ int ruserok(rhost, superuser, ruser, luser)
#endif
}
}
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
#else
@@ -366,7 +425,7 @@ int ruserok(rhost, superuser, ruser, luser)
}
#endif
for (ap = hp->h_addr_list; *ap; ++ap) {
- bcopy(*ap, &addr, sizeof(addr));
+ memmove(&addr, *ap, sizeof(addr));
if (iruserok2(addr, superuser, ruser, luser, rhost) == 0)
return 0;
}
@@ -376,7 +435,7 @@ int ruserok(rhost, superuser, ruser, luser)
/* Extremely paranoid file open function. */
static FILE *
-iruserfopen (char *file, uid_t okuser)
+iruserfopen (const char *file, uid_t okuser)
{
struct stat st;
char *cp = NULL;
@@ -385,8 +444,7 @@ iruserfopen (char *file, uid_t okuser)
/* If not a regular file, if owned by someone other than user or
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";
@@ -395,7 +453,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";
@@ -408,7 +466,6 @@ iruserfopen (char *file, uid_t okuser)
/* If there were any problems, quit. */
if (cp != NULL)
{
- __rcmd_errstr = cp;
if (res)
fclose (res);
return NULL;
@@ -456,7 +513,7 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
struct passwd pwdbuf;
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
char *buffer = alloca (buflen);
#else
char *buffer = malloc (buflen);
@@ -465,12 +522,12 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
if (getpwnam_r (luser, &pwdbuf, buffer,
buflen, &pwd) != 0 || pwd == NULL)
{
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
return -1;
}
-#ifndef __ARCH_HAS_MMU__
+#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
#else
@@ -478,10 +535,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
@@ -503,6 +560,7 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
}
/* This is the exported version. */
+int iruserok (u_int32_t raddr, int superuser, const char * ruser, const char * luser);
int iruserok (u_int32_t raddr, int superuser, const char * ruser, const char * luser)
{
return iruserok2 (raddr, superuser, ruser, luser, "-");
@@ -521,6 +579,8 @@ int iruserok (u_int32_t raddr, int superuser, const char * ruser, const char * l
* Returns 0 if ok, -1 if not ok.
*/
int
+__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser);
+int
__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser)
{
return __ivaliduser2(hostf, raddr, luser, ruser, "-");
@@ -546,18 +606,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.. */
}
@@ -587,7 +647,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. */
@@ -606,23 +666,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;
}
/*
@@ -664,16 +724,16 @@ __ivaliduser2(hostf, raddr, luser, ruser, rhost)
}
/* Skip lines that are too long. */
- if (__strchr (p, '\n') == NULL) {
- int ch = __getc_unlocked (hostf);
+ if (strchr (p, '\n') == NULL) {
+ 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/rexec.c b/libc/inet/rpc/rexec.c
index 239e87fb0..bbbaac645 100644
--- a/libc/inet/rpc/rexec.c
+++ b/libc/inet/rpc/rexec.c
@@ -27,17 +27,6 @@
* SUCH DAMAGE.
*/
-#define getsockname __getsockname
-#define getnameinfo __getnameinfo
-#define getaddrinfo __getaddrinfo
-#define freeaddrinfo __freeaddrinfo
-#define sleep __sleep
-#define atoi __atoi
-#define connect __connect
-#define snprintf __snprintf
-#define accept __accept
-#define listen __listen
-
#define __FORCE_GLIBC
#include <features.h>
#include <sys/types.h>
@@ -53,15 +42,37 @@
#include <string.h>
#include <unistd.h>
+libc_hidden_proto(memset)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(close)
+libc_hidden_proto(socket)
+libc_hidden_proto(perror)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(snprintf)
+libc_hidden_proto(getsockname)
+libc_hidden_proto(getnameinfo)
+libc_hidden_proto(getaddrinfo)
+libc_hidden_proto(freeaddrinfo)
+libc_hidden_proto(sleep)
+libc_hidden_proto(atoi)
+libc_hidden_proto(connect)
+libc_hidden_proto(accept)
+libc_hidden_proto(listen)
+
#define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
extern int __libc_sa_len (sa_family_t __af) __THROW attribute_hidden;
int rexecoptions;
-char ahostbuf[NI_MAXHOST];
-extern int __ruserpass(const char *host, const char **aname, const char **apass) attribute_hidden;
+char ahostbuf[NI_MAXHOST] attribute_hidden;
+extern int ruserpass(const char *host, const char **aname, const char **apass) attribute_hidden;
+libc_hidden_proto(ruserpass)
-int attribute_hidden
-__rexec_af(char **ahost, int rport, const char *name, const char *pass, const char *cmd, int *fd2p, sa_family_t af)
+libc_hidden_proto(rexec_af)
+int
+rexec_af(char **ahost, int rport, const char *name, const char *pass, const char *cmd, int *fd2p, sa_family_t af)
{
struct sockaddr_storage sa2, from;
struct addrinfo hints, *res0;
@@ -76,7 +87,7 @@ __rexec_af(char **ahost, int rport, const char *name, const char *pass, const ch
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;
@@ -87,51 +98,51 @@ __rexec_af(char **ahost, int rport, const char *name, const char *pass, const ch
}
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;
}
else{
*ahost = NULL;
}
- __ruserpass(res0->ai_canonname, &name, &pass);
+ ruserpass(res0->ai_canonname, &name, &pass);
retry:
- s = __socket(res0->ai_family, res0->ai_socktype, 0);
+ s = socket(res0->ai_family, res0->ai_socktype, 0);
if (s < 0) {
- __perror("rexec: socket");
+ perror("rexec: socket");
return (-1);
}
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;
}
- __perror(res0->ai_canonname);
+ perror(res0->ai_canonname);
return (-1);
}
if (fd2p == 0) {
- (void) __write(s, "", 1);
+ (void) write(s, "", 1);
port = 0;
} else {
char num[32];
int s2, sa2len;
- s2 = __socket(res0->ai_family, res0->ai_socktype, 0);
+ 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);
+ perror("getsockname");
+ (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;
@@ -139,23 +150,23 @@ retry:
NULL, 0, servbuff, sizeof(servbuff),
NI_NUMERICSERV))
port = atoi(servbuff);
- (void) __sprintf(num, "%u", port);
- (void) __write(s, num, __strlen(num)+1);
+ (void) sprintf(num, "%u", port);
+ (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");
+ perror("accept");
port = 0;
goto bad;
}
}
*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. */
@@ -164,13 +175,13 @@ retry:
if (pass != orig_pass)
free ((char *) pass);
- if (__read(s, &c, 1) != 1) {
- __perror(*ahost);
+ 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;
}
@@ -180,12 +191,12 @@ retry:
return (s);
bad:
if (port)
- (void) __close(*fd2p);
- (void) __close(s);
+ (void) close(*fd2p);
+ (void) close(s);
freeaddrinfo(res0);
return (-1);
}
-strong_alias(__rexec_af,rexec_af)
+libc_hidden_def(rexec_af)
int
rexec(ahost, rport, name, pass, cmd, fd2p)
@@ -194,5 +205,5 @@ rexec(ahost, rport, name, pass, cmd, fd2p)
const char *name, *pass, *cmd;
int *fd2p;
{
- return __rexec_af(ahost, rport, name, pass, cmd, fd2p, AF_INET);
+ return rexec_af(ahost, rport, name, pass, cmd, fd2p, AF_INET);
}
diff --git a/libc/inet/rpc/rpc_callmsg.c b/libc/inet/rpc/rpc_cmsg.c
index 6368e5920..b47a67c71 100644
--- a/libc/inet/rpc/rpc_callmsg.c
+++ b/libc/inet/rpc/rpc_cmsg.c
@@ -38,12 +38,6 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
*
*/
-#define xdr_enum __xdr_enum
-#define xdr_opaque __xdr_opaque
-#define xdr_u_int __xdr_u_int
-#define xdr_u_long __xdr_u_long
-#define xdr_opaque_auth __xdr_opaque_auth
-
#define __FORCE_GLIBC
#include <features.h>
@@ -51,11 +45,19 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
#include <sys/param.h>
#include <rpc/rpc.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(xdr_enum)
+libc_hidden_proto(xdr_opaque)
+libc_hidden_proto(xdr_u_int)
+libc_hidden_proto(xdr_u_long)
+libc_hidden_proto(xdr_opaque_auth)
+
/*
* XDR a call message
*/
-bool_t attribute_hidden
-__xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
+libc_hidden_proto(xdr_callmsg)
+bool_t
+xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
{
int32_t *buf;
struct opaque_auth *oa;
@@ -91,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);
buf = (int32_t *) ((char *) buf + RNDUP (oa->oa_length));
}
oa = &cmsg->rm_call.cb_verf;
@@ -99,7 +101,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));
*/
@@ -147,7 +149,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));
@@ -187,7 +189,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));
@@ -210,4 +212,4 @@ __xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
return xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_verf));
return FALSE;
}
-strong_alias(__xdr_callmsg,xdr_callmsg)
+libc_hidden_def(xdr_callmsg)
diff --git a/libc/inet/rpc/rpc_dtablesize.c b/libc/inet/rpc/rpc_dtablesize.c
index ede7120b3..11a7ad457 100644
--- a/libc/inet/rpc/rpc_dtablesize.c
+++ b/libc/inet/rpc/rpc_dtablesize.c
@@ -31,8 +31,6 @@
static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
#endif
-#define getdtablesize __getdtablesize
-
#define __FORCE_GLIBC
#define __USE_BSD
#include <features.h>
@@ -40,12 +38,15 @@ static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
#include <unistd.h>
#include <rpc/clnt.h>
+libc_hidden_proto(getdtablesize)
+
/*
* Cache the result of getdtablesize(), so we don't have to do an
* expensive system call every time.
*/
-int attribute_hidden
-_rpc_dtablesize_internal (void)
+libc_hidden_proto(_rpc_dtablesize)
+int
+_rpc_dtablesize(void)
{
static int size;
@@ -54,4 +55,4 @@ _rpc_dtablesize_internal (void)
return size;
}
-strong_alias(_rpc_dtablesize_internal,_rpc_dtablesize)
+libc_hidden_def(_rpc_dtablesize)
diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h
index d899b401d..4826d362b 100644
--- a/libc/inet/rpc/rpc_private.h
+++ b/libc/inet/rpc/rpc_private.h
@@ -4,10 +4,8 @@
/* 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 ())
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(stderr)
/*
* Multi-threaded support
diff --git a/libc/inet/rpc/rpc_prot.c b/libc/inet/rpc/rpc_prot.c
index afc1dccd1..ebe6c3128 100644
--- a/libc/inet/rpc/rpc_prot.c
+++ b/libc/inet/rpc/rpc_prot.c
@@ -44,12 +44,6 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
* routines are also in this program.
*/
-#define xdr_bytes __xdr_bytes
-#define xdr_union __xdr_union
-#define xdr_enum __xdr_enum
-#define xdr_opaque __xdr_opaque
-#define xdr_u_long __xdr_u_long
-
#define __FORCE_GLIBC
#include <features.h>
@@ -57,14 +51,21 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/rpc.h>
+libc_hidden_proto(xdr_bytes)
+libc_hidden_proto(xdr_union)
+libc_hidden_proto(xdr_enum)
+libc_hidden_proto(xdr_opaque)
+libc_hidden_proto(xdr_u_long)
+
/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
/*
* XDR an opaque authentication struct
* (see auth.h)
*/
-bool_t attribute_hidden
-__xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
+libc_hidden_proto(xdr_opaque_auth)
+bool_t
+xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
{
if (xdr_enum (xdrs, &(ap->oa_flavor)))
@@ -72,7 +73,7 @@ __xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
&ap->oa_length, MAX_AUTH_BYTES);
return FALSE;
}
-strong_alias(__xdr_opaque_auth,xdr_opaque_auth)
+libc_hidden_def(xdr_opaque_auth)
/*
* XDR a DES block
@@ -88,11 +89,13 @@ xdr_des_block (XDR *xdrs, des_block *blkp)
/*
* XDR the MSG_ACCEPTED part of a reply message union
*/
+extern bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar);
+libc_hidden_proto(xdr_accepted_reply)
bool_t
xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
{
/* personalized union, rather than calling xdr_union */
- if (!__xdr_opaque_auth (xdrs, &(ar->ar_verf)))
+ if (!xdr_opaque_auth (xdrs, &(ar->ar_verf)))
return FALSE;
if (!xdr_enum (xdrs, (enum_t *) & (ar->ar_stat)))
return FALSE;
@@ -109,10 +112,13 @@ xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
}
return TRUE; /* TRUE => open ended set of problems */
}
+libc_hidden_def(xdr_accepted_reply)
/*
* XDR the MSG_DENIED part of a reply message union
*/
+extern bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr);
+libc_hidden_proto(xdr_rejected_reply)
bool_t
xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
{
@@ -131,6 +137,7 @@ xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
}
return FALSE;
}
+libc_hidden_def(xdr_rejected_reply)
static const struct xdr_discrim reply_dscrm[3] =
{
@@ -141,8 +148,9 @@ static const struct xdr_discrim reply_dscrm[3] =
/*
* XDR a reply message
*/
-bool_t attribute_hidden
-__xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg)
+libc_hidden_proto(xdr_replymsg)
+bool_t
+xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg)
{
if (xdr_u_long (xdrs, &(rmsg->rm_xid)) &&
xdr_enum (xdrs, (enum_t *) & (rmsg->rm_direction)) &&
@@ -152,7 +160,7 @@ __xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg)
NULL_xdrproc_t);
return FALSE;
}
-strong_alias(__xdr_replymsg,xdr_replymsg)
+libc_hidden_def(xdr_replymsg)
/*
@@ -160,8 +168,9 @@ strong_alias(__xdr_replymsg,xdr_replymsg)
* The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
-bool_t attribute_hidden
-__xdr_callhdr (XDR *xdrs, struct rpc_msg *cmsg)
+libc_hidden_proto(xdr_callhdr)
+bool_t
+xdr_callhdr (XDR *xdrs, struct rpc_msg *cmsg)
{
cmsg->rm_direction = CALL;
@@ -175,7 +184,7 @@ __xdr_callhdr (XDR *xdrs, struct rpc_msg *cmsg)
return xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers));
return FALSE;
}
-strong_alias(__xdr_callhdr,xdr_callhdr)
+libc_hidden_def(xdr_callhdr)
/* ************************** Client utility routine ************* */
@@ -240,8 +249,9 @@ rejected (enum reject_stat rjct_stat,
/*
* given a reply message, fills in the error
*/
-void attribute_hidden
-__seterr_reply (struct rpc_msg *msg,
+libc_hidden_proto(_seterr_reply)
+void
+_seterr_reply (struct rpc_msg *msg,
struct rpc_err *error)
{
/* optimized for normal, SUCCESSful case */
@@ -285,4 +295,4 @@ __seterr_reply (struct rpc_msg *msg,
break;
}
}
-strong_alias(__seterr_reply,_seterr_reply)
+libc_hidden_def(_seterr_reply)
diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c
index f716444a3..4031b77be 100644
--- a/libc/inet/rpc/rpc_thread.c
+++ b/libc/inet/rpc/rpc_thread.c
@@ -1,9 +1,20 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#define __FORCE_GLIBC
#include <features.h>
#include <stdio.h>
#include <assert.h>
#include "rpc_private.h"
+libc_hidden_proto(__rpc_thread_svc_fdset)
+libc_hidden_proto(__rpc_thread_createerr)
+libc_hidden_proto(__rpc_thread_svc_pollfd)
+libc_hidden_proto(__rpc_thread_svc_max_pollfd)
+
#ifdef __UCLIBC_HAS_THREADS__
#include <bits/libc-tsd.h>
@@ -77,8 +88,8 @@ __rpc_thread_variables (void)
#undef svc_pollfd
#undef svc_max_pollfd
-fd_set attribute_hidden *
-__rpc_thread_svc_fdset_internal (void)
+fd_set *
+__rpc_thread_svc_fdset (void)
{
struct rpc_thread_variables *tvp;
@@ -87,10 +98,9 @@ __rpc_thread_svc_fdset_internal (void)
return &svc_fdset;
return &tvp->svc_fdset_s;
}
-strong_alias(__rpc_thread_svc_fdset_internal,__rpc_thread_svc_fdset)
-struct rpc_createerr attribute_hidden *
-__rpc_thread_createerr_internal (void)
+struct rpc_createerr *
+__rpc_thread_createerr (void)
{
struct rpc_thread_variables *tvp;
@@ -99,11 +109,9 @@ __rpc_thread_createerr_internal (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)
+struct pollfd **
+__rpc_thread_svc_pollfd (void)
{
struct rpc_thread_variables *tvp;
@@ -112,10 +120,9 @@ __rpc_thread_svc_pollfd_internal (void)
return &svc_pollfd;
return &tvp->svc_pollfd_s;
}
-strong_alias(__rpc_thread_svc_pollfd_internal,__rpc_thread_svc_pollfd)
-int attribute_hidden *
-__rpc_thread_svc_max_pollfd_internal (void)
+int *
+__rpc_thread_svc_max_pollfd (void)
{
struct rpc_thread_variables *tvp;
@@ -124,7 +131,6 @@ __rpc_thread_svc_max_pollfd_internal (void)
return &svc_max_pollfd;
return &tvp->svc_max_pollfd_s;
}
-strong_alias(__rpc_thread_svc_max_pollfd_internal,__rpc_thread_svc_max_pollfd)
#else
#undef svc_fdset
@@ -132,34 +138,33 @@ strong_alias(__rpc_thread_svc_max_pollfd_internal,__rpc_thread_svc_max_pollfd)
#undef svc_pollfd
#undef svc_max_pollfd
-fd_set attribute_hidden * __rpc_thread_svc_fdset_internal (void)
+fd_set * __rpc_thread_svc_fdset (void)
{
extern fd_set svc_fdset;
return &(svc_fdset);
}
-strong_alias(__rpc_thread_svc_fdset_internal,__rpc_thread_svc_fdset)
-struct rpc_createerr attribute_hidden * __rpc_thread_createerr_internal (void)
+struct rpc_createerr * __rpc_thread_createerr (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)
+struct pollfd ** __rpc_thread_svc_pollfd (void)
{
extern struct pollfd *svc_pollfd;
return &(svc_pollfd);
}
-strong_alias(__rpc_thread_svc_pollfd_internal,__rpc_thread_svc_pollfd)
-int attribute_hidden * __rpc_thread_svc_max_pollfd_internal (void)
+int * __rpc_thread_svc_max_pollfd (void)
{
extern int svc_max_pollfd;
return &(svc_max_pollfd);
}
-strong_alias(__rpc_thread_svc_max_pollfd_internal,__rpc_thread_svc_max_pollfd)
#endif /* __UCLIBC_HAS_THREADS__ */
+libc_hidden_def(__rpc_thread_svc_fdset)
+libc_hidden_def(__rpc_thread_createerr)
+libc_hidden_def(__rpc_thread_svc_pollfd)
+libc_hidden_def(__rpc_thread_svc_max_pollfd)
diff --git a/libc/inet/rpc/rtime.c b/libc/inet/rpc/rtime.c
index b4bbca19c..fc4cfe548 100644
--- a/libc/inet/rpc/rtime.c
+++ b/libc/inet/rpc/rtime.c
@@ -43,11 +43,6 @@ static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 S
* what unix uses.
*/
-#define connect __connect
-#define recvfrom __recvfrom
-#define sendto __sendto
-#define poll __poll
-
#define __FORCE_GLIBC
#include <features.h>
@@ -63,6 +58,14 @@ static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 S
#include <errno.h>
#include <netinet/in.h>
+libc_hidden_proto(read)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(connect)
+libc_hidden_proto(recvfrom)
+libc_hidden_proto(sendto)
+libc_hidden_proto(poll)
+
#define NYEARS (u_long)(1970 - 1900)
#define TOFFSET (u_long)(60*60*24*(365*NYEARS + (NYEARS/4)))
@@ -74,7 +77,7 @@ do_close (int s)
int save;
save = errno;
- __close (s);
+ close (s);
__set_errno (save);
}
@@ -96,7 +99,7 @@ rtime (struct sockaddr_in *addrp, struct rpc_timeval *timep,
else
type = SOCK_DGRAM;
- s = __socket (AF_INET, type, 0);
+ s = socket (AF_INET, type, 0);
if (s < 0)
return (-1);
@@ -138,7 +141,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 728ea5bb7..97f1284b3 100644
--- a/libc/inet/rpc/ruserpass.c
+++ b/libc/inet/rpc/ruserpass.c
@@ -27,14 +27,6 @@
* SUCH DAMAGE.
*/
-#define __fsetlocking __fsetlocking_internal
-#define getgid __getgid
-#define getuid __getuid
-#define getegid __getegid
-#define geteuid __geteuid
-#define gethostname __gethostname
-#define fileno __fileno
-
#define __FORCE_GLIBC
#include <features.h>
#include <sys/types.h>
@@ -50,7 +42,27 @@
#include <string.h>
#include <unistd.h>
-extern int __getc_unlocked (FILE *__stream) attribute_hidden;
+libc_hidden_proto(strcat)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcasecmp)
+libc_hidden_proto(strncasecmp)
+libc_hidden_proto(getenv)
+libc_hidden_proto(printf)
+libc_hidden_proto(fstat)
+libc_hidden_proto(__fsetlocking)
+libc_hidden_proto(getgid)
+libc_hidden_proto(getuid)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(gethostname)
+libc_hidden_proto(fileno)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(getc_unlocked)
+libc_hidden_proto(__fgetc_unlocked)
#define _(X) (X)
/* #include "ftp_var.h" */
@@ -101,7 +113,9 @@ static const struct toktab {
-int attribute_hidden __ruserpass(const char *host, const char **aname, const char **apass)
+extern int ruserpass(const char *host, const char **aname, const char **apass);
+libc_hidden_proto(ruserpass)
+int ruserpass(const char *host, const char **aname, const char **apass)
{
char *hdir, *buf, *tmp;
char myname[1024], *mydomain;
@@ -111,20 +125,20 @@ int attribute_hidden __ruserpass(const char *host, const char **aname, const cha
/* Give up when running a setuid or setgid app. */
if ((getuid() != geteuid()) || getgid() != getegid())
return -1;
- hdir = __getenv("HOME");
+ hdir = getenv("HOME");
if (hdir == NULL) {
/* If we can't get HOME, fail instead of trying ".",
which is no improvement. */
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)
- __printf("%s", buf);
+ printf("%s", buf);
return (0);
}
/* No threads use this stream. */
@@ -133,9 +147,9 @@ int attribute_hidden __ruserpass(const char *host, const char **aname, const cha
#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) {
@@ -153,11 +167,11 @@ next:
* or official hostname. Also allow match of
* incompletely-specified host in local domain.
*/
- if (__strcasecmp(host, tokval) == 0)
+ if (strcasecmp(host, tokval) == 0)
goto match;
- if ((tmp = __strchr(host, '.')) != NULL &&
- __strcasecmp(tmp, mydomain) == 0 &&
- __strncasecmp(host, tokval, tmp - host) == 0 &&
+ if ((tmp = strchr(host, '.')) != NULL &&
+ strcasecmp(tmp, mydomain) == 0 &&
+ strncasecmp(host, tokval, tmp - host) == 0 &&
tokval[tmp - host] == '\0')
goto match;
continue;
@@ -169,49 +183,49 @@ 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"));
+ 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") &&
- __fstat(fileno(cfile), &stb) >= 0 &&
+ if (strcmp(*aname, "anonymous") &&
+ 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."));
+ printf(_("Error: .netrc file is readable by others."));
+ printf(_("Remove password or make file unreadable by others."));
goto bad;
}
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"));
+ printf(_("out of memory"));
goto bad;
}
- *apass = __strcpy(newp, tokval);
+ *apass = strcpy(newp, tokval);
}
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.");
+ printf("Error: .netrc file is readable by others.");
+ printf("Remove account or make file unreadable by others.");
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;
@@ -221,33 +235,33 @@ 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");
+ printf("Missing macdef name argument.\n");
goto bad;
}
if (macnum == 16) {
- __printf("Limit of 16 macros have already been defined\n");
+ printf("Limit of 16 macros have already been defined\n");
goto bad;
}
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;
}
if (c == EOF) {
- __printf("Macro definition missing null line terminator.\n");
+ printf("Macro definition missing null line terminator.\n");
goto bad;
}
*tmp = '\0';
if (c != '\n') {
- while ((c=__getc_unlocked(cfile)) != EOF
+ while ((c=getc_unlocked(cfile)) != EOF
&& c != '\n');
}
if (c == EOF) {
- __printf("Macro definition missing null line terminator.\n");
+ printf("Macro definition missing null line terminator.\n");
goto bad;
}
if (macnum == 0) {
@@ -258,8 +272,8 @@ next:
}
tmp = macros[macnum].mac_start;
while (tmp != macbuf + 4096) {
- if ((c=__getc_unlocked(cfile)) == EOF) {
- __printf("Macro definition missing null line terminator.\n");
+ if ((c=getc_unlocked(cfile)) == EOF) {
+ printf("Macro definition missing null line terminator.\n");
goto bad;
}
*tmp = c;
@@ -273,13 +287,13 @@ next:
tmp++;
}
if (tmp == macbuf + 4096) {
- __printf("4K macro buffer exceeded\n");
+ printf("4K macro buffer exceeded\n");
goto bad;
}
#endif
break;
default:
- __printf(_("Unknown .netrc keyword %s"), tokval);
+ printf(_("Unknown .netrc keyword %s"), tokval);
break;
}
goto done;
@@ -291,7 +305,7 @@ bad:
(void) fclose(cfile);
return (-1);
}
-strong_alias(__ruserpass,ruserpass)
+libc_hidden_def(ruserpass)
static int
token()
@@ -302,24 +316,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;
}
}
@@ -327,7 +341,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/sa_len.c b/libc/inet/rpc/sa_len.c
index 21a6417af..3b37eba44 100644
--- a/libc/inet/rpc/sa_len.c
+++ b/libc/inet/rpc/sa_len.c
@@ -31,7 +31,8 @@
#include <netrose/rose.h>
#endif
-int attribute_hidden __libc_sa_len (sa_family_t af)
+int __libc_sa_len (sa_family_t af) attribute_hidden;
+int __libc_sa_len (sa_family_t af)
{
switch (af)
{
diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c
index 168c6e406..d41d7644c 100644
--- a/libc/inet/rpc/svc.c
+++ b/libc/inet/rpc/svc.c
@@ -36,19 +36,7 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define ffs __ffs
-#define pmap_set __pmap_set
-#define pmap_unset __pmap_unset
-#define _authenticate _authenticate_internal
-#define _rpc_dtablesize _rpc_dtablesize_internal
-/* used by svc_[max_]pollfd */
-#define __rpc_thread_svc_pollfd __rpc_thread_svc_pollfd_internal
-#define __rpc_thread_svc_max_pollfd __rpc_thread_svc_max_pollfd_internal
-/* used by svc_fdset */
-#define __rpc_thread_svc_fdset __rpc_thread_svc_fdset_internal
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
@@ -58,6 +46,17 @@
#include <rpc/pmap_clnt.h>
#include <sys/poll.h>
+libc_hidden_proto(ffs)
+libc_hidden_proto(pmap_set)
+libc_hidden_proto(pmap_unset)
+libc_hidden_proto(_authenticate)
+libc_hidden_proto(_rpc_dtablesize)
+/* used by svc_[max_]pollfd */
+libc_hidden_proto(__rpc_thread_svc_pollfd)
+libc_hidden_proto(__rpc_thread_svc_max_pollfd)
+/* used by svc_fdset */
+libc_hidden_proto(__rpc_thread_svc_fdset)
+
#ifdef __UCLIBC_HAS_THREADS__
#define xports (*(SVCXPRT ***)&RPC_THREAD_VARIABLE(svc_xports_s))
#else
@@ -86,8 +85,9 @@ static struct svc_callout *svc_head;
/* *************** SVCXPRT related stuff **************** */
/* Activate a transport handle. */
-void attribute_hidden
-__xprt_register (SVCXPRT *xprt)
+libc_hidden_proto(xprt_register)
+void
+xprt_register (SVCXPRT *xprt)
{
register int sock = xprt->xp_sock;
register int i;
@@ -126,11 +126,12 @@ __xprt_register (SVCXPRT *xprt)
POLLRDNORM | POLLRDBAND);
}
}
-strong_alias(__xprt_register,xprt_register)
+libc_hidden_def(xprt_register)
/* De-activate a transport handle. */
-void attribute_hidden
-__xprt_unregister (SVCXPRT *xprt)
+libc_hidden_proto(xprt_unregister)
+void
+xprt_unregister (SVCXPRT *xprt)
{
register int sock = xprt->xp_sock;
register int i;
@@ -147,7 +148,7 @@ __xprt_unregister (SVCXPRT *xprt)
svc_pollfd[i].fd = -1;
}
}
-strong_alias(__xprt_unregister,xprt_unregister)
+libc_hidden_def(xprt_unregister)
/* ********************** CALLOUT list related stuff ************* */
@@ -174,8 +175,9 @@ done:
/* Add a service program to the callout list.
The dispatch routine will be called when a rpc request for this
program number comes in. */
-bool_t attribute_hidden
-__svc_register (SVCXPRT * xprt, rpcprog_t prog, rpcvers_t vers,
+libc_hidden_proto(svc_register)
+bool_t
+svc_register (SVCXPRT * xprt, rpcprog_t prog, rpcvers_t vers,
void (*dispatch) (struct svc_req *, SVCXPRT *),
rpcproc_t protocol)
{
@@ -205,11 +207,12 @@ pmap_it:
return TRUE;
}
-strong_alias(__svc_register,svc_register)
+libc_hidden_def(svc_register)
/* Remove a service program from the callout list. */
-void attribute_hidden
-__svc_unregister (rpcprog_t prog, rpcvers_t vers)
+libc_hidden_proto(svc_unregister)
+void
+svc_unregister (rpcprog_t prog, rpcvers_t vers)
{
struct svc_callout *prev;
register struct svc_callout *s;
@@ -227,13 +230,14 @@ __svc_unregister (rpcprog_t prog, rpcvers_t vers)
/* now unregister the information with the local binder service */
pmap_unset (prog, vers);
}
-strong_alias(__svc_unregister,svc_unregister)
+libc_hidden_def(svc_unregister)
/* ******************* REPLY GENERATION ROUTINES ************ */
/* Send a reply to an rpc request */
-bool_t attribute_hidden
-__svc_sendreply (register SVCXPRT *xprt, xdrproc_t xdr_results,
+libc_hidden_proto(svc_sendreply)
+bool_t
+svc_sendreply (register SVCXPRT *xprt, xdrproc_t xdr_results,
caddr_t xdr_location)
{
struct rpc_msg rply;
@@ -246,7 +250,7 @@ __svc_sendreply (register SVCXPRT *xprt, xdrproc_t xdr_results,
rply.acpted_rply.ar_results.proc = xdr_results;
return SVC_REPLY (xprt, &rply);
}
-strong_alias(__svc_sendreply,svc_sendreply)
+libc_hidden_def(svc_sendreply)
/* No procedure error reply */
void
@@ -262,8 +266,9 @@ svcerr_noproc (register SVCXPRT *xprt)
}
/* Can't decode args error reply */
-void attribute_hidden
-__svcerr_decode (register SVCXPRT *xprt)
+libc_hidden_proto(svcerr_decode)
+void
+svcerr_decode (register SVCXPRT *xprt)
{
struct rpc_msg rply;
@@ -273,7 +278,7 @@ __svcerr_decode (register SVCXPRT *xprt)
rply.acpted_rply.ar_stat = GARBAGE_ARGS;
SVC_REPLY (xprt, &rply);
}
-strong_alias(__svcerr_decode,svcerr_decode)
+libc_hidden_def(svcerr_decode)
/* Some system error */
void
@@ -289,8 +294,9 @@ svcerr_systemerr (register SVCXPRT *xprt)
}
/* Authentication error reply */
-void attribute_hidden
-__svcerr_auth (SVCXPRT *xprt, enum auth_stat why)
+libc_hidden_proto(svcerr_auth)
+void
+svcerr_auth (SVCXPRT *xprt, enum auth_stat why)
{
struct rpc_msg rply;
@@ -300,18 +306,19 @@ __svcerr_auth (SVCXPRT *xprt, enum auth_stat why)
rply.rjcted_rply.rj_why = why;
SVC_REPLY (xprt, &rply);
}
-strong_alias(__svcerr_auth,svcerr_auth)
+libc_hidden_def(svcerr_auth)
/* Auth too weak error reply */
void
svcerr_weakauth (SVCXPRT *xprt)
{
- __svcerr_auth (xprt, AUTH_TOOWEAK);
+ svcerr_auth (xprt, AUTH_TOOWEAK);
}
/* Program unavailable error reply */
-void attribute_hidden
-__svcerr_noprog (register SVCXPRT *xprt)
+libc_hidden_proto(svcerr_noprog)
+void
+svcerr_noprog (register SVCXPRT *xprt)
{
struct rpc_msg rply;
@@ -321,11 +328,12 @@ __svcerr_noprog (register SVCXPRT *xprt)
rply.acpted_rply.ar_stat = PROG_UNAVAIL;
SVC_REPLY (xprt, &rply);
}
-strong_alias(__svcerr_noprog,svcerr_noprog)
+libc_hidden_def(svcerr_noprog)
/* Program version mismatch error reply */
-void attribute_hidden
-__svcerr_progvers (register SVCXPRT *xprt, rpcvers_t low_vers,
+libc_hidden_proto(svcerr_progvers)
+void
+svcerr_progvers (register SVCXPRT *xprt, rpcvers_t low_vers,
rpcvers_t high_vers)
{
struct rpc_msg rply;
@@ -338,7 +346,7 @@ __svcerr_progvers (register SVCXPRT *xprt, rpcvers_t low_vers,
rply.acpted_rply.ar_vers.high = high_vers;
SVC_REPLY (xprt, &rply);
}
-strong_alias(__svcerr_progvers,svcerr_progvers)
+libc_hidden_def(svcerr_progvers)
/* ******************* SERVER INPUT STUFF ******************* */
@@ -358,8 +366,9 @@ strong_alias(__svcerr_progvers,svcerr_progvers)
* is mallocated in kernel land.
*/
-void attribute_hidden
-__svc_getreq_common (const int fd)
+libc_hidden_proto(svc_getreq_common)
+void
+svc_getreq_common (const int fd)
{
enum xprt_stat stat;
struct rpc_msg msg;
@@ -403,7 +412,7 @@ __svc_getreq_common (const int fd)
}
else if ((why = _authenticate (&r, &msg)) != AUTH_OK)
{
- __svcerr_auth (xprt, why);
+ svcerr_auth (xprt, why);
goto call_done;
}
@@ -433,9 +442,9 @@ __svc_getreq_common (const int fd)
/* if we got here, the program or version
is not served ... */
if (prog_found)
- __svcerr_progvers (xprt, low_vers, high_vers);
+ svcerr_progvers (xprt, low_vers, high_vers);
else
- __svcerr_noprog (xprt);
+ svcerr_noprog (xprt);
/* Fall through to ... */
}
call_done:
@@ -447,10 +456,11 @@ __svc_getreq_common (const int fd)
}
while (stat == XPRT_MOREREQS);
}
-strong_alias(__svc_getreq_common,svc_getreq_common)
+libc_hidden_def(svc_getreq_common)
-void attribute_hidden
-__svc_getreqset (fd_set *readfds)
+libc_hidden_proto(svc_getreqset)
+void
+svc_getreqset (fd_set *readfds)
{
register u_int32_t mask;
register u_int32_t *maskp;
@@ -462,23 +472,25 @@ __svc_getreqset (fd_set *readfds)
maskp = (u_int32_t *) readfds->fds_bits;
for (sock = 0; sock < setsize; sock += 32)
for (mask = *maskp++; (bit = ffs (mask)); mask ^= (1 << (bit - 1)))
- __svc_getreq_common (sock + bit - 1);
+ svc_getreq_common (sock + bit - 1);
}
-strong_alias(__svc_getreqset,svc_getreqset)
+libc_hidden_def(svc_getreqset)
-void attribute_hidden
-__svc_getreq (int rdfds)
+libc_hidden_proto(svc_getreq)
+void
+svc_getreq (int rdfds)
{
fd_set readfds;
FD_ZERO (&readfds);
readfds.fds_bits[0] = rdfds;
- __svc_getreqset (&readfds);
+ svc_getreqset (&readfds);
}
-strong_alias(__svc_getreq,svc_getreq)
+libc_hidden_def(svc_getreq)
-void attribute_hidden
-__svc_getreq_poll (struct pollfd *pfdp, int pollretval)
+libc_hidden_proto(svc_getreq_poll)
+void
+svc_getreq_poll (struct pollfd *pfdp, int pollretval)
{
register int i;
register int fds_found;
@@ -493,13 +505,13 @@ __svc_getreq_poll (struct pollfd *pfdp, int pollretval)
++fds_found;
if (p->revents & POLLNVAL)
- __xprt_unregister (xports[p->fd]);
+ xprt_unregister (xports[p->fd]);
else
- __svc_getreq_common (p->fd);
+ svc_getreq_common (p->fd);
}
}
}
-strong_alias(__svc_getreq_poll,svc_getreq_poll)
+libc_hidden_def(svc_getreq_poll)
#ifdef __UCLIBC_HAS_THREADS__
@@ -508,7 +520,7 @@ void attribute_hidden __rpc_thread_svc_cleanup (void)
struct svc_callout *svcp;
while ((svcp = svc_head) != NULL)
- __svc_unregister (svcp->sc_prog, svcp->sc_vers);
+ svc_unregister (svcp->sc_prog, svcp->sc_vers);
}
#endif /* __UCLIBC_HAS_THREADS__ */
diff --git a/libc/inet/rpc/svc_auth.c b/libc/inet/rpc/svc_auth.c
index 812463396..1a5dcf0ca 100644
--- a/libc/inet/rpc/svc_auth.c
+++ b/libc/inet/rpc/svc_auth.c
@@ -101,8 +101,9 @@ svcauthsw[] =
* There is an assumption that any flavour less than AUTH_NULL is
* invalid.
*/
-enum auth_stat attribute_hidden
-_authenticate_internal (register struct svc_req *rqst, struct rpc_msg *msg)
+libc_hidden_proto(_authenticate)
+enum auth_stat
+_authenticate (register struct svc_req *rqst, struct rpc_msg *msg)
{
register int cred_flavor;
@@ -115,7 +116,7 @@ _authenticate_internal (register struct svc_req *rqst, struct rpc_msg *msg)
return AUTH_REJECTEDCRED;
}
-strong_alias(_authenticate_internal,_authenticate)
+libc_hidden_def(_authenticate)
static enum auth_stat
_svcauth_null (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused)
diff --git a/libc/inet/rpc/svc_auth_unix.c b/libc/inet/rpc/svc_authux.c
index abddc6ea8..ef8476784 100644
--- a/libc/inet/rpc/svc_auth_unix.c
+++ b/libc/inet/rpc/svc_authux.c
@@ -38,11 +38,7 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define xdrmem_create __xdrmem_create
-#define xdr_authunix_parms __xdr_authunix_parms
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -50,10 +46,17 @@
#include <rpc/rpc.h>
#include <rpc/svc.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(printf)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_authunix_parms)
+
/*
* Unix longhand authenticator
*/
enum auth_stat
+_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg) attribute_hidden;
+enum auth_stat
_svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg)
{
enum auth_stat stat;
@@ -87,7 +90,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);
@@ -110,7 +113,7 @@ _svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg)
*/
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len)
{
- (void) __printf ("bad auth_len gid %d str %d auth %d\n",
+ (void) printf ("bad auth_len gid %d str %d auth %d\n",
gid_len, str_len, auth_len);
stat = AUTH_BADCRED;
goto done;
@@ -152,6 +155,8 @@ done:
*/
/*ARGSUSED */
enum auth_stat
+_svcauth_short (struct svc_req *rqst attribute_unused, struct rpc_msg *msg attribute_unused) attribute_hidden;
+enum auth_stat
_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 986350882..0cdbbb89a 100644
--- a/libc/inet/rpc/svc_raw.c
+++ b/libc/inet/rpc/svc_raw.c
@@ -40,15 +40,15 @@ static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define xdrmem_create __xdrmem_create
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-
#define __FORCE_GLIBC
#include <features.h>
#include "rpc_private.h"
#include <rpc/svc.h>
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+
/*
* This is the "network" that we will be moving data over
*/
diff --git a/libc/inet/rpc/svc_run.c b/libc/inet/rpc/svc_run.c
index d2c06b895..50e5fcd79 100644
--- a/libc/inet/rpc/svc_run.c
+++ b/libc/inet/rpc/svc_run.c
@@ -31,15 +31,7 @@
* Wait for input, call server program.
*/
-#define svc_getreq_poll __svc_getreq_poll
-#define poll __poll
-
-/* used by svc_[max_]pollfd */
-#define __rpc_thread_svc_pollfd __rpc_thread_svc_pollfd_internal
-#define __rpc_thread_svc_max_pollfd __rpc_thread_svc_max_pollfd_internal
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
@@ -47,6 +39,13 @@
#include <sys/poll.h>
#include <rpc/rpc.h>
+libc_hidden_proto(perror)
+libc_hidden_proto(svc_getreq_poll)
+libc_hidden_proto(poll)
+/* used by svc_[max_]pollfd */
+libc_hidden_proto(__rpc_thread_svc_pollfd)
+libc_hidden_proto(__rpc_thread_svc_max_pollfd)
+
/* This function can be used as a signal handler to terminate the
server loop. */
void
@@ -83,7 +82,7 @@ svc_run (void)
free (my_pollfd);
if (errno == EINTR)
continue;
- __perror (_("svc_run: - poll failed"));
+ perror (_("svc_run: - poll failed"));
return;
case 0:
free (my_pollfd);
diff --git a/libc/inet/rpc/svc_simple.c b/libc/inet/rpc/svc_simple.c
index 825235450..075b930b1 100644
--- a/libc/inet/rpc/svc_simple.c
+++ b/libc/inet/rpc/svc_simple.c
@@ -38,16 +38,7 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define svc_sendreply __svc_sendreply
-#define svc_register __svc_register
-#define svcerr_decode __svcerr_decode
-#define svcudp_create __svcudp_create
-#define pmap_unset __pmap_unset
-#define asprintf __asprintf
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -64,6 +55,19 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
# define fputs(s, f) _IO_fputs (s, f)
#endif
+libc_hidden_proto(strdup)
+libc_hidden_proto(memset)
+libc_hidden_proto(asprintf)
+libc_hidden_proto(fputs)
+libc_hidden_proto(write)
+libc_hidden_proto(exit)
+libc_hidden_proto(svc_sendreply)
+libc_hidden_proto(svc_register)
+libc_hidden_proto(svcerr_decode)
+libc_hidden_proto(svcudp_create)
+libc_hidden_proto(pmap_unset)
+libc_hidden_proto(xdr_void)
+
struct proglst_
{
char *(*p_progname) (char *);
@@ -86,6 +90,8 @@ static void universal (struct svc_req *rqstp, SVCXPRT *transp_s);
static SVCXPRT *transp;
#endif
+int registerrpc (u_long prognum, u_long versnum, u_long procnum,
+ char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc);
int
registerrpc (u_long prognum, u_long versnum, u_long procnum,
char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
@@ -105,7 +111,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;
}
}
@@ -120,7 +126,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;
@@ -159,8 +165,8 @@ 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);
+ write (STDERR_FILENO, "xxx\n", 4);
+ exit (1);
}
return;
}
@@ -170,7 +176,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);
@@ -185,7 +191,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);
@@ -199,5 +205,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 4a2556159..c94f2de07 100644
--- a/libc/inet/rpc/svc_tcp.c
+++ b/libc/inet/rpc/svc_tcp.c
@@ -41,24 +41,7 @@ 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 xdrrec_endofrecord __xdrrec_endofrecord
-#define xdrrec_skiprecord __xdrrec_skiprecord
-#define xdrrec_eof __xdrrec_eof
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-#define xprt_register __xprt_register
-#define xprt_unregister __xprt_unregister
-#define getsockname __getsockname
-#define bind __bind
-#define bindresvport __bindresvport
-#define poll __poll
-#define accept __accept
-#define listen __listen
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -76,6 +59,32 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
# define fputs(s, f) _IO_fputs (s, f)
#endif
+libc_hidden_proto(memset)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(perror)
+libc_hidden_proto(xdrrec_create)
+libc_hidden_proto(xdrrec_endofrecord)
+libc_hidden_proto(xdrrec_skiprecord)
+libc_hidden_proto(xdrrec_eof)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xprt_register)
+libc_hidden_proto(xprt_unregister)
+libc_hidden_proto(getsockname)
+libc_hidden_proto(bind)
+libc_hidden_proto(bindresvport)
+libc_hidden_proto(poll)
+libc_hidden_proto(accept)
+libc_hidden_proto(listen)
+libc_hidden_proto(fputs)
+libc_hidden_proto(fclose)
+libc_hidden_proto(abort)
+libc_hidden_proto(stderr)
+
/*
* Ops vector for TCP/IP based rpc service handle
*/
@@ -101,7 +110,7 @@ static const struct xp_ops svctcp_op =
*/
static bool_t rendezvous_request (SVCXPRT *, struct rpc_msg *);
static enum xprt_stat rendezvous_stat (SVCXPRT *);
-static void svctcp_rendezvous_abort (void);
+static void svctcp_rendezvous_abort (void) attribute_noreturn;
/* This function makes sure abort() relocation goes through PLT
and thus can be lazy bound. */
@@ -170,14 +179,14 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
if (sock == RPC_ANYSOCK)
{
- if ((sock = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+ if ((sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
- __perror (_("svc_tcp.c - tcp socket creation problem"));
+ perror (_("svc_tcp.c - tcp socket creation problem"));
return (SVCXPRT *) NULL;
}
madesock = TRUE;
}
- __memset ((char *) &addr, 0, sizeof (addr));
+ memset ((char *) &addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
if (bindresvport (sock, &addr))
{
@@ -187,9 +196,9 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
if ((getsockname (sock, (struct sockaddr *) &addr, &len) != 0) ||
(listen (sock, 2) != 0))
{
- __perror (_("svc_tcp.c - cannot getsockname or listen"));
+ 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));
@@ -223,6 +232,8 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
* descriptor as its first input.
*/
SVCXPRT *
+svcfd_create (int fd, u_int sendsize, u_int recvsize);
+SVCXPRT *
svcfd_create (int fd, u_int sendsize, u_int recvsize)
{
return makefd_xprt (fd, sendsize, recvsize);
@@ -285,7 +296,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 */
}
@@ -302,7 +313,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 */
@@ -352,7 +363,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:
@@ -372,7 +383,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 82f279814..53ef7ab35 100644
--- a/libc/inet/rpc/svc_udp.c
+++ b/libc/inet/rpc/svc_udp.c
@@ -39,23 +39,7 @@ 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 xprt_unregister __xprt_unregister
-#define xdrmem_create __xdrmem_create
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-#define getsockname __getsockname
-#define setsockopt __setsockopt
-#define bind __bind
-#define bindresvport __bindresvport
-#define recvfrom __recvfrom
-#define sendto __sendto
-#define recvmsg __recvmsg
-#define sendmsg __sendmsg
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -73,8 +57,32 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
+libc_hidden_proto(fwprintf)
#endif
+libc_hidden_proto(memcmp)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(perror)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(xprt_register)
+libc_hidden_proto(xprt_unregister)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(getsockname)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(bind)
+libc_hidden_proto(bindresvport)
+libc_hidden_proto(recvfrom)
+libc_hidden_proto(sendto)
+libc_hidden_proto(recvmsg)
+libc_hidden_proto(sendmsg)
+libc_hidden_proto(fputs)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(stderr)
+
#define rpc_buffer(xprt) ((xprt)->xp_p1)
#ifndef MAX
#define MAX(a, b) ((a > b) ? a : b)
@@ -127,8 +135,9 @@ struct svcudp_data
* see (svc.h, xprt_register).
* The routines returns NULL if a problem occurred.
*/
-SVCXPRT attribute_hidden *
-__svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
+libc_hidden_proto(svcudp_bufcreate)
+SVCXPRT *
+svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
{
bool_t madesock = FALSE;
SVCXPRT *xprt;
@@ -140,14 +149,14 @@ __svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
if (sock == RPC_ANYSOCK)
{
- if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
- __perror (_("svcudp_create: socket creation problem"));
+ perror (_("svcudp_create: socket creation problem"));
return (SVCXPRT *) NULL;
}
madesock = TRUE;
}
- __memset ((char *) &addr, 0, sizeof (addr));
+ memset ((char *) &addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
if (bindresvport (sock, &addr))
{
@@ -156,9 +165,9 @@ __svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
}
if (getsockname (sock, (struct sockaddr *) &addr, &len) != 0)
{
- __perror (_("svcudp_create - cannot getsockname"));
+ perror (_("svcudp_create - cannot getsockname"));
if (madesock)
- (void) __close (sock);
+ (void) close (sock);
return (SVCXPRT *) NULL;
}
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
@@ -168,7 +177,7 @@ __svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
+ (void) fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
else
#endif
(void) fputs (_("svcudp_create: out of memory\n"), stderr);
@@ -194,7 +203,7 @@ __svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
{
# ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
else
# endif
@@ -211,20 +220,21 @@ __svcudp_bufcreate (int sock, u_int sendsz, u_int 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;
}
-strong_alias(__svcudp_bufcreate,svcudp_bufcreate)
+libc_hidden_def(svcudp_bufcreate)
-SVCXPRT attribute_hidden *
-__svcudp_create (int sock)
+libc_hidden_proto(svcudp_create)
+SVCXPRT *
+svcudp_create (int sock)
{
- return __svcudp_bufcreate (sock, UDPMSGSIZE, UDPMSGSIZE);
+ return svcudp_bufcreate (sock, UDPMSGSIZE, UDPMSGSIZE);
}
-strong_alias(__svcudp_create,svcudp_create)
+libc_hidden_def(svcudp_create)
static enum xprt_stat
svcudp_stat (xprt)
@@ -387,7 +397,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));
@@ -420,7 +430,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
@@ -476,6 +486,7 @@ struct udp_cache
* Enable use of the cache.
* Note: there is no disable.
*/
+int svcudp_enablecache (SVCXPRT *transp, u_long size);
int
svcudp_enablecache (SVCXPRT *transp, u_long size)
{
@@ -598,7 +609,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)
@@ -621,6 +632,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 d71485f0a..d91a9acbb 100644
--- a/libc/inet/rpc/svc_unix.c
+++ b/libc/inet/rpc/svc_unix.c
@@ -37,26 +37,6 @@
* and a record/unix stream.
*/
-#define xdrrec_create __xdrrec_create
-#define xdrrec_endofrecord __xdrrec_endofrecord
-#define xdrrec_skiprecord __xdrrec_skiprecord
-#define xdrrec_eof __xdrrec_eof
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-#define xprt_register __xprt_register
-#define xprt_unregister __xprt_unregister
-#define getegid __getegid
-#define geteuid __geteuid
-#define getsockname __getsockname
-#define setsockopt __setsockopt
-#define bind __bind
-#define recvmsg __recvmsg
-#define sendmsg __sendmsg
-#define poll __poll
-#define accept __accept
-#define listen __listen
-#define fputs __fputs
-
#define __FORCE_GLIBC
#include <features.h>
@@ -75,6 +55,35 @@
# include <wchar.h>
#endif
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(strlen)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(perror)
+libc_hidden_proto(getpid)
+libc_hidden_proto(xdrrec_create)
+libc_hidden_proto(xdrrec_endofrecord)
+libc_hidden_proto(xdrrec_skiprecord)
+libc_hidden_proto(xdrrec_eof)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xprt_register)
+libc_hidden_proto(xprt_unregister)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(getsockname)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(bind)
+libc_hidden_proto(recvmsg)
+libc_hidden_proto(sendmsg)
+libc_hidden_proto(poll)
+libc_hidden_proto(accept)
+libc_hidden_proto(listen)
+libc_hidden_proto(fputs)
+libc_hidden_proto(abort)
+libc_hidden_proto(stderr)
+
/*
* Ops vector for AF_UNIX based rpc service handle
*/
@@ -100,7 +109,7 @@ static const struct xp_ops svcunix_op =
*/
static bool_t rendezvous_request (SVCXPRT *, struct rpc_msg *);
static enum xprt_stat rendezvous_stat (SVCXPRT *);
-static void svcunix_rendezvous_abort (void);
+static void svcunix_rendezvous_abort (void) attribute_noreturn;
/* This function makes sure abort() relocation goes through PLT
and thus can be lazy bound. */
@@ -167,17 +176,17 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path)
if (sock == RPC_ANYSOCK)
{
- if ((sock = __socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ if ((sock = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- __perror (_("svc_unix.c - AF_UNIX socket creation problem"));
+ perror (_("svc_unix.c - AF_UNIX socket creation problem"));
return (SVCXPRT *) NULL;
}
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);
@@ -185,9 +194,9 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path)
if (getsockname (sock, (struct sockaddr *) &addr, &len) != 0
|| listen (sock, 2) != 0)
{
- __perror (_("svc_unix.c - cannot getsockname or listen"));
+ perror (_("svc_unix.c - cannot getsockname or listen"));
if (madesock)
- __close (sock);
+ close (sock);
return (SVCXPRT *) NULL;
}
@@ -222,6 +231,8 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path)
* descriptor as its first input.
*/
SVCXPRT *
+svcunixfd_create (int fd, u_int sendsize, u_int recvsize);
+SVCXPRT *
svcunixfd_create (int fd, u_int sendsize, u_int recvsize)
{
return makefd_xprt (fd, sendsize, recvsize);
@@ -284,10 +295,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 */
}
@@ -304,7 +315,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 */
@@ -392,11 +403,11 @@ __msgwrite (int sock, void *data, size_t cnt)
/* XXX I'm not sure, if gete?id() is always correct, or if we should use
get?id(). But since keyserv needs geteuid(), we have no other chance.
It would be much better, if the kernel could pass both to the server. */
- cred.pid = __getpid ();
+ cred.pid = getpid ();
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 1474c1e08..34787a898 100644
--- a/libc/inet/rpc/xdr.c
+++ b/libc/inet/rpc/xdr.c
@@ -41,10 +41,7 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
* xdr.
*/
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -56,8 +53,13 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
#ifdef USE_IN_LIBIO
# include <wchar.h>
+libc_hidden_proto(fwprintf)
#endif
+libc_hidden_proto(strlen)
+libc_hidden_proto(fputs)
+libc_hidden_proto(stderr)
+
/*
* constants specific to the xdr "protocol"
*/
@@ -86,19 +88,22 @@ xdr_free (xdrproc_t proc, char *objp)
/*
* XDR nothing
*/
+libc_hidden_proto(xdr_void)
bool_t
xdr_void (void)
{
return TRUE;
}
+libc_hidden_def(xdr_void)
/*
* XDR long integers
* The definition of xdr_long() is kept for backward
* compatibility. Instead xdr_int() should be used.
*/
-bool_t attribute_hidden
-__xdr_long (XDR *xdrs, long *lp)
+libc_hidden_proto(xdr_long)
+bool_t
+xdr_long (XDR *xdrs, long *lp)
{
if (xdrs->x_op == XDR_ENCODE
@@ -114,13 +119,14 @@ __xdr_long (XDR *xdrs, long *lp)
return FALSE;
}
-strong_alias(__xdr_long,xdr_long)
+libc_hidden_def(xdr_long)
/*
* XDR short integers
*/
-bool_t attribute_hidden
-__xdr_short (XDR *xdrs, short *sp)
+libc_hidden_proto(xdr_short)
+bool_t
+xdr_short (XDR *xdrs, short *sp)
{
long l;
@@ -143,13 +149,14 @@ __xdr_short (XDR *xdrs, short *sp)
}
return FALSE;
}
-strong_alias(__xdr_short,xdr_short)
+libc_hidden_def(xdr_short)
/*
* XDR integers
*/
-bool_t attribute_hidden
-__xdr_int (XDR *xdrs, int *ip)
+libc_hidden_proto(xdr_int)
+bool_t
+xdr_int (XDR *xdrs, int *ip)
{
#if INT_MAX < LONG_MAX
@@ -172,22 +179,23 @@ __xdr_int (XDR *xdrs, int *ip)
}
return FALSE;
#elif INT_MAX == LONG_MAX
- return __xdr_long (xdrs, (long *) ip);
+ return xdr_long (xdrs, (long *) ip);
#elif INT_MAX == SHRT_MAX
- return __xdr_short (xdrs, (short *) ip);
+ return xdr_short (xdrs, (short *) ip);
#else
#error unexpected integer sizes in xdr_int()
#endif
}
-strong_alias(__xdr_int,xdr_int)
+libc_hidden_def(xdr_int)
/*
* XDR unsigned long integers
* The definition of xdr_u_long() is kept for backward
* compatibility. Instead xdr_u_int() should be used.
*/
-bool_t attribute_hidden
-__xdr_u_long (XDR *xdrs, u_long *ulp)
+libc_hidden_proto(xdr_u_long)
+bool_t
+xdr_u_long (XDR *xdrs, u_long *ulp)
{
switch (xdrs->x_op)
{
@@ -214,13 +222,14 @@ __xdr_u_long (XDR *xdrs, u_long *ulp)
}
return FALSE;
}
-strong_alias(__xdr_u_long,xdr_u_long)
+libc_hidden_def(xdr_u_long)
/*
* XDR unsigned integers
*/
-bool_t attribute_hidden
-__xdr_u_int (XDR *xdrs, u_int *up)
+libc_hidden_proto(xdr_u_int)
+bool_t
+xdr_u_int (XDR *xdrs, u_int *up)
{
#if UINT_MAX < ULONG_MAX
u_long l;
@@ -242,21 +251,22 @@ __xdr_u_int (XDR *xdrs, u_int *up)
}
return FALSE;
#elif UINT_MAX == ULONG_MAX
- return __xdr_u_long (xdrs, (u_long *) up);
+ return xdr_u_long (xdrs, (u_long *) up);
#elif UINT_MAX == USHRT_MAX
- return __xdr_short (xdrs, (short *) up);
+ return xdr_short (xdrs, (short *) up);
#else
#error unexpected integer sizes in xdr_u_int()
#endif
}
-strong_alias(__xdr_u_int,xdr_u_int)
+libc_hidden_def(xdr_u_int)
/*
* XDR hyper integers
* same as xdr_u_hyper - open coded to save a proc call!
*/
-bool_t attribute_hidden
-__xdr_hyper (XDR *xdrs, quad_t *llp)
+libc_hidden_proto(xdr_hyper)
+bool_t
+xdr_hyper (XDR *xdrs, quad_t *llp)
{
long t1;
unsigned long int t2;
@@ -282,15 +292,16 @@ __xdr_hyper (XDR *xdrs, quad_t *llp)
return FALSE;
}
-strong_alias(__xdr_hyper,xdr_hyper)
+libc_hidden_def(xdr_hyper)
/*
* XDR hyper integers
* same as xdr_hyper - open coded to save a proc call!
*/
-bool_t attribute_hidden
-__xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
+libc_hidden_proto(xdr_u_hyper)
+bool_t
+xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
{
unsigned long t1;
unsigned long t2;
@@ -316,23 +327,24 @@ __xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
return FALSE;
}
-strong_alias(__xdr_u_hyper,xdr_u_hyper)
+libc_hidden_def(xdr_u_hyper)
bool_t
xdr_longlong_t (XDR *xdrs, quad_t *llp)
{
- return __xdr_hyper (xdrs, llp);
+ return xdr_hyper (xdrs, llp);
}
bool_t
xdr_u_longlong_t (XDR *xdrs, u_quad_t *ullp)
{
- return __xdr_u_hyper (xdrs, ullp);
+ return xdr_u_hyper (xdrs, ullp);
}
/*
* XDR unsigned short integers
*/
+libc_hidden_proto(xdr_u_short)
bool_t
xdr_u_short (XDR *xdrs, u_short *usp)
{
@@ -357,6 +369,7 @@ xdr_u_short (XDR *xdrs, u_short *usp)
}
return FALSE;
}
+libc_hidden_def(xdr_u_short)
/*
@@ -368,7 +381,7 @@ xdr_char (XDR *xdrs, char *cp)
int i;
i = (*cp);
- if (!__xdr_int (xdrs, &i))
+ if (!xdr_int (xdrs, &i))
{
return FALSE;
}
@@ -385,7 +398,7 @@ xdr_u_char (XDR *xdrs, u_char *cp)
u_int u;
u = (*cp);
- if (!__xdr_u_int (xdrs, &u))
+ if (!xdr_u_int (xdrs, &u))
{
return FALSE;
}
@@ -396,8 +409,9 @@ xdr_u_char (XDR *xdrs, u_char *cp)
/*
* XDR booleans
*/
-bool_t attribute_hidden
-__xdr_bool (XDR *xdrs, bool_t *bp)
+libc_hidden_proto(xdr_bool)
+bool_t
+xdr_bool (XDR *xdrs, bool_t *bp)
{
long lb;
@@ -420,13 +434,14 @@ __xdr_bool (XDR *xdrs, bool_t *bp)
}
return FALSE;
}
-strong_alias(__xdr_bool,xdr_bool)
+libc_hidden_def(xdr_bool)
/*
* XDR enumerations
*/
-bool_t attribute_hidden
-__xdr_enum (XDR *xdrs, enum_t *ep)
+libc_hidden_proto(xdr_enum)
+bool_t
+xdr_enum (XDR *xdrs, enum_t *ep)
{
enum sizecheck
{
@@ -459,27 +474,28 @@ __xdr_enum (XDR *xdrs, enum_t *ep)
}
return FALSE;
#else
- return __xdr_long (xdrs, (long *) ep);
+ return xdr_long (xdrs, (long *) ep);
#endif
}
else if (sizeof (enum sizecheck) == sizeof (short))
{
- return __xdr_short (xdrs, (short *) ep);
+ return xdr_short (xdrs, (short *) ep);
}
else
{
return FALSE;
}
}
-strong_alias(__xdr_enum,xdr_enum)
+libc_hidden_def(xdr_enum)
/*
* XDR opaque data
* Allows the specification of a fixed size sequence of opaque bytes.
* cp points to the opaque object and cnt gives the byte length.
*/
-bool_t attribute_hidden
-__xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
+libc_hidden_proto(xdr_opaque)
+bool_t
+xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
{
u_int rndup;
static char crud[BYTES_PER_XDR_UNIT];
@@ -522,15 +538,16 @@ __xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
}
return FALSE;
}
-strong_alias(__xdr_opaque,xdr_opaque)
+libc_hidden_def(xdr_opaque)
/*
* XDR counted bytes
* *cpp is a pointer to the bytes, *sizep is the count.
* If *cpp is NULL maxsize bytes are allocated
*/
-bool_t attribute_hidden
-__xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
+libc_hidden_proto(xdr_bytes)
+bool_t
+xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
{
char *sp = *cpp; /* sp is the actual string pointer */
u_int nodesize;
@@ -538,7 +555,7 @@ __xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
/*
* first deal with the length since xdr bytes are counted
*/
- if (!__xdr_u_int (xdrs, sizep))
+ if (!xdr_u_int (xdrs, sizep))
{
return FALSE;
}
@@ -566,7 +583,7 @@ __xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", _("xdr_bytes: out of memory\n"));
+ (void) fwprintf (stderr, L"%s", _("xdr_bytes: out of memory\n"));
else
#endif
(void) fputs (_("xdr_bytes: out of memory\n"), stderr);
@@ -575,7 +592,7 @@ __xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
/* fall into ... */
case XDR_ENCODE:
- return __xdr_opaque (xdrs, sp, nodesize);
+ return xdr_opaque (xdrs, sp, nodesize);
case XDR_FREE:
if (sp != NULL)
@@ -587,7 +604,7 @@ __xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
}
return FALSE;
}
-strong_alias(__xdr_bytes,xdr_bytes)
+libc_hidden_def(xdr_bytes)
/*
* Implemented here due to commonality of the object.
@@ -598,7 +615,7 @@ xdr_netobj (xdrs, np)
struct netobj *np;
{
- return __xdr_bytes (xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ);
+ return xdr_bytes (xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ);
}
/*
@@ -612,15 +629,16 @@ xdr_netobj (xdrs, np)
* routine may be called.
* If there is no specific or default routine an error is returned.
*/
-bool_t attribute_hidden
-__xdr_union (XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
+libc_hidden_proto(xdr_union)
+bool_t
+xdr_union (XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
{
enum_t dscm;
/*
* we deal with the discriminator; it's an enum
*/
- if (!__xdr_enum (xdrs, dscmp))
+ if (!xdr_enum (xdrs, dscmp))
{
return FALSE;
}
@@ -642,7 +660,7 @@ __xdr_union (XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choi
return ((dfault == NULL_xdrproc_t) ? FALSE :
(*dfault) (xdrs, unp, LASTUNSIGNED));
}
-strong_alias(__xdr_union,xdr_union)
+libc_hidden_def(xdr_union)
/*
* Non-portable xdr primitives.
@@ -658,8 +676,9 @@ strong_alias(__xdr_union,xdr_union)
* storage is allocated. The last parameter is the max allowed length
* of the string as specified by a protocol.
*/
-bool_t attribute_hidden
-__xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
+libc_hidden_proto(xdr_string)
+bool_t
+xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
{
char *sp = *cpp; /* sp is the actual string pointer */
u_int size;
@@ -679,12 +698,12 @@ __xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
case XDR_ENCODE:
if (sp == NULL)
return FALSE;
- size = __strlen (sp);
+ size = strlen (sp);
break;
case XDR_DECODE:
break;
}
- if (!__xdr_u_int (xdrs, &size))
+ if (!xdr_u_int (xdrs, &size))
{
return FALSE;
}
@@ -710,7 +729,7 @@ __xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("xdr_string: out of memory\n"));
else
#endif
@@ -721,7 +740,7 @@ __xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
/* fall into ... */
case XDR_ENCODE:
- return __xdr_opaque (xdrs, sp, size);
+ return xdr_opaque (xdrs, sp, size);
case XDR_FREE:
mem_free (sp, nodesize);
@@ -730,7 +749,7 @@ __xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
}
return FALSE;
}
-strong_alias(__xdr_string,xdr_string)
+libc_hidden_def(xdr_string)
/*
* Wrapper for xdr_string that can be called directly from
@@ -741,7 +760,7 @@ xdr_wrapstring (xdrs, cpp)
XDR *xdrs;
char **cpp;
{
- if (__xdr_string (xdrs, cpp, LASTUNSIGNED))
+ if (xdr_string (xdrs, cpp, LASTUNSIGNED))
{
return TRUE;
}
diff --git a/libc/inet/rpc/xdr_array.c b/libc/inet/rpc/xdr_array.c
index 5432a5d01..ddafc63b7 100644
--- a/libc/inet/rpc/xdr_array.c
+++ b/libc/inet/rpc/xdr_array.c
@@ -40,11 +40,7 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* arrays. See xdr.h for more info on the interface to xdr.
*/
-#define xdr_u_int __xdr_u_int
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -55,8 +51,14 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
#ifdef USE_IN_LIBIO
# include <wchar.h>
+libc_hidden_proto(fwprintf)
#endif
+libc_hidden_proto(memset)
+libc_hidden_proto(fputs)
+libc_hidden_proto(xdr_u_int)
+libc_hidden_proto(stderr)
+
#define LASTUNSIGNED ((u_int)0-1)
@@ -67,8 +69,9 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* elsize is the size (in bytes) of each element, and elproc is the
* xdr procedure to call to handle each element of the array.
*/
-bool_t attribute_hidden
-__xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize, xdrproc_t elproc)
+libc_hidden_proto(xdr_array)
+bool_t
+xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize, xdrproc_t elproc)
{
u_int i;
caddr_t target = *addrp;
@@ -107,14 +110,14 @@ __xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsiz
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("xdr_array: out of memory\n"));
else
#endif
(void) fputs (_("xdr_array: out of memory\n"), stderr);
return FALSE;
}
- __memset (target, 0, nodesize);
+ memset (target, 0, nodesize);
break;
case XDR_FREE:
@@ -142,7 +145,7 @@ __xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsiz
}
return stat;
}
-strong_alias(__xdr_array,xdr_array)
+libc_hidden_def(xdr_array)
/*
* xdr_vector():
diff --git a/libc/inet/rpc/xdr_float.c b/libc/inet/rpc/xdr_float.c
index e78cd2915..03632c5ca 100644
--- a/libc/inet/rpc/xdr_float.c
+++ b/libc/inet/rpc/xdr_float.c
@@ -42,7 +42,6 @@ static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
*/
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c
index 4b6a4817e..7613ffc2f 100644
--- a/libc/inet/rpc/xdr_mem.c
+++ b/libc/inet/rpc/xdr_mem.c
@@ -38,21 +38,20 @@
*
*/
-#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
-
-
#include <string.h>
+#include <limits.h>
#include <rpc/rpc.h>
+libc_hidden_proto(memcpy)
+
static bool_t xdrmem_getlong (XDR *, long *);
static bool_t xdrmem_putlong (XDR *, const long *);
static bool_t xdrmem_getbytes (XDR *, caddr_t, u_int);
static bool_t xdrmem_putbytes (XDR *, const char *, u_int);
static u_int xdrmem_getpos (const XDR *);
static bool_t xdrmem_setpos (XDR *, u_int);
-static int32_t *xdrmem_inline (XDR *, int);
+static int32_t *xdrmem_inline (XDR *, u_int);
static void xdrmem_destroy (XDR *);
static bool_t xdrmem_getint32 (XDR *, int32_t *);
static bool_t xdrmem_putint32 (XDR *, const int32_t *);
@@ -75,8 +74,9 @@ static const struct xdr_ops xdrmem_ops =
* The procedure xdrmem_create initializes a stream descriptor for a
* memory buffer.
*/
-void attribute_hidden
-__xdrmem_create (XDR *xdrs, const caddr_t addr, u_int size, enum xdr_op op)
+libc_hidden_proto(xdrmem_create)
+void
+xdrmem_create (XDR *xdrs, const caddr_t addr, u_int size, enum xdr_op op)
{
xdrs->x_op = op;
/* We have to add the const since the `struct xdr_ops' in `struct XDR'
@@ -85,7 +85,7 @@ __xdrmem_create (XDR *xdrs, const caddr_t addr, u_int size, enum xdr_op op)
xdrs->x_private = xdrs->x_base = addr;
xdrs->x_handy = size;
}
-strong_alias(__xdrmem_create,xdrmem_create)
+libc_hidden_def(xdrmem_create)
/*
* Nothing needs to be done for the memory case. The argument is clearly
@@ -105,8 +105,9 @@ xdrmem_destroy (XDR *xdrs attribute_unused)
static bool_t
xdrmem_getlong (XDR *xdrs, long *lp)
{
- if ((xdrs->x_handy -= 4) < 0)
+ if (xdrs->x_handy < 4)
return FALSE;
+ xdrs->x_handy -= 4;
*lp = (int32_t) ntohl ((*((int32_t *) (xdrs->x_private))));
xdrs->x_private += 4;
return TRUE;
@@ -120,8 +121,9 @@ xdrmem_getlong (XDR *xdrs, long *lp)
static bool_t
xdrmem_putlong (XDR *xdrs, const long *lp)
{
- if ((xdrs->x_handy -= 4) < 0)
+ if (xdrs->x_handy < 4)
return FALSE;
+ xdrs->x_handy -= 4;
*(int32_t *) xdrs->x_private = htonl (*lp);
xdrs->x_private += 4;
return TRUE;
@@ -136,9 +138,10 @@ xdrmem_putlong (XDR *xdrs, const long *lp)
static bool_t
xdrmem_getbytes (XDR *xdrs, caddr_t addr, u_int len)
{
- if ((xdrs->x_handy -= len) < 0)
+ if (xdrs->x_handy < len)
return FALSE;
- __memcpy (addr, xdrs->x_private, len);
+ xdrs->x_handy -= len;
+ memcpy (addr, xdrs->x_private, len);
xdrs->x_private += len;
return TRUE;
}
@@ -150,9 +153,10 @@ xdrmem_getbytes (XDR *xdrs, caddr_t addr, u_int len)
static bool_t
xdrmem_putbytes (XDR *xdrs, const char *addr, u_int len)
{
- if ((xdrs->x_handy -= len) < 0)
+ if (xdrs->x_handy < len)
return FALSE;
- __memcpy (xdrs->x_private, addr, len);
+ xdrs->x_handy -= len;
+ memcpy (xdrs->x_private, addr, len);
xdrs->x_private += len;
return TRUE;
}
@@ -178,7 +182,9 @@ xdrmem_setpos (xdrs, pos)
caddr_t newaddr = xdrs->x_base + pos;
caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
- if ((long) newaddr > (long) lastaddr)
+ if ((long) newaddr > (long) lastaddr
+ || (UINT_MAX < LONG_MAX
+ && (long) UINT_MAX < (long) lastaddr - (long) newaddr))
return FALSE;
xdrs->x_private = newaddr;
xdrs->x_handy = (long) lastaddr - (long) newaddr;
@@ -189,7 +195,7 @@ xdrmem_setpos (xdrs, pos)
* xdrs modified
*/
static int32_t *
-xdrmem_inline (XDR *xdrs, int len)
+xdrmem_inline (XDR *xdrs, u_int len)
{
int32_t *buf = 0;
@@ -210,8 +216,9 @@ xdrmem_inline (XDR *xdrs, int len)
static bool_t
xdrmem_getint32 (XDR *xdrs, int32_t *ip)
{
- if ((xdrs->x_handy -= 4) < 0)
+ if (xdrs->x_handy < 4)
return FALSE;
+ xdrs->x_handy -= 4;
*ip = ntohl ((*((int32_t *) (xdrs->x_private))));
xdrs->x_private += 4;
return TRUE;
@@ -225,8 +232,9 @@ xdrmem_getint32 (XDR *xdrs, int32_t *ip)
static bool_t
xdrmem_putint32 (XDR *xdrs, const int32_t *ip)
{
- if ((xdrs->x_handy -= 4) < 0)
+ if (xdrs->x_handy < 4)
return FALSE;
+ xdrs->x_handy -= 4;
*(int32_t *) xdrs->x_private = htonl (*ip);
xdrs->x_private += 4;
return TRUE;
diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c
index 15381a6cc..99e6fe9c3 100644
--- a/libc/inet/rpc/xdr_rec.c
+++ b/libc/inet/rpc/xdr_rec.c
@@ -44,10 +44,7 @@
* The other 31 bits encode the byte length of the fragment.
*/
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
@@ -60,15 +57,21 @@
# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
+libc_hidden_proto(fwprintf)
#endif
+libc_hidden_proto(memcpy)
+libc_hidden_proto(fputs)
+libc_hidden_proto(lseek)
+libc_hidden_proto(stderr)
+
static bool_t xdrrec_getlong (XDR *, long *);
static bool_t xdrrec_putlong (XDR *, const long *);
static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int);
static bool_t xdrrec_putbytes (XDR *, const char *, u_int);
static u_int xdrrec_getpos (const XDR *);
static bool_t xdrrec_setpos (XDR *, u_int);
-static int32_t *xdrrec_inline (XDR *, int);
+static int32_t *xdrrec_inline (XDR *, u_int);
static void xdrrec_destroy (XDR *);
static bool_t xdrrec_getint32 (XDR *, int32_t *);
static bool_t xdrrec_putint32 (XDR *, const int32_t *);
@@ -144,8 +147,9 @@ 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 attribute_hidden
-__xdrrec_create (XDR *xdrs, u_int sendsize,
+libc_hidden_proto(xdrrec_create)
+void
+xdrrec_create (XDR *xdrs, u_int sendsize,
u_int recvsize, caddr_t tcp_handle,
int (*readit) (char *, char *, int),
int (*writeit) (char *, char *, int))
@@ -162,7 +166,7 @@ __xdrrec_create (XDR *xdrs, u_int sendsize,
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", _("xdrrec_create: out of memory\n"));
+ (void) fwprintf (stderr, L"%s", _("xdrrec_create: out of memory\n"));
else
#endif
(void) fputs (_("xdrrec_create: out of memory\n"), stderr);
@@ -206,7 +210,7 @@ __xdrrec_create (XDR *xdrs, u_int sendsize,
rstrm->fbtbc = 0;
rstrm->last_frag = TRUE;
}
-strong_alias(__xdrrec_create,xdrrec_create)
+libc_hidden_def(xdrrec_create)
/*
@@ -299,7 +303,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;
@@ -319,7 +323,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)
{
@@ -380,7 +384,7 @@ xdrrec_setpos (XDR *xdrs, u_int pos)
}
static int32_t *
-xdrrec_inline (XDR *xdrs, int len)
+xdrrec_inline (XDR *xdrs, u_int len)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
int32_t *buf = NULL;
@@ -478,8 +482,9 @@ xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
* Before reading (deserializing from the stream, one should always call
* this procedure to guarantee proper record alignment.
*/
-bool_t attribute_hidden
-__xdrrec_skiprecord (XDR *xdrs)
+libc_hidden_proto(xdrrec_skiprecord)
+bool_t
+xdrrec_skiprecord (XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
@@ -494,15 +499,16 @@ __xdrrec_skiprecord (XDR *xdrs)
rstrm->last_frag = FALSE;
return TRUE;
}
-strong_alias(__xdrrec_skiprecord,xdrrec_skiprecord)
+libc_hidden_def(xdrrec_skiprecord)
/*
* Lookahead function.
* Returns TRUE iff there is no more input in the buffer
* after consuming the rest of the current record.
*/
-bool_t attribute_hidden
-__xdrrec_eof (XDR *xdrs)
+libc_hidden_proto(xdrrec_eof)
+bool_t
+xdrrec_eof (XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
@@ -518,7 +524,7 @@ __xdrrec_eof (XDR *xdrs)
return TRUE;
return FALSE;
}
-strong_alias(__xdrrec_eof,xdrrec_eof)
+libc_hidden_def(xdrrec_eof)
/*
* The client must tell the package when an end-of-record has occurred.
@@ -526,8 +532,9 @@ strong_alias(__xdrrec_eof,xdrrec_eof)
* (output) tcp stream. (This lets the package support batched or
* pipelined procedure calls.) TRUE => immediate flush to tcp connection.
*/
-bool_t attribute_hidden
-__xdrrec_endofrecord (XDR *xdrs, bool_t sendnow)
+libc_hidden_proto(xdrrec_endofrecord)
+bool_t
+xdrrec_endofrecord (XDR *xdrs, bool_t sendnow)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
u_long len; /* fragment length */
@@ -545,7 +552,7 @@ __xdrrec_endofrecord (XDR *xdrs, bool_t sendnow)
rstrm->out_finger += BYTES_PER_XDR_UNIT;
return TRUE;
}
-strong_alias(__xdrrec_endofrecord,xdrrec_endofrecord)
+libc_hidden_def(xdrrec_endofrecord)
/*
* Internal useful routines
@@ -603,7 +610,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 de310b08a..842d54426 100644
--- a/libc/inet/rpc/xdr_reference.c
+++ b/libc/inet/rpc/xdr_reference.c
@@ -40,11 +40,7 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
* "pointers". See xdr.h for more info on the interface to xdr.
*/
-#define xdr_bool __xdr_bool
-#define fputs __fputs
-
#define __FORCE_GLIBC
-#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
@@ -56,8 +52,14 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
# include <wchar.h>
# include <libio/iolibio.h>
# define fputs(s, f) _IO_fputs (s, f)
+libc_hidden_proto(fwprintf)
#endif
+libc_hidden_proto(memset)
+libc_hidden_proto(xdr_bool)
+libc_hidden_proto(fputs)
+libc_hidden_proto(stderr)
+
#define LASTUNSIGNED ((u_int)0-1)
/*
@@ -69,8 +71,9 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
* size is the size of the referneced structure.
* proc is the routine to handle the referenced structure.
*/
-bool_t attribute_hidden
-__xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
+libc_hidden_proto(xdr_reference)
+bool_t
+xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
{
caddr_t loc = *pp;
bool_t stat;
@@ -87,14 +90,14 @@ __xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
{
#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
+ (void) fwprintf (stderr, L"%s",
_("xdr_reference: out of memory\n"));
else
#endif
(void) fputs (_("xdr_reference: out of memory\n"), stderr);
return FALSE;
}
- __memset (loc, 0, (int) size);
+ memset (loc, 0, (int) size);
break;
default:
break;
@@ -109,7 +112,7 @@ __xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
}
return stat;
}
-strong_alias(__xdr_reference,xdr_reference)
+libc_hidden_def(xdr_reference)
/*
* xdr_pointer():
@@ -150,5 +153,5 @@ xdr_pointer (xdrs, objpp, obj_size, xdr_obj)
*objpp = NULL;
return TRUE;
}
- return __xdr_reference (xdrs, objpp, obj_size, xdr_obj);
+ return xdr_reference (xdrs, objpp, obj_size, xdr_obj);
}
diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c
index 5c8aec6f9..32689e132 100644
--- a/libc/inet/rpc/xdr_stdio.c
+++ b/libc/inet/rpc/xdr_stdio.c
@@ -37,12 +37,6 @@
* from the stream.
*/
-#define fread __fread
-#define fwrite __fwrite
-#define fseek __fseek
-#define fflush __fflush
-#define ftell __ftell
-
#include <rpc/types.h>
#include <stdio.h>
#include <rpc/xdr.h>
@@ -55,13 +49,19 @@
# define fwrite(p, m, n, s) _IO_fwrite (p, m, n, s)
#endif
+libc_hidden_proto(fread)
+libc_hidden_proto(fwrite)
+libc_hidden_proto(fseek)
+libc_hidden_proto(fflush)
+libc_hidden_proto(ftell)
+
static bool_t xdrstdio_getlong (XDR *, long *);
static bool_t xdrstdio_putlong (XDR *, const long *);
static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int);
static bool_t xdrstdio_putbytes (XDR *, const char *, u_int);
static u_int xdrstdio_getpos (const XDR *);
static bool_t xdrstdio_setpos (XDR *, u_int);
-static int32_t *xdrstdio_inline (XDR *, int);
+static int32_t *xdrstdio_inline (XDR *, u_int);
static void xdrstdio_destroy (XDR *);
static bool_t xdrstdio_getint32 (XDR *, int32_t *);
static bool_t xdrstdio_putint32 (XDR *, const int32_t *);
@@ -114,20 +114,20 @@ xdrstdio_destroy (XDR *xdrs)
static bool_t
xdrstdio_getlong (XDR *xdrs, long *lp)
{
- int32_t mycopy;
+ u_int32_t mycopy;
- if (fread ((caddr_t) & mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
+ if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
return FALSE;
- *lp = (int32_t) ntohl (mycopy);
+ *lp = (long) ntohl (mycopy);
return TRUE;
}
static bool_t
xdrstdio_putlong (XDR *xdrs, const long *lp)
{
- long mycopy = htonl (*lp);
- lp = &mycopy;
- if (fwrite ((caddr_t) lp, 4, 1, (FILE *) xdrs->x_private) != 1)
+ int32_t mycopy = htonl ((u_int32_t) *lp);
+
+ if (fwrite ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
return FALSE;
return TRUE;
}
@@ -163,7 +163,7 @@ xdrstdio_setpos (XDR *xdrs, u_int pos)
}
static int32_t *
-xdrstdio_inline (XDR *xdrs attribute_unused, int len attribute_unused)
+xdrstdio_inline (XDR *xdrs attribute_unused, u_int len attribute_unused)
{
/*
* Must do some work to implement this: must insure
diff --git a/libc/inet/send.c b/libc/inet/send.c
new file mode 100644
index 000000000..6b7d44b53
--- /dev/null
+++ b/libc/inet/send.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_send
+#include "socketcalls.c"
diff --git a/libc/inet/sendmsg.c b/libc/inet/sendmsg.c
new file mode 100644
index 000000000..834e83998
--- /dev/null
+++ b/libc/inet/sendmsg.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_sendmsg
+#include "socketcalls.c"
diff --git a/libc/inet/sendto.c b/libc/inet/sendto.c
new file mode 100644
index 000000000..328baa326
--- /dev/null
+++ b/libc/inet/sendto.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_sendto
+#include "socketcalls.c"
diff --git a/libc/inet/setsockopt.c b/libc/inet/setsockopt.c
new file mode 100644
index 000000000..b0f4a4e96
--- /dev/null
+++ b/libc/inet/setsockopt.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_setsockopt
+#include "socketcalls.c"
diff --git a/libc/inet/shutdown.c b/libc/inet/shutdown.c
new file mode 100644
index 000000000..0bcdb9f38
--- /dev/null
+++ b/libc/inet/shutdown.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_shutdown
+#include "socketcalls.c"
diff --git a/libc/inet/socket.c b/libc/inet/socket.c
new file mode 100644
index 000000000..752744b88
--- /dev/null
+++ b/libc/inet/socket.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_socket
+#include "socketcalls.c"
diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c
index db2da8c5b..9a6e2e151 100644
--- a/libc/inet/socketcalls.c
+++ b/libc/inet/socketcalls.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#define __FORCE_GLIBC
#include <features.h>
#include <errno.h>
@@ -29,6 +35,7 @@ extern int __socketcall(int call, unsigned long *args) attribute_hidden;
#ifdef L_accept
+extern __typeof(accept) __libc_accept;
#ifdef __NR_accept
#define __NR___libc_accept __NR_accept
_syscall3(int, __libc_accept, int, call, struct sockaddr *, addr, socklen_t *,addrlen);
@@ -43,16 +50,17 @@ int __libc_accept(int s, struct sockaddr *addr, socklen_t * addrlen)
return __socketcall(SYS_ACCEPT, args);
}
#endif
-hidden_weak_alias(__libc_accept,__accept)
+libc_hidden_proto(accept)
weak_alias(__libc_accept,accept)
+libc_hidden_weak(accept)
#endif
#ifdef L_bind
+libc_hidden_proto(bind)
#ifdef __NR_bind
-#define __NR___bind __NR_bind
-attribute_hidden _syscall3(int, __bind, int, sockfd, const struct sockaddr *, myaddr, socklen_t, addrlen);
+_syscall3(int, bind, int, sockfd, const struct sockaddr *, myaddr, socklen_t, addrlen);
#elif defined(__NR_socketcall)
-int attribute_hidden __bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen)
+int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen)
{
unsigned long args[3];
@@ -62,10 +70,11 @@ int attribute_hidden __bind(int sockfd, const struct sockaddr *myaddr, socklen_t
return __socketcall(SYS_BIND, args);
}
#endif
-strong_alias(__bind,bind)
+libc_hidden_def(bind)
#endif
#ifdef L_connect
+extern __typeof(connect) __libc_connect;
#ifdef __NR_connect
#define __NR___libc_connect __NR_connect
_syscall3(int, __libc_connect, int, sockfd, const struct sockaddr *, saddr, socklen_t, addrlen);
@@ -80,8 +89,9 @@ int __libc_connect(int sockfd, const struct sockaddr *saddr, socklen_t addrlen)
return __socketcall(SYS_CONNECT, args);
}
#endif
-hidden_weak_alias(__libc_connect,__connect)
+libc_hidden_proto(connect)
weak_alias(__libc_connect,connect)
+libc_hidden_weak(connect)
#endif
#ifdef L_getpeername
@@ -101,11 +111,11 @@ int getpeername(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
#endif
#ifdef L_getsockname
+libc_hidden_proto(getsockname)
#ifdef __NR_getsockname
-#define __NR___getsockname __NR_getsockname
-attribute_hidden _syscall3(int, __getsockname, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
+_syscall3(int, getsockname, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
#elif defined(__NR_socketcall)
-int attribute_hidden __getsockname(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
+int getsockname(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
{
unsigned long args[3];
@@ -115,7 +125,7 @@ int attribute_hidden __getsockname(int sockfd, struct sockaddr *addr, socklen_t
return __socketcall(SYS_GETSOCKNAME, args);
}
#endif
-strong_alias(__getsockname,getsockname)
+libc_hidden_def(getsockname)
#endif
#ifdef L_getsockopt
@@ -138,11 +148,11 @@ int getsockopt(int fd, int level, int optname, __ptr_t optval,
#endif
#ifdef L_listen
+libc_hidden_proto(listen)
#ifdef __NR_listen
-#define __NR___listen __NR_listen
-attribute_hidden _syscall2(int, __listen, int, sockfd, int, backlog);
+_syscall2(int, listen, int, sockfd, int, backlog);
#elif defined(__NR_socketcall)
-int attribute_hidden __listen(int sockfd, int backlog)
+int listen(int sockfd, int backlog)
{
unsigned long args[2];
@@ -151,10 +161,11 @@ int attribute_hidden __listen(int sockfd, int backlog)
return __socketcall(SYS_LISTEN, args);
}
#endif
-strong_alias(__listen,listen)
+libc_hidden_def(listen)
#endif
#ifdef L_recv
+extern __typeof(recv) __libc_recv;
#ifdef __NR_recv
#define __NR___libc_recv __NR_recv
_syscall4(ssize_t, __libc_recv, int, sockfd, __ptr_t, buffer, size_t, len, int, flags);
@@ -171,16 +182,19 @@ ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags)
return (__socketcall(SYS_RECV, args));
}
#elif defined(__NR_recvfrom)
+libc_hidden_proto(recvfrom)
ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags)
{
- return (__recvfrom(sockfd, buffer, len, flags, NULL, NULL));
+ return (recvfrom(sockfd, buffer, len, flags, NULL, NULL));
}
#endif
-hidden_weak_alias(__libc_recv,__recv)
+libc_hidden_proto(recv)
weak_alias(__libc_recv,recv)
+libc_hidden_weak(recv)
#endif
#ifdef L_recvfrom
+extern __typeof(recvfrom) __libc_recvfrom;
#ifdef __NR_recvfrom
#define __NR___libc_recvfrom __NR_recvfrom
_syscall6(ssize_t, __libc_recvfrom, int, sockfd, __ptr_t, buffer, size_t, len, int, flags,
@@ -201,11 +215,13 @@ ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags,
return (__socketcall(SYS_RECVFROM, args));
}
#endif
-hidden_weak_alias(__libc_recvfrom,__recvfrom)
+libc_hidden_proto(recvfrom)
weak_alias(__libc_recvfrom,recvfrom)
+libc_hidden_weak(recvfrom)
#endif
#ifdef L_recvmsg
+extern __typeof(recvmsg) __libc_recvmsg;
#ifdef __NR_recvmsg
#define __NR___libc_recvmsg __NR_recvmsg
_syscall3(ssize_t, __libc_recvmsg, int, sockfd, struct msghdr *, msg, int, flags);
@@ -220,11 +236,13 @@ ssize_t __libc_recvmsg(int sockfd, struct msghdr *msg, int flags)
return (__socketcall(SYS_RECVMSG, args));
}
#endif
-hidden_weak_alias(__libc_recvmsg,__recvmsg)
+libc_hidden_proto(recvmsg)
weak_alias(__libc_recvmsg,recvmsg)
+libc_hidden_weak(recvmsg)
#endif
#ifdef L_send
+extern __typeof(send) __libc_send;
#ifdef __NR_send
#define __NR___libc_send __NR_send
_syscall4(ssize_t, __libc_send, int, sockfd, const void *, buffer, size_t, len, int, flags);
@@ -241,20 +259,19 @@ ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags)
return (__socketcall(SYS_SEND, args));
}
#elif defined(__NR_sendto)
-extern ssize_t __sendto (int __fd, __const void *__buf, size_t __n,
- int __flags, __CONST_SOCKADDR_ARG __addr,
- socklen_t __addr_len) attribute_hidden;
-
+libc_hidden_proto(sendto)
ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags)
{
- return (__sendto(sockfd, buffer, len, flags, NULL, 0));
+ return (sendto(sockfd, buffer, len, flags, NULL, 0));
}
#endif
-hidden_weak_alias(__libc_send,__send)
+libc_hidden_proto(send)
weak_alias(__libc_send,send)
+libc_hidden_weak(send)
#endif
#ifdef L_sendmsg
+extern __typeof(sendmsg) __libc_sendmsg;
#ifdef __NR_sendmsg
#define __NR___libc_sendmsg __NR_sendmsg
_syscall3(ssize_t, __libc_sendmsg, int, sockfd, const struct msghdr *, msg, int, flags);
@@ -269,11 +286,13 @@ ssize_t __libc_sendmsg(int sockfd, const struct msghdr *msg, int flags)
return (__socketcall(SYS_SENDMSG, args));
}
#endif
-hidden_weak_alias(__libc_sendmsg,__sendmsg)
+libc_hidden_proto(sendmsg)
weak_alias(__libc_sendmsg,sendmsg)
+libc_hidden_weak(sendmsg)
#endif
#ifdef L_sendto
+extern __typeof(sendto) __libc_sendto;
#ifdef __NR_sendto
#define __NR___libc_sendto __NR_sendto
_syscall6(ssize_t, __libc_sendto, int, sockfd, const void *, buffer, size_t, len,
@@ -294,17 +313,18 @@ ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags,
return (__socketcall(SYS_SENDTO, args));
}
#endif
-hidden_weak_alias(__libc_sendto,__sendto)
+libc_hidden_proto(sendto)
weak_alias(__libc_sendto,sendto)
+libc_hidden_weak(sendto)
#endif
#ifdef L_setsockopt
+libc_hidden_proto(setsockopt)
#ifdef __NR_setsockopt
-#define __NR___setsockopt __NR_setsockopt
-attribute_hidden _syscall5(int, __setsockopt, int, fd, int, level, int, optname, const void *, optval, socklen_t, optlen);
+_syscall5(int, setsockopt, int, fd, int, level, int, optname, const void *, optval, socklen_t, optlen);
#elif defined(__NR_socketcall)
/* [sg]etsockoptions by bir7@leland.stanford.edu */
-int attribute_hidden __setsockopt(int fd, int level, int optname, const void *optval,
+int setsockopt(int fd, int level, int optname, const void *optval,
socklen_t optlen)
{
unsigned long args[5];
@@ -317,7 +337,7 @@ int attribute_hidden __setsockopt(int fd, int level, int optname, const void *op
return (__socketcall(SYS_SETSOCKOPT, args));
}
#endif
-strong_alias(__setsockopt,setsockopt)
+libc_hidden_def(setsockopt)
#endif
#ifdef L_shutdown
@@ -337,11 +357,11 @@ int shutdown(int sockfd, int how)
#endif
#ifdef L_socket
+libc_hidden_proto(socket)
#ifdef __NR_socket
-#define __NR___socket __NR_socket
-attribute_hidden _syscall3(int, __socket, int, family, int, type, int, protocol);
+_syscall3(int, socket, int, family, int, type, int, protocol);
#elif defined(__NR_socketcall)
-int attribute_hidden __socket(int family, int type, int protocol)
+int socket(int family, int type, int protocol)
{
unsigned long args[3];
@@ -351,7 +371,7 @@ int attribute_hidden __socket(int family, int type, int protocol)
return __socketcall(SYS_SOCKET, args);
}
#endif
-strong_alias(__socket,socket)
+libc_hidden_def(socket)
#endif
#ifdef L_socketpair
diff --git a/libc/inet/socketpair.c b/libc/inet/socketpair.c
new file mode 100644
index 000000000..f7c435474
--- /dev/null
+++ b/libc/inet/socketpair.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_socketpair
+#include "socketcalls.c"
diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in
index b62032a25..b710b8b7c 100644
--- a/libc/misc/time/Makefile.in
+++ b/libc/misc/time/Makefile.in
@@ -1,73 +1,40 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-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:=
+CSRC := adjtime.c ftime.c
+# multi source time.c
+CSRC += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
+ localtime.c localtime_r.c mktime.c strftime.c strptime.c tzset.c \
+ _time_t2tm.c __time_tm.c _time_mktime.c dysize.c timegm.c \
+ _time_mktime_tzi.c _time_localtime_tzi.c
ifeq ($(UCLIBC_HAS_FLOATS),y)
-MOBJ+=difftime.o
+CSRC += difftime.c
endif
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx:=strftime_l.o strptime_l.o
+CSRC += strftime_l.c strptime_l.c
endif
-
ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJ+=wcsftime.o
+CSRC += wcsftime.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx+=wcsftime_l.o
+CSRC += wcsftime_l.c
endif
endif
-CSRC:=adjtime.c ftime.c
-
-MISC_TIME_DIR:=$(top_srcdir)libc/misc/time
-MISC_TIME_OUT:=$(top_builddir)libc/misc/time
-
-MISC_TIME_NO_MULTI:=strftime.o mktime.o strptime.o gmtime.o localtime.o asctime.o asctime_r.o gmtime_r.o localtime_r.o
-
-MISC_TIME_SRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
-MISC_TIME_OBJ:=$(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
-
-MISC_TIME_MSRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(MSRC))
-MISC_TIME_MOBJ:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJ))
-MISC_TIME_MOBJx:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJx))
-
-MISC_TIME_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(MISC_TIME_NO_MULTI),$(notdir $(MISC_TIME_MOBJ)))))
-
-MISC_TIME_OBJS:=$(MISC_TIME_OBJ) $(MISC_TIME_MOBJ)
-
-$(MISC_TIME_MOBJ): $(MISC_TIME_MSRC)
- $(compile.m)
-
-$(MISC_TIME_MOBJ:.o=.os): $(MISC_TIME_MSRC)
- $(compile.m)
-
-$(MISC_TIME_MOBJx): $(MISC_TIME_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(MISC_TIME_MOBJx:.o=.os): $(MISC_TIME_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+MISC_TIME_DIR := $(top_srcdir)libc/misc/time
+MISC_TIME_OUT := $(top_builddir)libc/misc/time
-libc-a-y+=$(MISC_TIME_OBJS)
-libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)
-libc-so-y+=$(MISC_TIME_OBJS:.o=.os)
-libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx:.o=.os)
+MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
+MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
-CFLAGS-multi-y+=$(MISC_TIME_DEF)
-libc-multi-y+=$(MISC_TIME_MSRC)
-libc-nomulti-y+=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MISC_TIME_NO_MULTI))
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)
+libc-y += $(MISC_TIME_OBJ)
-objclean-y+=misc_time_objclean
+objclean-y += misc_time_objclean
misc_time_objclean:
$(RM) $(MISC_TIME_OUT)/*.{o,os}
diff --git a/libc/misc/time/__time_tm.c b/libc/misc/time/__time_tm.c
new file mode 100644
index 000000000..59b7d8aac
--- /dev/null
+++ b/libc/misc/time/__time_tm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___time_tm
+#include "time.c"
diff --git a/libc/misc/time/_time_localtime_tzi.c b/libc/misc/time/_time_localtime_tzi.c
new file mode 100644
index 000000000..32728a491
--- /dev/null
+++ b/libc/misc/time/_time_localtime_tzi.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_localtime_tzi
+#include "time.c"
diff --git a/libc/misc/time/_time_mktime.c b/libc/misc/time/_time_mktime.c
new file mode 100644
index 000000000..1fd920020
--- /dev/null
+++ b/libc/misc/time/_time_mktime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_mktime
+#include "time.c"
diff --git a/libc/misc/time/_time_mktime_tzi.c b/libc/misc/time/_time_mktime_tzi.c
new file mode 100644
index 000000000..543893e6a
--- /dev/null
+++ b/libc/misc/time/_time_mktime_tzi.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_mktime_tzi
+#include "time.c"
diff --git a/libc/misc/time/_time_t2tm.c b/libc/misc/time/_time_t2tm.c
new file mode 100644
index 000000000..903651ffd
--- /dev/null
+++ b/libc/misc/time/_time_t2tm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__time_t2tm
+#include "time.c"
diff --git a/libc/misc/time/adjtime.c b/libc/misc/time/adjtime.c
index fd33ff60d..cfa94339a 100644
--- a/libc/misc/time/adjtime.c
+++ b/libc/misc/time/adjtime.c
@@ -1,10 +1,16 @@
-#define adjtimex __adjtimex
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <limits.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <errno.h>
+libc_hidden_proto(adjtimex)
+
#define MAX_SEC (LONG_MAX / 1000000L - 2)
#define MIN_SEC (LONG_MIN / 1000000L + 2)
diff --git a/libc/misc/time/asctime.c b/libc/misc/time/asctime.c
new file mode 100644
index 000000000..d80c017a6
--- /dev/null
+++ b/libc/misc/time/asctime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_asctime
+#include "time.c"
diff --git a/libc/misc/time/asctime_r.c b/libc/misc/time/asctime_r.c
new file mode 100644
index 000000000..aec38b139
--- /dev/null
+++ b/libc/misc/time/asctime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_asctime_r
+#include "time.c"
diff --git a/libc/misc/time/clock.c b/libc/misc/time/clock.c
new file mode 100644
index 000000000..9cc425412
--- /dev/null
+++ b/libc/misc/time/clock.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_clock
+#include "time.c"
diff --git a/libc/misc/time/ctime.c b/libc/misc/time/ctime.c
new file mode 100644
index 000000000..4bd09a8a9
--- /dev/null
+++ b/libc/misc/time/ctime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ctime
+#include "time.c"
diff --git a/libc/misc/time/ctime_r.c b/libc/misc/time/ctime_r.c
new file mode 100644
index 000000000..c03f5c95d
--- /dev/null
+++ b/libc/misc/time/ctime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ctime_r
+#include "time.c"
diff --git a/libc/misc/time/difftime.c b/libc/misc/time/difftime.c
new file mode 100644
index 000000000..4bcec2c06
--- /dev/null
+++ b/libc/misc/time/difftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_difftime
+#include "time.c"
diff --git a/libc/misc/time/dysize.c b/libc/misc/time/dysize.c
new file mode 100644
index 000000000..b1bf84b64
--- /dev/null
+++ b/libc/misc/time/dysize.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_dysize
+#include "time.c"
diff --git a/libc/misc/time/ftime.c b/libc/misc/time/ftime.c
index 904763241..233d6f70d 100644
--- a/libc/misc/time/ftime.c
+++ b/libc/misc/time/ftime.c
@@ -16,11 +16,11 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define gettimeofday __gettimeofday
-
#include <sys/timeb.h>
#include <sys/time.h>
+libc_hidden_proto(gettimeofday)
+
int ftime(timebuf)
struct timeb *timebuf;
{
diff --git a/libc/misc/time/gmtime.c b/libc/misc/time/gmtime.c
new file mode 100644
index 000000000..24a512c03
--- /dev/null
+++ b/libc/misc/time/gmtime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gmtime
+#include "time.c"
diff --git a/libc/misc/time/gmtime_r.c b/libc/misc/time/gmtime_r.c
new file mode 100644
index 000000000..8677dd2d6
--- /dev/null
+++ b/libc/misc/time/gmtime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gmtime_r
+#include "time.c"
diff --git a/libc/misc/time/localtime.c b/libc/misc/time/localtime.c
new file mode 100644
index 000000000..e4bffbd2d
--- /dev/null
+++ b/libc/misc/time/localtime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_localtime
+#include "time.c"
diff --git a/libc/misc/time/localtime_r.c b/libc/misc/time/localtime_r.c
new file mode 100644
index 000000000..5351834b2
--- /dev/null
+++ b/libc/misc/time/localtime_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_localtime_r
+#include "time.c"
diff --git a/libc/misc/time/mktime.c b/libc/misc/time/mktime.c
new file mode 100644
index 000000000..2b2c8e459
--- /dev/null
+++ b/libc/misc/time/mktime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_mktime
+#include "time.c"
diff --git a/libc/misc/time/strftime.c b/libc/misc/time/strftime.c
new file mode 100644
index 000000000..2eb827dad
--- /dev/null
+++ b/libc/misc/time/strftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strftime
+#include "time.c"
diff --git a/libc/misc/time/strftime_l.c b/libc/misc/time/strftime_l.c
new file mode 100644
index 000000000..e1d34ad4a
--- /dev/null
+++ b/libc/misc/time/strftime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strftime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"
diff --git a/libc/misc/time/strptime.c b/libc/misc/time/strptime.c
new file mode 100644
index 000000000..771633fb6
--- /dev/null
+++ b/libc/misc/time/strptime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strptime
+#include "time.c"
diff --git a/libc/misc/time/strptime_l.c b/libc/misc/time/strptime_l.c
new file mode 100644
index 000000000..16ee7e1bd
--- /dev/null
+++ b/libc/misc/time/strptime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strptime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 74b38f99e..fb79883c9 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -129,49 +129,62 @@
* differs (intentionally) from glibc's behavior.
*/
-#define strnlen __strnlen
-#define gettimeofday __gettimeofday
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
+#include <sys/time.h>
#include <limits.h>
#include <assert.h>
#include <errno.h>
#include <ctype.h>
#include <langinfo.h>
#include <locale.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <bits/uClibc_uintmaxtostr.h>
-extern void __tzset (void) __THROW attribute_hidden;
-
-extern long int __strtol (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- __THROW __nonnull ((1)) __wur attribute_hidden;
-
-extern char *__nl_langinfo (nl_item __item) __THROW attribute_hidden;
-
+#ifdef __UCLIBC_HAS_WCHAR__
+#include <wchar.h>
+#endif
#ifdef __UCLIBC_HAS_XLOCALE__
#include <xlocale.h>
-extern long int __strtol_l (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base,
- __locale_t __loc) __THROW __nonnull ((1, 4)) __wur attribute_hidden;
-extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
- size_t __n, __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 4)) attribute_hidden;
-extern size_t __strftime_l (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp,
- __locale_t __loc) __THROW attribute_hidden;
+#endif
-extern char *__strptime_l (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp,
- __locale_t __loc) __THROW attribute_hidden;
+libc_hidden_proto(asctime)
+libc_hidden_proto(asctime_r)
+libc_hidden_proto(ctime)
+libc_hidden_proto(localtime)
+libc_hidden_proto(localtime_r)
+
+libc_hidden_proto(memset)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(strnlen)
+/* libc_hidden_proto(sprintf) */
+libc_hidden_proto(open)
+libc_hidden_proto(read)
+libc_hidden_proto(close)
+libc_hidden_proto(getenv)
+libc_hidden_proto(tzset)
+libc_hidden_proto(gettimeofday)
+libc_hidden_proto(strncasecmp)
+libc_hidden_proto(strtol)
+libc_hidden_proto(strtoul)
+libc_hidden_proto(nl_langinfo)
-extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(strncasecmp_l)
+libc_hidden_proto(strtol_l)
+libc_hidden_proto(strtoul_l)
+libc_hidden_proto(nl_langinfo_l)
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
#endif
#ifndef __isleap
@@ -191,8 +204,6 @@ extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
#ifdef __UCLIBC_HAS_TZ_FILE__
#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
#include "paths.h"
/* ":<tzname>+hh:mm:ss<tzname>+hh:mm:ss,Mmm.w.d/hh:mm:ss,Mmm.w.d/hh:mm:ss" + nul */
/* 1 + 2*(1+TZNAME_MAX+1 + 9 + 7 + 9) + 1 = 2*TZNAME_MAX + 56 */
@@ -206,12 +217,7 @@ extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
/**********************************************************************/
-extern struct tm __time_tm;
-
-extern struct tm *__localtime_r (__const time_t *__restrict __timer,
- struct tm *__restrict __tp) attribute_hidden;
-
-extern struct tm *__localtime (__const time_t *__timer) attribute_hidden;
+extern struct tm __time_tm attribute_hidden;
typedef struct {
long gmt_offset;
@@ -225,12 +231,12 @@ typedef struct {
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
-extern pthread_mutex_t _time_tzlock;
+extern pthread_mutex_t _time_tzlock attribute_hidden;
#endif
#define TZLOCK __pthread_mutex_lock(&_time_tzlock)
#define TZUNLOCK __pthread_mutex_unlock(&_time_tzlock)
-extern rule_struct _time_tzinfo[2];
+extern rule_struct _time_tzinfo[2] attribute_hidden;
extern struct tm *_time_t2tm(const time_t *__restrict timer,
int offset, struct tm *__restrict result) attribute_hidden;
@@ -244,21 +250,16 @@ extern struct tm *__time_localtime_tzi(const time_t *__restrict timer,
extern time_t _time_mktime_tzi(struct tm *timeptr, int store_on_success,
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 attribute_hidden *__asctime(const struct tm *ptm)
+char *asctime(const struct tm *ptm)
{
- return __asctime_r(ptm, __time_str);
+ return asctime_r(ptm, __time_str);
}
-strong_alias(__asctime,asctime)
+libc_hidden_def(asctime)
#endif
/**********************************************************************/
@@ -278,7 +279,7 @@ strong_alias(__asctime,asctime)
* };
* static char result[26];
*
- * __sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ * sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
* wday_name[timeptr->tm_wday],
* mon_name[timeptr->tm_mon],
* timeptr->tm_mday, timeptr->tm_hour,
@@ -326,7 +327,7 @@ static const unsigned char at_data[] = {
' ', '?', '?', '?', '?', '\n', 0
};
-char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm,
+char *asctime_r(register const struct tm *__restrict ptm,
register char *__restrict buffer)
{
int tmp;
@@ -335,23 +336,23 @@ char attribute_hidden *__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
@@ -400,16 +401,16 @@ char attribute_hidden *__asctime_r(register const struct tm *__restrict ptm,
return buffer - 8;
}
-strong_alias(__asctime_r,asctime_r)
+libc_hidden_def(asctime_r)
#endif
/**********************************************************************/
#ifdef L_clock
-#define times __times
-
#include <sys/times.h>
+libc_hidden_proto(times)
+
#ifndef __BCC__
#if CLOCKS_PER_SEC != 1000000L
#error unexpected value for CLOCKS_PER_SEC!
@@ -474,21 +475,21 @@ clock_t clock(void)
/**********************************************************************/
#ifdef L_ctime
-char attribute_hidden *__ctime(const time_t *clock)
+char *ctime(const time_t *t)
{
/* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */
- return __asctime(__localtime(clock));
+ return asctime(localtime(t));
}
-strong_alias(__ctime,ctime)
+libc_hidden_def(ctime)
#endif
/**********************************************************************/
#ifdef L_ctime_r
-char *ctime_r(const time_t *clock, char *buf)
+char *ctime_r(const time_t *t, char *buf)
{
struct tm xtm;
- return __asctime_r(__localtime_r(clock, &xtm), buf);
+ return asctime_r(localtime_r(t, &xtm), buf);
}
#endif
@@ -556,28 +557,28 @@ struct tm *gmtime_r(const time_t *__restrict timer,
/**********************************************************************/
#ifdef L_localtime
-struct tm attribute_hidden *__localtime(const time_t *timer)
+struct tm *localtime(const time_t *timer)
{
register struct tm *ptm = &__time_tm;
/* In this implementation, tzset() is called by localtime_r(). */
- __localtime_r(timer, ptm); /* Can return NULL... */
+ localtime_r(timer, ptm); /* Can return NULL... */
return ptm;
}
-strong_alias(__localtime,localtime)
+libc_hidden_def(localtime)
#endif
/**********************************************************************/
#ifdef L_localtime_r
-struct tm attribute_hidden *__localtime_r(register const time_t *__restrict timer,
+struct tm *localtime_r(register const time_t *__restrict timer,
register struct tm *__restrict result)
{
TZLOCK;
- __tzset();
+ tzset();
__time_localtime_tzi(timer, result, _time_tzinfo);
@@ -585,7 +586,7 @@ struct tm attribute_hidden *__localtime_r(register const time_t *__restrict time
return result;
}
-strong_alias(__localtime_r,localtime_r)
+libc_hidden_def(localtime_r)
#endif
/**********************************************************************/
@@ -610,7 +611,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;
}
}
@@ -621,7 +622,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;
}
}
@@ -754,7 +755,7 @@ time_t mktime(struct tm *timeptr)
/* Another name for `mktime'. */
/* time_t timelocal(struct tm *tp) */
-weak_alias(mktime,timelocal)
+strong_alias(mktime,timelocal)
#endif
/**********************************************************************/
@@ -765,8 +766,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);
}
@@ -777,13 +778,17 @@ time_t timegm(struct tm *timeptr)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-size_t attribute_hidden __strftime(char *__restrict s, size_t maxsize,
+libc_hidden_proto(strftime)
+
+libc_hidden_proto(strftime_l)
+
+size_t strftime(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr)
{
- return __strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
+ return strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
-strong_alias(__strftime,strftime)
+libc_hidden_def(strftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -983,7 +988,8 @@ static int load_field(int k, const struct tm *__restrict timeptr)
#warning TODO: Check multibyte format string validity.
#endif
-size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
+libc_hidden_proto(__XL_NPP(strftime))
+size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
{
@@ -1003,7 +1009,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
unsigned char mod;
unsigned char code;
- __tzset(); /* We'll, let's get this out of the way. */
+ tzset(); /* We'll, let's get this out of the way. */
lvl = 0;
p = format;
@@ -1056,7 +1062,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
+ (code & 7);
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
- && (*(o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ && (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(((unsigned char *)p)[4]))
__LOCALE_ARG
)))
@@ -1065,7 +1071,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
goto LOOP;
}
#endif
- p = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(*((unsigned char *)p)))
__LOCALE_ARG
);
@@ -1242,7 +1248,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
if ((code & MASK_SPEC) == STRING_SPEC) {
o_count = SIZE_MAX;
field_val += spec[STRINGS_NL_ITEM_START + (code & 0xf)];
- o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
+ o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
} else {
o_count = ((i >> 1) & 3) + 1;
o = buf + o_count;
@@ -1265,8 +1271,7 @@ size_t attribute_hidden __UCXL(strftime)(char *__restrict s, size_t maxsize,
}
goto LOOP;
}
-
-__UCXL_ALIAS(strftime)
+libc_hidden_def(__XL_NPP(strftime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1284,12 +1289,16 @@ __UCXL_ALIAS(strftime)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-char attribute_hidden *__strptime(const char *__restrict buf, const char *__restrict format,
+libc_hidden_proto(strptime)
+
+libc_hidden_proto(strptime_l)
+
+char *strptime(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm)
{
- return __strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
+ return strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
}
-strong_alias(__strptime,strptime)
+libc_hidden_def(strptime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1435,7 +1444,8 @@ static const unsigned char spec[] = {
#define MAX_PUSH 4
-char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *__restrict format,
+libc_hidden_proto(__XL_NPP(strptime))
+char *__XL_NPP(strptime)(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm __LOCALE_PARAM)
{
register const char *p;
@@ -1503,7 +1513,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
+ (code & 7);
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
- && (*(o = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ && (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(((unsigned char *)p)[4]))
__LOCALE_ARG
)))
@@ -1512,7 +1522,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
goto LOOP;
}
#endif
- p = __UCXL(nl_langinfo)(_NL_ITEM(LC_TIME,
+ p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
(int)(*((unsigned char *)p)))
__LOCALE_ARG );
goto LOOP;
@@ -1527,8 +1537,8 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
/* Go backwards to check full names before abreviations. */
do {
--j;
- o = __UCXL(nl_langinfo)(i+j __LOCALE_ARG);
- if (!__UCXL(strncasecmp)(buf,o,__strlen(o) __LOCALE_ARG) && *o) {
+ o = __XL_NPP(nl_langinfo)(i+j __LOCALE_ARG);
+ if (!__XL_NPP(strncasecmp)(buf,o,strlen(o) __LOCALE_ARG) && *o) {
do { /* Found a match. */
++buf;
} while (*++o);
@@ -1556,9 +1566,9 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
__set_errno(0);
if (!ISSPACE(*buf)) { /* Signal an error if whitespace. */
#ifdef TIME_T_IS_UNSIGNED
- t = __UCXL(strtoul)(buf, &o, 10 __LOCALE_ARG);
+ t = __XL_NPP(strtoul)(buf, &o, 10 __LOCALE_ARG);
#else
- t = __UCXL(strtol)(buf, &o, 10 __LOCALE_ARG);
+ t = __XL_NPP(strtol)(buf, &o, 10 __LOCALE_ARG);
#endif
}
if ((o == buf) || errno) { /* Not a number or overflow. */
@@ -1568,7 +1578,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
buf = o;
if (!code) { /* s */
- __localtime_r(&t, tm); /* TODO: check for failure? */
+ localtime_r(&t, tm); /* TODO: check for failure? */
i = 0;
do { /* Now copy values from tm to fields. */
fields[i] = ((int *) tm)[i];
@@ -1644,8 +1654,7 @@ char attribute_hidden *__UCXL(strptime)(const char *__restrict buf, const char *
}
return NULL;
}
-
-__UCXL_ALIAS(strptime)
+libc_hidden_def(__XL_NPP(strptime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1694,12 +1703,18 @@ static const char vals[] = {
#define DEFAULT_RULES (vals + 22)
/* Initialize to UTC. */
+libc_hidden_proto(daylight)
int daylight = 0;
+libc_hidden_data_def(daylight)
+libc_hidden_proto(timezone)
long timezone = 0;
+libc_hidden_data_def(timezone)
+libc_hidden_proto(tzname)
char *tzname[2] = { (char *) UTC, (char *) (UTC-1) };
+libc_hidden_data_def(tzname)
#ifdef __UCLIBC_HAS_THREADS__
-pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+attribute_hidden pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
rule_struct _time_tzinfo[2];
@@ -1783,11 +1798,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) {
@@ -1807,14 +1822,18 @@ static char *read_TZ_file(char *buf)
ERROR:
p = NULL;
}
- __close(fd);
+ close(fd);
}
return p;
}
#endif /* __UCLIBC_HAS_TZ_FILE__ */
-void attribute_hidden __tzset(void)
+#ifndef __UCLIBC_HAS_CTYPE_TABLES__
+libc_hidden_proto(isascii)
+#endif
+
+void tzset(void)
{
register const char *e;
register char *s;
@@ -1832,7 +1851,7 @@ void attribute_hidden __tzset(void)
TZLOCK;
- e = __getenv(TZ); /* TZ env var always takes precedence. */
+ e = getenv(TZ); /* TZ env var always takes precedence. */
#if defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__)
/* Put this inside the lock to prevent the possiblity of two different
@@ -1859,8 +1878,8 @@ void attribute_hidden __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;
}
@@ -1869,13 +1888,13 @@ void attribute_hidden __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;
@@ -1989,7 +2008,7 @@ void attribute_hidden __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;
@@ -2001,7 +2020,7 @@ void attribute_hidden __tzset(void)
#endif
TZUNLOCK;
}
-strong_alias(__tzset,tzset)
+libc_hidden_def(tzset)
#endif
/**********************************************************************/
/* #ifdef L_utime */
@@ -2203,7 +2222,7 @@ time_t attribute_hidden _time_mktime(struct tm *timeptr, int store_on_success)
TZLOCK;
- __tzset();
+ tzset();
t = _time_mktime_tzi(timeptr, store_on_success, _time_tzinfo);
@@ -2236,7 +2255,7 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
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. */
@@ -2326,7 +2345,7 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
if (store_on_success) {
- __memcpy(timeptr, p, sizeof(struct tm));
+ memcpy(timeptr, p, sizeof(struct tm));
}
@@ -2340,29 +2359,29 @@ time_t attribute_hidden _time_mktime_tzi(struct tm *timeptr, int store_on_succes
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-extern size_t __wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __timeptr,
- __locale_t __loc) __THROW attribute_hidden;
+libc_hidden_proto(wcsftime)
+
+libc_hidden_proto(wcsftime_l)
size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr)
{
- return __wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
+ return wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
+libc_hidden_def(wcsftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-size_t attribute_hidden __UCXL(wcsftime)(wchar_t *__restrict s, size_t maxsize,
+libc_hidden_proto(__XL_NPP(wcsftime))
+size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
{
#warning wcsftime always fails
return 0; /* always fail */
}
-
-__UCXL_ALIAS(wcsftime)
+libc_hidden_def(__XL_NPP(wcsftime))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/misc/time/timegm.c b/libc/misc/time/timegm.c
new file mode 100644
index 000000000..ae2fc7df5
--- /dev/null
+++ b/libc/misc/time/timegm.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_timegm
+#include "time.c"
diff --git a/libc/misc/time/tzset.c b/libc/misc/time/tzset.c
new file mode 100644
index 000000000..e5607a51b
--- /dev/null
+++ b/libc/misc/time/tzset.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tzset
+#include "time.c"
diff --git a/libc/misc/time/wcsftime.c b/libc/misc/time/wcsftime.c
new file mode 100644
index 000000000..e4b25c0d1
--- /dev/null
+++ b/libc/misc/time/wcsftime.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcsftime
+#include "time.c"
diff --git a/libc/misc/time/wcsftime_l.c b/libc/misc/time/wcsftime_l.c
new file mode 100644
index 000000000..68c295458
--- /dev/null
+++ b/libc/misc/time/wcsftime_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcsftime_l
+#define __UCLIBC_DO_XLOCALE
+#include "time.c"
diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in
index 52527e1e5..202e25df2 100644
--- a/libc/stdlib/Makefile.in
+++ b/libc/stdlib/Makefile.in
@@ -1,7 +1,7 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -10,133 +10,82 @@ include $(top_srcdir)libc/stdlib/malloc/Makefile.in
include $(top_srcdir)libc/stdlib/malloc-simple/Makefile.in
include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in
-MSRC1:=stdlib.c
-MOBJ1:= abs.o labs.o atoi.o atol.o strtol.o strtoul.o _stdlib_strto_l.o \
- qsort.o bsearch.o \
- llabs.o atoll.o strtoll.o strtoull.o _stdlib_strto_ll.o
-# (aliases) strtoq.o strtouq.o
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJ1x:=strtol_l.o strtoul_l.o _stdlib_strto_l_l.o \
- strtoll_l.o strtoull_l.o _stdlib_strto_ll_l.o
+CSRC := \
+ abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \
+ rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
+ getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \
+ jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
+ nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
+ valloc.c posix_memalign.c a64l.c l64a.c
+ifeq ($(UCLIBC_HAS_ARC4RANDOM),y)
+CSRC += arc4random.c
+endif
+ifeq ($(UCLIBC_HAS_LFS),y)
+CSRC += mkstemp64.c
+endif
+ifeq ($(UCLIBC_HAS_FLOATS),y)
+CSRC += drand48.c drand48_r.c erand48.c erand48_r.c
endif
-MSRC2:=strtod.c
-MOBJ2:=
-MOBJ2x:=
-
+# multi source stdlib.c
+CSRC += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
+ qsort.c bsearch.c \
+ llabs.c atoll.c strtoll.c strtoull.c _stdlib_strto_ll.c
+# (aliases) strtoq.o strtouq.o
ifeq ($(UCLIBC_HAS_FLOATS),y)
-MOBJ1+=atof.o
-MOBJ2+=strtod.o strtof.o strtold.o __strtofpmax.o __fp_range_check.o
+CSRC += atof.c
+endif
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJ2x+=strtod_l.o strtof_l.o strtold_l.o __strtofpmax_l.o
+CSRC += strtol_l.c strtoul_l.c _stdlib_strto_l_l.c \
+ strtoll_l.c strtoull_l.c _stdlib_strto_ll_l.c
endif
ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJ2+=wcstod.o wcstof.o wcstold.o __wcstofpmax.o
+CSRC += mblen.c mbtowc.c wctomb.c mbstowcs.c wcstombs.c \
+ _stdlib_mb_cur_max.c _stdlib_wcsto_l.c _stdlib_wcsto_ll.c \
+ wcstol.c wcstoul.c wcstoll.c wcstoull.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJ2x+=wcstod_l.o wcstof_l.o wcstold_l.o __wcstofpmax_l.o
-endif
+CSRC +=_stdlib_wcsto_l_l.c _stdlib_wcsto_ll_l.c \
+ wcstol_l.c wcstoul_l.c wcstoll_l.c wcstoull_l.c
endif
endif
+# multi source _strtod.c
+ifeq ($(UCLIBC_HAS_FLOATS),y)
+CSRC += strtod.c strtof.c strtold.c __strtofpmax.c __fp_range_check.c
+ifeq ($(UCLIBC_HAS_XLOCALE),y)
+CSRC += strtod_l.c strtof_l.c strtold_l.c __strtofpmax_l.c
+endif
ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJ1+= mblen.o mbtowc.o wctomb.o mbstowcs.o wcstombs.o \
- _stdlib_mb_cur_max.o _stdlib_wcsto_l.o _stdlib_wcsto_ll.o \
- wcstol.o wcstoul.o wcstoll.o wcstoull.o
+CSRC += wcstod.c wcstof.c wcstold.c __wcstofpmax.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJ1x+=_stdlib_wcsto_l_l.o _stdlib_wcsto_ll_l.o \
- wcstol_l.o wcstoul_l.o wcstoll_l.o wcstoull_l.o
+CSRC += wcstod_l.c wcstof_l.c wcstold_l.c __wcstofpmax_l.c
+endif
endif
endif
# (aliases) wcstoq.o wcstouq.o
# wcstod wcstof wcstold
-MSRC3:=atexit.c
-MOBJ3:=on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o
+# multi source _atexit.c
+CSRC += __cxa_atexit.c __cxa_finalize.c __exit_handler.c exit.c on_exit.c
ifeq ($(COMPAT_ATEXIT),y)
-MOBJ3+=old_atexit.o
-endif
-
-CSRC:= \
- abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \
- rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
- getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \
- jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
- nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
- valloc.c posix_memalign.c a64l.c l64a.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC+=drand48.c drand48_r.c erand48.c erand48_r.c
+CSRC += old_atexit.c
endif
-STDLIB_MOBJ1_NO_MULTI:=_stdlib_strto_l.o _stdlib_strto_ll.o
-STDLIB_MOBJ2_NO_MULTI:=strtod.o strtof.o __strtofpmax.o
-STDLIB_MOBJ_NO_MULTI:=$(STDLIB_MOBJ1_NO_MULTI) $(STDLIB_MOBJ2_NO_MULTI)
-
-STDLIB_DIR:=$(top_srcdir)libc/stdlib
-STDLIB_OUT:=$(top_builddir)libc/stdlib
-
-STDLIB_SRC:=$(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC))
-STDLIB_OBJ:=$(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC))
-
-STDLIB_MSRC1:=$(patsubst %.c,$(STDLIB_DIR)/%.c,$(MSRC1))
-STDLIB_MSRC2:=$(patsubst %.c,$(STDLIB_DIR)/%.c,$(MSRC2))
-STDLIB_MSRC3:=$(patsubst %.c,$(STDLIB_DIR)/%.c,$(MSRC3))
-STDLIB_MOBJ1:=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(MOBJ1))
-STDLIB_MOBJ2:=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(MOBJ2))
-STDLIB_MOBJ3:=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(MOBJ3))
-STDLIB_MOBJ1x:=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(MOBJ1x))
-STDLIB_MOBJ2x:=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(MOBJ2x))
-
-STDLIB_MSRC:=$(STDLIB_MSRC1) $(STDLIB_MSRC2) $(STDLIB_MSRC3)
-STDLIB_MOBJ:=$(STDLIB_MOBJ1) $(STDLIB_MOBJ2) $(STDLIB_MOBJ3)
-
-STDLIB_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(STDLIB_MOBJ_NO_MULTI),$(notdir $(STDLIB_MOBJ)))))
-
-STDLIB_MOBJx:=$(STDLIB_MOBJ1x) $(STDLIB_MOBJ2x)
-
-STDLIB_OBJS:=$(STDLIB_OBJ) $(STDLIB_MOBJ) $(STDLIB_MOBJx)
-
-$(STDLIB_MOBJ1): $(STDLIB_MSRC1)
- $(compile.m)
-
-$(STDLIB_MOBJ1:.o=.os): $(STDLIB_MSRC1)
- $(compile.m)
-
-$(STDLIB_MOBJ2): $(STDLIB_MSRC2)
- $(compile.m)
-
-$(STDLIB_MOBJ2:.o=.os): $(STDLIB_MSRC2)
- $(compile.m)
-
-$(STDLIB_MOBJ3): $(STDLIB_MSRC3)
- $(compile.m)
-
-$(STDLIB_MOBJ3:.o=.os) $(STDLIB_OUT)/atexit.os: $(STDLIB_MSRC3)
- $(compile.m)
-
-$(STDLIB_MOBJ1x): $(STDLIB_MSRC1)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(STDLIB_MOBJ1x:.o=.os): $(STDLIB_MSRC1)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(STDLIB_MOBJ2x): $(STDLIB_MSRC2)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+STDLIB_DIR := $(top_srcdir)libc/stdlib
+STDLIB_OUT := $(top_builddir)libc/stdlib
-$(STDLIB_MOBJ2x:.o=.os): $(STDLIB_MSRC2)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+STDLIB_SRC := $(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC))
+STDLIB_OBJ := $(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC))
-libc-a-y+=$(STDLIB_OBJS)
-libc-static-y+=$(STDLIB_OUT)/atexit.o
-libc-so-y+=$(STDLIB_OBJS:.o=.os)
+libc-y += $(STDLIB_OBJ)
+libc-static-y += $(STDLIB_OUT)/atexit.o
# this should always be the PIC version, because it could be used in shared libs
-libc-nonshared-y+=$(STDLIB_OUT)/atexit.os
+libc-nonshared-y += $(STDLIB_OUT)/atexit.os
-CFLAGS-multi-y+=$(STDLIB_DEF)
-libc-multi-y+=$(STDLIB_SRC) $(STDLIB_MSRC)
-libc-nomulti-y+=$(patsubst %.o,$(STDLIB_OUT)/%.o,$(STDLIB_MOBJ_NO_MULTI))
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(STDLIB_MOBJx)
+libc-nomulti-y += $(STDLIB_OUT)/labs.o $(STDLIB_OUT)/atol.o $(STDLIB_OUT)/_stdlib_strto_l.o $(STDLIB_OUT)/_stdlib_strto_ll.o
+libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STDLIB_OUT)/_stdlib_strto_l_l.o $(STDLIB_OUT)/_stdlib_strto_ll_l.o
-objclean-y+=stdlib_objclean
+objclean-y += stdlib_objclean
stdlib_objclean:
- $(RM) $(STDLIB_OUT)/*.{o,os}
+ $(RM) $(STDLIB_OUT)/*.{o,os,oS}
diff --git a/libc/stdlib/__cxa_atexit.c b/libc/stdlib/__cxa_atexit.c
new file mode 100644
index 000000000..fbf06e5a7
--- /dev/null
+++ b/libc/stdlib/__cxa_atexit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___cxa_atexit
+#include "_atexit.c"
diff --git a/libc/stdlib/__cxa_finalize.c b/libc/stdlib/__cxa_finalize.c
new file mode 100644
index 000000000..4a91626bd
--- /dev/null
+++ b/libc/stdlib/__cxa_finalize.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___cxa_finalize
+#include "_atexit.c"
diff --git a/libc/stdlib/__exit_handler.c b/libc/stdlib/__exit_handler.c
new file mode 100644
index 000000000..ae4ff84be
--- /dev/null
+++ b/libc/stdlib/__exit_handler.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___exit_handler
+#include "_atexit.c"
diff --git a/libc/stdlib/__fp_range_check.c b/libc/stdlib/__fp_range_check.c
new file mode 100644
index 000000000..9c60972ad
--- /dev/null
+++ b/libc/stdlib/__fp_range_check.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___fp_range_check
+#include "_strtod.c"
diff --git a/libc/stdlib/__strtofpmax.c b/libc/stdlib/__strtofpmax.c
new file mode 100644
index 000000000..6b01aca0f
--- /dev/null
+++ b/libc/stdlib/__strtofpmax.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___strtofpmax
+#include "_strtod.c"
diff --git a/libc/stdlib/__strtofpmax_l.c b/libc/stdlib/__strtofpmax_l.c
new file mode 100644
index 000000000..a6141323e
--- /dev/null
+++ b/libc/stdlib/__strtofpmax_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___strtofpmax_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/__wcstofpmax.c b/libc/stdlib/__wcstofpmax.c
new file mode 100644
index 000000000..3c3fdccee
--- /dev/null
+++ b/libc/stdlib/__wcstofpmax.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___wcstofpmax
+#include "_strtod.c"
diff --git a/libc/stdlib/__wcstofpmax_l.c b/libc/stdlib/__wcstofpmax_l.c
new file mode 100644
index 000000000..909b7204d
--- /dev/null
+++ b/libc/stdlib/__wcstofpmax_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___wcstofpmax_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c
new file mode 100644
index 000000000..bf35ab2d6
--- /dev/null
+++ b/libc/stdlib/_atexit.c
@@ -0,0 +1,348 @@
+/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+
+/*
+ * Dec 2000 Manuel Novoa III
+ *
+ * Made atexit handling conform to standards... i.e. no args.
+ * Removed on_exit since it did not match gnu libc definition.
+ * Combined atexit and __do_exit into one object file.
+ *
+ * Feb 2001 Manuel Novoa III
+ *
+ * Reworked file after addition of __uClibc_main.
+ * Changed name of __do_exit to atexit_handler.
+ * Changed name of __cleanup to __uClibc_cleanup.
+ * Moved declaration of __uClibc_cleanup to __uClibc_main
+ * where it is initialized with (possibly weak alias)
+ * _stdio_term.
+ *
+ * Jul 2001 Steve Thayer
+ *
+ * Added an on_exit implementation (that now matches gnu libc definition.)
+ * Pulled atexit_handler out of the atexit object since it is now required by
+ * on_exit as well. Renamed it to __exit_handler.
+ * Fixed a problem where exit functions stop getting called if one of
+ * them calls exit().
+ * As a side effect of these changes, abort() no longer calls the exit
+ * functions (it now matches the gnu libc definition).
+ *
+ * August 2002 Erik Andersen
+ * Added locking so atexit and friends can be thread safe
+ *
+ * August 2005 Stephen Warren
+ * Added __cxa_atexit and __cxa_finalize support
+ *
+ */
+
+#include <features.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <atomic.h>
+
+libc_hidden_proto(exit)
+libc_hidden_proto(_exit)
+
+#ifdef __UCLIBC_HAS_THREADS__
+# include <pthread.h>
+extern pthread_mutex_t mylock;
+libc_hidden_proto(mylock)
+#endif
+#define LOCK __pthread_mutex_lock(&mylock)
+#define UNLOCK __pthread_mutex_unlock(&mylock)
+
+
+typedef void (*aefuncp) (void); /* atexit function pointer */
+typedef void (*oefuncp) (int, void *); /* on_exit function pointer */
+typedef void (*cxaefuncp) (void *); /* __cxa_atexit function pointer */
+typedef enum {
+ ef_free,
+ ef_in_use,
+ ef_on_exit,
+ ef_cxa_atexit
+} ef_type; /* exit function types */
+
+/* this is in the L_exit object */
+extern void (*__exit_cleanup) (int) attribute_hidden;
+
+/* these are in the L___do_exit object */
+extern int __exit_slots attribute_hidden;
+extern int __exit_count attribute_hidden;
+extern void __exit_handler(int) attribute_hidden;
+struct exit_function {
+ /*
+ * 'type' should be of type of the 'enum ef_type' above but since we
+ * need this element in an atomic operation we have to use 'long int'.
+ */
+ long int type; /* enum ef_type */
+ union {
+ struct {
+ oefuncp func;
+ void *arg;
+ } on_exit;
+ struct {
+ cxaefuncp func;
+ void *arg;
+ void* dso_handle;
+ } cxa_atexit;
+ } funcs;
+};
+#ifdef __UCLIBC_DYNAMIC_ATEXIT__
+extern struct exit_function *__exit_function_table attribute_hidden;
+#else
+extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT] attribute_hidden;
+#endif
+extern struct exit_function *__new_exitfn (void) attribute_hidden;
+
+/* this is in the L___cxa_atexit object */
+extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle);
+
+
+/* remove old_atexit after 0.9.29 */
+#if defined(L_atexit) || defined(L_old_atexit)
+extern void *__dso_handle __attribute__ ((__weak__));
+
+/*
+ * register a function to be called at normal program termination
+ * (the registered function takes no arguments)
+ */
+#ifdef L_atexit
+int attribute_hidden atexit(aefuncp func)
+#else
+int old_atexit(aefuncp func)
+#endif
+{
+ /*
+ * glibc casts aefuncp to cxaefuncp.
+ * This seems dodgy, but I guess callling a function with more
+ * parameters than it needs will work everywhere?
+ */
+ return __cxa_atexit((cxaefuncp)func, NULL,
+ &__dso_handle == NULL ? NULL : __dso_handle);
+}
+#ifndef L_atexit
+weak_alias(old_atexit,atexit)
+#endif
+#endif
+
+#ifdef L_on_exit
+/*
+ * register a function to be called at normal program termination
+ * the registered function takes two arguments:
+ * status - the exit status that was passed to the exit() function
+ * arg - generic argument
+ */
+int on_exit(oefuncp func, void *arg)
+{
+ struct exit_function *efp;
+
+ if (func == NULL) {
+ return 0;
+ }
+
+ efp = __new_exitfn();
+ if (efp == NULL) {
+ return -1;
+ }
+
+ efp->funcs.on_exit.func = func;
+ efp->funcs.on_exit.arg = arg;
+ /* assign last for thread safety, since we're now unlocked */
+ efp->type = ef_on_exit;
+
+ return 0;
+}
+#endif
+
+#ifdef L___cxa_atexit
+libc_hidden_proto(__cxa_atexit)
+int __cxa_atexit (cxaefuncp func, void *arg, void *dso_handle)
+{
+ struct exit_function *efp;
+
+ if (func == NULL) {
+ return 0;
+ }
+
+ efp = __new_exitfn();
+ if (efp == NULL) {
+ return -1;
+ }
+
+ efp->funcs.cxa_atexit.func = func;
+ efp->funcs.cxa_atexit.arg = arg;
+ efp->funcs.cxa_atexit.dso_handle = dso_handle;
+ /* assign last for thread safety, since we're now unlocked */
+ efp->type = ef_cxa_atexit;
+
+ return 0;
+}
+libc_hidden_def(__cxa_atexit)
+#endif
+
+#ifdef L___cxa_finalize
+/*
+ * If D is non-NULL, call all functions registered with `__cxa_atexit'
+ * with the same dso handle. Otherwise, if D is NULL, call all of the
+ * registered handlers.
+ */
+void __cxa_finalize (void *dso_handle);
+void __cxa_finalize (void *dso_handle)
+{
+ struct exit_function *efp;
+ int exit_count_snapshot = __exit_count;
+
+ /* In reverse order */
+ while (exit_count_snapshot) {
+ efp = &__exit_function_table[--exit_count_snapshot];
+
+ /*
+ * We check dso_handle match before we verify the type of the union entry.
+ * However, the atomic_exchange will validate that we were really "allowed"
+ * to read dso_handle...
+ */
+ if ((dso_handle == NULL || dso_handle == efp->funcs.cxa_atexit.dso_handle)
+ /* We don't want to run this cleanup more than once. */
+ && !atomic_compare_and_exchange_bool_acq(&efp->type, ef_free, ef_cxa_atexit)
+ ) {
+ /* glibc passes status (0) too, but that's not in the prototype */
+ (*efp->funcs.cxa_atexit.func)(efp->funcs.cxa_atexit.arg);
+ }
+ }
+
+#if 0 /* haven't looked into this yet... */
+ /*
+ * Remove the registered fork handlers. We do not have to
+ * unregister anything if the program is going to terminate anyway.
+ */
+#ifdef UNREGISTER_ATFORK
+ if (d != NULL) {
+ UNREGISTER_ATFORK (d);
+ }
+#endif
+#endif
+}
+#endif
+
+#ifdef L___exit_handler
+int __exit_count = 0; /* Number of registered exit functions */
+#ifdef __UCLIBC_DYNAMIC_ATEXIT__
+struct exit_function *__exit_function_table = NULL;
+int __exit_slots = 0; /* Size of __exit_function_table */
+#else
+struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT];
+#endif
+
+/*
+ * Find and return a new exit_function pointer, for atexit,
+ * onexit and __cxa_atexit to initialize
+ */
+struct exit_function attribute_hidden *__new_exitfn(void)
+{
+ struct exit_function *efp;
+
+ LOCK;
+
+#ifdef __UCLIBC_DYNAMIC_ATEXIT__
+ /* If we are out of function table slots, make some more */
+ if (__exit_slots < __exit_count+1) {
+ efp=realloc(__exit_function_table,
+ (__exit_slots+20)*sizeof(struct exit_function));
+ if (efp == NULL) {
+ UNLOCK;
+ __set_errno(ENOMEM);
+ return 0;
+ }
+ __exit_function_table = efp;
+ __exit_slots += 20;
+ }
+#else
+ if (__exit_count >= __UCLIBC_MAX_ATEXIT) {
+ UNLOCK;
+ __set_errno(ENOMEM);
+ return 0;
+ }
+#endif
+
+ __exit_cleanup = __exit_handler; /* enable cleanup */
+ efp = &__exit_function_table[__exit_count++];
+ efp->type = ef_in_use;
+
+ UNLOCK;
+
+ return efp;
+}
+
+/*
+ * Handle the work of executing the registered exit functions
+ * This is called while we are locked, so no additional locking
+ * is needed...
+ */
+void __exit_handler(int status)
+{
+ struct exit_function *efp;
+
+ /* In reverse order */
+ while ( __exit_count ) {
+ efp = &__exit_function_table[--__exit_count];
+ switch (efp->type) {
+ case ef_on_exit:
+ if (efp->funcs.on_exit.func) {
+ (efp->funcs.on_exit.func) (status, efp->funcs.on_exit.arg);
+ }
+ break;
+ case ef_cxa_atexit:
+ if (efp->funcs.cxa_atexit.func) {
+ /* glibc passes status too, but that's not in the prototype */
+ (efp->funcs.cxa_atexit.func) (efp->funcs.cxa_atexit.arg);
+ }
+ break;
+ }
+ }
+#ifdef __UCLIBC_DYNAMIC_ATEXIT__
+ /* Free up memory used by the __exit_function_table structure */
+ if (__exit_function_table)
+ free(__exit_function_table);
+#endif
+}
+#endif
+
+#ifdef L_exit
+extern void weak_function _stdio_term(void) attribute_hidden;
+attribute_hidden void (*__exit_cleanup) (int) = 0;
+#ifdef __UCLIBC_HAS_THREADS__
+pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+libc_hidden_data_def(mylock)
+#endif
+
+extern void __uClibc_fini(void);
+libc_hidden_proto(__uClibc_fini)
+
+/*
+ * Normal program termination
+ */
+void exit(int rv)
+{
+ /* Perform exit-specific cleanup (atexit and on_exit) */
+ LOCK;
+ if (__exit_cleanup) {
+ __exit_cleanup(rv);
+ }
+ UNLOCK;
+
+ __uClibc_fini();
+
+ /* If we are using stdio, try to shut it down. At the very least,
+ * this will attempt to commit all buffered writes. It may also
+ * unbuffer all writable files, or close them outright.
+ * Check the stdio routines for details. */
+ if (_stdio_term)
+ _stdio_term();
+
+ _exit(rv);
+}
+libc_hidden_def(exit)
+#endif
diff --git a/libc/stdlib/_stdlib_mb_cur_max.c b/libc/stdlib/_stdlib_mb_cur_max.c
new file mode 100644
index 000000000..b87f6094b
--- /dev/null
+++ b/libc/stdlib/_stdlib_mb_cur_max.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_mb_cur_max
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_strto_l.c b/libc/stdlib/_stdlib_strto_l.c
new file mode 100644
index 000000000..4dfa03785
--- /dev/null
+++ b/libc/stdlib/_stdlib_strto_l.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_strto_l
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_strto_l_l.c b/libc/stdlib/_stdlib_strto_l_l.c
new file mode 100644
index 000000000..1692f0cf2
--- /dev/null
+++ b/libc/stdlib/_stdlib_strto_l_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_strto_l_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_strto_ll.c b/libc/stdlib/_stdlib_strto_ll.c
new file mode 100644
index 000000000..ce79598b4
--- /dev/null
+++ b/libc/stdlib/_stdlib_strto_ll.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_strto_ll
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_strto_ll_l.c b/libc/stdlib/_stdlib_strto_ll_l.c
new file mode 100644
index 000000000..b5fb11171
--- /dev/null
+++ b/libc/stdlib/_stdlib_strto_ll_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_strto_ll_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_wcsto_l.c b/libc/stdlib/_stdlib_wcsto_l.c
new file mode 100644
index 000000000..d05a20786
--- /dev/null
+++ b/libc/stdlib/_stdlib_wcsto_l.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_wcsto_l
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_wcsto_l_l.c b/libc/stdlib/_stdlib_wcsto_l_l.c
new file mode 100644
index 000000000..26ea5a704
--- /dev/null
+++ b/libc/stdlib/_stdlib_wcsto_l_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_wcsto_l_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_wcsto_ll.c b/libc/stdlib/_stdlib_wcsto_ll.c
new file mode 100644
index 000000000..e67a57739
--- /dev/null
+++ b/libc/stdlib/_stdlib_wcsto_ll.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_wcsto_ll
+#include "stdlib.c"
diff --git a/libc/stdlib/_stdlib_wcsto_ll_l.c b/libc/stdlib/_stdlib_wcsto_ll_l.c
new file mode 100644
index 000000000..9d6471282
--- /dev/null
+++ b/libc/stdlib/_stdlib_wcsto_ll_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__stdlib_wcsto_ll_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/_strtod.c b/libc/stdlib/_strtod.c
new file mode 100644
index 000000000..c4447d9ea
--- /dev/null
+++ b/libc/stdlib/_strtod.c
@@ -0,0 +1,623 @@
+/*
+ * Copyright (C) 2000-2005 Manuel Novoa III
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Notes:
+ *
+ * The primary objective of this implementation was minimal size and
+ * portablility, while providing robustness and resonable accuracy.
+ *
+ * This implementation depends on IEEE floating point behavior and expects
+ * to be able to generate +/- infinity as a result.
+ *
+ * There are a number of compile-time options below.
+ */
+
+/* July 27, 2003
+ *
+ * General cleanup and some minor size optimizations.
+ * Change implementation to support __strtofpmax() rather than strtod().
+ * Now all the strto{floating pt}() funcs are implemented in terms of
+ * of the internal __strtofpmax() function.
+ * Support "nan", "inf", and "infinity" strings (case-insensitive).
+ * Support hexadecimal floating point notation.
+ * Support wchar variants.
+ * Support xlocale variants.
+ *
+ * TODO:
+ *
+ * Consider accumulating blocks of digits in longs to save floating pt mults.
+ * This would likely be much better on anything that only supported floats
+ * where DECIMAL_DIG == 9. Actually, if floats have FLT_MAX_10_EXP == 38,
+ * we could calculate almost all the exponent multipliers (p_base) in
+ * long arithmetic as well.
+ */
+
+/**********************************************************************/
+/* OPTIONS */
+/**********************************************************************/
+
+/* Defined if we want to recognize "nan", "inf", and "infinity". (C99) */
+#define _STRTOD_NAN_INF_STRINGS 1
+
+/* Defined if we want support hexadecimal floating point notation. (C99) */
+/* Note! Now controlled by uClibc configuration. See below. */
+#define _STRTOD_HEXADECIMAL_FLOATS 1
+
+/* Defined if we want to scale with a O(log2(exp)) multiplications.
+ * This is generally a good thing to do unless you are really tight
+ * on space and do not expect to convert values of large magnitude. */
+
+#define _STRTOD_LOG_SCALING 1
+
+/* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
+ *
+ * Clearing any of the options below this point is not advised (or tested).
+ *
+ * WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! */
+
+/* Defined if we want strtod to set errno appropriately. */
+/* NOTE: Implies all options below. */
+#define _STRTOD_ERRNO 1
+
+/* Defined if we want support for the endptr arg. */
+/* Implied by _STRTOD_ERRNO. */
+#define _STRTOD_ENDPTR 1
+
+/* Defined if we want to prevent overflow in accumulating the exponent. */
+/* Implied by _STRTOD_ERRNO. */
+#define _STRTOD_RESTRICT_EXP 1
+
+/* Defined if we want to process mantissa digits more intelligently. */
+/* Implied by _STRTOD_ERRNO. */
+#define _STRTOD_RESTRICT_DIGITS 1
+
+/* Defined if we want to skip scaling 0 for the exponent. */
+/* Implied by _STRTOD_ERRNO. */
+#define _STRTOD_ZERO_CHECK 1
+
+/**********************************************************************/
+/* Don't change anything that follows. */
+/**********************************************************************/
+
+#ifdef _STRTOD_ERRNO
+#undef _STRTOD_ENDPTR
+#undef _STRTOD_RESTRICT_EXP
+#undef _STRTOD_RESTRICT_DIGITS
+#undef _STRTOD_ZERO_CHECK
+#define _STRTOD_ENDPTR 1
+#define _STRTOD_RESTRICT_EXP 1
+#define _STRTOD_RESTRICT_DIGITS 1
+#define _STRTOD_ZERO_CHECK 1
+#endif
+
+/**********************************************************************/
+
+#define _ISOC99_SOURCE 1
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <float.h>
+#include <bits/uClibc_fpmax.h>
+
+#include <locale.h>
+
+#ifdef __UCLIBC_HAS_WCHAR__
+
+#include <wchar.h>
+#include <wctype.h>
+#include <bits/uClibc_uwchar.h>
+libc_hidden_proto(iswspace)
+#endif
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+#include <xlocale.h>
+libc_hidden_proto(iswspace_l)
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+
+/* Handle _STRTOD_HEXADECIMAL_FLOATS via uClibc config now. */
+#undef _STRTOD_HEXADECIMAL_FLOATS
+#ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
+#define _STRTOD_HEXADECIMAL_FLOATS 1
+#endif /* __UCLIBC_HAS_HEXADECIMAL_FLOATS__ */
+
+/**********************************************************************/
+
+#undef _STRTOD_FPMAX
+
+#if FPMAX_TYPE == 3
+
+#define NEED_STRTOLD_WRAPPER
+#define NEED_STRTOD_WRAPPER
+#define NEED_STRTOF_WRAPPER
+
+#elif FPMAX_TYPE == 2
+
+#define NEED_STRTOD_WRAPPER
+#define NEED_STRTOF_WRAPPER
+
+#elif FPMAX_TYPE == 1
+
+#define NEED_STRTOF_WRAPPER
+
+#else
+
+#error unknown FPMAX_TYPE!
+
+#endif
+
+extern void __fp_range_check(__fpmax_t y, __fpmax_t x) attribute_hidden;
+
+/**********************************************************************/
+
+#ifdef _STRTOD_RESTRICT_DIGITS
+#define EXP_DENORM_ADJUST DECIMAL_DIG
+#define MAX_ALLOWED_EXP (DECIMAL_DIG + EXP_DENORM_ADJUST - FPMAX_MIN_10_EXP)
+
+#if MAX_ALLOWED_EXP > INT_MAX
+#error size assumption violated for MAX_ALLOWED_EXP
+#endif
+#else
+/* We want some excess if we're not restricting mantissa digits. */
+#define MAX_ALLOWED_EXP ((20 - FPMAX_MIN_10_EXP) * 2)
+#endif
+
+
+#if defined(_STRTOD_RESTRICT_DIGITS) || defined(_STRTOD_ENDPTR) || defined(_STRTOD_HEXADECIMAL_FLOATS)
+#undef _STRTOD_NEED_NUM_DIGITS
+#define _STRTOD_NEED_NUM_DIGITS 1
+#endif
+
+/**********************************************************************/
+#if defined(L___strtofpmax) || defined(L___strtofpmax_l) || defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+#ifdef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(__global_locale)
+#endif
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_tolower)
+#endif
+
+#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
+
+#define __strtofpmax __wcstofpmax
+#define __strtofpmax_l __wcstofpmax_l
+
+#define Wchar wchar_t
+#ifdef __UCLIBC_DO_XLOCALE
+#define ISSPACE(C) iswspace_l((C), locale_arg)
+#else
+#define ISSPACE(C) iswspace((C))
+#endif
+
+#else /* defined(L___wcstofpmax) || defined(L___wcstofpmax_l) */
+
+#define Wchar char
+#ifdef __UCLIBC_DO_XLOCALE
+#define ISSPACE(C) isspace_l((C), locale_arg)
+#else
+#define ISSPACE(C) isspace((C))
+#endif
+
+#endif /* defined(L___wcstofpmax) || defined(L___wcstofpmax_l) */
+
+
+#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
+
+__fpmax_t attribute_hidden __strtofpmax(const Wchar *str, Wchar **endptr, int exponent_power)
+{
+ return __strtofpmax_l(str, endptr, exponent_power, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+
+libc_hidden_proto(memcmp)
+
+__fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
+ __LOCALE_PARAM )
+{
+ __fpmax_t number;
+ __fpmax_t p_base = 10; /* Adjusted to 16 in the hex case. */
+ Wchar *pos0;
+#ifdef _STRTOD_ENDPTR
+ Wchar *pos1;
+#endif
+ Wchar *pos = (Wchar *) str;
+ int exponent_temp;
+ int negative; /* A flag for the number, a multiplier for the exponent. */
+#ifdef _STRTOD_NEED_NUM_DIGITS
+ int num_digits;
+#endif
+#ifdef __UCLIBC_HAS_LOCALE__
+#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
+ wchar_t decpt_wc = __LOCALE_PTR->decimal_point;
+#else
+ const char *decpt = __LOCALE_PTR->decimal_point;
+ int decpt_len = __LOCALE_PTR->decimal_point_len;
+#endif
+#endif
+
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ Wchar expchar = 'e';
+ Wchar *poshex = NULL;
+ __uint16_t is_mask = _ISdigit;
+#define EXPCHAR expchar
+#define IS_X_DIGIT(C) __isctype((C), is_mask)
+#else /* _STRTOD_HEXADECIMAL_FLOATS */
+#define EXPCHAR 'e'
+#define IS_X_DIGIT(C) isdigit((C))
+#endif /* _STRTOD_HEXADECIMAL_FLOATS */
+
+ while (ISSPACE(*pos)) { /* Skip leading whitespace. */
+ ++pos;
+ }
+
+ negative = 0;
+ switch(*pos) { /* Handle optional sign. */
+ case '-': negative = 1; /* Fall through to increment position. */
+ case '+': ++pos;
+ }
+
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ if ((*pos == '0') && (((pos[1])|0x20) == 'x')) {
+ poshex = ++pos; /* Save position of 'x' in case no digits */
+ ++pos; /* and advance past it. */
+ is_mask = _ISxdigit; /* Used by IS_X_DIGIT. */
+ expchar = 'p'; /* Adjust exponent char. */
+ p_base = 16; /* Adjust base multiplier. */
+ }
+#endif
+
+ number = 0.;
+#ifdef _STRTOD_NEED_NUM_DIGITS
+ num_digits = -1;
+#endif
+/* exponent_power = 0; */
+ pos0 = NULL;
+
+ LOOP:
+ while (IS_X_DIGIT(*pos)) { /* Process string of (hex) digits. */
+#ifdef _STRTOD_RESTRICT_DIGITS
+ if (num_digits < 0) { /* First time through? */
+ ++num_digits; /* We've now seen a digit. */
+ }
+ if (num_digits || (*pos != '0')) { /* Had/have nonzero. */
+ ++num_digits;
+ if (num_digits <= DECIMAL_DIG) { /* Is digit significant? */
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ number = number * p_base
+ + (isdigit(*pos)
+ ? (*pos - '0')
+ : (((*pos)|0x20) - ('a' - 10)));
+#else /* _STRTOD_HEXADECIMAL_FLOATS */
+ number = number * p_base + (*pos - '0');
+#endif /* _STRTOD_HEXADECIMAL_FLOATS */
+ }
+ }
+#else /* _STRTOD_RESTRICT_DIGITS */
+#ifdef _STRTOD_NEED_NUM_DIGITS
+ ++num_digits;
+#endif
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ number = number * p_base
+ + (isdigit(*pos)
+ ? (*pos - '0')
+ : (((*pos)|0x20) - ('a' - 10)));
+#else /* _STRTOD_HEXADECIMAL_FLOATS */
+ number = number * p_base + (*pos - '0');
+#endif /* _STRTOD_HEXADECIMAL_FLOATS */
+#endif /* _STRTOD_RESTRICT_DIGITS */
+ ++pos;
+ }
+
+#ifdef __UCLIBC_HAS_LOCALE__
+#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
+ if (!pos0 && (*pos == decpt_wc)) { /* First decimal point? */
+ pos0 = ++pos;
+ goto LOOP;
+ }
+#else
+ if (!pos0 && !memcmp(pos, decpt, decpt_len)) { /* First decimal point? */
+ pos0 = (pos += decpt_len);
+ goto LOOP;
+ }
+#endif
+#else /* __UCLIBC_HAS_LOCALE__ */
+ if ((*pos == '.') && !pos0) { /* First decimal point? */
+ pos0 = ++pos; /* Save position of decimal point */
+ goto LOOP; /* and process rest of digits. */
+ }
+#endif /* __UCLIBC_HAS_LOCALE__ */
+
+#ifdef _STRTOD_NEED_NUM_DIGITS
+ if (num_digits<0) { /* Must have at least one digit. */
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ if (poshex) { /* Back up to '0' in '0x' prefix. */
+ pos = poshex;
+ goto DONE;
+ }
+#endif /* _STRTOD_HEXADECIMAL_FLOATS */
+
+#ifdef _STRTOD_NAN_INF_STRINGS
+ if (!pos0) { /* No decimal point, so check for inf/nan. */
+ /* Note: nan is the first string so 'number = i/0.;' works. */
+ static const char nan_inf_str[] = "\05nan\0\012infinity\0\05inf\0";
+ int i = 0;
+
+#ifdef __UCLIBC_HAS_LOCALE__
+ /* Avoid tolower problems for INFINITY in the tr_TR locale. (yuk)*/
+#undef _tolower
+#define _tolower(C) ((C)|0x20)
+#endif /* __UCLIBC_HAS_LOCALE__ */
+
+ do {
+ /* Unfortunately, we have no memcasecmp(). */
+ int j = 0;
+ while (_tolower(pos[j]) == nan_inf_str[i+1+j]) {
+ ++j;
+ if (!nan_inf_str[i+1+j]) {
+ number = i / 0.;
+ if (negative) { /* Correct for sign. */
+ number = -number;
+ }
+ pos += nan_inf_str[i] - 2;
+ goto DONE;
+ }
+ }
+ i += nan_inf_str[i];
+ } while (nan_inf_str[i]);
+ }
+
+#endif /* STRTOD_NAN_INF_STRINGS */
+#ifdef _STRTOD_ENDPTR
+ pos = (Wchar *) str;
+#endif
+ goto DONE;
+ }
+#endif /* _STRTOD_NEED_NUM_DIGITS */
+
+#ifdef _STRTOD_RESTRICT_DIGITS
+ if (num_digits > DECIMAL_DIG) { /* Adjust exponent for skipped digits. */
+ exponent_power += num_digits - DECIMAL_DIG;
+ }
+#endif
+
+ if (pos0) {
+ exponent_power += pos0 - pos; /* Adjust exponent for decimal point. */
+ }
+
+#ifdef _STRTOD_HEXADECIMAL_FLOATS
+ if (poshex) {
+ exponent_power *= 4; /* Above is 2**4, but below is 2. */
+ p_base = 2;
+ }
+#endif /* _STRTOD_HEXADECIMAL_FLOATS */
+
+ if (negative) { /* Correct for sign. */
+ number = -number;
+ }
+
+ /* process an exponent string */
+ if (((*pos)|0x20) == EXPCHAR) {
+#ifdef _STRTOD_ENDPTR
+ pos1 = pos;
+#endif
+ negative = 1;
+ switch(*++pos) { /* Handle optional sign. */
+ case '-': negative = -1; /* Fall through to increment pos. */
+ case '+': ++pos;
+ }
+
+ pos0 = pos;
+ exponent_temp = 0;
+ while (isdigit(*pos)) { /* Process string of digits. */
+#ifdef _STRTOD_RESTRICT_EXP
+ if (exponent_temp < MAX_ALLOWED_EXP) { /* Avoid overflow. */
+ exponent_temp = exponent_temp * 10 + (*pos - '0');
+ }
+#else
+ exponent_temp = exponent_temp * 10 + (*pos - '0');
+#endif
+ ++pos;
+ }
+
+#ifdef _STRTOD_ENDPTR
+ if (pos == pos0) { /* No digits? */
+ pos = pos1; /* Back up to {e|E}/{p|P}. */
+ } /* else */
+#endif
+
+ exponent_power += negative * exponent_temp;
+ }
+
+#ifdef _STRTOD_ZERO_CHECK
+ if (number == 0.) {
+ goto DONE;
+ }
+#endif
+
+ /* scale the result */
+#ifdef _STRTOD_LOG_SCALING
+ exponent_temp = exponent_power;
+
+ if (exponent_temp < 0) {
+ exponent_temp = -exponent_temp;
+ }
+
+ while (exponent_temp) {
+ if (exponent_temp & 1) {
+ if (exponent_power < 0) {
+ /* Warning... caluclating a factor for the exponent and
+ * then dividing could easily be faster. But doing so
+ * might cause problems when dealing with denormals. */
+ number /= p_base;
+ } else {
+ number *= p_base;
+ }
+ }
+ exponent_temp >>= 1;
+ p_base *= p_base;
+ }
+
+#else /* _STRTOD_LOG_SCALING */
+ while (exponent_power) {
+ if (exponent_power < 0) {
+ number /= p_base;
+ exponent_power++;
+ } else {
+ number *= p_base;
+ exponent_power--;
+ }
+ }
+#endif /* _STRTOD_LOG_SCALING */
+
+#ifdef _STRTOD_ERRNO
+ if (__FPMAX_ZERO_OR_INF_CHECK(number)) {
+ __set_errno(ERANGE);
+ }
+#endif
+
+ DONE:
+#ifdef _STRTOD_ENDPTR
+ if (endptr) {
+ *endptr = pos;
+ }
+#endif
+
+ return number;
+}
+
+#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+
+#endif
+/**********************************************************************/
+#ifdef L___fp_range_check
+#if defined(NEED_STRTOF_WRAPPER) || defined(NEED_STRTOD_WRAPPER)
+
+void attribute_hidden __fp_range_check(__fpmax_t y, __fpmax_t x)
+{
+ if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */
+ && (y != 0) /* y is not 0 (could have x>0, y==0 if underflow) */
+ && !__FPMAX_ZERO_OR_INF_CHECK(x) /* x is not 0 or +/- infinity */
+ ) {
+ __set_errno(ERANGE); /* Then x is not in y's range. */
+ }
+}
+
+#endif
+#endif
+/**********************************************************************/
+#if defined(L_strtof) || defined(L_strtof_l) || defined(L_wcstof) || defined(L_wcstof_l)
+#if defined(NEED_STRTOF_WRAPPER)
+
+#if defined(L_wcstof) || defined(L_wcstof_l)
+#define strtof wcstof
+#define strtof_l wcstof_l
+#define __strtofpmax __wcstofpmax
+#define __strtofpmax_l __wcstofpmax_l
+#define Wchar wchar_t
+#else
+#define Wchar char
+#endif
+
+
+libc_hidden_proto(__XL_NPP(strtof))
+float __XL_NPP(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
+{
+#if FPMAX_TYPE == 1
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+#else
+ __fpmax_t x;
+ float y;
+
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ y = (float) x;
+
+ __fp_range_check(y, x);
+
+ return y;
+#endif
+}
+libc_hidden_def(__XL_NPP(strtof))
+
+#endif
+#endif
+/**********************************************************************/
+#if defined(L_strtod) || defined(L_strtod_l) || defined(L_wcstod) || defined(L_wcstod_l)
+#if defined(NEED_STRTOD_WRAPPER)
+
+#if defined(L_wcstod) || defined(L_wcstod_l)
+#define strtod wcstod
+#define strtod_l wcstod_l
+#define __strtofpmax __wcstofpmax
+#define __strtofpmax_l __wcstofpmax_l
+#define Wchar wchar_t
+#else
+#define Wchar char
+#endif
+
+libc_hidden_proto(__XL_NPP(strtod))
+double __XL_NPP(strtod)(const Wchar *__restrict str,
+ Wchar **__restrict endptr __LOCALE_PARAM )
+{
+#if FPMAX_TYPE == 2
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+#else
+ __fpmax_t x;
+ double y;
+
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ y = (double) x;
+
+ __fp_range_check(y, x);
+
+ return y;
+#endif
+}
+libc_hidden_def(__XL_NPP(strtod))
+
+#endif
+#endif
+/**********************************************************************/
+#if defined(L_strtold) || defined(L_strtold_l) || defined(L_wcstold) || defined(L_wcstold_l)
+#if defined(NEED_STRTOLD_WRAPPER)
+
+#if defined(L_wcstold) || defined(L_wcstold_l)
+#define strtold wcstold
+#define strtold_l wcstold_l
+#define __strtofpmax __wcstofpmax
+#define __strtofpmax_l __wcstofpmax_l
+#define Wchar wchar_t
+#else
+#define Wchar char
+#endif
+
+libc_hidden_proto(__XL_NPP(strtold))
+long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM )
+{
+#if FPMAX_TYPE == 3
+ return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+#else
+ __fpmax_t x;
+ long double y;
+
+ x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
+ y = (long double) x;
+
+ __fp_range_check(y, x);
+
+ return y;
+#endif
+}
+libc_hidden_def(__XL_NPP(strtold))
+
+#endif
+#endif
+/**********************************************************************/
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index 47252d1f7..a940768c0 100644
--- a/libc/stdlib/abort.c
+++ b/libc/stdlib/abort.c
@@ -18,9 +18,6 @@ Cambridge, MA 02139, USA. */
/* Hacked up for uClibc by Erik Andersen */
-#define sigaction __sigaction
-
-#define _GNU_SOURCE
#include <features.h>
#include <signal.h>
#include <stdio.h>
@@ -30,41 +27,20 @@ Cambridge, MA 02139, USA. */
#include <signal.h>
#include <errno.h>
+libc_hidden_proto(abort)
+
+libc_hidden_proto(memset)
+libc_hidden_proto(sigaction)
+libc_hidden_proto(sigprocmask)
+libc_hidden_proto(raise)
+libc_hidden_proto(_exit)
/* Our last ditch effort to commit suicide */
-#if defined(__alpha__)
-#define ABORT_INSTRUCTION asm ("call_pal 0")
-#elif defined(__arm__)
-#define ABORT_INSTRUCTION asm ("bl abort")
-#elif defined(__hppa__)
-#define ABORT_INSTRUCTION asm ("iitlbp %r0,(%r0)")
-#elif defined(__i386__)
-#define ABORT_INSTRUCTION asm ("hlt")
-#elif defined(__ia64__)
-#define ABORT_INSTRUCTION asm ("break 0")
-#elif defined(__m68k__)
-#define ABORT_INSTRUCTION asm ("illegal")
-#elif defined(__mc68000__)
-#define ABORT_INSTRUCTION asm (".long 0xffffffff")
-#elif defined(__mips__)
-#define ABORT_INSTRUCTION asm ("break 255")
-#elif defined(__powerpc__)
-#define ABORT_INSTRUCTION asm (".long 0")
-#elif defined(__s390__)
-#define ABORT_INSTRUCTION asm (".word 0")
-#elif defined(__sparc__)
-#define ABORT_INSTRUCTION asm ("unimp 0xf00")
-#elif defined(__SH5__)
-#define ABORT_INSTRUCTION asm ("movi 0x10, r9; shori 0xff, r9; trapa r9")
-#elif defined(__sh2__)
-#define ABORT_INSTRUCTION asm ("trapa #32")
-#elif defined(__sh__)
-#define ABORT_INSTRUCTION asm ("trapa #0xff")
-#elif defined(__x86_64__)
-#define ABORT_INSTRUCTION asm ("hlt")
+#ifdef __UCLIBC_ABORT_INSTRUCTION__
+# define ABORT_INSTRUCTION __asm__(__UCLIBC_ABORT_INSTRUCTION__)
#else
-#define ABORT_INSTRUCTION
-#warning no abort instruction defined for your arch
+# define ABORT_INSTRUCTION
+# warning "no abort instruction defined for your arch"
#endif
#ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__
@@ -80,21 +56,17 @@ static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#define LOCK __pthread_mutex_lock(&mylock)
#define UNLOCK __pthread_mutex_unlock(&mylock)
-extern int __raise (int __sig) __THROW attribute_hidden;
-
/* Cause an abnormal program termination with core-dump */
-#undef __abort
-#undef abort
-void attribute_hidden __abort(void)
+void abort(void)
{
- sigset_t sigset;
+ sigset_t sigs;
/* Make sure we acquire the lock before proceeding */
LOCK;
/* Unmask SIGABRT to be sure we can get it */
- if (__sigemptyset(&sigset) == 0 && __sigaddset(&sigset, SIGABRT) == 0) {
- __sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL);
+ if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) {
+ sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL);
}
while (1) {
@@ -104,8 +76,8 @@ void attribute_hidden __abort(void)
#ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__
/* If we are using stdio, try to shut it down. At the very least,
- * this will attemt to commit all buffered writes. It may also
- * unboffer all writable files, or close them outright.
+ * this will attempt to commit all buffered writes. It may also
+ * unbuffer all writable files, or close them outright.
* Check the stdio routines for details. */
if (_stdio_term) {
_stdio_term();
@@ -114,7 +86,7 @@ void attribute_hidden __abort(void)
abort_it:
UNLOCK;
- __raise(SIGABRT);
+ raise(SIGABRT);
LOCK;
}
@@ -123,7 +95,7 @@ abort_it:
struct sigaction act;
been_there_done_that++;
- __memset(&act, '\0', sizeof(struct sigaction));
+ memset(&act, '\0', sizeof(struct sigaction));
act.sa_handler = SIG_DFL;
__sigfillset(&act.sa_mask);
act.sa_flags = 0;
@@ -141,7 +113,7 @@ abort_it:
/* Still here? Try to at least exit */
if (been_there_done_that == 3) {
been_there_done_that++;
- _exit_internal(127);
+ _exit(127);
}
/* Still here? We're screwed. Sleepy time. Good night. */
@@ -150,4 +122,4 @@ abort_it:
ABORT_INSTRUCTION;
}
}
-strong_alias(__abort,abort)
+libc_hidden_def(abort)
diff --git a/libc/stdlib/abs.c b/libc/stdlib/abs.c
new file mode 100644
index 000000000..540c020ec
--- /dev/null
+++ b/libc/stdlib/abs.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_abs
+#include "stdlib.c"
diff --git a/libc/stdlib/arc4random.c b/libc/stdlib/arc4random.c
index ebdd7d561..836b79f6c 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -27,8 +27,6 @@
*/
#include <features.h>
-#ifdef __UCLIBC_HAS_ARC4RANDOM__
-
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
@@ -37,12 +35,18 @@
#include <sys/time.h>
#ifdef __ARC4RANDOM_USE_ERANDOM__
#include <sys/sysctl.h>
+//libc_hidden_proto(sysctl)
#endif
+libc_hidden_proto(open)
+libc_hidden_proto(read)
+libc_hidden_proto(close)
+libc_hidden_proto(gettimeofday)
+
struct arc4_stream {
- u_int8_t i;
- u_int8_t j;
- u_int8_t s[256];
+ uint8_t i;
+ uint8_t j;
+ uint8_t s[256];
};
static int rs_initialized;
@@ -51,8 +55,8 @@ static struct arc4_stream rs;
static inline void arc4_init(struct arc4_stream *);
static inline void arc4_addrandom(struct arc4_stream *, u_char *, int);
static void arc4_stir(struct arc4_stream *);
-static inline u_int8_t arc4_getbyte(struct arc4_stream *);
-static inline u_int32_t arc4_getword(struct arc4_stream *);
+static inline uint8_t arc4_getbyte(struct arc4_stream *);
+static inline uint32_t arc4_getword(struct arc4_stream *);
static inline void
arc4_init(as)
@@ -73,7 +77,7 @@ arc4_addrandom(as, dat, datlen)
int datlen;
{
int n;
- u_int8_t si;
+ uint8_t si;
as->i--;
for (n = 0; n < 256; n++) {
@@ -93,20 +97,20 @@ arc4_stir(as)
int fd;
struct {
struct timeval tv;
- u_int rnd[(128 - sizeof(struct timeval)) / sizeof(u_int)];
+ uint rnd[(128 - sizeof(struct timeval)) / sizeof(uint)];
} rdat;
int n;
gettimeofday(&rdat.tv, NULL);
- fd = __open("/dev/urandom", O_RDONLY);
+ fd = open("/dev/urandom", O_RDONLY);
if (fd != -1) {
- __read(fd, rdat.rnd, sizeof(rdat.rnd));
- __close(fd);
+ read(fd, rdat.rnd, sizeof(rdat.rnd));
+ close(fd);
}
#ifdef __ARC4RANDOM_USE_ERANDOM__
else {
int mib[3];
- u_int i;
+ uint i;
size_t len;
/* Device could not be opened, we might be chrooted, take
@@ -116,8 +120,8 @@ arc4_stir(as)
mib[1] = KERN_RANDOM;
mib[2] = RANDOM_ERANDOM;
- for (i = 0; i < sizeof(rdat.rnd) / sizeof(u_int); i++) {
- len = sizeof(u_int);
+ for (i = 0; i < sizeof(rdat.rnd) / sizeof(uint); i++) {
+ len = sizeof(uint);
if (sysctl(mib, 3, &rdat.rnd[i], &len, NULL, 0) == -1)
break;
}
@@ -137,11 +141,11 @@ arc4_stir(as)
arc4_getbyte(as);
}
-static inline u_int8_t
+static inline uint8_t
arc4_getbyte(as)
struct arc4_stream *as;
{
- u_int8_t si, sj;
+ uint8_t si, sj;
as->i = (as->i + 1);
si = as->s[as->i];
@@ -152,11 +156,11 @@ arc4_getbyte(as)
return (as->s[(si + sj) & 0xff]);
}
-static inline u_int32_t
+static inline uint32_t
arc4_getword(as)
struct arc4_stream *as;
{
- u_int32_t val;
+ uint32_t val;
val = arc4_getbyte(as) << 24;
val |= arc4_getbyte(as) << 16;
val |= arc4_getbyte(as) << 8;
@@ -164,8 +168,9 @@ arc4_getword(as)
return val;
}
+libc_hidden_proto(arc4random_stir)
void
-arc4random_stir()
+arc4random_stir(void)
{
if (!rs_initialized) {
arc4_init(&rs);
@@ -173,19 +178,18 @@ arc4random_stir()
}
arc4_stir(&rs);
}
+libc_hidden_def(arc4random_stir)
void
-arc4random_addrandom(dat, datlen)
- u_char *dat;
- int datlen;
+arc4random_addrandom(u_char *dat, int datlen)
{
if (!rs_initialized)
arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}
-u_int32_t
-arc4random()
+uint32_t
+arc4random(void)
{
if (!rs_initialized)
arc4random_stir();
@@ -204,5 +208,3 @@ int main(void) {
return 0;
}
#endif
-
-#endif /* __UCLIBC_HAS_ARC4RANDOM__ */
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index f6944edc5..158869e77 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -1,351 +1,8 @@
-/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
- * This file is part of the Linux-8086 C library and is distributed
- * under the GNU Library General Public License.
- */
-
/*
- * Dec 2000 Manuel Novoa III
- *
- * Made atexit handling conform to standards... i.e. no args.
- * Removed on_exit since it did not match gnu libc definition.
- * Combined atexit and __do_exit into one object file.
- *
- * Feb 2001 Manuel Novoa III
- *
- * Reworked file after addition of __uClibc_main.
- * Changed name of __do_exit to atexit_handler.
- * Changed name of __cleanup to __uClibc_cleanup.
- * Moved declaration of __uClibc_cleanup to __uClibc_main
- * where it is initialized with (possibly weak alias)
- * _stdio_term.
- *
- * Jul 2001 Steve Thayer
- *
- * Added an on_exit implementation (that now matches gnu libc definition.)
- * Pulled atexit_handler out of the atexit object since it is now required by
- * on_exit as well. Renamed it to __exit_handler.
- * Fixed a problem where exit functions stop getting called if one of
- * them calls exit().
- * As a side effect of these changes, abort() no longer calls the exit
- * functions (it now matches the gnu libc definition).
- *
- * August 2002 Erik Andersen
- * Added locking so atexit and friends can be thread safe
- *
- * August 2005 Stephen Warren
- * Added __cxa_atexit and __cxa_finalize support
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
-#include <features.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <atomic.h>
-
-#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-extern pthread_mutex_t mylock;
-#endif
-#define LOCK __pthread_mutex_lock(&mylock)
-#define UNLOCK __pthread_mutex_unlock(&mylock)
-
-
-typedef void (*aefuncp) (void); /* atexit function pointer */
-typedef void (*oefuncp) (int, void *); /* on_exit function pointer */
-typedef void (*cxaefuncp) (void *); /* __cxa_atexit function pointer */
-typedef enum {
- ef_free,
- ef_in_use,
- ef_on_exit,
- ef_cxa_atexit
-} ef_type; /* exit function types */
-
-/* this is in the L_exit object */
-extern void (*__exit_cleanup) (int);
-
-/* these are in the L___do_exit object */
-extern int __exit_slots;
-extern int __exit_count;
-extern void __exit_handler(int);
-struct exit_function {
- /*
- * 'type' should be of type of the 'enum ef_type' above but since we
- * need this element in an atomic operation we have to use 'long int'.
- */
- long int type; /* enum ef_type */
- union {
- struct {
- oefuncp func;
- void *arg;
- } on_exit;
- struct {
- cxaefuncp func;
- void *arg;
- void* dso_handle;
- } cxa_atexit;
- } funcs;
-};
-#ifdef __UCLIBC_DYNAMIC_ATEXIT__
-extern struct exit_function *__exit_function_table;
-#else
-extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT];
-#endif
-extern struct exit_function *__new_exitfn (void) attribute_hidden;
-
-/* this is in the L___cxa_atexit object */
-extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle);
-
-
-/* remove old_atexit after 0.9.29 */
-#if defined(L_atexit) || defined(L_old_atexit)
-extern void *__dso_handle __attribute__ ((__weak__));
-
-/*
- * register a function to be called at normal program termination
- * (the registered function takes no arguments)
- */
-#ifdef L_atexit
-int attribute_hidden atexit(aefuncp func)
-#else
-int old_atexit(aefuncp func)
-#endif
-{
- /*
- * glibc casts aefuncp to cxaefuncp.
- * This seems dodgy, but I guess callling a function with more
- * parameters than it needs will work everywhere?
- */
- return __cxa_atexit((cxaefuncp)func, NULL,
- &__dso_handle == NULL ? NULL : __dso_handle);
-}
-#ifndef L_atexit
-weak_alias(old_atexit,atexit)
-#endif
-#endif
-
-#ifdef L_on_exit
-/*
- * register a function to be called at normal program termination
- * the registered function takes two arguments:
- * status - the exit status that was passed to the exit() function
- * arg - generic argument
- */
-int on_exit(oefuncp func, void *arg)
-{
- struct exit_function *efp;
-
- if (func == NULL) {
- return 0;
- }
-
- efp = __new_exitfn();
- if (efp == NULL) {
- return -1;
- }
-
- efp->funcs.on_exit.func = func;
- efp->funcs.on_exit.arg = arg;
- /* assign last for thread safety, since we're now unlocked */
- efp->type = ef_on_exit;
-
- return 0;
-}
-#endif
-
-#ifdef L___cxa_atexit
-extern int __cxa_atexit (cxaefuncp func, void *arg, void *dso_handle)
-{
- struct exit_function *efp;
-
- if (func == NULL) {
- return 0;
- }
-
- efp = __new_exitfn();
- if (efp == NULL) {
- return -1;
- }
-
- efp->funcs.cxa_atexit.func = func;
- efp->funcs.cxa_atexit.arg = arg;
- efp->funcs.cxa_atexit.dso_handle = dso_handle;
- /* assign last for thread safety, since we're now unlocked */
- efp->type = ef_cxa_atexit;
-
- return 0;
-}
-#endif
-
-#ifdef L___cxa_finalize
-/*
- * If D is non-NULL, call all functions registered with `__cxa_atexit'
- * with the same dso handle. Otherwise, if D is NULL, call all of the
- * registered handlers.
- */
-void __cxa_finalize (void *dso_handle)
-{
- struct exit_function *efp;
- int exit_count_snapshot = __exit_count;
-
- /* In reverse order */
- while (exit_count_snapshot) {
- efp = &__exit_function_table[--exit_count_snapshot];
-
- /*
- * We check dso_handle match before we verify the type of the union entry.
- * However, the atomic_exchange will validate that we were really "allowed"
- * to read dso_handle...
- */
- if ((dso_handle == NULL || dso_handle == efp->funcs.cxa_atexit.dso_handle)
- /* We don't want to run this cleanup more than once. */
- && !atomic_compare_and_exchange_bool_acq(&efp->type, ef_free, ef_cxa_atexit)
- ) {
- /* glibc passes status (0) too, but that's not in the prototype */
- (*efp->funcs.cxa_atexit.func)(efp->funcs.cxa_atexit.arg);
- }
- }
-
-#if 0 /* haven't looked into this yet... */
- /*
- * Remove the registered fork handlers. We do not have to
- * unregister anything if the program is going to terminate anyway.
- */
-#ifdef UNREGISTER_ATFORK
- if (d != NULL) {
- UNREGISTER_ATFORK (d);
- }
-#endif
-#endif
-}
-#endif
-
-#ifdef L___exit_handler
-int __exit_count = 0; /* Number of registered exit functions */
-#ifdef __UCLIBC_DYNAMIC_ATEXIT__
-struct exit_function *__exit_function_table = NULL;
-int __exit_slots = 0; /* Size of __exit_function_table */
-#else
-struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT];
-#endif
-
-/*
- * Find and return a new exit_function pointer, for atexit,
- * onexit and __cxa_atexit to initialize
- */
-struct exit_function attribute_hidden *__new_exitfn(void)
-{
- struct exit_function *efp;
-
- LOCK;
-
-#ifdef __UCLIBC_DYNAMIC_ATEXIT__
- /* If we are out of function table slots, make some more */
- if (__exit_slots < __exit_count+1) {
- efp=realloc(__exit_function_table,
- (__exit_slots+20)*sizeof(struct exit_function));
- if (efp == NULL) {
- UNLOCK;
- __set_errno(ENOMEM);
- return 0;
- }
- __exit_function_table = efp;
- __exit_slots += 20;
- }
-#else
- if (__exit_count >= __UCLIBC_MAX_ATEXIT) {
- UNLOCK;
- __set_errno(ENOMEM);
- return 0;
- }
-#endif
-
- __exit_cleanup = __exit_handler; /* enable cleanup */
- efp = &__exit_function_table[__exit_count++];
- efp->type = ef_in_use;
-
- UNLOCK;
-
- return efp;
-}
-
-/*
- * Handle the work of executing the registered exit functions
- * This is called while we are locked, so no additional locking
- * is needed...
- */
-void __exit_handler(int status)
-{
- struct exit_function *efp;
-
- /* In reverse order */
- while ( __exit_count ) {
- efp = &__exit_function_table[--__exit_count];
- switch (efp->type) {
- case ef_on_exit:
- if (efp->funcs.on_exit.func) {
- (efp->funcs.on_exit.func) (status, efp->funcs.on_exit.arg);
- }
- break;
- case ef_cxa_atexit:
- if (efp->funcs.cxa_atexit.func) {
- /* glibc passes status too, but that's not in the prototype */
- (efp->funcs.cxa_atexit.func) (efp->funcs.cxa_atexit.arg);
- }
- break;
- }
- }
-#ifdef __UCLIBC_DYNAMIC_ATEXIT__
- /* Free up memory used by the __exit_function_table structure */
- if (__exit_function_table)
- free(__exit_function_table);
-#endif
-}
-#endif
-
-#ifdef L_exit
-extern void weak_function _stdio_term(void) attribute_hidden;
-void (*__exit_cleanup) (int) = 0;
-#ifdef __UCLIBC_HAS_THREADS__
-pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-#endif
-
-#ifdef __UCLIBC_CTOR_DTOR__
-extern void (*__app_fini)(void);
-#endif
-
-extern void (*__rtld_fini)(void);
-
-/*
- * Normal program termination
- */
-#undef exit
-#undef __exit
-void attribute_hidden __exit(int rv)
-{
- /* Perform exit-specific cleanup (atexit and on_exit) */
- LOCK;
- if (__exit_cleanup) {
- __exit_cleanup(rv);
- }
- UNLOCK;
-
-#ifdef __UCLIBC_CTOR_DTOR__
- if (__app_fini != NULL)
- (__app_fini)();
-#endif
- if (__rtld_fini != NULL)
- (__rtld_fini)();
-
- /* If we are using stdio, try to shut it down. At the very least,
- * this will attempt to commit all buffered writes. It may also
- * unbuffer all writable files, or close them outright.
- * Check the stdio routines for details. */
- if (_stdio_term)
- _stdio_term();
-
- _exit_internal(rv);
-}
-strong_alias(__exit,exit)
-#endif
+#define L_atexit
+#include "_atexit.c"
diff --git a/libc/stdlib/atof.c b/libc/stdlib/atof.c
new file mode 100644
index 000000000..2fdd75cda
--- /dev/null
+++ b/libc/stdlib/atof.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_atof
+#include "stdlib.c"
diff --git a/libc/stdlib/atoi.c b/libc/stdlib/atoi.c
new file mode 100644
index 000000000..61562bbb2
--- /dev/null
+++ b/libc/stdlib/atoi.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_atoi
+#include "stdlib.c"
diff --git a/libc/stdlib/atol.c b/libc/stdlib/atol.c
new file mode 100644
index 000000000..3e5772085
--- /dev/null
+++ b/libc/stdlib/atol.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_atol
+#include "stdlib.c"
diff --git a/libc/stdlib/atoll.c b/libc/stdlib/atoll.c
new file mode 100644
index 000000000..f6b04a66c
--- /dev/null
+++ b/libc/stdlib/atoll.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_atoll
+#include "stdlib.c"
diff --git a/libc/stdlib/bsd_getpt.c b/libc/stdlib/bsd_getpt.c
index aec0ca4bc..9b885c4e5 100644
--- a/libc/stdlib/bsd_getpt.c
+++ b/libc/stdlib/bsd_getpt.c
@@ -22,6 +22,8 @@
#include <string.h>
#include <unistd.h>
+libc_hidden_proto(open)
+libc_hidden_proto(mempcpy)
/* Prefix for master pseudo terminal nodes. */
#define _PATH_PTY "/dev/pty"
@@ -48,7 +50,7 @@ __getpt (void)
const char *p, *q;
char *s;
- s = __mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1);
+ s = mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1);
/* s[0] and s[1] will be filled in the loop. */
s[2] = '\0';
@@ -62,7 +64,7 @@ __getpt (void)
s[1] = *q;
- fd = __open (buf, O_RDWR);
+ fd = open (buf, O_RDWR);
if (fd != -1)
return fd;
diff --git a/libc/stdlib/bsearch.c b/libc/stdlib/bsearch.c
new file mode 100644
index 000000000..4feceefd3
--- /dev/null
+++ b/libc/stdlib/bsearch.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_bsearch
+#include "stdlib.c"
diff --git a/libc/stdlib/drand48-iter.c b/libc/stdlib/drand48-iter.c
index bc2c15cb6..0e674a3ce 100644
--- a/libc/stdlib/drand48-iter.c
+++ b/libc/stdlib/drand48-iter.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu <mailto:drepper@gnu.ai.mit.edu>>, August 1995.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -24,11 +24,14 @@
#include <sys/types.h>
/* Global state for non-reentrant functions. */
-struct drand48_data __libc_drand48_data;
+struct drand48_data __libc_drand48_data attribute_hidden;
-int attribute_hidden
-__drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
+int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
+int
+__drand48_iterate (xsubi, buffer)
+ unsigned short int xsubi[3];
+ struct drand48_data *buffer;
{
uint64_t X;
uint64_t result;
@@ -55,4 +58,3 @@ __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
return 0;
}
-
diff --git a/libc/stdlib/drand48.c b/libc/stdlib/drand48.c
index fc66816c1..ab6239d75 100644
--- a/libc/stdlib/drand48.c
+++ b/libc/stdlib/drand48.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2001,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu <mailto:drepper@gnu.ai.mit.edu>>, August 1995.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,18 +17,19 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define erand48_r __erand48_r
-
#include <stdlib.h>
+libc_hidden_proto(erand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
-double drand48 (void)
+double
+drand48 ()
{
- double result;
+ double result;
- erand48_r (__libc_drand48_data.__x, &__libc_drand48_data, &result);
+ (void) erand48_r (__libc_drand48_data.__x, &__libc_drand48_data, &result);
- return result;
+ return result;
}
diff --git a/libc/stdlib/drand48_r.c b/libc/stdlib/drand48_r.c
index 14235e6e0..1000a3acb 100644
--- a/libc/stdlib/drand48_r.c
+++ b/libc/stdlib/drand48_r.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu <mailto:drepper@gnu.ai.mit.edu>>, August 1995.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,13 +17,13 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define erand48_r __erand48_r
-
#include <errno.h>
#include <math.h>
#include <stdlib.h>
+libc_hidden_proto(erand48_r)
+
int drand48_r (struct drand48_data *buffer, double *result)
{
- return erand48_r (buffer->__x, buffer, result);
+ return erand48_r (buffer->__x, buffer, result);
}
diff --git a/libc/stdlib/erand48.c b/libc/stdlib/erand48.c
index 96a8ad115..853c2c35a 100644
--- a/libc/stdlib/erand48.c
+++ b/libc/stdlib/erand48.c
@@ -17,11 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define erand48_r __erand48_r
#include <stdlib.h>
+libc_hidden_proto(erand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
double erand48 (unsigned short int xsubi[3])
{
diff --git a/libc/stdlib/erand48_r.c b/libc/stdlib/erand48_r.c
index 0a69266a7..3dd0dfdf0 100644
--- a/libc/stdlib/erand48_r.c
+++ b/libc/stdlib/erand48_r.c
@@ -24,7 +24,8 @@
extern int __drand48_iterate(unsigned short xsubi[3],
struct drand48_data *buffer) attribute_hidden;
-int attribute_hidden __erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
+libc_hidden_proto(erand48_r)
+int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
{
union ieee754_double temp;
@@ -45,4 +46,4 @@ int attribute_hidden __erand48_r (unsigned short int xsubi[3], struct drand48_da
return 0;
}
-strong_alias(__erand48_r,erand48_r)
+libc_hidden_def(erand48_r)
diff --git a/libc/stdlib/exit.c b/libc/stdlib/exit.c
new file mode 100644
index 000000000..a2255d2b4
--- /dev/null
+++ b/libc/stdlib/exit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_exit
+#include "_atexit.c"
diff --git a/libc/stdlib/gcvt.c b/libc/stdlib/gcvt.c
index 75e3bbe70..f1c1f4270 100644
--- a/libc/stdlib/gcvt.c
+++ b/libc/stdlib/gcvt.c
@@ -1,11 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
+libc_hidden_proto(sprintf)
+
#ifdef __UCLIBC_HAS_FLOATS__
#define MAX_NDIGIT 17
char *gcvt (double number, int ndigit, char *buf)
{
- __sprintf(buf, "%.*g", (ndigit > MAX_NDIGIT)? MAX_NDIGIT : ndigit, number);
+ sprintf(buf, "%.*g", (ndigit > MAX_NDIGIT)? MAX_NDIGIT : ndigit, number);
return buf;
}
#endif
diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c
index 6cbdc3e65..4f4c4f1f8 100644
--- a/libc/stdlib/getenv.c
+++ b/libc/stdlib/getenv.c
@@ -1,42 +1,34 @@
/* getenv.c for uClibc
- Erik Andersen <andersen@codepoet.org>
-
- 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.
- */
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <string.h>
#include <unistd.h>
+#include <stdlib.h>
+
+libc_hidden_proto(getenv)
+libc_hidden_proto(memcmp)
+libc_hidden_proto(strlen)
+libc_hidden_proto(__environ)
/* IEEE Std 1003.1-2001 says getenv need not be thread safe, so
* don't bother locking access to __environ */
-char attribute_hidden *__getenv(const char *var)
+char *getenv(const char *var)
{
int len;
char **ep;
if (!(ep=__environ))
return NULL;
- len = __strlen(var);
+ len = strlen(var);
while(*ep) {
- if (__memcmp(var, *ep, len) == 0 && (*ep)[len] == '=') {
+ if (memcmp(var, *ep, len) == 0 && (*ep)[len] == '=') {
return *ep + len + 1;
}
ep++;
}
return NULL;
}
-
-strong_alias(__getenv,getenv)
+libc_hidden_def(getenv)
diff --git a/libc/stdlib/getpt.c b/libc/stdlib/getpt.c
index 4bd082823..cab96bb06 100644
--- a/libc/stdlib/getpt.c
+++ b/libc/stdlib/getpt.c
@@ -23,6 +23,9 @@
#include <unistd.h>
#include <paths.h>
+libc_hidden_proto(open)
+libc_hidden_proto(close)
+
#if !defined __ASSUME_DEVPTS__
# include <sys/statfs.h>
@@ -55,7 +58,7 @@ getpt (void)
if (!have_no_dev_ptmx)
#endif
{
- fd = __open (_PATH_DEVPTMX, O_RDWR);
+ fd = open (_PATH_DEVPTMX, O_RDWR);
if (fd != -1)
{
#if defined __ASSUME_DEVPTS__
@@ -79,7 +82,7 @@ getpt (void)
/* If /dev/pts is not mounted then the UNIX98 pseudo terminals
are not usable. */
- __close (fd);
+ close (fd);
#if !defined __UNIX98PTY_ONLY__
have_no_dev_ptmx = 1;
#endif
diff --git a/libc/stdlib/jrand48.c b/libc/stdlib/jrand48.c
index 44b32487f..6f812068b 100644
--- a/libc/stdlib/jrand48.c
+++ b/libc/stdlib/jrand48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define jrand48_r __jrand48_r
-
#include <stdlib.h>
+libc_hidden_proto(jrand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
long int jrand48 (unsigned short int xsubi[3])
{
diff --git a/libc/stdlib/jrand48_r.c b/libc/stdlib/jrand48_r.c
index a21bda080..912f70c4f 100644
--- a/libc/stdlib/jrand48_r.c
+++ b/libc/stdlib/jrand48_r.c
@@ -22,7 +22,8 @@
extern int __drand48_iterate(unsigned short xsubi[3],
struct drand48_data *buffer) attribute_hidden;
-int attribute_hidden __jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
+libc_hidden_proto(jrand48_r)
+int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
if (__drand48_iterate (xsubi, buffer) < 0)
@@ -33,4 +34,4 @@ int attribute_hidden __jrand48_r (unsigned short int xsubi[3], struct drand48_da
return 0;
}
-strong_alias(__jrand48_r,jrand48_r)
+libc_hidden_def(jrand48_r)
diff --git a/libc/stdlib/labs.c b/libc/stdlib/labs.c
new file mode 100644
index 000000000..95196af99
--- /dev/null
+++ b/libc/stdlib/labs.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_labs
+#include "stdlib.c"
diff --git a/libc/stdlib/ldiv.c b/libc/stdlib/ldiv.c
index f8e789a92..88a877116 100644
--- a/libc/stdlib/ldiv.c
+++ b/libc/stdlib/ldiv.c
@@ -57,5 +57,5 @@ ldiv (long int numer, long int denom)
#if __WORDSIZE == 64
#undef imaxdiv
-weak_alias (ldiv, imaxdiv)
+strong_alias(ldiv,imaxdiv)
#endif
diff --git a/libc/stdlib/llabs.c b/libc/stdlib/llabs.c
new file mode 100644
index 000000000..17ec30a64
--- /dev/null
+++ b/libc/stdlib/llabs.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_llabs
+#include "stdlib.c"
diff --git a/libc/stdlib/lldiv.c b/libc/stdlib/lldiv.c
index 56ccb2612..ff670174c 100644
--- a/libc/stdlib/lldiv.c
+++ b/libc/stdlib/lldiv.c
@@ -17,7 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define _GNU_SOURCE
#include <features.h>
#include <stdlib.h>
@@ -58,5 +57,5 @@ lldiv (long long int numer, long long int denom)
#if __WORDSIZE != 64
#undef imaxdiv
-weak_alias (lldiv, imaxdiv)
+strong_alias(lldiv,imaxdiv)
#endif
diff --git a/libc/stdlib/lrand48.c b/libc/stdlib/lrand48.c
index 88301d70f..863951f07 100644
--- a/libc/stdlib/lrand48.c
+++ b/libc/stdlib/lrand48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define nrand48_r __nrand48_r
-
#include <stdlib.h>
+libc_hidden_proto(nrand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
long int lrand48 (void)
{
diff --git a/libc/stdlib/lrand48_r.c b/libc/stdlib/lrand48_r.c
index 0ff1ef25e..277fb9ae3 100644
--- a/libc/stdlib/lrand48_r.c
+++ b/libc/stdlib/lrand48_r.c
@@ -17,11 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define nrand48_r __nrand48_r
-
#include <stdlib.h>
-int attribute_hidden __lrand48_r (struct drand48_data *buffer, long int *result)
+libc_hidden_proto(nrand48_r)
+
+libc_hidden_proto(lrand48_r)
+int lrand48_r (struct drand48_data *buffer, long int *result)
{
/* Be generous for the arguments, detect some errors. */
if (buffer == NULL)
@@ -29,4 +30,4 @@ int attribute_hidden __lrand48_r (struct drand48_data *buffer, long int *result)
return nrand48_r (buffer->__x, buffer, result);
}
-strong_alias(__lrand48_r,lrand48_r)
+libc_hidden_def(lrand48_r)
diff --git a/libc/stdlib/malloc-simple/Makefile.in b/libc/stdlib/malloc-simple/Makefile.in
index 7add9deaa..51488ff58 100644
--- a/libc/stdlib/malloc-simple/Makefile.in
+++ b/libc/stdlib/malloc-simple/Makefile.in
@@ -1,33 +1,22 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MSRC:=alloc.c
-MOBJ:=malloc.o realloc.o free.o calloc.o memalign.o
+STDLIB_MALLOC_SIMPLE_DIR := $(top_srcdir)libc/stdlib/malloc-simple
+STDLIB_MALLOC_SIMPLE_OUT := $(top_builddir)libc/stdlib/malloc-simple
-STDLIB_MALLOC_SIMPLE_DIR:=$(top_srcdir)libc/stdlib/malloc-simple
-STDLIB_MALLOC_SIMPLE_OUT:=$(top_builddir)libc/stdlib/malloc-simple
+CSRC := $(notdir $(wildcard $(STDLIB_MALLOC_SIMPLE_DIR)/*.c))
+CSRC := $(filter-out alloc.c,$(CSRC))
-STDLIB_MALLOC_SIMPLE_MSRC:=$(STDLIB_MALLOC_SIMPLE_DIR)/$(MSRC)
-STDLIB_MALLOC_SIMPLE_MOBJ:=$(patsubst %.o,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(MOBJ))
-STDLIB_MALLOC_SIMPLE_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(STDLIB_MALLOC_SIMPLE_MOBJ))))
+STDLIB_MALLOC_SIMPLE_SRC := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_DIR)/%.c,$(CSRC))
+STDLIB_MALLOC_SIMPLE_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(CSRC))
-libc-a-$(MALLOC_SIMPLE)+=$(STDLIB_MALLOC_SIMPLE_MOBJ)
-libc-so-$(MALLOC_SIMPLE)+=$(STDLIB_MALLOC_SIMPLE_MOBJ:.o=.os)
+libc-$(MALLOC_SIMPLE) += $(STDLIB_MALLOC_SIMPLE_OBJ)
-CFLAGS-multi-$(MALLOC_SIMPLE)+=$(STDLIB_MALLOC_SIMPLE_DEF)
-libc-multi-$(MALLOC_SIMPLE)+=$(STDLIB_MALLOC_SIMPLE_MSRC)
-
-$(STDLIB_MALLOC_SIMPLE_MOBJ): $(STDLIB_MALLOC_SIMPLE_MSRC)
- $(compile.m)
-
-$(STDLIB_MALLOC_SIMPLE_MOBJ:.o=.os): $(STDLIB_MALLOC_SIMPLE_MSRC)
- $(compile.m)
-
-objclean-y+=stdlib_malloc_simple_objclean
+objclean-y += stdlib_malloc_simple_objclean
stdlib_malloc_simple_objclean:
$(RM) $(STDLIB_MALLOC_SIMPLE_OUT)/*.{o,os}
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index 5a208bf28..e382cee55 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -1,15 +1,13 @@
/* alloc.c
*
- * Written by Erik Andersen <andersee@codepoet.org>
- * LGPLv2
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+/*
* Parts of the memalign code were stolen from malloc-930716.
*/
-#define mmap __mmap
-#define munmap __munmap
-
-#define _GNU_SOURCE
#include <features.h>
#include <unistd.h>
#include <stdio.h>
@@ -19,6 +17,10 @@
#include <errno.h>
#include <sys/mman.h>
+libc_hidden_proto(memcpy)
+/*libc_hidden_proto(memset)*/
+libc_hidden_proto(mmap)
+libc_hidden_proto(munmap)
#ifdef L_malloc
void *malloc(size_t size)
@@ -34,7 +36,7 @@ void *malloc(size_t size)
#endif
}
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
# define MMAP_FLAGS MAP_PRIVATE | MAP_ANONYMOUS
#else
# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS
@@ -67,7 +69,7 @@ void * calloc(size_t nmemb, size_t lsize)
* doesn't need to actually zero anything....
*/
if (result != NULL) {
- __memset(result, 0, size);
+ memset(result, 0, size);
}
#endif
return result;
@@ -88,7 +90,7 @@ void *realloc(void *ptr, size_t size)
newptr = malloc(size);
if (newptr) {
- __memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t))));
+ memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t))));
free(ptr);
}
return newptr;
diff --git a/libc/stdlib/malloc-simple/calloc.c b/libc/stdlib/malloc-simple/calloc.c
new file mode 100644
index 000000000..75edff86d
--- /dev/null
+++ b/libc/stdlib/malloc-simple/calloc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_calloc
+#include "alloc.c"
diff --git a/libc/stdlib/malloc-simple/free.c b/libc/stdlib/malloc-simple/free.c
new file mode 100644
index 000000000..553a6bfc8
--- /dev/null
+++ b/libc/stdlib/malloc-simple/free.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_free
+#include "alloc.c"
diff --git a/libc/stdlib/malloc-simple/malloc.c b/libc/stdlib/malloc-simple/malloc.c
new file mode 100644
index 000000000..61f33d871
--- /dev/null
+++ b/libc/stdlib/malloc-simple/malloc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_malloc
+#include "alloc.c"
diff --git a/libc/stdlib/malloc-simple/memalign.c b/libc/stdlib/malloc-simple/memalign.c
new file mode 100644
index 000000000..24b7ab9c5
--- /dev/null
+++ b/libc/stdlib/malloc-simple/memalign.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_memalign
+#include "alloc.c"
diff --git a/libc/stdlib/malloc-simple/realloc.c b/libc/stdlib/malloc-simple/realloc.c
new file mode 100644
index 000000000..de9675d59
--- /dev/null
+++ b/libc/stdlib/malloc-simple/realloc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_realloc
+#include "alloc.c"
diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in
index e566dad8c..1d29703c4 100644
--- a/libc/stdlib/malloc-standard/Makefile.in
+++ b/libc/stdlib/malloc-standard/Makefile.in
@@ -1,32 +1,29 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
# Turn on malloc debugging if requested
ifeq ($(UCLIBC_MALLOC_DEBUGGING),y)
-CFLAGS+=-D__MALLOC_DEBUGGING
+CFLAGS += -D__MALLOC_DEBUGGING
endif
# calloc.c can be found at uClibc/libc/stdlib/calloc.c
# valloc.c can be found at uClibc/libc/stdlib/valloc.c
-CSRC:=malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
+CSRC := malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
-STDLIB_MALLOC_STANDARD_DIR:=$(top_srcdir)libc/stdlib/malloc-standard
-STDLIB_MALLOC_STANDARD_OUT:=$(top_builddir)libc/stdlib/malloc-standard
+STDLIB_MALLOC_STANDARD_DIR := $(top_srcdir)libc/stdlib/malloc-standard
+STDLIB_MALLOC_STANDARD_OUT := $(top_builddir)libc/stdlib/malloc-standard
-STDLIB_MALLOC_STANDARD_SRC:=$(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_STANDARD_OBJ:=$(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC))
+STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC))
-libc-a-$(MALLOC_STANDARD)+=$(STDLIB_MALLOC_STANDARD_OBJ)
-libc-so-$(MALLOC_STANDARD)+=$(STDLIB_MALLOC_STANDARD_OBJ:.o=.os)
+libc-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ)
-libc-multi-$(MALLOC_STANDARD)+=$(STDLIB_MALLOC_STANDARD_SRC)
-
-objclean-y+=stdlib_malloc_standard_objclean
+objclean-y += stdlib_malloc_standard_objclean
stdlib_malloc_standard_objclean:
$(RM) $(STDLIB_MALLOC_STANDARD_OUT)/*.{o,os}
diff --git a/libc/stdlib/malloc-standard/calloc.c b/libc/stdlib/malloc-standard/calloc.c
index b8c43d9dc..99e8884ad 100644
--- a/libc/stdlib/malloc-standard/calloc.c
+++ b/libc/stdlib/malloc-standard/calloc.c
@@ -16,6 +16,7 @@
#include "malloc.h"
+libc_hidden_proto(memset)
/* ------------------------------ calloc ------------------------------ */
void* calloc(size_t n_elements, size_t elem_size)
@@ -54,7 +55,7 @@ void* calloc(size_t n_elements, size_t elem_size)
assert(nclears >= 3);
if (nclears > 9)
- __memset(d, 0, clearsize);
+ memset(d, 0, clearsize);
else {
*(d+0) = 0;
@@ -83,7 +84,7 @@ void* calloc(size_t n_elements, size_t elem_size)
d = (size_t*)mem;
/* Note the additional (sizeof(size_t)) */
clearsize = chunksize(p) - 2*(sizeof(size_t));
- __memset(d, 0, clearsize);
+ memset(d, 0, clearsize);
}
#endif
}
diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c
index 1b294d706..e0c6ef061 100644
--- a/libc/stdlib/malloc-standard/free.c
+++ b/libc/stdlib/malloc-standard/free.c
@@ -14,10 +14,9 @@
Hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define munmap __munmap
-
#include "malloc.h"
+libc_hidden_proto(munmap)
/* ------------------------- __malloc_trim -------------------------
__malloc_trim is an inverse of sorts to __malloc_alloc. It gives memory
@@ -402,13 +401,10 @@ void free(void* mem)
*/
else {
- int ret;
size_t offset = p->prev_size;
av->n_mmaps--;
av->mmapped_mem -= (size + offset);
- ret = munmap((char*)p - offset, size + offset);
- /* munmap returns non-zero on failure */
- assert(ret == 0);
+ munmap((char*)p - offset, size + offset);
}
UNLOCK;
}
diff --git a/libc/stdlib/malloc-standard/mallinfo.c b/libc/stdlib/malloc-standard/mallinfo.c
index 029ceda1f..89c9a6e7e 100644
--- a/libc/stdlib/malloc-standard/mallinfo.c
+++ b/libc/stdlib/malloc-standard/mallinfo.c
@@ -16,9 +16,12 @@
#include "malloc.h"
+libc_hidden_proto(fprintf)
+libc_hidden_proto(stderr)
/* ------------------------------ mallinfo ------------------------------ */
-struct mallinfo attribute_hidden __mallinfo(void)
+libc_hidden_proto(mallinfo)
+struct mallinfo mallinfo(void)
{
mstate av;
struct mallinfo mi;
@@ -78,7 +81,7 @@ struct mallinfo attribute_hidden __mallinfo(void)
UNLOCK;
return mi;
}
-strong_alias(__mallinfo,mallinfo)
+libc_hidden_def(mallinfo)
void malloc_stats(FILE *file)
{
@@ -88,7 +91,7 @@ void malloc_stats(FILE *file)
file = stderr;
}
- mi = __mallinfo();
+ mi = mallinfo();
fprintf(file, "total bytes allocated = %10u\n", (unsigned int)(mi.arena + mi.hblkhd));
fprintf(file, "total bytes in use bytes = %10u\n", (unsigned int)(mi.uordblks + mi.hblkhd));
fprintf(file, "total non-mmapped bytes allocated = %10d\n", mi.arena);
diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c
index 7025e8335..10d421330 100644
--- a/libc/stdlib/malloc-standard/malloc.c
+++ b/libc/stdlib/malloc-standard/malloc.c
@@ -14,12 +14,12 @@
Hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define _GNU_SOURCE
#include "malloc.h"
#ifdef __UCLIBC_HAS_THREADS__
pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+libc_hidden_data_def(__malloc_lock)
#endif
/*
diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h
index 68d38cb3d..a3fabb0c4 100644
--- a/libc/stdlib/malloc-standard/malloc.h
+++ b/libc/stdlib/malloc-standard/malloc.h
@@ -14,10 +14,6 @@
Hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define mmap __mmap
-#define sysconf __sysconf
-#define sbrk __sbrk
-
#include <features.h>
#include <stddef.h>
#include <unistd.h>
@@ -25,11 +21,17 @@
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
+#include <sys/mman.h>
+libc_hidden_proto(mmap)
+libc_hidden_proto(sysconf)
+libc_hidden_proto(sbrk)
+libc_hidden_proto(abort)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
extern pthread_mutex_t __malloc_lock;
+libc_hidden_proto(__malloc_lock)
#endif
#define LOCK __pthread_mutex_lock(&__malloc_lock)
#define UNLOCK __pthread_mutex_unlock(&__malloc_lock)
@@ -352,7 +354,7 @@ extern pthread_mutex_t __malloc_lock;
#define MAP_ANONYMOUS MAP_ANON
#endif
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
#define MMAP(addr, size, prot) \
(mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
diff --git a/libc/stdlib/malloc-standard/memalign.c b/libc/stdlib/malloc-standard/memalign.c
index bd9536272..27502893d 100644
--- a/libc/stdlib/malloc-standard/memalign.c
+++ b/libc/stdlib/malloc-standard/memalign.c
@@ -28,7 +28,7 @@ void* memalign(size_t alignment, size_t bytes)
size_t nb; /* padded request size */
char* m; /* memory returned by malloc call */
mchunkptr p; /* corresponding chunk */
- char* brk; /* alignment point within p */
+ char* _brk; /* alignment point within p */
mchunkptr newp; /* chunk to return */
size_t newsize; /* its size */
size_t leadsize; /* leading space before alignment point */
@@ -79,13 +79,13 @@ void* memalign(size_t alignment, size_t bytes)
total room so that this is always possible.
*/
- brk = (char*)mem2chunk((unsigned long)(((unsigned long)(m + alignment - 1)) &
+ _brk = (char*)mem2chunk((unsigned long)(((unsigned long)(m + alignment - 1)) &
-((signed long) alignment)));
- if ((unsigned long)(brk - (char*)(p)) < MINSIZE)
- brk += alignment;
+ if ((unsigned long)(_brk - (char*)(p)) < MINSIZE)
+ _brk += alignment;
- newp = (mchunkptr)brk;
- leadsize = brk - (char*)(p);
+ newp = (mchunkptr)_brk;
+ leadsize = _brk - (char*)(p);
newsize = chunksize(p) - leadsize;
/* For mmapped chunks, just adjust offset */
diff --git a/libc/stdlib/malloc-standard/realloc.c b/libc/stdlib/malloc-standard/realloc.c
index 36bfe4d99..ae2d33bee 100644
--- a/libc/stdlib/malloc-standard/realloc.c
+++ b/libc/stdlib/malloc-standard/realloc.c
@@ -14,11 +14,10 @@
Hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define mremap __mremap
-
#include "malloc.h"
-
+libc_hidden_proto(mremap)
+libc_hidden_proto(memcpy)
/* ------------------------------ realloc ------------------------------ */
void* realloc(void* oldmem, size_t bytes)
@@ -128,7 +127,7 @@ void* realloc(void* oldmem, size_t bytes)
assert(ncopies >= 3);
if (ncopies > 9)
- __memcpy(d, s, copysize);
+ memcpy(d, s, copysize);
else {
*(d+0) = *(s+0);
@@ -228,7 +227,7 @@ void* realloc(void* oldmem, size_t bytes)
/* Must alloc, copy, free. */
newmem = malloc(nb - MALLOC_ALIGN_MASK);
if (newmem != 0) {
- __memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t)));
+ memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t)));
free(oldmem);
}
}
diff --git a/libc/stdlib/malloc/Makefile.in b/libc/stdlib/malloc/Makefile.in
index 55831c379..73e0d6419 100644
--- a/libc/stdlib/malloc/Makefile.in
+++ b/libc/stdlib/malloc/Makefile.in
@@ -2,35 +2,32 @@
#
# Copyright (C) 2002-2003 NEC Electronics Corporation
# Copyright (C) 2002-2003 Miles Bader <miles@gnu.org>
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:= malloc.c calloc.c free.c realloc.c memalign.c \
+CSRC := malloc.c calloc.c free.c realloc.c memalign.c \
heap_alloc.c heap_alloc_at.c heap_free.c
# Turn on malloc debugging if requested
ifeq ($(UCLIBC_MALLOC_DEBUGGING),y)
-CSRC+=malloc_debug.c heap_debug.c
-CFLAGS+=-DMALLOC_DEBUGGING -DHEAP_DEBUGGING
+CSRC += malloc_debug.c heap_debug.c
+CFLAGS += -DMALLOC_DEBUGGING -DHEAP_DEBUGGING
ifeq ($(UCLIBC_UCLINUX_BROKEN_MUNMAP),y)
-CFLAGS+=-DMALLOC_MMB_DEBUGGING
+CFLAGS += -DMALLOC_MMB_DEBUGGING
endif
endif
-STDLIB_MALLOC_DIR:=$(top_srcdir)libc/stdlib/malloc
-STDLIB_MALLOC_OUT:=$(top_builddir)libc/stdlib/malloc
+STDLIB_MALLOC_DIR := $(top_srcdir)libc/stdlib/malloc
+STDLIB_MALLOC_OUT := $(top_builddir)libc/stdlib/malloc
-STDLIB_MALLOC_SRC:=$(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_OBJ:=$(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_SRC := $(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC))
+STDLIB_MALLOC_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC))
-libc-a-$(MALLOC)+=$(STDLIB_MALLOC_OBJ)
-libc-so-$(MALLOC)+=$(STDLIB_MALLOC_OBJ:.o=.os)
+libc-$(MALLOC) += $(STDLIB_MALLOC_OBJ)
-libc-multi-$(MALLOC)+=$(STDLIB_MALLOC_SRC)
-
-objclean-y+=stdlib_malloc_objclean
+objclean-y += stdlib_malloc_objclean
stdlib_malloc_objclean:
$(RM) $(STDLIB_MALLOC_OUT)/*.{o,os}
diff --git a/libc/stdlib/malloc/calloc.c b/libc/stdlib/malloc/calloc.c
index 94031ce29..5925a9e0a 100644
--- a/libc/stdlib/malloc/calloc.c
+++ b/libc/stdlib/malloc/calloc.c
@@ -22,6 +22,8 @@
#include <string.h>
#include <errno.h>
+libc_hidden_proto(memset)
+
void * calloc(size_t nmemb, size_t lsize)
{
void *result;
@@ -34,7 +36,7 @@ void * calloc(size_t nmemb, size_t lsize)
return NULL;
}
if ((result=malloc(size)) != NULL) {
- __memset(result, 0, size);
+ memset(result, 0, size);
}
return result;
}
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c
index 81ec38cd9..81c718376 100644
--- a/libc/stdlib/malloc/free.c
+++ b/libc/stdlib/malloc/free.c
@@ -11,17 +11,16 @@
* Written by Miles Bader <miles@gnu.org>
*/
-#define munmap __munmap
-#define sbrk __sbrk
-
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
+libc_hidden_proto(munmap)
+libc_hidden_proto(sbrk)
+
#include "malloc.h"
#include "heap.h"
-
static void
free_to_heap (void *mem, struct heap *heap)
{
diff --git a/libc/stdlib/malloc/heap_debug.c b/libc/stdlib/malloc/heap_debug.c
index 7dab95627..9e5b61c43 100644
--- a/libc/stdlib/malloc/heap_debug.c
+++ b/libc/stdlib/malloc/heap_debug.c
@@ -11,13 +11,14 @@
* Written by Miles Bader <miles@gnu.org>
*/
-#define vfprintf __vfprintf
-
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+libc_hidden_proto(vfprintf)
+libc_hidden_proto(fprintf)
+
#include "malloc.h"
#include "heap.h"
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index 6bc8d8773..2ec8b07da 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -11,14 +11,14 @@
* Written by Miles Bader <miles@gnu.org>
*/
-#define mmap __mmap
-#define sbrk __sbrk
-
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
+libc_hidden_proto(mmap)
+libc_hidden_proto(sbrk)
+
#include "malloc.h"
#include "heap.h"
@@ -106,7 +106,7 @@ malloc_from_heap (size_t size, struct heap *heap)
#else /* !MALLOC_USE_SBRK */
/* Otherwise, use mmap. */
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#else
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
index 707cad13d..753205443 100644
--- a/libc/stdlib/malloc/malloc.h
+++ b/libc/stdlib/malloc/malloc.h
@@ -16,6 +16,7 @@
/* The system pagesize... */
extern size_t __pagesize;
+libc_hidden_proto(__pagesize)
#define MALLOC_PAGE_SIZE __pagesize
/* The minimum size of block we request from the the system to extend the
@@ -43,7 +44,7 @@ extern size_t __pagesize;
heap, instead of mmap/munmap. This is a tradeoff -- sbrk is faster than
mmap/munmap, and guarantees contiguous allocation, but is also less
flexible, and causes the heap to only be shrinkable from the end. */
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
# define MALLOC_USE_SBRK
#endif
diff --git a/libc/stdlib/malloc/malloc_debug.c b/libc/stdlib/malloc/malloc_debug.c
index abe5546ca..6c74d78bb 100644
--- a/libc/stdlib/malloc/malloc_debug.c
+++ b/libc/stdlib/malloc/malloc_debug.c
@@ -11,14 +11,16 @@
* Written by Miles Bader <miles@gnu.org>
*/
-#define atoi __atoi
-#define vfprintf __vfprintf
-
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
+libc_hidden_proto(atoi)
+libc_hidden_proto(vfprintf)
+libc_hidden_proto(putc)
+libc_hidden_proto(getenv)
+
#include "malloc.h"
#include "heap.h"
@@ -42,7 +44,7 @@ __malloc_debug_printf (int indent, const char *fmt, ...)
while (spaces > 0)
{
- __putc (' ', stderr);
+ putc (' ', stderr);
spaces--;
}
@@ -50,7 +52,7 @@ __malloc_debug_printf (int indent, const char *fmt, ...)
vfprintf (stderr, fmt, val);
va_end (val);
- __putc ('\n', stderr);
+ putc ('\n', stderr);
__malloc_debug_indent (indent);
}
@@ -58,7 +60,7 @@ __malloc_debug_printf (int indent, const char *fmt, ...)
void
__malloc_debug_init (void)
{
- char *ev = __getenv ("MALLOC_DEBUG");
+ char *ev = getenv ("MALLOC_DEBUG");
if (ev)
{
int val = atoi (ev);
diff --git a/libc/stdlib/malloc/memalign.c b/libc/stdlib/malloc/memalign.c
index ce13eb99d..5b248f3e2 100644
--- a/libc/stdlib/malloc/memalign.c
+++ b/libc/stdlib/malloc/memalign.c
@@ -30,6 +30,7 @@
\____ INIT ____/ \______ RETURNED _______/ \____ END ___/
*/
+void *memalign (size_t alignment, size_t size);
void *
memalign (size_t alignment, size_t size)
{
diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c
index 8dcc35360..4d56565aa 100644
--- a/libc/stdlib/malloc/realloc.c
+++ b/libc/stdlib/malloc/realloc.c
@@ -15,6 +15,8 @@
#include <string.h>
#include <errno.h>
+libc_hidden_proto(memcpy)
+
#include "malloc.h"
#include "heap.h"
@@ -26,13 +28,13 @@ realloc (void *mem, size_t new_size)
char *base_mem;
/* Check for special cases. */
- if (! mem)
- return malloc (new_size);
if (! new_size)
{
free (mem);
return malloc (new_size);
}
+ if (! mem)
+ return malloc (new_size);
/* Normal realloc. */
@@ -66,7 +68,7 @@ realloc (void *mem, size_t new_size)
void *new_mem = malloc (new_size - MALLOC_HEADER_SIZE);
if (new_mem)
{
- __memcpy (new_mem, mem, size - MALLOC_HEADER_SIZE);
+ memcpy (new_mem, mem, size - MALLOC_HEADER_SIZE);
free (mem);
}
mem = new_mem;
diff --git a/libc/stdlib/mblen.c b/libc/stdlib/mblen.c
new file mode 100644
index 000000000..c7a0ccb6e
--- /dev/null
+++ b/libc/stdlib/mblen.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_mblen
+#include "stdlib.c"
diff --git a/libc/stdlib/mbstowcs.c b/libc/stdlib/mbstowcs.c
new file mode 100644
index 000000000..f61800373
--- /dev/null
+++ b/libc/stdlib/mbstowcs.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_mbstowcs
+#include "stdlib.c"
diff --git a/libc/stdlib/mbtowc.c b/libc/stdlib/mbtowc.c
new file mode 100644
index 000000000..5d888d163
--- /dev/null
+++ b/libc/stdlib/mbtowc.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_mbtowc
+#include "stdlib.c"
diff --git a/libc/stdlib/mrand48.c b/libc/stdlib/mrand48.c
index e9d5353ad..6905545bd 100644
--- a/libc/stdlib/mrand48.c
+++ b/libc/stdlib/mrand48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define jrand48_r __jrand48_r
-
#include <stdlib.h>
+libc_hidden_proto(jrand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
long int mrand48 (void)
{
diff --git a/libc/stdlib/mrand48_r.c b/libc/stdlib/mrand48_r.c
index f79e5f887..ca2bd7bbb 100644
--- a/libc/stdlib/mrand48_r.c
+++ b/libc/stdlib/mrand48_r.c
@@ -17,10 +17,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define jrand48_r __jrand48_r
-
#include <stdlib.h>
+libc_hidden_proto(jrand48_r)
+
int mrand48_r (struct drand48_data *buffer, long int *result)
{
/* Be generous for the arguments, detect some errors. */
diff --git a/libc/stdlib/nrand48.c b/libc/stdlib/nrand48.c
index 6cdf4ebad..0199a30a5 100644
--- a/libc/stdlib/nrand48.c
+++ b/libc/stdlib/nrand48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define nrand48_r __nrand48_r
-
#include <stdlib.h>
+libc_hidden_proto(nrand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
long int nrand48 (unsigned short int xsubi[3])
{
diff --git a/libc/stdlib/nrand48_r.c b/libc/stdlib/nrand48_r.c
index f72c07030..f45cb1132 100644
--- a/libc/stdlib/nrand48_r.c
+++ b/libc/stdlib/nrand48_r.c
@@ -22,7 +22,8 @@
extern int __drand48_iterate(unsigned short xsubi[3],
struct drand48_data *buffer) attribute_hidden;
-int attribute_hidden __nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
+libc_hidden_proto(nrand48_r)
+int nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
if (__drand48_iterate (xsubi, buffer) < 0)
@@ -36,4 +37,4 @@ int attribute_hidden __nrand48_r (unsigned short int xsubi[3], struct drand48_da
return 0;
}
-strong_alias(__nrand48_r,nrand48_r)
+libc_hidden_def(nrand48_r)
diff --git a/libc/stdlib/old_atexit.c b/libc/stdlib/old_atexit.c
new file mode 100644
index 000000000..b15fd0aa2
--- /dev/null
+++ b/libc/stdlib/old_atexit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_old_atexit
+#include "_atexit.c"
diff --git a/libc/stdlib/on_exit.c b/libc/stdlib/on_exit.c
new file mode 100644
index 000000000..cb943aca1
--- /dev/null
+++ b/libc/stdlib/on_exit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_on_exit
+#include "_atexit.c"
diff --git a/libc/stdlib/ptsname.c b/libc/stdlib/ptsname.c
index 8e18e3989..b41f6a118 100644
--- a/libc/stdlib/ptsname.c
+++ b/libc/stdlib/ptsname.c
@@ -17,8 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define isatty __isatty
-
#define _ISOC99_SOURCE
#include <stdio.h>
#include <errno.h>
@@ -32,6 +30,13 @@
#include <unistd.h>
#include <bits/uClibc_uintmaxtostr.h>
+libc_hidden_proto(strcat)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(isatty)
+libc_hidden_proto(ioctl)
+libc_hidden_proto(fstat)
+libc_hidden_proto(stat)
#if !defined __UNIX98PTY_ONLY__
@@ -64,7 +69,8 @@ extern const char __libc_ptyname2[] attribute_hidden;
/* Store at most BUFLEN characters of the pathname of the slave pseudo
terminal associated with the master FD is open on in BUF.
Return 0 on success, otherwise an error number. */
-int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
+libc_hidden_proto(ptsname_r)
+int ptsname_r (int fd, char *buf, size_t buflen)
{
int save_errno = errno;
#if !defined __UNIX98PTY_ONLY__
@@ -88,7 +94,7 @@ int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
# error "__UNIX98PTY_ONLY__ enabled but TIOCGPTN ioctl not supported by your kernel."
#endif
#ifdef TIOCGPTN
- if (__ioctl (fd, TIOCGPTN, &ptyno) == 0)
+ if (ioctl (fd, TIOCGPTN, &ptyno) == 0)
{
/* Buffer we use to print the number in. */
char numbuf[__BUFLEN_INT10TOSTR];
@@ -103,8 +109,8 @@ int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
return ERANGE;
}
- __strcpy (buf, devpts);
- __strcat (buf, p);
+ strcpy (buf, devpts);
+ strcat (buf, p);
/* Note: Don't bother with stat on the slave name and checking the
driver's major device number - the ioctl above succeeded so
we know the fd was a Unix'98 master and the /dev/pts/ prefix
@@ -130,13 +136,13 @@ int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
{
char *p;
- if (buflen < __strlen (_PATH_TTY) + 3)
+ if (buflen < strlen (_PATH_TTY) + 3)
{
errno = ERANGE;
return ERANGE;
}
- if (__fstat (fd, &st) < 0)
+ if (fstat (fd, &st) < 0)
return errno;
/* Check if FD really is a master pseudo terminal. */
@@ -152,20 +158,20 @@ int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
if (major (st.st_rdev) == 4)
ptyno -= 128;
- if (ptyno / 16 >= __strlen (__libc_ptyname1))
+ if (ptyno / 16 >= strlen (__libc_ptyname1))
{
errno = ENOTTY;
return ENOTTY;
}
- __strcpy (buf, _PATH_TTY);
- p = buf + __strlen (buf);
+ strcpy (buf, _PATH_TTY);
+ p = buf + strlen (buf);
p[0] = __libc_ptyname1[ptyno / 16];
p[1] = __libc_ptyname2[ptyno % 16];
p[2] = '\0';
}
- if (__stat(buf, &st) < 0)
+ if (stat(buf, &st) < 0)
return errno;
/* Check if the name we're about to return really corresponds to a
@@ -181,7 +187,7 @@ int attribute_hidden __ptsname_r (int fd, char *buf, size_t buflen)
errno = save_errno;
return 0;
}
-strong_alias(__ptsname_r,ptsname_r)
+libc_hidden_def(ptsname_r)
/* Return the pathname of the pseudo terminal slave assoicated with
the master FD is open on, or NULL on errors.
@@ -191,5 +197,5 @@ ptsname (int fd)
{
static char buffer[sizeof (_PATH_DEVPTS) + 20];
- return __ptsname_r (fd, buffer, sizeof (buffer)) != 0 ? NULL : buffer;
+ return ptsname_r (fd, buffer, sizeof (buffer)) != 0 ? NULL : buffer;
}
diff --git a/libc/stdlib/qsort.c b/libc/stdlib/qsort.c
new file mode 100644
index 000000000..31fc2eaf8
--- /dev/null
+++ b/libc/stdlib/qsort.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_qsort
+#include "stdlib.c"
diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c
index a4c739c18..cdf58ecc7 100644
--- a/libc/stdlib/rand.c
+++ b/libc/stdlib/rand.c
@@ -17,10 +17,10 @@
* write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA. */
-#define random __random
-
#include <stdlib.h>
+libc_hidden_proto(random)
+
int rand (void)
{
return((int)random());
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index eb146098a..9f1977ee3 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -22,17 +22,16 @@
* Rewritten to use reentrant functions by Ulrich Drepper, 1995.
*/
-#define random_r __random_r
-#define srandom_r __srandom_r
-#define setstate_r __setstate_r
-#define initstate_r __initstate_r
-
-#define _GNU_SOURCE
#include <features.h>
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
+libc_hidden_proto(random_r)
+libc_hidden_proto(srandom_r)
+libc_hidden_proto(setstate_r)
+libc_hidden_proto(initstate_r)
+
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
/* POSIX.1c requires that there is mutual exclusion for the `rand' and
@@ -191,7 +190,7 @@ void srandom (unsigned int x)
srandom_r (x, &unsafe_state);
__pthread_mutex_unlock(&lock);
}
-weak_alias (srandom, srand)
+strong_alias(srandom,srand)
/* Initialize the state information in the given array of N bytes for
future random number generation. Based on the number of bytes we
@@ -246,7 +245,8 @@ char * setstate (char *arg_state)
rear pointers can't wrap on the same call by not testing the rear
pointer if the front one has wrapped. Returns a 31-bit random number. */
-long int attribute_hidden __random (void)
+libc_hidden_proto(random)
+long int random (void)
{
int32_t retval;
@@ -255,4 +255,4 @@ long int attribute_hidden __random (void)
__pthread_mutex_unlock(&lock);
return retval;
}
-strong_alias(__random,random)
+libc_hidden_def(random)
diff --git a/libc/stdlib/random_r.c b/libc/stdlib/random_r.c
index b10f29519..e95653545 100644
--- a/libc/stdlib/random_r.c
+++ b/libc/stdlib/random_r.c
@@ -22,7 +22,6 @@
* Rewritten to be reentrant by Ulrich Drepper, 1995
*/
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
#include <limits.h>
@@ -134,7 +133,8 @@ static const struct random_poly_info random_poly_info =
rear pointers can't wrap on the same call by not testing the rear
pointer if the front one has wrapped. Returns a 31-bit random number. */
-int attribute_hidden __random_r(struct random_data *buf, int32_t *result)
+libc_hidden_proto(random_r)
+int random_r(struct random_data *buf, int32_t *result)
{
int32_t *state;
@@ -181,7 +181,7 @@ fail:
__set_errno (EINVAL);
return -1;
}
-strong_alias(__random_r,random_r)
+libc_hidden_def(random_r)
/* Initialize the random number generator based on the given seed. If the
type is the trivial no-state-information type, just remember the seed.
@@ -191,7 +191,8 @@ strong_alias(__random_r,random_r)
information a given number of times to get rid of any initial dependencies
introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
for default usage relies on values produced by this routine. */
-int attribute_hidden __srandom_r (unsigned int seed, struct random_data *buf)
+libc_hidden_proto(srandom_r)
+int srandom_r (unsigned int seed, struct random_data *buf)
{
int type;
int32_t *state;
@@ -236,7 +237,7 @@ int attribute_hidden __srandom_r (unsigned int seed, struct random_data *buf)
while (--kc >= 0)
{
int32_t discard;
- (void) __random_r (buf, &discard);
+ (void) random_r (buf, &discard);
}
done:
@@ -245,7 +246,7 @@ done:
fail:
return -1;
}
-strong_alias(__srandom_r,srandom_r)
+libc_hidden_def(srandom_r)
/* Initialize the state information in the given array of N bytes for
future random number generation. Based on the number of bytes we
@@ -258,7 +259,8 @@ strong_alias(__srandom_r,srandom_r)
Note: The first thing we do is save the current state, if any, just like
setstate so that it doesn't matter when initstate is called.
Returns a pointer to the old state. */
-int attribute_hidden __initstate_r (unsigned int seed, char *arg_state, size_t n, struct random_data *buf)
+libc_hidden_proto(initstate_r)
+int initstate_r (unsigned int seed, char *arg_state, size_t n, struct random_data *buf)
{
int type;
int degree;
@@ -294,7 +296,7 @@ int attribute_hidden __initstate_r (unsigned int seed, char *arg_state, size_t n
buf->state = state;
- __srandom_r (seed, buf);
+ srandom_r (seed, buf);
state[-1] = TYPE_0;
if (type != TYPE_0)
@@ -306,7 +308,7 @@ fail:
__set_errno (EINVAL);
return -1;
}
-strong_alias(__initstate_r,initstate_r)
+libc_hidden_def(initstate_r)
/* Restore the state from the given state array.
Note: It is important that we also remember the locations of the pointers
@@ -316,7 +318,8 @@ strong_alias(__initstate_r,initstate_r)
to the order in which things are done, it is OK to call setstate with the
same state as the current state
Returns a pointer to the old state information. */
-int attribute_hidden __setstate_r (char *arg_state, struct random_data *buf)
+libc_hidden_proto(setstate_r)
+int setstate_r (char *arg_state, struct random_data *buf)
{
int32_t *new_state = 1 + (int32_t *) arg_state;
int type;
@@ -359,4 +362,4 @@ fail:
__set_errno (EINVAL);
return -1;
}
-strong_alias(__setstate_r,setstate_r)
+libc_hidden_def(setstate_r)
diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c
index 88677f7a7..c3cc517de 100644
--- a/libc/stdlib/realpath.c
+++ b/libc/stdlib/realpath.c
@@ -1,21 +1,11 @@
/*
* realpath.c -- canonicalize pathname by removing symlinks
* Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
+ * Copyright (C) 2000-2006 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 Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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 Public License for more details.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define readlink __readlink
-#define getcwd __getcwd
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -28,9 +18,16 @@
#include <limits.h> /* for PATH_MAX */
#include <sys/param.h> /* for MAXPATHLEN */
#include <errno.h>
+#include <stdlib.h>
#include <sys/stat.h> /* for S_IFLNK */
+libc_hidden_proto(strcat)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(readlink)
+libc_hidden_proto(getcwd)
+
#ifndef PATH_MAX
#ifdef _POSIX_VERSION
#define PATH_MAX _POSIX_PATH_MAX
@@ -62,11 +59,11 @@ char resolved_path[];
int n;
/* Make a copy of the source path since we may need to modify it. */
- if (__strlen(path) >= PATH_MAX - 2) {
+ if (strlen(path) >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
return NULL;
}
- __strcpy(copy_path, path);
+ strcpy(copy_path, path);
path = copy_path;
max_path = copy_path + PATH_MAX - 2;
/* If it's a relative pathname use getwd for starters. */
@@ -78,7 +75,7 @@ char resolved_path[];
#else
getwd(new_path);
#endif
- new_path += __strlen(new_path);
+ new_path += strlen(new_path);
if (new_path[-1] != '/')
*new_path++ = '/';
} else {
@@ -132,7 +129,7 @@ char resolved_path[];
if (errno != EINVAL) {
/* Make sure it's null terminated. */
*new_path = '\0';
- __strcpy(resolved_path, got_path);
+ strcpy(resolved_path, got_path);
return NULL;
}
} else {
@@ -145,13 +142,13 @@ char resolved_path[];
/* Otherwise back up over this component. */
while (*(--new_path) != '/');
/* Safe sex check. */
- if (__strlen(path) + n >= PATH_MAX - 2) {
+ if (strlen(path) + n >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
return NULL;
}
/* Insert symlink contents into path. */
- __strcat(link_path, path);
- __strcpy(copy_path, link_path);
+ strcat(link_path, path);
+ strcpy(copy_path, link_path);
path = copy_path;
}
#endif /* S_IFLNK */
@@ -162,6 +159,6 @@ char resolved_path[];
new_path--;
/* Make sure it's null terminated. */
*new_path = '\0';
- __strcpy(resolved_path, got_path);
+ strcpy(resolved_path, got_path);
return resolved_path;
}
diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c
index 3de07aa31..f068b980d 100644
--- a/libc/stdlib/seed48.c
+++ b/libc/stdlib/seed48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define seed48_r __seed48_r
-
#include <stdlib.h>
+libc_hidden_proto(seed48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
unsigned short int *
seed48 (unsigned short int seed16v[3])
diff --git a/libc/stdlib/seed48_r.c b/libc/stdlib/seed48_r.c
index d1c74f24c..c88d0f23e 100644
--- a/libc/stdlib/seed48_r.c
+++ b/libc/stdlib/seed48_r.c
@@ -21,10 +21,13 @@
#include <string.h>
#include <limits.h>
-int attribute_hidden __seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer)
+libc_hidden_proto(memcpy)
+
+libc_hidden_proto(seed48_r)
+int seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer)
{
/* Save old value at a private place to be used as return value. */
- __memcpy (buffer->__old_x, buffer->__x, sizeof (buffer->__x));
+ memcpy (buffer->__old_x, buffer->__x, sizeof (buffer->__x));
/* Install new state. */
buffer->__x[2] = seed16v[2];
@@ -36,4 +39,4 @@ int attribute_hidden __seed48_r (unsigned short int seed16v[3], struct drand48_d
return 0;
}
-strong_alias(__seed48_r,seed48_r)
+libc_hidden_def(seed48_r)
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 413ebed9e..e7dc26053 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -19,15 +19,20 @@
modified for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define strndup __strndup
-
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(strndup)
+libc_hidden_proto(unsetenv)
+libc_hidden_proto(__environ)
+
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
@@ -35,7 +40,6 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
#define LOCK __pthread_mutex_lock(&mylock)
#define UNLOCK __pthread_mutex_unlock(&mylock)
-extern int __unsetenv (__const char *__name) attribute_hidden;
/* If this variable is not a null pointer we allocated the current
environment. */
@@ -48,13 +52,15 @@ static char **last_environ;
must be used directly. This is all complicated by the fact that we try
to reuse values once generated for a `setenv' call since we can never
free the strings. */
-int attribute_hidden __add_to_environ (const char *name, const char *value,
+int __add_to_environ (const char *name, const char *value,
+ const char *combined, int replace) attribute_hidden;
+int __add_to_environ (const char *name, const char *value,
const char *combined, int replace)
{
register char **ep;
register size_t size;
- const size_t namelen = __strlen (name);
- const size_t vallen = value != NULL ? __strlen (value) + 1 : 0;
+ const size_t namelen = strlen (name);
+ const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
LOCK;
@@ -65,7 +71,7 @@ int attribute_hidden __add_to_environ (const char *name, const char *value,
size = 0;
if (ep != NULL) {
for (; *ep != NULL; ++ep) {
- if (!__strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+ if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
break;
else
++size;
@@ -97,13 +103,13 @@ int attribute_hidden __add_to_environ (const char *name, const char *value,
return -1;
}
- __memcpy (new_environ[size], name, namelen);
+ memcpy (new_environ[size], name, namelen);
new_environ[size][namelen] = '=';
- __memcpy (&new_environ[size][namelen + 1], value, vallen);
+ memcpy (&new_environ[size][namelen + 1], value, vallen);
}
if (__environ != last_environ) {
- __memcpy ((char *) new_environ, (char *) __environ,
+ memcpy ((char *) new_environ, (char *) __environ,
size * sizeof (char *));
}
@@ -121,9 +127,9 @@ int attribute_hidden __add_to_environ (const char *name, const char *value,
UNLOCK;
return -1;
}
- __memcpy (np, name, namelen);
+ memcpy (np, name, namelen);
np[namelen] = '=';
- __memcpy (&np[namelen + 1], value, vallen);
+ memcpy (&np[namelen + 1], value, vallen);
}
*ep = np;
}
@@ -132,27 +138,29 @@ int attribute_hidden __add_to_environ (const char *name, const char *value,
return 0;
}
-int attribute_hidden __setenv (const char *name, const char *value, int replace)
+libc_hidden_proto(setenv)
+int setenv (const char *name, const char *value, int replace)
{
return __add_to_environ (name, value, NULL, replace);
}
-strong_alias(__setenv,setenv)
+libc_hidden_def(setenv)
-int attribute_hidden __unsetenv (const char *name)
+libc_hidden_proto(unsetenv)
+int unsetenv (const char *name)
{
size_t len;
char **ep;
- if (name == NULL || *name == '\0' || __strchr (name, '=') != NULL) {
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) {
__set_errno (EINVAL);
return -1;
}
- len = __strlen (name);
+ len = strlen (name);
LOCK;
ep = __environ;
while (*ep != NULL) {
- if (!__strncmp (*ep, name, len) && (*ep)[len] == '=') {
+ if (!strncmp (*ep, name, len) && (*ep)[len] == '=') {
/* Found it. Remove this pointer by moving later ones back. */
char **dp = ep;
do {
@@ -166,7 +174,7 @@ int attribute_hidden __unsetenv (const char *name)
UNLOCK;
return 0;
}
-strong_alias(__unsetenv,unsetenv)
+libc_hidden_def(unsetenv)
/* The `clearenv' was planned to be added to POSIX.1 but probably
never made it. Nevertheless the POSIX.9 standard (POSIX bindings
@@ -189,7 +197,7 @@ int clearenv (void)
int putenv (char *string)
{
int result;
- const char *const name_end = __strchr (string, '=');
+ const char *const name_end = strchr (string, '=');
if (name_end != NULL) {
char *name = strndup(string, name_end - string);
@@ -197,7 +205,7 @@ int putenv (char *string)
free(name);
return(result);
}
- __unsetenv (string);
+ unsetenv (string);
return 0;
}
diff --git a/libc/stdlib/srand48.c b/libc/stdlib/srand48.c
index 1dcdc14a7..42e90c9f9 100644
--- a/libc/stdlib/srand48.c
+++ b/libc/stdlib/srand48.c
@@ -17,12 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define srand48_r __srand48_r
-
#include <stdlib.h>
+libc_hidden_proto(srand48_r)
+
/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data;
+extern struct drand48_data __libc_drand48_data attribute_hidden;
void srand48 (long seedval)
{
diff --git a/libc/stdlib/srand48_r.c b/libc/stdlib/srand48_r.c
index d2f959c79..45bb75f11 100644
--- a/libc/stdlib/srand48_r.c
+++ b/libc/stdlib/srand48_r.c
@@ -20,7 +20,8 @@
#include <stdlib.h>
#include <limits.h>
-int attribute_hidden __srand48_r (long int seedval, struct drand48_data *buffer)
+libc_hidden_proto(srand48_r)
+int srand48_r (long int seedval, struct drand48_data *buffer)
{
/* The standards say we only have 32 bits. */
if (sizeof (long int) > 4)
@@ -36,4 +37,4 @@ int attribute_hidden __srand48_r (long int seedval, struct drand48_data *buffer)
return 0;
}
-strong_alias(__srand48_r,srand48_r)
+libc_hidden_def(srand48_r)
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 8203881a4..f9ec75555 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -32,55 +32,67 @@
* Add wscto{inttype} functions.
*/
-#define wcsrtombs __wcsrtombs
-#define mbsrtowcs __mbsrtowcs
-#define mbrtowc __mbrtowc
-#define mbrlen __mbrlen
-#define iswspace __iswspace
-#define iswspace_l __iswspace_l
-#define wcrtomb __wcrtomb
-
#define _ISOC99_SOURCE /* for ULLONG primarily... */
-#define _GNU_SOURCE
#include <limits.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <ctype.h>
-#include <errno.h>
-#include <assert.h>
-#include <unistd.h>
-
/* Work around gcc's refusal to create aliases.
* TODO: Add in a define to disable the aliases? */
#if UINT_MAX == ULONG_MAX
-#define atoi __ignore_atoi
+#ifdef L_labs
#define abs __ignore_abs
#endif
+#ifdef L_atol
+#define atoi __ignore_atoi
+#endif
+#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
+#ifdef L_labs
#define llabs __ignore_llabs
+#endif
+#ifdef L_atol
#define atoll __ignore_atoll
+#endif
+#ifdef L_strtol
#define strtoll __ignore_strtoll
+#endif
+#ifdef L_strtoul
#define strtoull __ignore_strtoull
+#endif
+#ifdef L_wcstol
#define wcstoll __ignore_wcstoll
+#endif
+#ifdef L_wcstoul
#define wcstoull __ignore_wcstoull
+#endif
+#ifdef strtol_l
#define strtoll_l __ignore_strtoll_l
+#endif
+#ifdef L_strtoul_l
#define strtoull_l __ignore_strtoull_l
+#endif
+#ifdef L_wcstol_l
#define wcstoll_l __ignore_wcstoll_l
+#endif
+#ifdef L_wcstoul_l
#define wcstoull_l __ignore_wcstoull_l
#endif
+#endif
+#if defined(ULLONG_MAX) && (ULLONG_MAX == UINTMAX_MAX)
+#if defined L_labs || defined L_llabs
+#define imaxabs __ignore_imaxabs
+#endif
+#endif
+
+#include <stdint.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <errno.h>
+#include <assert.h>
+#include <unistd.h>
#include <stdlib.h>
#include <locale.h>
-extern long int __strtol (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- __THROW __nonnull ((1)) __wur attribute_hidden;
-__extension__
-extern long long int __strtoll (__const char *__restrict __nptr,
- char **__restrict __endptr, int __base)
- __THROW __nonnull ((1)) __wur attribute_hidden;
-
#ifdef __UCLIBC_HAS_WCHAR__
#include <wchar.h>
@@ -90,6 +102,9 @@ extern long long int __strtoll (__const char *__restrict __nptr,
#ifdef __UCLIBC_HAS_XLOCALE__
#include <xlocale.h>
#endif /* __UCLIBC_HAS_XLOCALE__ */
+#ifdef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(__global_locale)
+#endif
/* TODO: clean up the following... */
@@ -127,49 +142,32 @@ extern long long int __strtoll (__const char *__restrict __nptr,
#endif /* __UCLIBC_HAS_LOCALE__ */
-#if UINT_MAX == ULONG_MAX
-#undef atoi
-#undef abs
-#endif
-#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#undef llabs
-#undef atoll
-#undef strtoll
-#undef strtoull
-#undef wcstoll
-#undef wcstoull
-#undef strtoll_l
-#undef strtoull_l
-#undef wcstoll_l
-#undef wcstoull_l
-#endif /* __UCLIBC_HAS_WCHAR__ */
-
/**********************************************************************/
#ifdef __UCLIBC_HAS_XLOCALE__
extern unsigned long
_stdlib_strto_l_l(register const char * __restrict str,
char ** __restrict endptr, int base, int sflag,
- __locale_t locale_arg);
+ __locale_t locale_arg) attribute_hidden;
#if defined(ULLONG_MAX)
extern unsigned long long
_stdlib_strto_ll_l(register const char * __restrict str,
char ** __restrict endptr, int base, int sflag,
- __locale_t locale_arg);
+ __locale_t locale_arg) attribute_hidden;
#endif
#ifdef __UCLIBC_HAS_WCHAR__
extern unsigned long
_stdlib_wcsto_l_l(register const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base, int sflag,
- __locale_t locale_arg);
+ __locale_t locale_arg) attribute_hidden;
#if defined(ULLONG_MAX)
extern unsigned long long
_stdlib_wcsto_ll_l(register const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base, int sflag,
- __locale_t locale_arg);
+ __locale_t locale_arg) attribute_hidden;
#endif
#endif /* __UCLIBC_HAS_WCHAR__ */
@@ -179,35 +177,33 @@ _stdlib_wcsto_ll_l(register const wchar_t * __restrict str,
extern unsigned long
_stdlib_strto_l(register const char * __restrict str,
- char ** __restrict endptr, int base, int sflag);
+ char ** __restrict endptr, int base, int sflag) attribute_hidden;
#if defined(ULLONG_MAX)
extern unsigned long long
_stdlib_strto_ll(register const char * __restrict str,
- char ** __restrict endptr, int base, int sflag);
+ char ** __restrict endptr, int base, int sflag) attribute_hidden;
#endif
#ifdef __UCLIBC_HAS_WCHAR__
extern unsigned long
_stdlib_wcsto_l(register const wchar_t * __restrict str,
- wchar_t ** __restrict endptr, int base, int sflag);
+ wchar_t ** __restrict endptr, int base, int sflag) attribute_hidden;
#if defined(ULLONG_MAX)
extern unsigned long long
_stdlib_wcsto_ll(register const wchar_t * __restrict str,
- wchar_t ** __restrict endptr, int base, int sflag);
+ wchar_t ** __restrict endptr, int base, int sflag) attribute_hidden;
#endif
#endif /* __UCLIBC_HAS_WCHAR__ */
/**********************************************************************/
#ifdef L_atof
-extern double __strtod (__const char *__restrict __nptr,
- char **__restrict __endptr)
- __THROW __nonnull ((1)) __wur attribute_hidden;
+libc_hidden_proto(strtod)
double atof(const char *nptr)
{
- return __strtod(nptr, (char **) NULL);
+ return strtod(nptr, (char **) NULL);
}
#endif
@@ -233,14 +229,20 @@ long int labs(long int j)
}
#if UINT_MAX == ULONG_MAX
+#undef abs
+extern __typeof(labs) abs;
strong_alias(labs,abs)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
+#undef llabs
+extern __typeof(labs) llabs;
strong_alias(labs,llabs)
#endif
#if ULONG_MAX == UINTMAX_MAX
+#undef imaxabs
+extern __typeof(labs) imaxabs;
strong_alias(labs,imaxabs)
#endif
@@ -256,6 +258,8 @@ long long int llabs(long long int j)
}
#if (ULLONG_MAX == UINTMAX_MAX)
+#undef imaxabs
+extern __typeof(llabs) imaxabs;
strong_alias(llabs,imaxabs)
#endif
@@ -267,11 +271,14 @@ strong_alias(llabs,imaxabs)
#if INT_MAX < LONG_MAX
-int attribute_hidden __atoi(const char *nptr)
+libc_hidden_proto(strtol)
+
+libc_hidden_proto(atoi)
+int atoi(const char *nptr)
{
- return (int) __strtol(nptr, (char **) NULL, 10);
+ return (int) strtol(nptr, (char **) NULL, 10);
}
-strong_alias(__atoi,atoi)
+libc_hidden_def(atoi)
#endif /* INT_MAX < LONG_MAX */
@@ -279,19 +286,27 @@ strong_alias(__atoi,atoi)
/**********************************************************************/
#ifdef L_atol
-long attribute_hidden __atol(const char *nptr)
+libc_hidden_proto(strtol)
+
+libc_hidden_proto(atol)
+long atol(const char *nptr)
{
- return __strtol(nptr, (char **) NULL, 10);
+ return strtol(nptr, (char **) NULL, 10);
}
-strong_alias(__atol,atol)
+libc_hidden_def(atol)
#if UINT_MAX == ULONG_MAX
-hidden_strong_alias(__atol,__atoi)
-strong_alias(__atol,atoi)
+#undef atoi
+extern __typeof(atol) atoi;
+libc_hidden_proto(atoi)
+strong_alias(atol,atoi)
+libc_hidden_def(atoi)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-strong_alias(__atol,atoll)
+#undef atoll
+extern __typeof(atol) atoll;
+strong_alias(atol,atoll)
#endif
#endif
@@ -300,9 +315,11 @@ strong_alias(__atol,atoll)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
+libc_hidden_proto(strtoll)
+
long long atoll(const char *nptr)
{
- return __strtoll(nptr, (char **) NULL, 10);
+ return strtoll(nptr, (char **) NULL, 10);
}
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
@@ -311,20 +328,28 @@ long long atoll(const char *nptr)
/**********************************************************************/
#if defined(L_strtol) || defined(L_strtol_l)
-long attribute_hidden __UCXL(strtol)(const char * __restrict str, char ** __restrict endptr,
+libc_hidden_proto(__XL_NPP(strtol))
+long __XL_NPP(strtol)(const char * __restrict str, char ** __restrict endptr,
int base __LOCALE_PARAM )
{
return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 1 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(strtol)
+libc_hidden_def(__XL_NPP(strtol))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_strtol_l)
strong_alias(strtol,strtoimax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-strong_alias(__XL(strtol),__XL(strtoll))
+#ifdef L_strtol_l
+#undef strtoll_l
+#else
+#undef strtoll
+#endif
+extern __typeof(strtol) __XL_NPP(strtoll);
+libc_hidden_proto(__XL_NPP(strtoll))
+strong_alias(__XL_NPP(strtol),__XL_NPP(strtoll))
+libc_hidden_def(__XL_NPP(strtoll))
#endif
#endif
@@ -333,15 +358,15 @@ strong_alias(__XL(strtol),__XL(strtoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-long long attribute_hidden __UCXL(strtoll)(const char * __restrict str,
+libc_hidden_proto(__XL_NPP(strtoll))
+long long __XL_NPP(strtoll)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1
__LOCALE_ARG );
}
-
-__UCXL_ALIAS(strtoll)
+libc_hidden_def(__XL_NPP(strtoll))
#if !defined(L_strtoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -356,21 +381,29 @@ strong_alias(strtoll,strtoq)
/**********************************************************************/
#if defined(L_strtoul) || defined(L_strtoul_l)
-unsigned long attribute_hidden __UCXL(strtoul)(const char * __restrict str,
+libc_hidden_proto(__XL_NPP(strtoul))
+unsigned long __XL_NPP(strtoul)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 0 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(strtoul)
+libc_hidden_def(__XL_NPP(strtoul))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_strtoul_l)
strong_alias(strtoul,strtoumax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-strong_alias(__XL(strtoul),__XL(strtoull))
+#ifdef L_strtoul_l
+#undef strtoull_l
+#else
+#undef strtoull
+#endif
+extern __typeof(strtoul) __XL_NPP(strtoull);
+libc_hidden_proto(__XL_NPP(strtoull))
+strong_alias(__XL_NPP(strtoul),__XL_NPP(strtoull))
+libc_hidden_def(__XL_NPP(strtoull))
#endif
@@ -380,14 +413,14 @@ strong_alias(__XL(strtoul),__XL(strtoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-unsigned long long attribute_hidden __UCXL(strtoull)(const char * __restrict str,
+libc_hidden_proto(__XL_NPP(strtoull))
+unsigned long long __XL_NPP(strtoull)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM )
{
return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(strtoull)
+libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -435,8 +468,10 @@ strong_alias(strtoull,strtouq)
#define Wuchar __uwchar_t
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) iswspace_l((C), locale_arg)
+libc_hidden_proto(iswspace_l)
#else
#define ISSPACE(C) iswspace((C))
+libc_hidden_proto(iswspace)
#endif
#else /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
@@ -445,8 +480,10 @@ strong_alias(strtoull,strtouq)
#define Wuchar unsigned char
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) isspace_l((C), locale_arg)
+libc_hidden_proto(isspace_l)
#else
#define ISSPACE(C) isspace((C))
+libc_hidden_proto(isspace)
#endif
#endif /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
@@ -466,6 +503,12 @@ unsigned long attribute_hidden _stdlib_strto_l(register const Wchar * __restrict
/* This is the main work fuction which handles both strtol (sflag = 1) and
* strtoul (sflag = 0). */
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
+
unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar * __restrict str,
Wchar ** __restrict endptr, int base,
int sflag __LOCALE_PARAM )
@@ -580,8 +623,10 @@ unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar *
#define Wuchar __uwchar_t
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) iswspace_l((C), locale_arg)
+libc_hidden_proto(iswspace_l)
#else
#define ISSPACE(C) iswspace((C))
+libc_hidden_proto(iswspace)
#endif
#else /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
@@ -590,8 +635,10 @@ unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar *
#define Wuchar unsigned char
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) isspace_l((C), locale_arg)
+libc_hidden_proto(isspace_l)
#else
#define ISSPACE(C) isspace((C))
+libc_hidden_proto(isspace)
#endif
#endif /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
@@ -608,6 +655,9 @@ unsigned long long attribute_hidden _stdlib_strto_ll(register const Wchar * __re
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b)
+#endif
/* This is the main work fuction which handles both strtoll (sflag = 1) and
* strtoull (sflag = 0). */
@@ -721,10 +771,10 @@ unsigned long long attribute_hidden __XL_NPP(_stdlib_strto_ll)(register const Wc
/**********************************************************************/
/* Made _Exit() an alias for _exit(), as per C99. */
/* #ifdef L__Exit */
-
+/* libc_hidden_proto(_exit) */
/* void _Exit(int status) */
/* { */
-/* _exit_internal(status); */
+/* _exit(status); */
/* } */
/* #endif */
@@ -769,7 +819,8 @@ void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
* calculation, as well as to reduce the generated code size with
* bcc and gcc. */
-void attribute_hidden __qsort (void *base,
+libc_hidden_proto(qsort)
+void qsort (void *base,
size_t nel,
size_t width,
int (*comp)(const void *, const void *))
@@ -814,7 +865,7 @@ void attribute_hidden __qsort (void *base,
} while (wgap);
}
}
-strong_alias(__qsort,qsort)
+libc_hidden_def(qsort)
/* ---------- original snippets version below ---------- */
@@ -868,7 +919,8 @@ void ssort (void *base,
/**********************************************************************/
#ifdef L__stdlib_mb_cur_max
-size_t attribute_hidden _stdlib_mb_cur_max_internal(void)
+libc_hidden_proto(_stdlib_mb_cur_max)
+size_t _stdlib_mb_cur_max(void)
{
#ifdef __CTYPE_HAS_UTF_8_LOCALES
return __UCLIBC_CURLOCALE_DATA.mb_cur_max;
@@ -881,12 +933,14 @@ size_t attribute_hidden _stdlib_mb_cur_max_internal(void)
return 1;
#endif
}
-strong_alias(_stdlib_mb_cur_max_internal,_stdlib_mb_cur_max)
+libc_hidden_def(_stdlib_mb_cur_max)
#endif
/**********************************************************************/
#ifdef L_mblen
+libc_hidden_proto(mbrlen)
+
int mblen(register const char *s, size_t n)
{
static mbstate_t state;
@@ -904,7 +958,7 @@ int mblen(register const char *s, size_t n)
if ((r = mbrlen(s, n, &state)) == (size_t) -2) {
/* TODO: Should we set an error state? */
state.__wc = 0xffffU; /* Make sure we're in an error state. */
- return (size_t) -1; /* TODO: Change error code above? */
+ return -1; /* TODO: Change error code above? */
}
return r;
}
@@ -913,6 +967,8 @@ int mblen(register const char *s, size_t n)
/**********************************************************************/
#ifdef L_mbtowc
+libc_hidden_proto(mbrtowc)
+
int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
{
static mbstate_t state;
@@ -930,7 +986,7 @@ int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
if ((r = mbrtowc(pwc, s, n, &state)) == (size_t) -2) {
/* TODO: Should we set an error state? */
state.__wc = 0xffffU; /* Make sure we're in an error state. */
- return (size_t) -1; /* TODO: Change error code above? */
+ return -1; /* TODO: Change error code above? */
}
return r;
}
@@ -941,6 +997,8 @@ int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
/* Note: We completely ignore state in all currently supported conversions. */
+libc_hidden_proto(wcrtomb)
+
int wctomb(register char *__restrict s, wchar_t swc)
{
return (!s)
@@ -957,6 +1015,8 @@ int wctomb(register char *__restrict s, wchar_t swc)
/**********************************************************************/
#ifdef L_mbstowcs
+libc_hidden_proto(mbsrtowcs)
+
size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
{
mbstate_t state;
@@ -972,6 +1032,8 @@ size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
/* Note: We completely ignore state in all currently supported conversions. */
+libc_hidden_proto(wcsrtombs)
+
size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
{
const wchar_t *e = pwcs; /* Needed because of restrict. */
@@ -983,20 +1045,28 @@ size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
/**********************************************************************/
#if defined(L_wcstol) || defined(L_wcstol_l)
-long __UCXL(wcstol)(const wchar_t * __restrict str,
+libc_hidden_proto(__XL_NPP(wcstol))
+long __XL_NPP(wcstol)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base __LOCALE_PARAM )
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(wcstol)
+libc_hidden_def(__XL_NPP(wcstol))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstol_l)
strong_alias(wcstol,wcstoimax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-strong_alias(__XL(wcstol),__XL(wcstoll))
+#ifdef L_wcstol_l
+#undef wcstoll_l
+#else
+#undef wcstoll
+#endif
+extern __typeof(wcstol) __XL_NPP(wcstoll);
+libc_hidden_proto(__XL_NPP(wcstoll))
+strong_alias(__XL_NPP(wcstol),__XL_NPP(wcstoll))
+libc_hidden_def(__XL_NPP(wcstoll))
#endif
#endif
@@ -1005,15 +1075,15 @@ strong_alias(__XL(wcstol),__XL(wcstoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-long long attribute_hidden __UCXL(wcstoll)(const wchar_t * __restrict str,
+libc_hidden_proto(__XL_NPP(wcstoll))
+long long __XL_NPP(wcstoll)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1
__LOCALE_ARG );
}
-
-__UCXL_ALIAS(wcstoll)
+libc_hidden_def(__XL_NPP(wcstoll))
#if !defined(L_wcstoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1028,21 +1098,29 @@ strong_alias(wcstoll,wcstoq)
/**********************************************************************/
#if defined(L_wcstoul) || defined(L_wcstoul_l)
-unsigned long attribute_hidden __UCXL(wcstoul)(const wchar_t * __restrict str,
+libc_hidden_proto(__XL_NPP(wcstoul))
+unsigned long __XL_NPP(wcstoul)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(wcstoul)
+libc_hidden_def(__XL_NPP(wcstoul))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstoul_l)
strong_alias(wcstoul,wcstoumax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-strong_alias(__XL(wcstoul),__XL(wcstoull))
+#ifdef L_wcstoul_l
+#undef wcstoull_l
+#else
+#undef wcstoull
+#endif
+extern __typeof(wcstoul) __XL_NPP(wcstoull);
+libc_hidden_proto(__XL_NPP(wcstoull))
+strong_alias(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
+libc_hidden_def(__XL_NPP(wcstoull))
#endif
#endif
@@ -1051,14 +1129,14 @@ strong_alias(__XL(wcstoul),__XL(wcstoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-unsigned long long attribute_hidden __UCXL(wcstoull)(const wchar_t * __restrict str,
+libc_hidden_proto(__XL_NPP(wcstoull))
+unsigned long long __XL_NPP(wcstoull)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM )
{
return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG );
}
-
-__UCXL_ALIAS(wcstoull)
+libc_hidden_def(__XL_NPP(wcstoull))
#if !defined(L_wcstoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c
index 3a5adcd4e..7f59aef49 100644
--- a/libc/stdlib/strtod.c
+++ b/libc/stdlib/strtod.c
@@ -1,622 +1,8 @@
/*
- * Copyright (C) 2000-2005 Manuel Novoa III
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* Notes:
- *
- * The primary objective of this implementation was minimal size and
- * portablility, while providing robustness and resonable accuracy.
- *
- * This implementation depends on IEEE floating point behavior and expects
- * to be able to generate +/- infinity as a result.
- *
- * There are a number of compile-time options below.
- */
-
-/* July 27, 2003
- *
- * General cleanup and some minor size optimizations.
- * Change implementation to support __strtofpmax() rather than strtod().
- * Now all the strto{floating pt}() funcs are implemented in terms of
- * of the internal __strtofpmax() function.
- * Support "nan", "inf", and "infinity" strings (case-insensitive).
- * Support hexadecimal floating point notation.
- * Support wchar variants.
- * Support xlocale variants.
- *
- * TODO:
- *
- * Consider accumulating blocks of digits in longs to save floating pt mults.
- * This would likely be much better on anything that only supported floats
- * where DECIMAL_DIG == 9. Actually, if floats have FLT_MAX_10_EXP == 38,
- * we could calculate almost all the exponent multipliers (p_base) in
- * long arithmetic as well.
- */
-
-/**********************************************************************/
-/* OPTIONS */
-/**********************************************************************/
-
-/* Defined if we want to recognize "nan", "inf", and "infinity". (C99) */
-#define _STRTOD_NAN_INF_STRINGS 1
-
-/* Defined if we want support hexadecimal floating point notation. (C99) */
-/* Note! Now controlled by uClibc configuration. See below. */
-#define _STRTOD_HEXADECIMAL_FLOATS 1
-
-/* Defined if we want to scale with a O(log2(exp)) multiplications.
- * This is generally a good thing to do unless you are really tight
- * on space and do not expect to convert values of large magnitude. */
-
-#define _STRTOD_LOG_SCALING 1
-
-/* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
- *
- * Clearing any of the options below this point is not advised (or tested).
- *
- * WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! */
-
-/* Defined if we want strtod to set errno appropriately. */
-/* NOTE: Implies all options below. */
-#define _STRTOD_ERRNO 1
-
-/* Defined if we want support for the endptr arg. */
-/* Implied by _STRTOD_ERRNO. */
-#define _STRTOD_ENDPTR 1
-
-/* Defined if we want to prevent overflow in accumulating the exponent. */
-/* Implied by _STRTOD_ERRNO. */
-#define _STRTOD_RESTRICT_EXP 1
-
-/* Defined if we want to process mantissa digits more intelligently. */
-/* Implied by _STRTOD_ERRNO. */
-#define _STRTOD_RESTRICT_DIGITS 1
-
-/* Defined if we want to skip scaling 0 for the exponent. */
-/* Implied by _STRTOD_ERRNO. */
-#define _STRTOD_ZERO_CHECK 1
-
-/**********************************************************************/
-/* Don't change anything that follows. */
-/**********************************************************************/
-
-#ifdef _STRTOD_ERRNO
-#undef _STRTOD_ENDPTR
-#undef _STRTOD_RESTRICT_EXP
-#undef _STRTOD_RESTRICT_DIGITS
-#undef _STRTOD_ZERO_CHECK
-#define _STRTOD_ENDPTR 1
-#define _STRTOD_RESTRICT_EXP 1
-#define _STRTOD_RESTRICT_DIGITS 1
-#define _STRTOD_ZERO_CHECK 1
-#endif
-
-/**********************************************************************/
-
-#define iswspace __iswspace
-#define iswspace_l __iswspace_l
-
-#define _ISOC99_SOURCE 1
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <float.h>
-#include <bits/uClibc_fpmax.h>
-
-#include <locale.h>
-
-#ifdef __UCLIBC_HAS_WCHAR__
-
-#include <wchar.h>
-#include <wctype.h>
-#include <bits/uClibc_uwchar.h>
-
-#endif
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-
-
-/* Handle _STRTOD_HEXADECIMAL_FLOATS via uClibc config now. */
-#undef _STRTOD_HEXADECIMAL_FLOATS
-#ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
-#define _STRTOD_HEXADECIMAL_FLOATS 1
-#endif /* __UCLIBC_HAS_HEXADECIMAL_FLOATS__ */
-
-/**********************************************************************/
-
-#undef _STRTOD_FPMAX
-
-#if FPMAX_TYPE == 3
-
-#define NEED_STRTOLD_WRAPPER
-#define NEED_STRTOD_WRAPPER
-#define NEED_STRTOF_WRAPPER
-
-#elif FPMAX_TYPE == 2
-
-#define NEED_STRTOD_WRAPPER
-#define NEED_STRTOF_WRAPPER
-
-#elif FPMAX_TYPE == 1
-
-#define NEED_STRTOF_WRAPPER
-
-#else
-
-#error unknown FPMAX_TYPE!
-
-#endif
-
-extern void __fp_range_check(__fpmax_t y, __fpmax_t x) attribute_hidden;
-
-/**********************************************************************/
-
-#ifdef _STRTOD_RESTRICT_DIGITS
-#define EXP_DENORM_ADJUST DECIMAL_DIG
-#define MAX_ALLOWED_EXP (DECIMAL_DIG + EXP_DENORM_ADJUST - FPMAX_MIN_10_EXP)
-
-#if MAX_ALLOWED_EXP > INT_MAX
-#error size assumption violated for MAX_ALLOWED_EXP
-#endif
-#else
-/* We want some excess if we're not restricting mantissa digits. */
-#define MAX_ALLOWED_EXP ((20 - FPMAX_MIN_10_EXP) * 2)
-#endif
-
-
-#if defined(_STRTOD_RESTRICT_DIGITS) || defined(_STRTOD_ENDPTR) || defined(_STRTOD_HEXADECIMAL_FLOATS)
-#undef _STRTOD_NEED_NUM_DIGITS
-#define _STRTOD_NEED_NUM_DIGITS 1
-#endif
-
-/**********************************************************************/
-#if defined(L___strtofpmax) || defined(L___strtofpmax_l) || defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
-
-#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
-
-#define __strtofpmax __wcstofpmax
-#define __strtofpmax_l __wcstofpmax_l
-
-#define Wchar wchar_t
-#ifdef __UCLIBC_DO_XLOCALE
-#define ISSPACE(C) iswspace_l((C), locale_arg)
-#else
-#define ISSPACE(C) iswspace((C))
-#endif
-
-#else /* defined(L___wcstofpmax) || defined(L___wcstofpmax_l) */
-
-#define Wchar char
-#ifdef __UCLIBC_DO_XLOCALE
-#define ISSPACE(C) isspace_l((C), locale_arg)
-#else
-#define ISSPACE(C) isspace((C))
-#endif
-
-#endif /* defined(L___wcstofpmax) || defined(L___wcstofpmax_l) */
-
-
-#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-
-__fpmax_t attribute_hidden __strtofpmax(const Wchar *str, Wchar **endptr, int exponent_power)
-{
- return __strtofpmax_l(str, endptr, exponent_power, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-
-__fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
- __LOCALE_PARAM )
-{
- __fpmax_t number;
- __fpmax_t p_base = 10; /* Adjusted to 16 in the hex case. */
- Wchar *pos0;
-#ifdef _STRTOD_ENDPTR
- Wchar *pos1;
-#endif
- Wchar *pos = (Wchar *) str;
- int exponent_temp;
- int negative; /* A flag for the number, a multiplier for the exponent. */
-#ifdef _STRTOD_NEED_NUM_DIGITS
- int num_digits;
-#endif
-#ifdef __UCLIBC_HAS_LOCALE__
-#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
- wchar_t decpt_wc = __LOCALE_PTR->decimal_point;
-#else
- const char *decpt = __LOCALE_PTR->decimal_point;
- int decpt_len = __LOCALE_PTR->decimal_point_len;
-#endif
-#endif
-
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- Wchar expchar = 'e';
- Wchar *poshex = NULL;
- __uint16_t is_mask = _ISdigit;
-#define EXPCHAR expchar
-#define IS_X_DIGIT(C) __isctype((C), is_mask)
-#else /* _STRTOD_HEXADECIMAL_FLOATS */
-#define EXPCHAR 'e'
-#define IS_X_DIGIT(C) isdigit((C))
-#endif /* _STRTOD_HEXADECIMAL_FLOATS */
-
- while (ISSPACE(*pos)) { /* Skip leading whitespace. */
- ++pos;
- }
-
- negative = 0;
- switch(*pos) { /* Handle optional sign. */
- case '-': negative = 1; /* Fall through to increment position. */
- case '+': ++pos;
- }
-
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- if ((*pos == '0') && (((pos[1])|0x20) == 'x')) {
- poshex = ++pos; /* Save position of 'x' in case no digits */
- ++pos; /* and advance past it. */
- is_mask = _ISxdigit; /* Used by IS_X_DIGIT. */
- expchar = 'p'; /* Adjust exponent char. */
- p_base = 16; /* Adjust base multiplier. */
- }
-#endif
-
- number = 0.;
-#ifdef _STRTOD_NEED_NUM_DIGITS
- num_digits = -1;
-#endif
-/* exponent_power = 0; */
- pos0 = NULL;
-
- LOOP:
- while (IS_X_DIGIT(*pos)) { /* Process string of (hex) digits. */
-#ifdef _STRTOD_RESTRICT_DIGITS
- if (num_digits < 0) { /* First time through? */
- ++num_digits; /* We've now seen a digit. */
- }
- if (num_digits || (*pos != '0')) { /* Had/have nonzero. */
- ++num_digits;
- if (num_digits <= DECIMAL_DIG) { /* Is digit significant? */
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- number = number * p_base
- + (isdigit(*pos)
- ? (*pos - '0')
- : (((*pos)|0x20) - ('a' - 10)));
-#else /* _STRTOD_HEXADECIMAL_FLOATS */
- number = number * p_base + (*pos - '0');
-#endif /* _STRTOD_HEXADECIMAL_FLOATS */
- }
- }
-#else /* _STRTOD_RESTRICT_DIGITS */
-#ifdef _STRTOD_NEED_NUM_DIGITS
- ++num_digits;
-#endif
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- number = number * p_base
- + (isdigit(*pos)
- ? (*pos - '0')
- : (((*pos)|0x20) - ('a' - 10)));
-#else /* _STRTOD_HEXADECIMAL_FLOATS */
- number = number * p_base + (*pos - '0');
-#endif /* _STRTOD_HEXADECIMAL_FLOATS */
-#endif /* _STRTOD_RESTRICT_DIGITS */
- ++pos;
- }
-
-#ifdef __UCLIBC_HAS_LOCALE__
-#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
- if (!pos0 && (*pos == decpt_wc)) { /* First decimal point? */
- pos0 = ++pos;
- goto LOOP;
- }
-#else
- if (!pos0 && !__memcmp(pos, decpt, decpt_len)) { /* First decimal point? */
- pos0 = (pos += decpt_len);
- goto LOOP;
- }
-#endif
-#else /* __UCLIBC_HAS_LOCALE__ */
- if ((*pos == '.') && !pos0) { /* First decimal point? */
- pos0 = ++pos; /* Save position of decimal point */
- goto LOOP; /* and process rest of digits. */
- }
-#endif /* __UCLIBC_HAS_LOCALE__ */
-
-#ifdef _STRTOD_NEED_NUM_DIGITS
- if (num_digits<0) { /* Must have at least one digit. */
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- if (poshex) { /* Back up to '0' in '0x' prefix. */
- pos = poshex;
- goto DONE;
- }
-#endif /* _STRTOD_HEXADECIMAL_FLOATS */
-
-#ifdef _STRTOD_NAN_INF_STRINGS
- if (!pos0) { /* No decimal point, so check for inf/nan. */
- /* Note: nan is the first string so 'number = i/0.;' works. */
- static const char nan_inf_str[] = "\05nan\0\012infinity\0\05inf\0";
- int i = 0;
-
-#ifdef __UCLIBC_HAS_LOCALE__
- /* Avoid tolower problems for INFINITY in the tr_TR locale. (yuk)*/
-#undef _tolower
-#define _tolower(C) ((C)|0x20)
-#endif /* __UCLIBC_HAS_LOCALE__ */
-
- do {
- /* Unfortunately, we have no memcasecmp(). */
- int j = 0;
- while (_tolower(pos[j]) == nan_inf_str[i+1+j]) {
- ++j;
- if (!nan_inf_str[i+1+j]) {
- number = i / 0.;
- if (negative) { /* Correct for sign. */
- number = -number;
- }
- pos += nan_inf_str[i] - 2;
- goto DONE;
- }
- }
- i += nan_inf_str[i];
- } while (nan_inf_str[i]);
- }
-
-#endif /* STRTOD_NAN_INF_STRINGS */
-#ifdef _STRTOD_ENDPTR
- pos = (Wchar *) str;
-#endif
- goto DONE;
- }
-#endif /* _STRTOD_NEED_NUM_DIGITS */
-
-#ifdef _STRTOD_RESTRICT_DIGITS
- if (num_digits > DECIMAL_DIG) { /* Adjust exponent for skipped digits. */
- exponent_power += num_digits - DECIMAL_DIG;
- }
-#endif
-
- if (pos0) {
- exponent_power += pos0 - pos; /* Adjust exponent for decimal point. */
- }
-
-#ifdef _STRTOD_HEXADECIMAL_FLOATS
- if (poshex) {
- exponent_power *= 4; /* Above is 2**4, but below is 2. */
- p_base = 2;
- }
-#endif /* _STRTOD_HEXADECIMAL_FLOATS */
-
- if (negative) { /* Correct for sign. */
- number = -number;
- }
-
- /* process an exponent string */
- if (((*pos)|0x20) == EXPCHAR) {
-#ifdef _STRTOD_ENDPTR
- pos1 = pos;
-#endif
- negative = 1;
- switch(*++pos) { /* Handle optional sign. */
- case '-': negative = -1; /* Fall through to increment pos. */
- case '+': ++pos;
- }
-
- pos0 = pos;
- exponent_temp = 0;
- while (isdigit(*pos)) { /* Process string of digits. */
-#ifdef _STRTOD_RESTRICT_EXP
- if (exponent_temp < MAX_ALLOWED_EXP) { /* Avoid overflow. */
- exponent_temp = exponent_temp * 10 + (*pos - '0');
- }
-#else
- exponent_temp = exponent_temp * 10 + (*pos - '0');
-#endif
- ++pos;
- }
-
-#ifdef _STRTOD_ENDPTR
- if (pos == pos0) { /* No digits? */
- pos = pos1; /* Back up to {e|E}/{p|P}. */
- } /* else */
-#endif
-
- exponent_power += negative * exponent_temp;
- }
-
-#ifdef _STRTOD_ZERO_CHECK
- if (number == 0.) {
- goto DONE;
- }
-#endif
-
- /* scale the result */
-#ifdef _STRTOD_LOG_SCALING
- exponent_temp = exponent_power;
-
- if (exponent_temp < 0) {
- exponent_temp = -exponent_temp;
- }
-
- while (exponent_temp) {
- if (exponent_temp & 1) {
- if (exponent_power < 0) {
- /* Warning... caluclating a factor for the exponent and
- * then dividing could easily be faster. But doing so
- * might cause problems when dealing with denormals. */
- number /= p_base;
- } else {
- number *= p_base;
- }
- }
- exponent_temp >>= 1;
- p_base *= p_base;
- }
-
-#else /* _STRTOD_LOG_SCALING */
- while (exponent_power) {
- if (exponent_power < 0) {
- number /= p_base;
- exponent_power++;
- } else {
- number *= p_base;
- exponent_power--;
- }
- }
-#endif /* _STRTOD_LOG_SCALING */
-
-#ifdef _STRTOD_ERRNO
- if (__FPMAX_ZERO_OR_INF_CHECK(number)) {
- __set_errno(ERANGE);
- }
-#endif
-
- DONE:
-#ifdef _STRTOD_ENDPTR
- if (endptr) {
- *endptr = pos;
- }
-#endif
-
- return number;
-}
-
-#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-
-#endif
-/**********************************************************************/
-#ifdef L___fp_range_check
-#if defined(NEED_STRTOF_WRAPPER) || defined(NEED_STRTOD_WRAPPER)
-
-void attribute_hidden __fp_range_check(__fpmax_t y, __fpmax_t x)
-{
- if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */
- && (y != 0) /* y is not 0 (could have x>0, y==0 if underflow) */
- && !__FPMAX_ZERO_OR_INF_CHECK(x) /* x is not 0 or +/- infinity */
- ) {
- __set_errno(ERANGE); /* Then x is not in y's range. */
- }
-}
-
-#endif
-#endif
-/**********************************************************************/
-#if defined(L_strtof) || defined(L_strtof_l) || defined(L_wcstof) || defined(L_wcstof_l)
-#if defined(NEED_STRTOF_WRAPPER)
-
-#if defined(L_wcstof) || defined(L_wcstof_l)
-#define strtof wcstof
-#define strtof_l wcstof_l
-#define __strtof __wcstof
-#define __strtof_l __wcstof_l
-#define __strtofpmax __wcstofpmax
-#define __strtofpmax_l __wcstofpmax_l
-#define Wchar wchar_t
-#else
-#define Wchar char
-#endif
-
-
-float attribute_hidden __UCXL(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
-{
-#if FPMAX_TYPE == 1
- return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
-#else
- __fpmax_t x;
- float y;
-
- x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
- y = (float) x;
-
- __fp_range_check(y, x);
-
- return y;
-#endif
-}
-
-__UCXL_ALIAS(strtof)
-
-#endif
-#endif
-/**********************************************************************/
-#if defined(L_strtod) || defined(L_strtod_l) || defined(L_wcstod) || defined(L_wcstod_l)
-#if defined(NEED_STRTOD_WRAPPER)
-
-#if defined(L_wcstod) || defined(L_wcstod_l)
-#define strtod wcstod
-#define strtod_l wcstod_l
-#define __strtod __wcstod
-#define __strtod_l __wcstod_l
-#define __strtofpmax __wcstofpmax
-#define __strtofpmax_l __wcstofpmax_l
-#define Wchar wchar_t
-#else
-#define Wchar char
-#endif
-
-double attribute_hidden __UCXL(strtod)(const Wchar *__restrict str,
- Wchar **__restrict endptr __LOCALE_PARAM )
-{
-#if FPMAX_TYPE == 2
- return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
-#else
- __fpmax_t x;
- double y;
-
- x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
- y = (double) x;
-
- __fp_range_check(y, x);
-
- return y;
-#endif
-}
-
-__UCXL_ALIAS(strtod)
-
-#endif
-#endif
-/**********************************************************************/
-#if defined(L_strtold) || defined(L_strtold_l) || defined(L_wcstold) || defined(L_wcstold_l)
-#if defined(NEED_STRTOLD_WRAPPER)
-
-#if defined(L_wcstold) || defined(L_wcstold_l)
-#define strtold wcstold
-#define strtold_l wcstold_l
-#define __strtold __wcstold
-#define __strtold_l __wcstold_l
-#define __strtofpmax __wcstofpmax
-#define __strtofpmax_l __wcstofpmax_l
-#define Wchar wchar_t
-#else
-#define Wchar char
-#endif
-
-long double attribute_hidden __UCXL(strtold)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
-{
-#if FPMAX_TYPE == 3
- return __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
-#else
- __fpmax_t x;
- long double y;
-
- x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG );
- y = (long double) x;
-
- __fp_range_check(y, x);
-
- return y;
-#endif
-}
-
-__UCXL_ALIAS(strtold)
-
-#endif
-#endif
-/**********************************************************************/
+#define L_strtod
+#include "_strtod.c"
diff --git a/libc/stdlib/strtod_l.c b/libc/stdlib/strtod_l.c
new file mode 100644
index 000000000..413124230
--- /dev/null
+++ b/libc/stdlib/strtod_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtod_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/strtof.c b/libc/stdlib/strtof.c
index d25a67d05..35e89771a 100644
--- a/libc/stdlib/strtof.c
+++ b/libc/stdlib/strtof.c
@@ -1,34 +1,8 @@
-/* vi: set sw=4 ts=4: */
-/* strtof for uClibc
- *
- * Copyright (C) 2002 by 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.
- *
- * 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
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* This implementation is a bit lame, since we are actually making the compiler
- * to an internal conversion from a double to a float, thereby wasting a bunch
- * of precision. But this is small, and works for now... */
-
-#define strtod __strtod
-
-#include <stdlib.h>
-
-float strtof (const char *str, char **endptr)
-{
- return(strtod(str,endptr));
-}
-
+#define L_strtof
+#include "_strtod.c"
diff --git a/libc/stdlib/strtof_l.c b/libc/stdlib/strtof_l.c
new file mode 100644
index 000000000..7b44d1b05
--- /dev/null
+++ b/libc/stdlib/strtof_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtof_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/strtol.c b/libc/stdlib/strtol.c
new file mode 100644
index 000000000..cee4e1347
--- /dev/null
+++ b/libc/stdlib/strtol.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtol
+#include "stdlib.c"
diff --git a/libc/stdlib/strtol_l.c b/libc/stdlib/strtol_l.c
new file mode 100644
index 000000000..d59c1e50c
--- /dev/null
+++ b/libc/stdlib/strtol_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtol_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/strtold.c b/libc/stdlib/strtold.c
index 3ef1fc491..91a3ba79d 100644
--- a/libc/stdlib/strtold.c
+++ b/libc/stdlib/strtold.c
@@ -1,34 +1,8 @@
-/* vi: set sw=4 ts=4: */
-/* strtold for uClibc
- *
- * Copyright (C) 2002 by 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.
- *
- * 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
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* This implementation is a bit lame, since we are actually making the compiler
- * to an internal conversion from a double to a long double, thereby losing
- * tons of precision. But this is small, and works for now... */
-
-#define strtod __strtod
-
-#include <stdlib.h>
-
-long double strtold (const char *str, char **endptr)
-{
- return(strtod(str,endptr));
-}
-
+#define L_strtold
+#include "_strtod.c"
diff --git a/libc/stdlib/strtold_l.c b/libc/stdlib/strtold_l.c
new file mode 100644
index 000000000..7eccd00bb
--- /dev/null
+++ b/libc/stdlib/strtold_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtold_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/strtoll.c b/libc/stdlib/strtoll.c
new file mode 100644
index 000000000..a9c7c83ee
--- /dev/null
+++ b/libc/stdlib/strtoll.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoll
+#include "stdlib.c"
diff --git a/libc/stdlib/strtoll_l.c b/libc/stdlib/strtoll_l.c
new file mode 100644
index 000000000..9fa46bdd4
--- /dev/null
+++ b/libc/stdlib/strtoll_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoll_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/strtoul.c b/libc/stdlib/strtoul.c
new file mode 100644
index 000000000..e92d2464b
--- /dev/null
+++ b/libc/stdlib/strtoul.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoul
+#include "stdlib.c"
diff --git a/libc/stdlib/strtoul_l.c b/libc/stdlib/strtoul_l.c
new file mode 100644
index 000000000..2aef138a5
--- /dev/null
+++ b/libc/stdlib/strtoul_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoul_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/strtoull.c b/libc/stdlib/strtoull.c
new file mode 100644
index 000000000..60b626fe0
--- /dev/null
+++ b/libc/stdlib/strtoull.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoull
+#include "stdlib.c"
diff --git a/libc/stdlib/strtoull_l.c b/libc/stdlib/strtoull_l.c
new file mode 100644
index 000000000..81e045a4d
--- /dev/null
+++ b/libc/stdlib/strtoull_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_strtoull_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c
index a537156fd..5c16dbee2 100644
--- a/libc/stdlib/system.c
+++ b/libc/stdlib/system.c
@@ -1,22 +1,40 @@
-#define wait4 __wait4
-#define execl __execl
-#define signal __signal
-#define vfork __vfork
-#define fork __fork
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#define SHELL_PATH "/bin/sh" /* Path of the shell. */
+#define SHELL_NAME "sh" /* Name to give it. */
#include <stdio.h>
#include <stddef.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <stdlib.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sched.h>
+#include <errno.h>
+#include <bits/libc-lock.h>
+#include <sysdep-cancel.h>
+#endif
+
+libc_hidden_proto(_exit)
+libc_hidden_proto(wait4)
+libc_hidden_proto(execl)
+libc_hidden_proto(signal)
+libc_hidden_proto(vfork)
+#if !defined __UCLIBC_HAS_THREADS_NATIVE__
/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
#include <sys/syscall.h>
-#if ! defined __NR_vfork
-#define vfork fork
+#ifndef __NR_vfork
+# define vfork fork
+libc_hidden_proto(fork)
#endif
-int __libc_system(char *command)
+extern __typeof(system) __libc_system;
+int __libc_system(const char *command)
{
int wait_val, pid;
__sighandler_t save_quit, save_int, save_chld;
@@ -39,8 +57,8 @@ int __libc_system(char *command)
signal(SIGINT, SIG_DFL);
signal(SIGCHLD, SIG_DFL);
- execl("/bin/sh", "sh", "-c", command, (char *) 0);
- _exit_internal(127);
+ execl(SHELL_PATH, SHELL_NAME, "-c", command, (char *) 0);
+ _exit(127);
}
/* Signals are not absolutly guarenteed with vfork */
signal(SIGQUIT, SIG_IGN);
@@ -58,4 +76,192 @@ int __libc_system(char *command)
signal(SIGCHLD, save_chld);
return wait_val;
}
-weak_alias(__libc_system, system)
+#else
+/* We have to and actually can handle cancelable system(). The big
+ problem: we have to kill the child process if necessary. To do
+ this a cleanup handler has to be registered and is has to be able
+ to find the PID of the child. The main problem is to reliable have
+ the PID when needed. It is not necessary for the parent thread to
+ return. It might still be in the kernel when the cancellation
+ request comes. Therefore we have to use the clone() calls ability
+ to have the kernel write the PID into the user-level variable. */
+#if defined __ia64__
+# define FORK() \
+ INLINE_SYSCALL (clone2, 6, CLONE_PARENT_SETTID | SIGCHLD, NULL, 0, \
+ &pid, NULL, NULL)
+#elif defined __sparc__
+# define FORK() \
+ INLINE_CLONE_SYSCALL (CLONE_PARENT_SETTID | SIGCHLD, 0, &pid, NULL, NULL)
+#elif defined __s390__
+# define FORK() \
+ INLINE_SYSCALL (clone, 3, 0, CLONE_PARENT_SETTID | SIGCHLD, &pid)
+#else
+# define FORK() \
+ INLINE_SYSCALL (clone, 3, CLONE_PARENT_SETTID | SIGCHLD, 0, &pid)
+#endif
+
+static void cancel_handler (void *arg);
+
+# define CLEANUP_HANDLER \
+ __libc_cleanup_region_start (1, cancel_handler, &pid)
+
+# define CLEANUP_RESET \
+ __libc_cleanup_region_end (0)
+
+static struct sigaction intr, quit;
+static int sa_refcntr;
+__libc_lock_define_initialized (static, lock);
+
+# define DO_LOCK() __libc_lock_lock (lock)
+# define DO_UNLOCK() __libc_lock_unlock (lock)
+# define INIT_LOCK() ({ __libc_lock_init (lock); sa_refcntr = 0; })
+# define ADD_REF() sa_refcntr++
+# define SUB_REF() --sa_refcntr
+
+/* Execute LINE as a shell command, returning its status. */
+static int
+do_system (const char *line)
+{
+ int status, save;
+ pid_t pid;
+ struct sigaction sa;
+ sigset_t omask;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ __sigemptyset (&sa.sa_mask);
+
+ DO_LOCK ();
+ if (ADD_REF () == 0)
+ {
+ if (__sigaction (SIGINT, &sa, &intr) < 0)
+ {
+ SUB_REF ();
+ goto out;
+ }
+ if (__sigaction (SIGQUIT, &sa, &quit) < 0)
+ {
+ save = errno;
+ SUB_REF ();
+ goto out_restore_sigint;
+ }
+ }
+ DO_UNLOCK ();
+
+ /* We reuse the bitmap in the 'sa' structure. */
+ __sigaddset (&sa.sa_mask, SIGCHLD);
+ save = errno;
+ if (sigprocmask (SIG_BLOCK, &sa.sa_mask, &omask) < 0)
+ {
+ {
+ DO_LOCK ();
+ if (SUB_REF () == 0)
+ {
+ save = errno;
+ (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ out_restore_sigint:
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ __set_errno (save);
+ }
+ out:
+ DO_UNLOCK ();
+ return -1;
+ }
+ }
+
+ CLEANUP_HANDLER;
+
+ pid = FORK ();
+ if (pid == (pid_t) 0)
+ {
+ /* Child side. */
+ const char *new_argv[4];
+ new_argv[0] = SHELL_NAME;
+ new_argv[1] = "-c";
+ new_argv[2] = line;
+ new_argv[3] = NULL;
+
+ /* Restore the signals. */
+ (void) sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ (void) sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
+ INIT_LOCK ();
+
+ /* Exec the shell. */
+ (void) execve (SHELL_PATH, (char *const *) new_argv, __environ);
+ _exit (127);
+ }
+ else if (pid < (pid_t) 0)
+ /* The fork failed. */
+ status = -1;
+ else
+ /* Parent side. */
+ {
+ /* Note the system() is a cancellation point. But since we call
+ waitpid() which itself is a cancellation point we do not
+ have to do anything here. */
+ if (TEMP_FAILURE_RETRY (__waitpid (pid, &status, 0)) != pid)
+ status = -1;
+ }
+
+ CLEANUP_RESET;
+
+ save = errno;
+ DO_LOCK ();
+ if ((SUB_REF () == 0
+ && (sigaction (SIGINT, &intr, (struct sigaction *) NULL)
+ | sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)) != 0)
+ || sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL) != 0)
+ {
+ status = -1;
+ }
+ DO_UNLOCK ();
+
+ return status;
+}
+
+
+int
+__libc_system (const char *line)
+{
+ if (line == NULL)
+ /* Check that we have a command processor available. It might
+ not be available after a chroot(), for example. */
+ return do_system ("exit 0") == 0;
+
+ if (SINGLE_THREAD_P)
+ return do_system (line);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = do_system (line);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+
+/* The cancellation handler. */
+static void
+cancel_handler (void *arg)
+{
+ pid_t child = *(pid_t *) arg;
+
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (kill, err, 2, child, SIGKILL);
+
+ TEMP_FAILURE_RETRY (__waitpid (child, NULL, 0));
+
+ DO_LOCK ();
+
+ if (SUB_REF () == 0)
+ {
+ (void) sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ }
+
+ DO_UNLOCK ();
+}
+#endif
+weak_alias(__libc_system,system)
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index 0e7d50a99..f88a54bc0 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -17,16 +17,6 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define memchr __memchr
-#define getgid __getgid
-#define getuid __getuid
-#define setrlimit __setrlimit
-#define waitpid __waitpid
-#define dup2 __dup2
-#define chmod __chmod
-#define vfork __vfork
-#define fork __fork
-
#include <assert.h>
#include <errno.h>
#include <grp.h>
@@ -40,6 +30,20 @@
#include <unistd.h>
#include "pty-private.h"
+libc_hidden_proto(memchr)
+libc_hidden_proto(getgid)
+libc_hidden_proto(getuid)
+libc_hidden_proto(setrlimit)
+libc_hidden_proto(waitpid)
+libc_hidden_proto(dup2)
+libc_hidden_proto(chmod)
+libc_hidden_proto(chown)
+libc_hidden_proto(vfork)
+libc_hidden_proto(fork)
+libc_hidden_proto(stat)
+libc_hidden_proto(ptsname_r)
+libc_hidden_proto(execle)
+libc_hidden_proto(_exit)
/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
#include <sys/syscall.h>
@@ -47,8 +51,6 @@
#define vfork fork
#endif
-extern int __ptsname_r (int fd, char *buf, size_t buflen) attribute_hidden;
-
/* Return the result of ptsname_r in the buffer pointed to by PTS,
which should be of length BUF_LEN. If it is too long to fit in
this buffer, a sufficiently long buffer is allocated using malloc,
@@ -65,7 +67,7 @@ pts_name (int fd, char **pts, size_t buf_len)
if (buf_len)
{
- rv = __ptsname_r (fd, buf, buf_len);
+ rv = ptsname_r (fd, buf, buf_len);
if (rv != 0 || memchr (buf, '\0', buf_len))
/* We either got an error, or we succeeded and the
@@ -122,7 +124,7 @@ grantpt (int fd)
if (pts_name (fd, &buf, sizeof (_buf)))
return -1;
- if (__stat(buf, &st) < 0)
+ if (stat(buf, &st) < 0)
goto cleanup;
/* Make sure that we own the device. */
@@ -168,10 +170,10 @@ grantpt (int fd)
/* We pase the master pseudo terminal as file descriptor PTY_FILENO. */
if (fd != PTY_FILENO)
if (dup2 (fd, PTY_FILENO) < 0)
- _exit_internal (FAIL_EBADF);
+ _exit (FAIL_EBADF);
execle (_PATH_PT_CHOWN, _PATH_PT_CHOWN, NULL, NULL);
- _exit_internal (FAIL_EXEC);
+ _exit (FAIL_EXEC);
}
else
{
diff --git a/libc/stdlib/unlockpt.c b/libc/stdlib/unlockpt.c
index 3f99c1c0b..8c426553c 100644
--- a/libc/stdlib/unlockpt.c
+++ b/libc/stdlib/unlockpt.c
@@ -22,6 +22,7 @@
#include <sys/ioctl.h>
#include <termios.h>
+libc_hidden_proto(ioctl)
/* Unlock the slave pseudo terminal associated with the master pseudo
terminal specified by FD. */
@@ -32,7 +33,7 @@ unlockpt (int fd)
int save_errno = errno;
int unlock = 0;
- if (__ioctl (fd, TIOCSPTLCK, &unlock))
+ if (ioctl (fd, TIOCSPTLCK, &unlock))
{
if (errno == EINVAL)
{
diff --git a/libc/stdlib/valloc.c b/libc/stdlib/valloc.c
index d4f21d121..13dbe0f67 100644
--- a/libc/stdlib/valloc.c
+++ b/libc/stdlib/valloc.c
@@ -20,12 +20,12 @@ Cambridge, MA 02139, USA.
The author may be reached (Email) at the address mike@@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
-#define getpagesize __getpagesize_internal
-
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
+libc_hidden_proto(getpagesize)
+
static size_t pagesize;
__ptr_t valloc (size_t size)
diff --git a/libc/stdlib/wcstod.c b/libc/stdlib/wcstod.c
new file mode 100644
index 000000000..08f802112
--- /dev/null
+++ b/libc/stdlib/wcstod.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstod
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstod_l.c b/libc/stdlib/wcstod_l.c
new file mode 100644
index 000000000..be0e58e51
--- /dev/null
+++ b/libc/stdlib/wcstod_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstod_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstof.c b/libc/stdlib/wcstof.c
new file mode 100644
index 000000000..27ad22f61
--- /dev/null
+++ b/libc/stdlib/wcstof.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstof
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstof_l.c b/libc/stdlib/wcstof_l.c
new file mode 100644
index 000000000..953ebe040
--- /dev/null
+++ b/libc/stdlib/wcstof_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstof_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstol.c b/libc/stdlib/wcstol.c
new file mode 100644
index 000000000..74462e1a8
--- /dev/null
+++ b/libc/stdlib/wcstol.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstol
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstol_l.c b/libc/stdlib/wcstol_l.c
new file mode 100644
index 000000000..4282987dc
--- /dev/null
+++ b/libc/stdlib/wcstol_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstol_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstold.c b/libc/stdlib/wcstold.c
new file mode 100644
index 000000000..cd879c110
--- /dev/null
+++ b/libc/stdlib/wcstold.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstold
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstold_l.c b/libc/stdlib/wcstold_l.c
new file mode 100644
index 000000000..2ea23b0d5
--- /dev/null
+++ b/libc/stdlib/wcstold_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstold_l
+#define __UCLIBC_DO_XLOCALE
+#include "_strtod.c"
diff --git a/libc/stdlib/wcstoll.c b/libc/stdlib/wcstoll.c
new file mode 100644
index 000000000..4cc9b05fb
--- /dev/null
+++ b/libc/stdlib/wcstoll.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoll
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstoll_l.c b/libc/stdlib/wcstoll_l.c
new file mode 100644
index 000000000..66c23c290
--- /dev/null
+++ b/libc/stdlib/wcstoll_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoll_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstombs.c b/libc/stdlib/wcstombs.c
new file mode 100644
index 000000000..c3d08d8d5
--- /dev/null
+++ b/libc/stdlib/wcstombs.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstombs
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstoul.c b/libc/stdlib/wcstoul.c
new file mode 100644
index 000000000..55427447c
--- /dev/null
+++ b/libc/stdlib/wcstoul.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoul
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstoul_l.c b/libc/stdlib/wcstoul_l.c
new file mode 100644
index 000000000..529e8e40b
--- /dev/null
+++ b/libc/stdlib/wcstoul_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoul_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstoull.c b/libc/stdlib/wcstoull.c
new file mode 100644
index 000000000..ea884ef08
--- /dev/null
+++ b/libc/stdlib/wcstoull.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoull
+#include "stdlib.c"
diff --git a/libc/stdlib/wcstoull_l.c b/libc/stdlib/wcstoull_l.c
new file mode 100644
index 000000000..976d103ee
--- /dev/null
+++ b/libc/stdlib/wcstoull_l.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wcstoull_l
+#define __UCLIBC_DO_XLOCALE
+#include "stdlib.c"
diff --git a/libc/stdlib/wctomb.c b/libc/stdlib/wctomb.c
new file mode 100644
index 000000000..3f612be27
--- /dev/null
+++ b/libc/stdlib/wctomb.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wctomb
+#include "stdlib.c"
diff --git a/libc/string/Makefile.in b/libc/string/Makefile.in
index 4f96b8354..376316b7e 100644
--- a/libc/string/Makefile.in
+++ b/libc/string/Makefile.in
@@ -1,79 +1,113 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-# order is relevant
--include $(top_srcdir)libc/string/$(TARGET_ARCH)/Makefile.arch
-include $(top_srcdir)libc/string/generic/Makefile.in
+#
+# Arch specific fun
+#
+STRING_ARCH_DIR := $(top_srcdir)libc/string/$(TARGET_ARCH)
+STRING_ARCH_OUT := $(top_builddir)libc/string/$(TARGET_ARCH)
+
+STRING_ARCH_SRC := $(wildcard $(STRING_ARCH_DIR)/*.c)
+STRING_ARCH_OBJ := $(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC))
+
+STRING_ARCH_SSRC := $(wildcard $(STRING_ARCH_DIR)/*.S)
+STRING_ARCH_SOBJ := $(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC))
+
+STRING_ARCH_OBJS := $(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ)
+
+libc-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_OBJS)
+
+libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_SOBJ)
+
+#
+# Generic stuff
+#
+STRING_GENERIC_DIR := $(top_srcdir)libc/string/generic
+STRING_GENERIC_OUT := $(top_builddir)libc/string/generic
-STRING_DIR:=$(top_srcdir)libc/string
-STRING_OUT:=$(top_builddir)libc/string
+STRING_GENERIC_SRC := $(wildcard $(STRING_GENERIC_DIR)/*.c)
+
+ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
+ifneq ($(strip $(STRING_ARCH_OBJS)),)
+STRING_GENERIC_SRC := $(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_GENERIC_SRC))
+endif
+endif
+
+STRING_GENERIC_OBJS := $(patsubst $(STRING_GENERIC_DIR)/%.c,$(STRING_GENERIC_OUT)/%.o,$(STRING_GENERIC_SRC))
+
+libc-$(UCLIBC_HAS_STRING_GENERIC_OPT) += $(STRING_GENERIC_OBJS)
+
+#
+# Top level string
+#
+STRING_DIR := $(top_srcdir)libc/string
+STRING_OUT := $(top_builddir)libc/string
-STRING_ALL_WXSRC:=$(wildcard $(STRING_DIR)/w*_l.c)
+STRING_ALL_WXSRC := $(wildcard $(STRING_DIR)/w*_l.c)
ifeq ($(UCLIBC_HAS_LOCALE),y)
-STRING_WXSRC:=$(STRING_ALL_WXSRC)
+STRING_WXSRC := $(STRING_ALL_WXSRC)
else
# wcscoll_l
-STRING_WXSRC:=$(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC))
+STRING_WXSRC := $(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC))
endif
-STRING_ALL_XLSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c))
+STRING_ALL_XLSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c))
ifeq ($(UCLIBC_HAS_LOCALE),y)
-STRING_XLSRC:=$(STRING_ALL_XLSRC)
+STRING_XLSRC := $(STRING_ALL_XLSRC)
else
# strcoll_l
-STRING_XLSRC:=$(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC))
+STRING_XLSRC := $(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC))
endif
-STRING_ALL_WSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c))
+STRING_ALL_WSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c))
ifeq ($(UCLIBC_HAS_LOCALE),y)
-STRING_WSRC:=$(STRING_ALL_WSRC)
+STRING_WSRC := $(STRING_ALL_WSRC)
else
# wcscoll
-STRING_WSRC:=$(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC))
+STRING_WSRC := $(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC))
endif
-STRING_ALL_CSRC:=$(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c))
+STRING_ALL_CSRC := $(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c))
ifeq ($(UCLIBC_HAS_LOCALE),y)
-STRING_CSRC:=$(STRING_ALL_CSRC)
+STRING_CSRC := $(STRING_ALL_CSRC)
else
# strcoll
-STRING_CSRC:=$(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC))
+STRING_CSRC := $(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC))
endif
ifeq ($(UCLIBC_HAS_WCHAR),y)
-STRING_CSRC+=$(STRING_WSRC)
+STRING_CSRC += $(STRING_WSRC)
endif
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-STRING_CSRC+=$(STRING_XLSRC)
+STRING_CSRC += $(STRING_XLSRC)
ifeq ($(UCLIBC_HAS_WCHAR),y)
-STRING_CSRC+=$(STRING_WXSRC)
+STRING_CSRC += $(STRING_WXSRC)
endif
endif
ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
ifneq ($(strip $(STRING_ARCH_OBJS)),)
-STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC))
+STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC))
endif
endif
ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y)
ifneq ($(strip $(STRING_GENERIC_OBJS)),)
-STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC))
+STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC))
endif
endif
-STRING_COBJ:=$(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC))
+STRING_COBJ := $(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC))
-libc-a-y+=$(STRING_COBJ)
-libc-so-y+=$(STRING_COBJ:.o=.os)
+libc-y += $(STRING_COBJ)
-libc-multi-y+=$(STRING_CSRC)
+libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STRING_OUT)/wcsxfrm_l.o
-objclean-y+=string_objclean
+objclean-y += string_objclean
string_objclean:
$(RM) $(STRING_OUT)/{,*/}*.{o,os}
diff --git a/libc/string/__glibc_strerror_r.c b/libc/string/__glibc_strerror_r.c
index 54955ec25..0f9cd16a9 100644
--- a/libc/string/__glibc_strerror_r.c
+++ b/libc/string/__glibc_strerror_r.c
@@ -8,12 +8,13 @@
#include <features.h>
#include <string.h>
-char attribute_hidden *__glibc_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen)
+libc_hidden_proto(__glibc_strerror_r)
+libc_hidden_proto(__xpg_strerror_r)
+
+char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
- __xpg_strerror_r_internal(errnum, strerrbuf, buflen);
+ __xpg_strerror_r(errnum, strerrbuf, buflen);
return strerrbuf;
}
-
-strong_alias(__glibc_strerror_r_internal,__glibc_strerror_r)
-/*hidden_weak_alias(__glibc_strerror_r_internal,__strerror_r)*/
+libc_hidden_def(__glibc_strerror_r)
diff --git a/libc/string/__xpg_basename.c b/libc/string/__xpg_basename.c
index 6281f015c..2449d1d42 100644
--- a/libc/string/__xpg_basename.c
+++ b/libc/string/__xpg_basename.c
@@ -6,6 +6,7 @@
*/
#include "_string.h"
+#include <libgen.h>
char *__xpg_basename(register char *path)
{
diff --git a/libc/string/__xpg_strerror_r.c b/libc/string/__xpg_strerror_r.c
index 93dffc732..d146d35ac 100644
--- a/libc/string/__xpg_strerror_r.c
+++ b/libc/string/__xpg_strerror_r.c
@@ -1,19 +1,23 @@
/*
* Copyright (C) 2002 Manuel Novoa III
- * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
+#include <string.h>
#include <bits/uClibc_uintmaxtostr.h>
#include "_syserrmsg.h"
+libc_hidden_proto(__xpg_strerror_r)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strlen)
+
#ifdef __UCLIBC_HAS_ERRNO_MESSAGES__
-extern const char _string_syserrmsgs[];
+extern const char _string_syserrmsgs[] attribute_hidden;
#if defined(__alpha__) || defined(__mips__) || defined(__sparc__)
@@ -140,22 +144,21 @@ static const unsigned char estridx[] = {
ENAVAIL,
EISNAM,
EREMOTEIO,
-#ifdef __mips__
- 0, /* mips has an outrageous value for this... */
+#if EDQUOT > 200 /* mips has an outrageous value for this... */
+ 0,
#else
EDQUOT,
#endif
ENOMEDIUM,
EMEDIUMTYPE,
-#if defined(__mips__) || defined(__sparc__)
+#if EDEADLOCK != EDEADLK
EDEADLOCK,
#endif
};
#endif
-/* __xpg_strerror_r is used in header */
-int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen)
+int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
register char *s;
int i, retval;
@@ -177,11 +180,10 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
}
}
i = INT_MAX; /* Failed, but may need to check mips special case. */
-#ifdef __mips__
- if (errnum == EDQUOT) { /* Deal with large EDQUOT value on mips */
+#if EDQUOT > 200 /* Deal with large EDQUOT value on mips */
+ if (errnum == EDQUOT)
i = 122;
- }
-#endif /* __mips__ */
+#endif
GOT_ESTRIDX:
#else
/* No errno to string index translation needed. */
@@ -207,20 +209,20 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
#endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */
s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown);
- __memcpy(s, unknown, sizeof(unknown));
+ memcpy(s, unknown, sizeof(unknown));
GOT_MESG:
if (!strerrbuf) { /* SUSv3 */
buflen = 0;
}
- i = __strlen(s) + 1;
+ i = strlen(s) + 1;
if (i > buflen) {
i = buflen;
retval = ERANGE;
}
if (i) {
- __memcpy(strerrbuf, s, i);
+ memcpy(strerrbuf, s, i);
strerrbuf[i-1] = 0; /* In case buf was too small. */
}
@@ -233,7 +235,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
#else /* __UCLIBC_HAS_ERRNO_MESSAGES__ */
-int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen)
+int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
register char *s;
int i, retval;
@@ -243,7 +245,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
};
s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown);
- __memcpy(s, unknown, sizeof(unknown));
+ memcpy(s, unknown, sizeof(unknown));
if (!strerrbuf) { /* SUSv3 */
buflen = 0;
@@ -259,7 +261,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
}
if (i) {
- __memcpy(strerrbuf, s, i);
+ memcpy(strerrbuf, s, i);
strerrbuf[i-1] = 0; /* In case buf was too small. */
}
@@ -269,5 +271,4 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size
}
#endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */
-
-strong_alias(__xpg_strerror_r_internal,__xpg_strerror_r)
+libc_hidden_def(__xpg_strerror_r)
diff --git a/libc/string/_collate.c b/libc/string/_collate.c
index 35fe7dc1b..42216e9e4 100644
--- a/libc/string/_collate.c
+++ b/libc/string/_collate.c
@@ -19,19 +19,13 @@
#include <errno.h>
#include <assert.h>
-extern size_t __strlcpy(char *__restrict dst, const char *__restrict src,
- size_t n) attribute_hidden;
-
+libc_hidden_proto(memset)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strlcpy)
+libc_hidden_proto(strcmp)
#ifdef WANT_WIDE
-extern int __wcscmp (__const wchar_t *__s1, __const wchar_t *__s2) attribute_hidden;
-extern size_t __wcsxfrm (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n) attribute_hidden;
-#endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) attribute_hidden;
-extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n, __locale_t __l) attribute_hidden;
-extern int __wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2, __locale_t __loc) attribute_hidden;
-extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __locale_t __loc) attribute_hidden;
+libc_hidden_proto(wcsxfrm)
+libc_hidden_proto(wcscmp)
#endif
#ifdef __UCLIBC_HAS_LOCALE__
@@ -49,13 +43,9 @@ extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __l
#if defined(L_strxfrm) || defined(L_strxfrm_l)
#define wcscoll strcoll
-#define __wcscoll __strcoll
#define wcscoll_l strcoll_l
-#define __wcscoll_l __strcoll_l
#define wcsxfrm strxfrm
-#define __wcsxfrm __strxfrm
#define wcsxfrm_l strxfrm_l
-#define __wcsxfrm_l __strxfrm_l
#undef WANT_WIDE
#undef Wvoid
@@ -67,19 +57,27 @@ extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __l
#endif /* defined(L_strxfrm) || defined(L_strxfrm_l) */
+libc_hidden_proto(__global_locale)
+
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-int attribute_hidden __wcscoll (const Wchar *s0, const Wchar *s1)
+libc_hidden_proto(wcscoll_l)
+
+libc_hidden_proto(wcscoll)
+int wcscoll (const Wchar *s0, const Wchar *s1)
{
- return __wcscoll_l(s0, s1, __UCLIBC_CURLOCALE );
+ return wcscoll_l(s0, s1, __UCLIBC_CURLOCALE );
}
-strong_alias(__wcscoll,wcscoll)
+libc_hidden_def(wcscoll)
-size_t attribute_hidden __wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
+libc_hidden_proto(wcsxfrm_l)
+
+libc_hidden_proto(wcsxfrm)
+size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
{
- return __wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
+ return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
}
-strong_alias(__wcsxfrm,wcsxfrm)
+libc_hidden_def(wcsxfrm)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -160,7 +158,7 @@ static int lookup(wchar_t wc __LOCALE_PARAM )
static void init_col_state(col_state_t *cs, const Wchar *wcs)
{
- __memset(cs, 0, sizeof(col_state_t));
+ memset(cs, 0, sizeof(col_state_t));
cs->s = wcs;
cs->bp = cs->back_buf = cs->ibb;
cs->bb_size = 128;
@@ -392,7 +390,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
cs->weight = 0;
return;
}
- __memcpy(cs->bp, cs->back_buf, cs->bb_size);
+ memcpy(cs->bp, cs->back_buf, cs->bb_size);
} else {
cs->bp = realloc(cs->back_buf, cs->bb_size + 128);
@@ -517,16 +515,17 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
} while (1);
}
-int attribute_hidden __UCXL(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
+libc_hidden_proto(__XL_NPP(wcscoll))
+int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
{
col_state_t ws[2];
int pass;
if (!CUR_COLLATE->num_weights) { /* C locale */
#ifdef WANT_WIDE
- return __wcscmp(s0, s1);
+ return wcscmp(s0, s1);
#else /* WANT_WIDE */
- return __strcmp(s0, s1);
+ return strcmp(s0, s1);
#endif /* WANT_WIDE */
}
@@ -550,11 +549,15 @@ int attribute_hidden __UCXL(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCAL
return 0;
}
-__UCXL_ALIAS(wcscoll)
+libc_hidden_def(__XL_NPP(wcscoll))
#ifdef WANT_WIDE
-size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
+extern size_t __wcslcpy(wchar_t *__restrict dst,
+ const wchar_t *__restrict src, size_t n);
+
+libc_hidden_proto(__XL_NPP(wcsxfrm))
+size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
size_t n __LOCALE_PARAM )
{
col_state_t cs;
@@ -562,7 +565,7 @@ size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *
int pass;
if (!CUR_COLLATE->num_weights) { /* C locale */
- return __wcsxfrm(ws1, ws2, n);
+ return __wcslcpy(ws1, ws2, n);
}
#ifdef __UCLIBC_MJN3_ONLY__
@@ -591,8 +594,7 @@ size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *
}
return count-1;
}
-
-__UCXL_ALIAS(wcsxfrm)
+libc_hidden_def(__XL_NPP(wcsxfrm))
#else /* WANT_WIDE */
@@ -636,7 +638,8 @@ static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight)
return r;
}
-size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
+libc_hidden_proto(__XL_NPP(strxfrm))
+size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
__LOCALE_PARAM )
{
col_state_t cs;
@@ -644,7 +647,7 @@ size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__rest
int pass;
if (!CUR_COLLATE->num_weights) { /* C locale */
- return __strlcpy(ws1, ws2, n);
+ return strlcpy(ws1, ws2, n);
}
#ifdef __UCLIBC_MJN3_ONLY__
@@ -673,8 +676,7 @@ size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__rest
}
return count-1;
}
-
-__UCXL_ALIAS(strxfrm)
+libc_hidden_def(__XL_NPP(strxfrm))
#endif /* WANT_WIDE */
diff --git a/libc/string/_string.h b/libc/string/_string.h
index 4ecde30a7..67f17b1ff 100644
--- a/libc/string/_string.h
+++ b/libc/string/_string.h
@@ -8,7 +8,6 @@
#ifndef __STRING_H
#define __STRING_H
-#define _GNU_SOURCE
#include <features.h>
#include <string.h>
#include <limits.h>
diff --git a/libc/string/_string_syserrmsgs.c b/libc/string/_string_syserrmsgs.c
index a76c0e3af..893af5cc6 100644
--- a/libc/string/_string_syserrmsgs.c
+++ b/libc/string/_string_syserrmsgs.c
@@ -9,6 +9,7 @@
#ifdef __UCLIBC_HAS_ERRNO_MESSAGES__
+attribute_hidden
const char _string_syserrmsgs[] = {
/* 0: 0, 8 */ "Success\0"
/* 1: 8, 24 */ "Operation not permitted\0"
diff --git a/libc/string/_string_syssigmsgs.c b/libc/string/_string_syssigmsgs.c
index 4a94ddf4f..26c0948f4 100644
--- a/libc/string/_string_syssigmsgs.c
+++ b/libc/string/_string_syssigmsgs.c
@@ -9,6 +9,7 @@
#ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__
+attribute_hidden
const char _string_syssigmsgs[] = {
/* 0: 0, 1 */ "\0"
/* 1: 1, 7 */ "Hangup\0"
@@ -42,7 +43,7 @@ const char _string_syssigmsgs[] = {
/* 29: 445, 13 */ "I/O possible\0"
/* 30: 458, 14 */ "Power failure\0"
/* 31: 472, 16 */ "Bad system call"
-#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__)
+#if defined SIGEMT
/* 32: 488, 9 */ "\0EMT trap"
#endif
};
diff --git a/libc/string/arm/Makefile b/libc/string/arm/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/arm/Makefile
+++ b/libc/string/arm/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/arm/Makefile.arch b/libc/string/arm/Makefile.arch
deleted file mode 100644
index 4b2550ee2..000000000
--- a/libc/string/arm/Makefile.arch
+++ /dev/null
@@ -1,27 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-SSRC:= _memcpy.S bcopy.S bzero.S memcmp.S memcpy.S memmove.S memset.S \
- strcmp.S strlen.S strncmp.S
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/arm
-STRING_ARCH_OUT:=$(top_builddir)libc/string/arm
-
-STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC))
-STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/arm/_memcpy.S b/libc/string/arm/_memcpy.S
index e8d78af23..3704f96b5 100644
--- a/libc/string/arm/_memcpy.S
+++ b/libc/string/arm/_memcpy.S
@@ -37,7 +37,7 @@
* by Erik Andersen <andersen@codepoet.org>
*/
-
+#include <features.h>
#include <endian.h>
/*
@@ -83,8 +83,11 @@ _memcpy:
bcc .Lmemcpy_backwards
moveq r0, #0 /* Quick abort for len=0 */
- moveq pc, lr
-
+#if defined(__USE_BX__)
+ bxeq lr
+#else
+ moveq pc, lr
+#endif
stmdb sp!, {r0, lr} /* memcpy() returns dest addr */
subs r2, r2, #4
blt .Lmemcpy_fl4 /* less than 4 bytes */
@@ -389,8 +392,11 @@ _memcpy:
.Lmemcpy_bl4:
/* less than 4 bytes to go */
adds r2, r2, #4
+#if defined(__USE_BX__)
+ bxeq lr
+#else
moveq pc, lr /* done */
-
+#endif
/* copy the crud byte at a time */
cmp r2, #2
ldrb r3, [r1, #-1]!
@@ -399,8 +405,11 @@ _memcpy:
strgeb r3, [r0, #-1]!
ldrgtb r3, [r1, #-1]!
strgtb r3, [r0, #-1]!
+#if defined(__USE_BX__)
+ bx lr
+#else
mov pc, lr
-
+#endif
/* erg - unaligned destination */
.Lmemcpy_bdestul:
cmp r12, #2
diff --git a/libc/string/arm/bcopy.S b/libc/string/arm/bcopy.S
index 2914b8972..0e559225f 100644
--- a/libc/string/arm/bcopy.S
+++ b/libc/string/arm/bcopy.S
@@ -42,18 +42,15 @@
#include <features.h>
.text
-.global __bcopy
-.hidden __bcopy
-.type __bcopy,%function
+.global bcopy
+.type bcopy,%function
.align 4
-__bcopy:
+bcopy:
/* switch the source and destination registers */
eor r0, r1, r0
eor r1, r0, r1
eor r0, r1, r0
- b _memcpy (PLT)
+ b _memcpy /* (PLT) */
-.size __bcopy,.-__bcopy
-
-strong_alias(__bcopy,bcopy)
+.size bcopy,.-bcopy
diff --git a/libc/string/arm/bzero.S b/libc/string/arm/bzero.S
index 2cb67097e..c1eb93323 100644
--- a/libc/string/arm/bzero.S
+++ b/libc/string/arm/bzero.S
@@ -40,16 +40,13 @@
#include <features.h>
.text
-.global __bzero
-.hidden __bzero
-.type __bzero,%function
+.global bzero
+.type bzero,%function
.align 4
-__bzero:
+bzero:
mov r2, r1
mov r1, #0
- b __memset
+ b HIDDEN_JUMPTARGET(memset)
-.size __bzero,.-__bzero
-
-strong_alias(__bzero,bzero)
+.size bzero,.-bzero
diff --git a/libc/string/arm/memcmp.S b/libc/string/arm/memcmp.S
index a97e02742..af1b876ed 100644
--- a/libc/string/arm/memcmp.S
+++ b/libc/string/arm/memcmp.S
@@ -32,17 +32,19 @@
#include <features.h>
.text
-.global __memcmp
-.hidden __memcmp
-.type __memcmp,%function
+.global memcmp
+.type memcmp,%function
.align 4
-__memcmp:
+memcmp:
/* if ((len - 1) < 0) return 0 */
subs r2, r2, #1
movmi r0, #0
+#if defined(__USE_BX__)
+ bxmi lr
+#else
movmi pc, lr
-
+#endif
/* ip == last src address to compare */
add ip, r0, r2
1:
@@ -52,9 +54,13 @@ __memcmp:
cmpcs r2, r3
beq 1b
sub r0, r2, r3
- mov pc, lr
+#if defined(__USE_BX__)
+ bx lr
+#else
+ mov pc, lr
+#endif
-.size __memcmp,.-__memcmp
+.size memcmp,.-memcmp
-strong_alias(__memcmp,memcmp)
-strong_alias(__memcmp,bcmp)
+libc_hidden_def(memcmp)
+strong_alias(memcmp,bcmp)
diff --git a/libc/string/arm/memcpy.S b/libc/string/arm/memcpy.S
index 8f81a15e5..7a5b6ab76 100644
--- a/libc/string/arm/memcpy.S
+++ b/libc/string/arm/memcpy.S
@@ -40,16 +40,15 @@
#include <features.h>
.text
-.global __memcpy
-.hidden __memcpy
-.type __memcpy,%function
+.global memcpy
+.type memcpy,%function
.align 4
-__memcpy:
+memcpy:
stmfd sp!, {r0, lr}
bl _memcpy
ldmfd sp!, {r0, pc}
-.size __memcpy,.-__memcpy
+.size memcpy,.-memcpy
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/arm/memmove.S b/libc/string/arm/memmove.S
index a26cf731e..45cd9b4d4 100644
--- a/libc/string/arm/memmove.S
+++ b/libc/string/arm/memmove.S
@@ -40,16 +40,15 @@
#include <features.h>
.text
-.global __memmove
-.hidden __memmove
-.type __memmove,%function
+.global memmove
+.type memmove,%function
.align 4
-__memmove:
+memmove:
stmfd sp!, {r0, lr}
bl _memcpy
ldmfd sp!, {r0, pc}
-.size __memmove,.-__memmove
+.size memmove,.-memmove
-strong_alias(__memmove,memmove)
+libc_hidden_def(memmove)
diff --git a/libc/string/arm/memset.S b/libc/string/arm/memset.S
index dea05a6b0..16bfe0dc5 100644
--- a/libc/string/arm/memset.S
+++ b/libc/string/arm/memset.S
@@ -21,12 +21,11 @@
#include <sys/syscall.h>
.text
-.global __memset
-.hidden __memset
-.type __memset,%function
+.global memset
+.type memset,%function
.align 4
-__memset:
+memset:
mov a4, a1
cmp a3, $8 @ at least 8 bytes to do?
blt 2f
@@ -57,7 +56,11 @@ __memset:
bge 1b
2:
movs a3, a3 @ anything left?
- moveq pc, lr @ nope
+#if defined(__USE_BX__)
+ bxeq lr
+#else
+ moveq pc, lr @ nope
+#endif
rsb a3, a3, $7
add pc, pc, a3, lsl $2
mov r0, r0
@@ -68,8 +71,12 @@ __memset:
strb a2, [a4], $1
strb a2, [a4], $1
strb a2, [a4], $1
- mov pc, lr
+#if defined(__USE_BX__)
+ bx lr
+#else
+ mov pc, lr
+#endif
-.size __memset,.-__memset
+.size memset,.-memset
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/arm/strcmp.S b/libc/string/arm/strcmp.S
index 3f462dec0..89aa38874 100644
--- a/libc/string/arm/strcmp.S
+++ b/libc/string/arm/strcmp.S
@@ -32,12 +32,11 @@
#include <features.h>
.text
-.global __strcmp
-.hidden __strcmp
-.type __strcmp,%function
+.global strcmp
+.type strcmp,%function
.align 4
-__strcmp:
+strcmp:
1:
ldrb r2, [r0], #1
ldrb r3, [r1], #1
@@ -45,12 +44,16 @@ __strcmp:
cmpcs r2, r3
beq 1b
sub r0, r2, r3
- mov pc, lr
+#if defined(__USE_BX__)
+ bx lr
+#else
+ mov pc, lr
+#endif
-.size __strcmp,.-__strcmp
+.size strcmp,.-strcmp
-strong_alias(__strcmp,strcmp)
+libc_hidden_def(strcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-hidden_strong_alias(__strcmp,__strcoll)
-strong_alias(__strcmp,strcoll)
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
#endif
diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S
index f623cbe20..5b4b02e17 100644
--- a/libc/string/arm/strlen.S
+++ b/libc/string/arm/strlen.S
@@ -27,12 +27,11 @@
*/
.text
-.global __strlen
-.hidden __strlen
-.type __strlen,%function
+.global strlen
+.type strlen,%function
.align 4
-__strlen:
+strlen:
bic r1, r0, $3 @ addr of word containing first byte
ldr r2, [r1], $4 @ get the first word
ands r3, r0, $3 @ how many bytes are duff?
@@ -76,8 +75,12 @@ Llastword: @ drop through to here once we find a
tstne r2, $0x00ff0000 @ (if first three all non-zero, 4th
addne r0, r0, $1 @ must be zero)
#endif
- mov pc,lr
+#if defined(__USE_BX__)
+ bx lr
+#else
+ mov pc,lr
+#endif
-.size __strlen,.-__strlen
+.size strlen,.-strlen
-strong_alias(__strlen,strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/arm/strncmp.S b/libc/string/arm/strncmp.S
index a3278727e..d6b36312a 100644
--- a/libc/string/arm/strncmp.S
+++ b/libc/string/arm/strncmp.S
@@ -32,16 +32,19 @@
#include <features.h>
.text
-.global __strncmp
-.hidden __strncmp
-.type __strncmp,%function
+.global strncmp
+.type strncmp,%function
.align 4
-__strncmp:
+strncmp:
/* if (len == 0) return 0 */
cmp r2, #0
moveq r0, #0
+#if defined(__USE_BX__)
+ bxeq lr
+#else
moveq pc, lr
+#endif
subs r2, r2, #1
/* ip == last src address to compare */
@@ -54,8 +57,12 @@ __strncmp:
cmpcs r2, r3
beq 1b
sub r0, r2, r3
- mov pc, lr
+#if defined(__USE_BX__)
+ bx lr
+#else
+ mov pc, lr
+#endif
-.size __strncmp,.-__strncmp
+.size strncmp,.-strncmp
-strong_alias(__strncmp,strncmp)
+libc_hidden_def(strncmp)
diff --git a/libc/string/basename.c b/libc/string/basename.c
index 403cd770b..2c4937fca 100644
--- a/libc/string/basename.c
+++ b/libc/string/basename.c
@@ -7,7 +7,9 @@
#include "_string.h"
-char attribute_hidden *__basename(const char *path)
+libc_hidden_proto(basename)
+
+char *basename(const char *path)
{
register const char *s;
register const char *p;
@@ -22,5 +24,4 @@ char attribute_hidden *__basename(const char *path)
return (char *) p;
}
-
-strong_alias(__basename,basename)
+libc_hidden_def(basename)
diff --git a/libc/string/bcopy.c b/libc/string/bcopy.c
index 59e586b34..11c3e8015 100644
--- a/libc/string/bcopy.c
+++ b/libc/string/bcopy.c
@@ -7,10 +7,12 @@
#include "_string.h"
-void attribute_hidden __bcopy(const void *s2, void *s1, size_t n)
+libc_hidden_proto(memmove)
+
+void bcopy(const void *s2, void *s1, size_t n)
{
#if 1
- __memmove(s1, s2, n);
+ memmove(s1, s2, n);
#else
#ifdef __BCC__
register char *s;
@@ -49,5 +51,3 @@ void attribute_hidden __bcopy(const void *s2, void *s1, size_t n)
#endif
#endif
}
-
-strong_alias(__bcopy,bcopy)
diff --git a/libc/string/bzero.c b/libc/string/bzero.c
index 0439e39a1..30bdf5674 100644
--- a/libc/string/bzero.c
+++ b/libc/string/bzero.c
@@ -7,10 +7,12 @@
#include "_string.h"
-void attribute_hidden __bzero(void *s, size_t n)
+libc_hidden_proto(memset)
+
+void bzero(void *s, size_t n)
{
#if 1
- (void)__memset(s, 0, n);
+ (void)memset(s, 0, n);
#else
register unsigned char *p = s;
#ifdef __BCC__
@@ -27,5 +29,3 @@ void attribute_hidden __bzero(void *s, size_t n)
#endif
}
#undef np
-
-strong_alias(__bzero,bzero)
diff --git a/libc/string/dirname.c b/libc/string/dirname.c
index a6242e238..6265e562e 100644
--- a/libc/string/dirname.c
+++ b/libc/string/dirname.c
@@ -6,6 +6,7 @@
*/
#include "_string.h"
+#include <libgen.h>
char *dirname(char *path)
{
diff --git a/libc/string/ffs.c b/libc/string/ffs.c
index fc76e6c70..d98383d4e 100644
--- a/libc/string/ffs.c
+++ b/libc/string/ffs.c
@@ -9,7 +9,9 @@
#include "_string.h"
-int attribute_hidden __ffs(int i)
+libc_hidden_proto(ffs)
+
+int ffs(int i)
{
#if 1
/* inlined binary search method */
@@ -50,5 +52,4 @@ int attribute_hidden __ffs(int i)
return n;
#endif
}
-
-strong_alias(__ffs,ffs)
+libc_hidden_def(ffs)
diff --git a/libc/string/frv/Makefile b/libc/string/frv/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/frv/Makefile
+++ b/libc/string/frv/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/frv/Makefile.arch b/libc/string/frv/Makefile.arch
deleted file mode 100644
index a864e8d1a..000000000
--- a/libc/string/frv/Makefile.arch
+++ /dev/null
@@ -1,27 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2004 Alexandre Oliva <aoliva@redhat.com>
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-SSRC:=memcpy.S memset.S
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/frv
-STRING_ARCH_OUT:=$(top_builddir)libc/string/frv
-
-STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC))
-STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/frv/memcpy.S b/libc/string/frv/memcpy.S
index abd8a28db..ae843797d 100644
--- a/libc/string/frv/memcpy.S
+++ b/libc/string/frv/memcpy.S
@@ -31,10 +31,9 @@
# to caller's fixup routine, aborting the remainder of the copy
#
###############################################################################
- .globl __memcpy
- .hidden __memcpy
- .type __memcpy,@function
-__memcpy:
+ .globl memcpy
+ .type memcpy,@function
+memcpy:
or.p gr8,gr9,gr4
orcc gr10,gr0,gr0,icc3
or.p gr10,gr4,gr4
@@ -123,6 +122,6 @@ memcpy_32:
bne icc0,#2,0b
bralr
- .size __memcpy, .-__memcpy
+ .size memcpy, .-memcpy
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/frv/memset.S b/libc/string/frv/memset.S
index a548b3779..4e64550e4 100644
--- a/libc/string/frv/memset.S
+++ b/libc/string/frv/memset.S
@@ -32,10 +32,9 @@
# GR4, GR7, GR8, and GR11 must be managed
#
###############################################################################
- .globl __memset
- .hidden __memset
- .type __memset,@function
-__memset:
+ .globl memset
+ .type memset,@function
+memset:
orcc.p gr10,gr0,gr5,icc3 ; GR5 = count
andi gr9,#0xff,gr9
or.p gr8,gr0,gr4 ; GR4 = address
@@ -154,6 +153,6 @@ __memset:
cknc icc0,cc7
cstb.p gr12,@(gr4,gr0) ,cc7,#1
bralr
- .size __memset, .-__memset
+ .size memset, .-memset
-strong_alias(__memset,memset)
+libc_hidden_proto(memset)
diff --git a/libc/string/generic/Makefile b/libc/string/generic/Makefile
index 4a8f4a072..0a95346fd 100644
--- a/libc/string/generic/Makefile
+++ b/libc/string/generic/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.in
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/generic/Makefile.in b/libc/string/generic/Makefile.in
deleted file mode 100644
index 82910172a..000000000
--- a/libc/string/generic/Makefile.in
+++ /dev/null
@@ -1,29 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-STRING_GENERIC_DIR:=$(top_srcdir)libc/string/generic
-STRING_GENERIC_OUT:=$(top_builddir)libc/string/generic
-
-STRING_GENERIC_SRC:=$(wildcard $(STRING_GENERIC_DIR)/*.c)
-
-ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
-ifneq ($(strip $(STRING_ARCH_OBJS)),)
-STRING_GENERIC_SRC:=$(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_GENERIC_SRC))
-endif
-endif
-
-STRING_GENERIC_OBJS:=$(patsubst $(STRING_GENERIC_DIR)/%.c,$(STRING_GENERIC_OUT)/%.o,$(STRING_GENERIC_SRC))
-
-libc-a-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_OBJS:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_SRC)
-
-objclean-y+=string_generic_objclean
-
-string_generic_objclean:
- $(RM) $(STRING_GENERIC_OUT)/*.{o,os}
diff --git a/libc/string/generic/memchr.c b/libc/string/generic/memchr.c
index 68c820814..4bda5d758 100644
--- a/libc/string/generic/memchr.c
+++ b/libc/string/generic/memchr.c
@@ -25,12 +25,15 @@
#include <stdlib.h>
#include <limits.h>
+libc_hidden_proto(memchr)
+libc_hidden_proto(abort)
+
#include "memcopy.h"
#define LONG_MAX_32_BITS 2147483647
/* Search no more than N bytes of S for C. */
-void attribute_hidden *__memchr (const void * s, int c_in, size_t n)
+void *memchr (const void * s, int c_in, size_t n)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -171,5 +174,4 @@ void attribute_hidden *__memchr (const void * s, int c_in, size_t n)
return 0;
}
-
-strong_alias(__memchr,memchr)
+libc_hidden_def(memchr)
diff --git a/libc/string/generic/memcmp.c b/libc/string/generic/memcmp.c
index 13e11692a..41f15369d 100644
--- a/libc/string/generic/memcmp.c
+++ b/libc/string/generic/memcmp.c
@@ -19,9 +19,10 @@
02111-1307 USA. */
#include <string.h>
-
#include "memcopy.h"
+libc_hidden_proto(memcmp)
+
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -273,7 +274,7 @@ memcmp_not_common_alignment (srcp1, srcp2, len)
}
int
-attribute_hidden __memcmp (const __ptr_t s1, const __ptr_t s2, size_t len)
+memcmp (const __ptr_t s1, const __ptr_t s2, size_t len)
{
op_t a0;
op_t b0;
@@ -329,7 +330,5 @@ attribute_hidden __memcmp (const __ptr_t s1, const __ptr_t s2, size_t len)
return 0;
}
-
-strong_alias(__memcmp,memcmp)
-
-strong_alias(__memcmp,bcmp)
+libc_hidden_def(memcmp)
+strong_alias(memcmp,bcmp)
diff --git a/libc/string/generic/memcpy.c b/libc/string/generic/memcpy.c
index 6db4d0d44..42e97a063 100644
--- a/libc/string/generic/memcpy.c
+++ b/libc/string/generic/memcpy.c
@@ -23,6 +23,8 @@
#include "memcopy.h"
#include "pagecopy.h"
+libc_hidden_proto(memcpy)
+
/* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
@@ -209,7 +211,7 @@ static void _wordcopy_fwd_dest_aligned (long int dstp, long int srcp, size_t len
((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2);
}
-void attribute_hidden *__memcpy (void *dstpp, const void *srcpp, size_t len)
+void *memcpy (void *dstpp, const void *srcpp, size_t len)
{
unsigned long int dstp = (long int) dstpp;
unsigned long int srcp = (long int) srcpp;
@@ -242,5 +244,4 @@ void attribute_hidden *__memcpy (void *dstpp, const void *srcpp, size_t len)
return dstpp;
}
-
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c
index 0353759e3..c2e8547be 100644
--- a/libc/string/generic/memmem.c
+++ b/libc/string/generic/memmem.c
@@ -19,8 +19,11 @@
#include <string.h>
#include <stddef.h>
+libc_hidden_proto(memmem)
+libc_hidden_proto(memcmp)
+
/* Return the first occurrence of NEEDLE in HAYSTACK. */
-void attribute_hidden *__memmem (const void *haystack, size_t haystack_len,
+void *memmem (const void *haystack, size_t haystack_len,
const void *needle, size_t needle_len)
{
const char *begin;
@@ -39,12 +42,11 @@ void attribute_hidden *__memmem (const void *haystack, size_t haystack_len,
for (begin = (const char *) haystack; begin <= last_possible; ++begin)
if (begin[0] == ((const char *) needle)[0] &&
- !__memcmp ((const void *) &begin[1],
+ !memcmp ((const void *) &begin[1],
(const void *) ((const char *) needle + 1),
needle_len - 1))
return (void *) begin;
return NULL;
}
-
-strong_alias(__memmem,memmem)
+libc_hidden_def(memmem)
diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c
index e34b0005d..68caacd78 100644
--- a/libc/string/generic/memmove.c
+++ b/libc/string/generic/memmove.c
@@ -24,6 +24,9 @@
#include "memcopy.h"
#include "pagecopy.h"
+libc_hidden_proto(memmove)
+libc_hidden_proto(memcpy)
+
static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len)
{
op_t a0, a1;
@@ -206,7 +209,7 @@ static void _wordcopy_bwd_dest_aligned (long int dstp, long int srcp, size_t len
((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2);
}
-void attribute_hidden *__memmove (void *dest, const void *src, size_t len)
+void *memmove (void *dest, const void *src, size_t len)
{
unsigned long int dstp = (long int) dest;
unsigned long int srcp = (long int) src;
@@ -217,7 +220,7 @@ void attribute_hidden *__memmove (void *dest, const void *src, size_t len)
{
#if 1
#warning REMINDER: generic-opt memmove assumes memcpy does forward copying!
- __memcpy(dest, src, len);
+ memcpy(dest, src, len);
#else
/* Copy from the beginning to the end. */
@@ -276,5 +279,4 @@ void attribute_hidden *__memmove (void *dest, const void *src, size_t len)
return (dest);
}
-
-strong_alias(__memmove,memmove)
+libc_hidden_def(memmove)
diff --git a/libc/string/generic/mempcpy.c b/libc/string/generic/mempcpy.c
index d121967cd..7c251914d 100644
--- a/libc/string/generic/mempcpy.c
+++ b/libc/string/generic/mempcpy.c
@@ -7,10 +7,12 @@
#include <string.h>
-void attribute_hidden *__mempcpy (void *dstpp, const void *srcpp, size_t len)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(memcpy)
+
+void *mempcpy (void *dstpp, const void *srcpp, size_t len)
{
- __memcpy(dstpp, srcpp, len);
+ memcpy(dstpp, srcpp, len);
return (void *)(((char *)dstpp) + len);
}
-
-strong_alias(__mempcpy,mempcpy)
+libc_hidden_def(mempcpy)
diff --git a/libc/string/generic/memrchr.c b/libc/string/generic/memrchr.c
index d27ae03ef..f63efa46b 100644
--- a/libc/string/generic/memrchr.c
+++ b/libc/string/generic/memrchr.c
@@ -26,12 +26,15 @@
#include <stdlib.h>
#include <limits.h>
+libc_hidden_proto(memrchr)
+libc_hidden_proto(abort)
+
#include "memcopy.h"
#define LONG_MAX_32_BITS 2147483647
/* Search no more than N bytes of S for C. */
-void attribute_hidden *__memrchr (const void * s, int c_in, size_t n)
+void *memrchr (const void * s, int c_in, size_t n)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -170,5 +173,4 @@ void attribute_hidden *__memrchr (const void * s, int c_in, size_t n)
return 0;
}
-
-strong_alias(__memrchr,memrchr)
+libc_hidden_def(memrchr)
diff --git a/libc/string/generic/memset.c b/libc/string/generic/memset.c
index 91401d7ee..1df1a450f 100644
--- a/libc/string/generic/memset.c
+++ b/libc/string/generic/memset.c
@@ -19,7 +19,8 @@
#include <string.h>
#include "memcopy.h"
-void attribute_hidden *__memset (void *dstpp, int c, size_t len)
+libc_hidden_proto(memset)
+void *memset (void *dstpp, int c, size_t len)
{
long int dstp = (long int) dstpp;
@@ -82,5 +83,4 @@ void attribute_hidden *__memset (void *dstpp, int c, size_t len)
return dstpp;
}
-
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/generic/rawmemchr.c b/libc/string/generic/rawmemchr.c
index d1be620eb..85fc09836 100644
--- a/libc/string/generic/rawmemchr.c
+++ b/libc/string/generic/rawmemchr.c
@@ -25,12 +25,15 @@
#include <stdlib.h>
#include <limits.h>
+libc_hidden_proto(rawmemchr)
+libc_hidden_proto(abort)
+
#include "memcopy.h"
#define LONG_MAX_32_BITS 2147483647
/* Find the first occurrence of C in S. */
-void attribute_hidden *__rawmemchr (const void * s, int c_in)
+void *rawmemchr (const void * s, int c_in)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -156,5 +159,4 @@ void attribute_hidden *__rawmemchr (const void * s, int c_in)
}
}
}
-
-strong_alias(__rawmemchr,rawmemchr)
+libc_hidden_def(rawmemchr)
diff --git a/libc/string/generic/strcat.c b/libc/string/generic/strcat.c
index 96412acc5..53c4d0d9e 100644
--- a/libc/string/generic/strcat.c
+++ b/libc/string/generic/strcat.c
@@ -19,8 +19,9 @@
#include <string.h>
#include "memcopy.h"
+libc_hidden_proto(strcat)
/* Append SRC on the end of DEST. */
-char attribute_hidden *__strcat (char *dest, const char *src)
+char *strcat (char *dest, const char *src)
{
char *s1 = dest;
const char *s2 = src;
@@ -44,5 +45,4 @@ char attribute_hidden *__strcat (char *dest, const char *src)
return dest;
}
-
-strong_alias(__strcat,strcat)
+libc_hidden_def(strcat)
diff --git a/libc/string/generic/strchr.c b/libc/string/generic/strchr.c
index dcb30ad7b..b1ffc7538 100644
--- a/libc/string/generic/strchr.c
+++ b/libc/string/generic/strchr.c
@@ -24,10 +24,13 @@
#include <string.h>
#include <stdlib.h>
+libc_hidden_proto(strchr)
+libc_hidden_proto(abort)
+
#include "memcopy.h"
/* Find the first occurrence of C in S. */
-char attribute_hidden *__strchr (const char *s, int c_in)
+char *strchr (const char *s, int c_in)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -178,7 +181,5 @@ char attribute_hidden *__strchr (const char *s, int c_in)
return NULL;
}
-
-strong_alias(__strchr,strchr)
-
-strong_alias(__strchr,index)
+libc_hidden_def(strchr)
+strong_alias(strchr,index)
diff --git a/libc/string/generic/strchrnul.c b/libc/string/generic/strchrnul.c
index a2aafbfb0..e699a6dfa 100644
--- a/libc/string/generic/strchrnul.c
+++ b/libc/string/generic/strchrnul.c
@@ -24,10 +24,13 @@
#include <string.h>
#include <stdlib.h>
+libc_hidden_proto(strchrnul)
+libc_hidden_proto(abort)
+
#include "memcopy.h"
/* Find the first occurrence of C in S or the final NUL byte. */
-char attribute_hidden *__strchrnul (const char *s, int c_in)
+char *strchrnul (const char *s, int c_in)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -161,5 +164,4 @@ char attribute_hidden *__strchrnul (const char *s, int c_in)
/* This should never happen. */
return NULL;
}
-
-strong_alias(__strchrnul,strchrnul)
+libc_hidden_def(strchrnul)
diff --git a/libc/string/generic/strcmp.c b/libc/string/generic/strcmp.c
index 209aeed15..acfefb6dc 100644
--- a/libc/string/generic/strcmp.c
+++ b/libc/string/generic/strcmp.c
@@ -20,10 +20,11 @@
#include "memcopy.h"
+libc_hidden_proto(strcmp)
/* Compare S1 and S2, returning less than, equal to or
greater than zero if S1 is lexicographically less than,
equal to or greater than S2. */
-int attribute_hidden __strcmp (const char *p1, const char *p2)
+int strcmp (const char *p1, const char *p2)
{
register const unsigned char *s1 = (const unsigned char *) p1;
register const unsigned char *s2 = (const unsigned char *) p2;
@@ -40,10 +41,10 @@ int attribute_hidden __strcmp (const char *p1, const char *p2)
return c1 - c2;
}
-
-strong_alias(__strcmp,strcmp)
+libc_hidden_def(strcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-hidden_strong_alias(__strcmp,__strcoll)
-strong_alias(__strcmp,strcoll)
+libc_hidden_proto(strcoll)
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
#endif
diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c
index 9280d3561..7e558ead1 100644
--- a/libc/string/generic/strcpy.c
+++ b/libc/string/generic/strcpy.c
@@ -22,8 +22,9 @@
#include "memcopy.h"
#include "bp-checks.h"
+libc_hidden_proto(strcpy)
/* Copy SRC to DEST. */
-char attribute_hidden *__strcpy (char *dest, const char *src)
+char *strcpy (char *dest, const char *src)
{
reg_char c;
char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
@@ -43,5 +44,4 @@ char attribute_hidden *__strcpy (char *dest, const char *src)
return dest;
}
-
-strong_alias(__strcpy,strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/generic/strcspn.c b/libc/string/generic/strcspn.c
index a06577bca..1b5e465ea 100644
--- a/libc/string/generic/strcspn.c
+++ b/libc/string/generic/strcspn.c
@@ -18,19 +18,21 @@
#include <string.h>
+libc_hidden_proto(strcspn)
+libc_hidden_proto(strchr)
+
/* Return the length of the maximum initial segment of S
which contains no characters from REJECT. */
-size_t attribute_hidden __strcspn (const char *s, const char *reject)
+size_t strcspn (const char *s, const char *reject)
{
size_t count = 0;
while (*s != '\0')
- if (__strchr (reject, *s++) == NULL)
+ if (strchr (reject, *s++) == NULL)
++count;
else
return count;
return count;
}
-
-strong_alias(__strcspn,strcspn)
+libc_hidden_def(strcspn)
diff --git a/libc/string/generic/strlen.c b/libc/string/generic/strlen.c
index 6c1b5eae3..3528829af 100644
--- a/libc/string/generic/strlen.c
+++ b/libc/string/generic/strlen.c
@@ -22,9 +22,12 @@
#include <string.h>
#include <stdlib.h>
+libc_hidden_proto(strlen)
+libc_hidden_proto(abort)
+
/* Return the length of the null-terminated string STR. Scan for
the null terminator quickly by testing four bytes at a time. */
-size_t attribute_hidden __strlen (const char *str)
+size_t strlen (const char *str)
{
const char *char_ptr;
const unsigned long int *longword_ptr;
@@ -146,5 +149,4 @@ size_t attribute_hidden __strlen (const char *str)
}
}
}
-
-strong_alias(__strlen,strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/generic/strncat.c b/libc/string/generic/strncat.c
index 5ece4d248..9e0dfcd78 100644
--- a/libc/string/generic/strncat.c
+++ b/libc/string/generic/strncat.c
@@ -20,7 +20,8 @@
#include "memcopy.h"
-char attribute_hidden *__strncat (char *s1, const char *s2, size_t n)
+libc_hidden_proto(strncat)
+char *strncat (char *s1, const char *s2, size_t n)
{
reg_char c;
char *s = s1;
@@ -73,5 +74,4 @@ char attribute_hidden *__strncat (char *s1, const char *s2, size_t n)
return s;
}
-
-strong_alias(__strncat,strncat)
+libc_hidden_def(strncat)
diff --git a/libc/string/generic/strncmp.c b/libc/string/generic/strncmp.c
index 849726f6b..4c1978439 100644
--- a/libc/string/generic/strncmp.c
+++ b/libc/string/generic/strncmp.c
@@ -19,11 +19,12 @@
#include <string.h>
#include "memcopy.h"
+libc_hidden_proto(strncmp)
/* Compare no more than N characters of S1 and S2,
returning less than, equal to or greater than zero
if S1 is lexicographically less than, equal to or
greater than S2. */
-int attribute_hidden __strncmp (const char *s1, const char *s2, size_t n)
+int strncmp (const char *s1, const char *s2, size_t n)
{
unsigned reg_char c1 = '\0';
unsigned reg_char c2 = '\0';
@@ -64,5 +65,4 @@ int attribute_hidden __strncmp (const char *s1, const char *s2, size_t n)
return c1 - c2;
}
-
-strong_alias(__strncmp,strncmp)
+libc_hidden_def(strncmp)
diff --git a/libc/string/generic/strncpy.c b/libc/string/generic/strncpy.c
index ca4f59e52..4b0b0894e 100644
--- a/libc/string/generic/strncpy.c
+++ b/libc/string/generic/strncpy.c
@@ -19,7 +19,8 @@
#include <string.h>
#include "memcopy.h"
-char attribute_hidden *__strncpy (char *s1, const char *s2, size_t n)
+libc_hidden_proto(strncpy)
+char *strncpy (char *s1, const char *s2, size_t n)
{
reg_char c;
char *s = s1;
@@ -78,5 +79,4 @@ char attribute_hidden *__strncpy (char *s1, const char *s2, size_t n)
return s;
}
-
-strong_alias(__strncpy,strncpy)
+libc_hidden_def(strncpy)
diff --git a/libc/string/generic/strnlen.c b/libc/string/generic/strnlen.c
index 4b96dde31..31b5ba8e0 100644
--- a/libc/string/generic/strnlen.c
+++ b/libc/string/generic/strnlen.c
@@ -24,9 +24,12 @@
#include <string.h>
#include <stdlib.h>
+libc_hidden_proto(strnlen)
+libc_hidden_proto(abort)
+
/* Find the length of S, but scan at most MAXLEN characters. If no
'\0' terminator is found in that many characters, return MAXLEN. */
-size_t attribute_hidden __strnlen (const char *str, size_t maxlen)
+size_t strnlen (const char *str, size_t maxlen)
{
const char *char_ptr, *end_ptr = str + maxlen;
const unsigned long int *longword_ptr;
@@ -156,5 +159,4 @@ size_t attribute_hidden __strnlen (const char *str, size_t maxlen)
char_ptr = end_ptr;
return char_ptr - str;
}
-
-strong_alias(__strnlen,strnlen)
+libc_hidden_def(strnlen)
diff --git a/libc/string/generic/strrchr.c b/libc/string/generic/strrchr.c
index 529016ede..b67e369fd 100644
--- a/libc/string/generic/strrchr.c
+++ b/libc/string/generic/strrchr.c
@@ -18,8 +18,11 @@
#include <string.h>
+libc_hidden_proto(strrchr)
+libc_hidden_proto(strchr)
+
/* Find the last occurrence of C in S. */
-char attribute_hidden *__strrchr (const char *s, int c)
+char *strrchr (const char *s, int c)
{
register const char *found, *p;
@@ -28,10 +31,10 @@ char attribute_hidden *__strrchr (const char *s, int c)
/* Since strchr is fast, we use it rather than the obvious loop. */
if (c == '\0')
- return __strchr (s, '\0');
+ return strchr (s, '\0');
found = NULL;
- while ((p = __strchr (s, c)) != NULL)
+ while ((p = strchr (s, c)) != NULL)
{
found = p;
s = p + 1;
@@ -39,7 +42,5 @@ char attribute_hidden *__strrchr (const char *s, int c)
return (char *) found;
}
-
-strong_alias(__strrchr,strrchr)
-
-strong_alias (__strrchr,rindex)
+libc_hidden_def(strrchr)
+strong_alias(strrchr,rindex)
diff --git a/libc/string/generic/strsep.c b/libc/string/generic/strsep.c
index 762b07ff9..7b34e2c16 100644
--- a/libc/string/generic/strsep.c
+++ b/libc/string/generic/strsep.c
@@ -16,11 +16,13 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define strpbrk __strpbrk
-
#include <string.h>
-char attribute_hidden *__strsep (char **stringp, const char *delim)
+libc_hidden_proto(strsep)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strpbrk)
+
+char *strsep (char **stringp, const char *delim)
{
char *begin, *end;
@@ -44,7 +46,7 @@ char attribute_hidden *__strsep (char **stringp, const char *delim)
else if (*begin == '\0')
end = NULL;
else
- end = __strchr (begin + 1, ch);
+ end = strchr (begin + 1, ch);
}
}
else
@@ -63,5 +65,4 @@ char attribute_hidden *__strsep (char **stringp, const char *delim)
return begin;
}
-
-strong_alias(__strsep,strsep)
+libc_hidden_def(strsep)
diff --git a/libc/string/generic/strspn.c b/libc/string/generic/strspn.c
index 129c58742..a194fdc7d 100644
--- a/libc/string/generic/strspn.c
+++ b/libc/string/generic/strspn.c
@@ -18,9 +18,10 @@
#include <string.h>
+libc_hidden_proto(strspn)
/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
-size_t attribute_hidden __strspn (const char *s, const char *accept)
+size_t strspn (const char *s, const char *accept)
{
const char *p;
const char *a;
@@ -39,5 +40,4 @@ size_t attribute_hidden __strspn (const char *s, const char *accept)
return count;
}
-
-strong_alias(__strspn,strspn)
+libc_hidden_def(strspn)
diff --git a/libc/string/generic/strstr.c b/libc/string/generic/strstr.c
index 12e384014..f151a820a 100644
--- a/libc/string/generic/strstr.c
+++ b/libc/string/generic/strstr.c
@@ -28,9 +28,11 @@
#include <string.h>
+libc_hidden_proto(strstr)
+
typedef unsigned chartype;
-char attribute_hidden *__strstr (const char *phaystack, const char *pneedle)
+char *strstr (const char *phaystack, const char *pneedle)
{
const unsigned char *haystack, *needle;
chartype b;
@@ -109,5 +111,4 @@ foundneedle:
ret0:
return 0;
}
-
-strong_alias(__strstr,strstr)
+libc_hidden_def(strstr)
diff --git a/libc/string/generic/strtok_r.c b/libc/string/generic/strtok_r.c
index 1a11166dd..0ab18b35e 100644
--- a/libc/string/generic/strtok_r.c
+++ b/libc/string/generic/strtok_r.c
@@ -17,9 +17,13 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define _GNU_SOURCE
#include <string.h>
+libc_hidden_proto(strtok_r)
+libc_hidden_proto(strspn)
+libc_hidden_proto(strpbrk)
+libc_hidden_proto(rawmemchr)
+
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
@@ -30,7 +34,7 @@
x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0"
*/
-char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr)
+char *strtok_r (char *s, const char *delim, char **save_ptr)
{
char *token;
@@ -38,7 +42,7 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr)
s = *save_ptr;
/* Scan leading delimiters. */
- s += __strspn (s, delim);
+ s += strspn (s, delim);
if (*s == '\0')
{
*save_ptr = s;
@@ -47,10 +51,10 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr)
/* Find the end of the token. */
token = s;
- s = __strpbrk (token, delim);
+ s = strpbrk (token, delim);
if (s == NULL)
/* This token finishes the string. */
- *save_ptr = __rawmemchr (token, '\0');
+ *save_ptr = rawmemchr (token, '\0');
else
{
/* Terminate the token and make *SAVE_PTR point past it. */
@@ -59,5 +63,4 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr)
}
return token;
}
-
-strong_alias(__strtok_r,strtok_r)
+libc_hidden_def(strtok_r)
diff --git a/libc/string/i386/Makefile b/libc/string/i386/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/i386/Makefile
+++ b/libc/string/i386/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/i386/Makefile.arch b/libc/string/i386/Makefile.arch
deleted file mode 100644
index 27a29dd16..000000000
--- a/libc/string/i386/Makefile.arch
+++ /dev/null
@@ -1,24 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/i386
-STRING_ARCH_OUT:=$(top_builddir)libc/string/i386
-
-STRING_ARCH_CSRC:=$(wildcard $(STRING_ARCH_DIR)/*.c)
-STRING_ARCH_COBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_CSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_COBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_CSRC)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/i386/memchr.c b/libc/string/i386/memchr.c
index c7cd33758..229d42919 100644
--- a/libc/string/i386/memchr.c
+++ b/libc/string/i386/memchr.c
@@ -32,7 +32,8 @@
#include <string.h>
-void attribute_hidden *__memchr(const void *cs, int c, size_t count)
+libc_hidden_proto(memchr)
+void *memchr(const void *cs, int c, size_t count)
{
int d0;
register void * __res;
@@ -47,5 +48,4 @@ void attribute_hidden *__memchr(const void *cs, int c, size_t count)
:"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
return __res;
}
-
-strong_alias(__memchr,memchr)
+libc_hidden_def(memchr)
diff --git a/libc/string/i386/memcpy.c b/libc/string/i386/memcpy.c
index 12ba8d7de..a2b8d3d8c 100644
--- a/libc/string/i386/memcpy.c
+++ b/libc/string/i386/memcpy.c
@@ -32,7 +32,8 @@
#include <string.h>
-void attribute_hidden *__memcpy(void * to, const void * from, size_t n)
+libc_hidden_proto(memcpy)
+void *memcpy(void * to, const void * from, size_t n)
{
int d0, d1, d2;
__asm__ __volatile__(
@@ -49,5 +50,4 @@ void attribute_hidden *__memcpy(void * to, const void * from, size_t n)
: "memory");
return (to);
}
-
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/i386/memmove.c b/libc/string/i386/memmove.c
index d6e29e553..a26fe2be1 100644
--- a/libc/string/i386/memmove.c
+++ b/libc/string/i386/memmove.c
@@ -32,7 +32,8 @@
#include <string.h>
-void attribute_hidden *__memmove(void *dest, const void *src, size_t n)
+libc_hidden_proto(memmove)
+void *memmove(void *dest, const void *src, size_t n)
{
int d0, d1, d2;
if (dest<src)
@@ -55,5 +56,4 @@ void attribute_hidden *__memmove(void *dest, const void *src, size_t n)
:"memory");
return dest;
}
-
-strong_alias(__memmove,memmove)
+libc_hidden_def(memmove)
diff --git a/libc/string/i386/memset.c b/libc/string/i386/memset.c
index eadbf9feb..eea48040a 100644
--- a/libc/string/i386/memset.c
+++ b/libc/string/i386/memset.c
@@ -32,7 +32,8 @@
#include <string.h>
-void attribute_hidden *__memset(void *s, int c, size_t count)
+libc_hidden_proto(memset)
+void *memset(void *s, int c, size_t count)
{
int d0, d1;
__asm__ __volatile__(
@@ -43,5 +44,4 @@ void attribute_hidden *__memset(void *s, int c, size_t count)
:"memory");
return s;
}
-
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/i386/strcat.c b/libc/string/i386/strcat.c
index 02b2a3c5b..e0b1f3b51 100644
--- a/libc/string/i386/strcat.c
+++ b/libc/string/i386/strcat.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strcat(char * dest, const char * src)
+libc_hidden_proto(strcat)
+char *strcat(char * dest, const char * src)
{
int d0, d1, d2, d3;
__asm__ __volatile__(
@@ -47,5 +48,4 @@ char attribute_hidden *__strcat(char * dest, const char * src)
: "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory");
return dest;
}
-
-strong_alias(__strcat,strcat)
+libc_hidden_def(strcat)
diff --git a/libc/string/i386/strchr.c b/libc/string/i386/strchr.c
index a8343fa00..5ed87e816 100644
--- a/libc/string/i386/strchr.c
+++ b/libc/string/i386/strchr.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strchr(const char *s, int c)
+libc_hidden_proto(strchr)
+char *strchr(const char *s, int c)
{
int d0;
register char * __res;
@@ -49,7 +50,5 @@ char attribute_hidden *__strchr(const char *s, int c)
:"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
return __res;
}
-
-strong_alias(__strchr,strchr)
-
-strong_alias(__strchr,index)
+libc_hidden_def(strchr)
+strong_alias(strchr,index)
diff --git a/libc/string/i386/strcmp.c b/libc/string/i386/strcmp.c
index f335da646..47635d817 100644
--- a/libc/string/i386/strcmp.c
+++ b/libc/string/i386/strcmp.c
@@ -32,7 +32,8 @@
#include <string.h>
-int attribute_hidden __strcmp(const char *cs, const char *ct)
+libc_hidden_proto(strcmp)
+int strcmp(const char *cs, const char *ct)
{
int d0, d1;
register int __res;
@@ -51,10 +52,10 @@ int attribute_hidden __strcmp(const char *cs, const char *ct)
:"1" (cs),"2" (ct));
return __res;
}
-
-strong_alias(__strcmp,strcmp)
+libc_hidden_def(strcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-hidden_strong_alias(__strcmp,__strcoll)
-strong_alias(__strcmp,strcoll)
+libc_hidden_proto(strcoll)
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
#endif
diff --git a/libc/string/i386/strcpy.c b/libc/string/i386/strcpy.c
index 59effd45e..9e2b81009 100644
--- a/libc/string/i386/strcpy.c
+++ b/libc/string/i386/strcpy.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strcpy(char * dest, const char * src)
+libc_hidden_proto(strcpy)
+char *strcpy(char * dest, const char * src)
{
int d0, d1, d2;
__asm__ __volatile__(
@@ -44,5 +45,4 @@ char attribute_hidden *__strcpy(char * dest, const char * src)
:"0" (src),"1" (dest) : "memory");
return dest;
}
-
-strong_alias(__strcpy,strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/i386/strlen.c b/libc/string/i386/strlen.c
index 01cc46f9e..f0767b600 100644
--- a/libc/string/i386/strlen.c
+++ b/libc/string/i386/strlen.c
@@ -32,7 +32,8 @@
#include <string.h>
-size_t attribute_hidden __strlen(const char *s)
+libc_hidden_proto(strlen)
+size_t strlen(const char *s)
{
int d0;
register int __res;
@@ -44,5 +45,4 @@ size_t attribute_hidden __strlen(const char *s)
:"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
return __res;
}
-
-strong_alias(__strlen,strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/i386/strncat.c b/libc/string/i386/strncat.c
index b55b87b59..c1061421e 100644
--- a/libc/string/i386/strncat.c
+++ b/libc/string/i386/strncat.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strncat(char * dest,
+libc_hidden_proto(strncat)
+char *strncat(char * dest,
const char * src, size_t count)
{
int d0, d1, d2, d3;
@@ -57,5 +58,4 @@ char attribute_hidden *__strncat(char * dest,
: "memory");
return dest;
}
-
-strong_alias(__strncat,strncat)
+libc_hidden_def(strncat)
diff --git a/libc/string/i386/strncmp.c b/libc/string/i386/strncmp.c
index 2e22bf642..0c42134e1 100644
--- a/libc/string/i386/strncmp.c
+++ b/libc/string/i386/strncmp.c
@@ -32,7 +32,8 @@
#include <string.h>
-int attribute_hidden __strncmp(const char *cs, const char *ct, size_t count)
+libc_hidden_proto(strncmp)
+int strncmp(const char *cs, const char *ct, size_t count)
{
register int __res;
int d0, d1, d2;
@@ -54,5 +55,4 @@ int attribute_hidden __strncmp(const char *cs, const char *ct, size_t count)
:"1" (cs),"2" (ct),"3" (count));
return __res;
}
-
-strong_alias(__strncmp,strncmp)
+libc_hidden_def(strncmp)
diff --git a/libc/string/i386/strncpy.c b/libc/string/i386/strncpy.c
index 272c60ee4..c061fe37e 100644
--- a/libc/string/i386/strncpy.c
+++ b/libc/string/i386/strncpy.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strncpy(char * dest, const char * src, size_t count)
+libc_hidden_proto(strncpy)
+char *strncpy(char * dest, const char * src, size_t count)
{
int d0, d1, d2, d3;
__asm__ __volatile__(
@@ -52,5 +53,4 @@ char attribute_hidden *__strncpy(char * dest, const char * src, size_t count)
:"0" (src),"1" (dest),"2" (count) : "memory");
return dest;
}
-
-strong_alias(__strncpy,strncpy)
+libc_hidden_def(strncpy)
diff --git a/libc/string/i386/strnlen.c b/libc/string/i386/strnlen.c
index ef5c83a9a..af512f10a 100644
--- a/libc/string/i386/strnlen.c
+++ b/libc/string/i386/strnlen.c
@@ -30,10 +30,10 @@
* -Erik
*/
-#define _GNU_SOURCE
#include <string.h>
-size_t attribute_hidden __strnlen(const char *s, size_t count)
+libc_hidden_proto(strnlen)
+size_t strnlen(const char *s, size_t count)
{
int d0;
register int __res;
@@ -51,5 +51,4 @@ size_t attribute_hidden __strnlen(const char *s, size_t count)
:"c" (s),"1" (count));
return __res;
}
-
-strong_alias(__strnlen,strnlen)
+libc_hidden_def(strnlen)
diff --git a/libc/string/i386/strrchr.c b/libc/string/i386/strrchr.c
index 9f0f65a36..7af990bd7 100644
--- a/libc/string/i386/strrchr.c
+++ b/libc/string/i386/strrchr.c
@@ -32,7 +32,8 @@
#include <string.h>
-char attribute_hidden *__strrchr(const char *s, int c)
+libc_hidden_proto(strrchr)
+char *strrchr(const char *s, int c)
{
int d0, d1;
register char * __res;
@@ -47,7 +48,5 @@ char attribute_hidden *__strrchr(const char *s, int c)
:"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
return __res;
}
-
-strong_alias(__strrchr,strrchr)
-
-strong_alias(__strrchr,rindex)
+libc_hidden_def(strrchr)
+strong_alias(strrchr,rindex)
diff --git a/libc/string/ia64/Makefile b/libc/string/ia64/Makefile
new file mode 100644
index 000000000..0a95346fd
--- /dev/null
+++ b/libc/string/ia64/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir:=../../../
+top_builddir:=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include ../Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libc/string/ia64/bcopy.S b/libc/string/ia64/bcopy.S
new file mode 100644
index 000000000..c4eb22b1f
--- /dev/null
+++ b/libc/string/ia64/bcopy.S
@@ -0,0 +1,10 @@
+#include "sysdep.h"
+
+ENTRY(bcopy)
+ .regstk 3, 0, 0, 0
+ mov r8 = in0
+ mov in0 = in1
+ ;;
+ mov in1 = r8
+ br.cond.sptk.many HIDDEN_JUMPTARGET(memmove)
+END(bcopy)
diff --git a/libc/string/ia64/bzero.S b/libc/string/ia64/bzero.S
new file mode 100644
index 000000000..0e2ff09cc
--- /dev/null
+++ b/libc/string/ia64/bzero.S
@@ -0,0 +1,315 @@
+/* Optimized version of the standard bzero() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>.
+ Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch>
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: count
+
+ The algorithm is fairly straightforward: set byte by byte until we
+ we get to a 16B-aligned address, then loop on 128 B chunks using an
+ early store as prefetching, then loop on 32B chucks, then clear remaining
+ words, finally clear remaining bytes.
+ Since a stf.spill f0 can store 16B in one go, we use this instruction
+ to get peak speed. */
+
+#include "sysdep.h"
+#undef ret
+
+#define dest in0
+#define cnt in1
+
+#define tmp r31
+#define save_lc r30
+#define ptr0 r29
+#define ptr1 r28
+#define ptr2 r27
+#define ptr3 r26
+#define ptr9 r24
+#define loopcnt r23
+#define linecnt r22
+#define bytecnt r21
+
+// This routine uses only scratch predicate registers (p6 - p15)
+#define p_scr p6 // default register for same-cycle branches
+#define p_unalgn p9
+#define p_y p11
+#define p_n p12
+#define p_yy p13
+#define p_nn p14
+
+#define movi0 mov
+
+#define MIN1 15
+#define MIN1P1HALF 8
+#define LINE_SIZE 128
+#define LSIZE_SH 7 // shift amount
+#define PREF_AHEAD 8
+
+#define USE_FLP
+#if defined(USE_INT)
+#define store st8
+#define myval r0
+#elif defined(USE_FLP)
+#define store stf8
+#define myval f0
+#endif
+
+.align 64
+ENTRY(bzero)
+{ .mmi
+ .prologue
+ alloc tmp = ar.pfs, 2, 0, 0, 0
+ lfetch.nt1 [dest]
+ .save ar.lc, save_lc
+ movi0 save_lc = ar.lc
+} { .mmi
+ .body
+ mov ret0 = dest // return value
+ nop.m 0
+ cmp.eq p_scr, p0 = cnt, r0
+;; }
+{ .mmi
+ and ptr2 = -(MIN1+1), dest // aligned address
+ and tmp = MIN1, dest // prepare to check for alignment
+ tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U)
+} { .mib
+ mov ptr1 = dest
+ nop.i 0
+(p_scr) br.ret.dpnt.many rp // return immediately if count = 0
+;; }
+{ .mib
+ cmp.ne p_unalgn, p0 = tmp, r0
+} { .mib // NB: # of bytes to move is 1
+ sub bytecnt = (MIN1+1), tmp // higher than loopcnt
+ cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task?
+(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U)
+;; }
+{ .mmi
+(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment
+(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ?
+;; }
+{ .mib
+(p_y) add cnt = -8, cnt
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ?
+} { .mib
+(p_y) st8 [ptr2] = r0,-4
+(p_n) add ptr2 = 4, ptr2
+;; }
+{ .mib
+(p_yy) add cnt = -4, cnt
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ?
+} { .mib
+(p_yy) st4 [ptr2] = r0,-2
+(p_nn) add ptr2 = 2, ptr2
+;; }
+{ .mmi
+ mov tmp = LINE_SIZE+1 // for compare
+(p_y) add cnt = -2, cnt
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ?
+} { .mmi
+ nop.m 0
+(p_y) st2 [ptr2] = r0,-1
+(p_n) add ptr2 = 1, ptr2
+;; }
+
+{ .mmi
+(p_yy) st1 [ptr2] = r0
+ cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task?
+} { .mbb
+(p_yy) add cnt = -1, cnt
+(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few
+;; }
+{ .mib
+ nop.m 0
+ shr.u linecnt = cnt, LSIZE_SH
+ nop.b 0
+;; }
+
+ .align 32
+.l1b: // ------------------// L1B: store ahead into cache lines; fill later
+{ .mmi
+ and tmp = -(LINE_SIZE), cnt // compute end of range
+ mov ptr9 = ptr1 // used for prefetching
+ and cnt = (LINE_SIZE-1), cnt // remainder
+} { .mmi
+ mov loopcnt = PREF_AHEAD-1 // default prefetch loop
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+;; }
+{ .mmi
+(p_scr) add loopcnt = -1, linecnt
+ add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores)
+ add ptr1 = tmp, ptr1 // first address beyond total range
+;; }
+{ .mmi
+ add tmp = -1, linecnt // next loop count
+ movi0 ar.lc = loopcnt
+;; }
+.pref_l1b:
+{ .mib
+ stf.spill [ptr9] = f0, 128 // Do stores one cache line apart
+ nop.i 0
+ br.cloop.dptk.few .pref_l1b
+;; }
+{ .mmi
+ add ptr0 = 16, ptr2 // Two stores in parallel
+ movi0 ar.lc = tmp
+;; }
+.l1bx:
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 32
+ ;; }
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 32
+ ;; }
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 64
+ cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ ;; }
+{ .mmb
+ stf.spill [ptr2] = f0, 32
+(p_scr) stf.spill [ptr9] = f0, 128
+ br.cloop.dptk.few .l1bx
+;; }
+{ .mib
+ cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment
+;; }
+
+.fraction_of_line:
+{ .mib
+ add ptr2 = 16, ptr1
+ shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32
+;; }
+{ .mib
+ cmp.eq p_scr, p0 = loopcnt, r0
+ add loopcnt = -1, loopcnt
+(p_scr) br.cond.dpnt.many .store_words
+;; }
+{ .mib
+ and cnt = 0x1f, cnt // compute the remaining cnt
+ movi0 ar.lc = loopcnt
+;; }
+ .align 32
+.l2: // -----------------------------// L2A: store 32B in 2 cycles
+{ .mmb
+ store [ptr1] = myval, 8
+ store [ptr2] = myval, 8
+;; } { .mmb
+ store [ptr1] = myval, 24
+ store [ptr2] = myval, 24
+ br.cloop.dptk.many .l2
+;; }
+.store_words:
+{ .mib
+ cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch
+;; }
+
+{ .mmi
+ store [ptr1] = myval, 8 // store
+ cmp.le p_y, p_n = 16, cnt //
+ add cnt = -8, cnt // subtract
+;; }
+{ .mmi
+(p_y) store [ptr1] = myval, 8 // store
+(p_y) cmp.le.unc p_yy, p_nn = 16, cnt
+(p_y) add cnt = -8, cnt // subtract
+;; }
+{ .mmi // store
+(p_yy) store [ptr1] = myval, 8
+(p_yy) add cnt = -8, cnt // subtract
+;; }
+
+.move_bytes_from_alignment:
+{ .mib
+ cmp.eq p_scr, p0 = cnt, r0
+ tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ?
+(p_scr) br.cond.dpnt.few .restore_and_exit
+;; }
+{ .mib
+(p_y) st4 [ptr1] = r0,4
+ tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ?
+;; }
+{ .mib
+(p_yy) st2 [ptr1] = r0,2
+ tbit.nz.unc p_y, p0 = cnt, 0 // should we terminate with a st1 ?
+;; }
+
+{ .mib
+(p_y) st1 [ptr1] = r0
+;; }
+.restore_and_exit:
+{ .mib
+ nop.m 0
+ movi0 ar.lc = save_lc
+ br.ret.sptk.many rp
+;; }
+
+.move_bytes_unaligned:
+{ .mmi
+ .pred.rel "mutex",p_y, p_n
+ .pred.rel "mutex",p_yy, p_nn
+(p_n) cmp.le p_yy, p_nn = 4, cnt
+(p_y) cmp.le p_yy, p_nn = 5, cnt
+(p_n) add ptr2 = 2, ptr1
+} { .mmi
+(p_y) add ptr2 = 3, ptr1
+(p_y) st1 [ptr1] = r0, 1 // fill 1 (odd-aligned) byte
+(p_y) add cnt = -1, cnt // [15, 14 (or less) left]
+;; }
+{ .mmi
+(p_yy) cmp.le.unc p_y, p0 = 8, cnt
+ add ptr3 = ptr1, cnt // prepare last store
+ movi0 ar.lc = save_lc
+} { .mmi
+(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
+(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
+(p_yy) add cnt = -4, cnt // [11, 10 (o less) left]
+;; }
+{ .mmi
+(p_y) cmp.le.unc p_yy, p0 = 8, cnt
+ add ptr3 = -1, ptr3 // last store
+ tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ?
+} { .mmi
+(p_y) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
+(p_y) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
+(p_y) add cnt = -4, cnt // [7, 6 (or less) left]
+;; }
+{ .mmi
+(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
+(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
+ // [3, 2 (or less) left]
+ tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ?
+} { .mmi
+(p_yy) add cnt = -4, cnt
+;; }
+{ .mmb
+(p_scr) st2 [ptr1] = r0 // fill 2 (aligned) bytes
+(p_y) st1 [ptr3] = r0 // fill last byte (using ptr3)
+ br.ret.sptk.many rp
+;; }
+END(bzero)
diff --git a/libc/string/ia64/memccpy.S b/libc/string/ia64/memccpy.S
new file mode 100644
index 000000000..1afba3637
--- /dev/null
+++ b/libc/string/ia64/memccpy.S
@@ -0,0 +1,213 @@
+/* Optimized version of the memccpy() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: a pointer to the next byte after char in dest or NULL
+
+ Inputs:
+ in0: dest
+ in1: src
+ in2: char
+ in3: byte count
+
+ This implementation assumes little endian mode (UM.be = 0).
+
+ This implementation assumes that it is safe to do read ahead
+ in the src block, without getting beyond its limit. */
+
+#include "sysdep.h"
+#undef ret
+
+#define OP_T_THRES 16
+#define OPSIZ 8
+
+#define saved_pr r17
+#define saved_lc r18
+#define dest r19
+#define src r20
+#define len r21
+#define asrc r22
+#define tmp r23
+#define char r24
+#define charx8 r25
+#define saved_ec r26
+#define sh2 r28
+#define sh1 r29
+#define loopcnt r30
+#define value r31
+
+#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
+/* Manually force proper loop-alignment. Note: be sure to
+ double-check the code-layout after making any changes to
+ this routine! */
+# define ALIGN(n) { nop 0 }
+#else
+# define ALIGN(n) .align n
+#endif
+
+ENTRY(memccpy)
+ .prologue
+ alloc r2 = ar.pfs, 4, 40 - 4, 0, 40
+
+#include "softpipe.h"
+ .rotr r[MEMLAT + 7], tmp1[4], tmp2[4], val[4], tmp3[2], pos0[2]
+ .rotp p[MEMLAT + 6 + 1]
+
+ mov ret0 = r0 // return NULL if no match
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicate registers
+ mov dest = in0 // dest
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ mov saved_ec = ar.ec // save the loop counter
+ .body
+ mov src = in1 // src
+ extr.u char = in2, 0, 8 // char
+ mov len = in3 // len
+ sub tmp = r0, in0 // tmp = -dest
+ cmp.ne p7, p0 = r0, r0 // clear p7
+ ;;
+ and loopcnt = 7, tmp // loopcnt = -dest % 8
+ cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
+ mov ar.ec = 0 // ec not guaranteed zero on entry
+(p6) br.cond.spnt .cpyfew // copy byte by byte
+ ;;
+ cmp.eq p6, p0 = loopcnt, r0
+ mux1 charx8 = char, @brcst
+(p6) br.cond.sptk .dest_aligned
+ sub len = len, loopcnt // len -= -dest % 8
+ adds loopcnt = -1, loopcnt // --loopcnt
+ ;;
+ mov ar.lc = loopcnt
+.l1: // copy -dest % 8 bytes
+ ld1 value = [src], 1 // value = *src++
+ ;;
+ st1 [dest] = value, 1 // *dest++ = value
+ cmp.eq p6, p0 = value, char
+(p6) br.cond.spnt .foundit
+ br.cloop.dptk .l1
+.dest_aligned:
+ and sh1 = 7, src // sh1 = src % 8
+ and tmp = -8, len // tmp = len & -OPSIZ
+ and asrc = -8, src // asrc = src & -OPSIZ -- align src
+ shr.u loopcnt = len, 3 // loopcnt = len / 8
+ and len = 7, len ;; // len = len % 8
+ shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
+ adds loopcnt = -1, loopcnt // --loopcnt
+ mov pr.rot = 1 << 16 ;; // set rotating predicates
+ sub sh2 = 64, sh1 // sh2 = 64 - sh1
+ mov ar.lc = loopcnt // set LC
+ cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+(p6) br.cond.sptk .src_aligned ;;
+ add src = src, tmp // src += len & -OPSIZ
+ mov ar.ec = MEMLAT + 6 + 1 // six more passes needed
+ ld8 r[1] = [asrc], 8 // r[1] = w0
+ cmp.ne p6, p0 = r0, r0 ;; // clear p6
+ ALIGN(32)
+.l2:
+(p[0]) ld8.s r[0] = [asrc], 8 // r[0] = w1
+(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1
+(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2
+(p[MEMLAT+4]) xor tmp3[0] = val[1], charx8
+(p[MEMLAT+5]) czx1.r pos0[0] = tmp3[1]
+(p[MEMLAT+6]) chk.s r[6 + MEMLAT], .recovery1 // our data isn't
+ // valid - rollback!
+(p[MEMLAT+6]) cmp.ne p6, p0 = 8, pos0[1]
+(p6) br.cond.spnt .gotit
+(p[MEMLAT+6]) st8 [dest] = val[3], 8 // store val to dest
+(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2
+ br.ctop.sptk .l2
+ br.cond.sptk .cpyfew
+
+.src_aligned:
+ cmp.ne p6, p0 = r0, r0 // clear p6
+ mov ar.ec = MEMLAT + 2 + 1 ;; // set EC
+.l3:
+(p[0]) ld8.s r[0] = [src], 8
+(p[MEMLAT]) xor tmp3[0] = r[MEMLAT], charx8
+(p[MEMLAT+1]) czx1.r pos0[0] = tmp3[1]
+(p[MEMLAT+2]) cmp.ne p7, p0 = 8, pos0[1]
+(p[MEMLAT+2]) chk.s r[MEMLAT+2], .recovery2
+(p7) br.cond.spnt .gotit
+.back2:
+(p[MEMLAT+2]) st8 [dest] = r[MEMLAT+2], 8
+ br.ctop.dptk .l3
+.cpyfew:
+ cmp.eq p6, p0 = len, r0 // is len == 0 ?
+ adds len = -1, len // --len;
+(p6) br.cond.spnt .restore_and_exit ;;
+ mov ar.lc = len
+.l4:
+ ld1 value = [src], 1
+ ;;
+ st1 [dest] = value, 1
+ cmp.eq p6, p0 = value, char
+(p6) br.cond.spnt .foundit
+ br.cloop.dptk .l4 ;;
+.foundit:
+(p6) mov ret0 = dest
+.restore_and_exit:
+ mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc // restore the loop counter
+ mov ar.ec = saved_ec ;; // restore the epilog counter
+ br.ret.sptk.many b0
+.gotit:
+ .pred.rel "mutex" p6, p7
+(p6) mov value = val[3] // if coming from l2
+(p7) mov value = r[MEMLAT+2] // if coming from l3
+ mov ar.lc = pos0[1] ;;
+.l5:
+ extr.u tmp = value, 0, 8 ;;
+ st1 [dest] = tmp, 1
+ shr.u value = value, 8
+ br.cloop.sptk .l5 ;;
+ mov ret0 = dest
+ mov pr = saved_pr, -1
+ mov ar.lc = saved_lc
+ br.ret.sptk.many b0
+
+.recovery1:
+ adds src = -(MEMLAT + 6 + 1) * 8, asrc
+ mov loopcnt = ar.lc
+ mov tmp = ar.ec ;;
+ sub sh1 = (MEMLAT + 6 + 1), tmp
+ shr.u sh2 = sh2, 3
+ ;;
+ shl loopcnt = loopcnt, 3
+ sub src = src, sh2
+ shl sh1 = sh1, 3
+ shl tmp = tmp, 3
+ ;;
+ add len = len, loopcnt
+ add src = sh1, src ;;
+ add len = tmp, len
+.back1:
+ br.cond.sptk .cpyfew
+
+.recovery2:
+ add tmp = -(MEMLAT + 3) * 8, src
+(p7) br.cond.spnt .gotit
+ ;;
+ ld8 r[MEMLAT+2] = [tmp] ;;
+ xor pos0[1] = r[MEMLAT+2], charx8 ;;
+ czx1.r pos0[1] = pos0[1] ;;
+ cmp.ne p7, p6 = 8, pos0[1]
+(p7) br.cond.spnt .gotit
+ br.cond.sptk .back2
+END(memccpy)
diff --git a/libc/string/ia64/memchr.S b/libc/string/ia64/memchr.S
new file mode 100644
index 000000000..2bf078fe6
--- /dev/null
+++ b/libc/string/ia64/memchr.S
@@ -0,0 +1,133 @@
+/* Optimized version of the standard memchr() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the address of the first occurence of chr in str or NULL
+
+ Inputs:
+ in0: str
+ in1: chr
+ in2: byte count
+
+ This implementation assumes little endian mode. For big endian mode,
+ the instruction czx1.r should be replaced by czx1.l.
+
+ The algorithm is fairly straightforward: search byte by byte until we
+ we get to a word aligned address, then search word by word as much as
+ possible; the remaining few bytes are searched one at a time.
+
+ The word by word search is performed by xor-ing the word with a word
+ containing chr in every byte. If there is a hit, the result will
+ contain a zero byte in the corresponding position. The presence and
+ position of that zero byte is detected with a czx instruction.
+
+ All the loops in this function could have had the internal branch removed
+ if br.ctop and br.cloop could be predicated :-(. */
+
+#include "sysdep.h"
+#undef ret
+
+#define saved_pr r15
+#define saved_lc r16
+#define chr r17
+#define len r18
+#define pos0 r20
+#define val r21
+#define tmp r24
+#define chrx8 r25
+#define loopcnt r30
+
+#define str in0
+
+ENTRY(__memchr)
+ .prologue
+ alloc r2 = ar.pfs, 3, 0, 29, 32
+#include "softpipe.h"
+ .rotr value[MEMLAT+1], addr[MEMLAT+3], aux[2], poschr[2]
+ .rotp p[MEMLAT+3]
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicates
+ .body
+ mov ret0 = str
+ and tmp = 7, str // tmp = str % 8
+ cmp.ne p7, p0 = r0, r0 // clear p7
+ extr.u chr = in1, 0, 8 // chr = (unsigned char) in1
+ mov len = in2
+ cmp.gtu p6, p0 = 16, in2 // use a simple loop for short
+(p6) br.cond.spnt .srchfew ;; // searches
+ sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ cmp.eq p6, p0 = tmp, r0
+(p6) br.cond.sptk .str_aligned;;
+ sub len = len, loopcnt
+ adds loopcnt = -1, loopcnt;;
+ mov ar.lc = loopcnt
+.l1:
+ ld1 val = [ret0], 1
+ ;;
+ cmp.eq p6, p0 = val, chr
+(p6) br.cond.spnt .foundit
+ br.cloop.sptk .l1 ;;
+.str_aligned:
+ cmp.ne p6, p0 = r0, r0 // clear p6
+ shr.u loopcnt = len, 3 // loopcnt = len / 8
+ and len = 7, len ;; // remaining len = len & 7
+ adds loopcnt = -1, loopcnt
+ mov ar.ec = MEMLAT + 3
+ mux1 chrx8 = chr, @brcst ;; // get a word full of chr
+ mov ar.lc = loopcnt
+ mov pr.rot = 1 << 16 ;;
+.l2:
+(p[0]) mov addr[0] = ret0
+(p[0]) ld8 value[0] = [ret0], 8
+(p[MEMLAT]) xor aux[0] = value[MEMLAT], chrx8
+(p[MEMLAT+1]) czx1.r poschr[0] = aux[1]
+(p[MEMLAT+2]) cmp.ne p7, p0 = 8, poschr[1]
+(p7) br.cond.dpnt .foundit
+ br.ctop.dptk .l2
+.srchfew:
+ adds loopcnt = -1, len
+ cmp.eq p6, p0 = len, r0
+(p6) br.cond.spnt .notfound ;;
+ mov ar.lc = loopcnt
+.l3:
+ ld1 val = [ret0], 1
+ ;;
+ cmp.eq p6, p0 = val, chr
+(p6) br.cond.dpnt .foundit
+ br.cloop.sptk .l3 ;;
+.notfound:
+ cmp.ne p6, p0 = r0, r0 // clear p6 (p7 was already 0 when we got here)
+ mov ret0 = r0 ;; // return NULL
+.foundit:
+ .pred.rel "mutex" p6, p7
+(p6) adds ret0 = -1, ret0 // if we got here from l1 or l3
+(p7) add ret0 = addr[MEMLAT+2], poschr[1] // if we got here from l2
+ mov pr = saved_pr, -1
+ mov ar.lc = saved_lc
+ br.ret.sptk.many b0
+
+END(__memchr)
+
+weak_alias (__memchr, memchr)
+#if !__BOUNDED_POINTERS__
+weak_alias (__memchr, __ubp_memchr)
+#endif
+libc_hidden_def (memchr)
diff --git a/libc/string/ia64/memcmp.S b/libc/string/ia64/memcmp.S
new file mode 100644
index 000000000..c6ea7529b
--- /dev/null
+++ b/libc/string/ia64/memcmp.S
@@ -0,0 +1,165 @@
+/* Optimized version of the standard memcmp() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the result of the comparison
+
+ Inputs:
+ in0: dest (aka s1)
+ in1: src (aka s2)
+ in2: byte count
+
+ In this form, it assumes little endian mode. For big endian mode, the
+ the two shifts in .l2 must be inverted:
+
+ shl tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 << sh1
+ shr.u tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 >> sh2
+
+ and all the mux1 instructions should be replaced by plain mov's. */
+
+#include "sysdep.h"
+#undef ret
+
+#define OP_T_THRES 16
+#define OPSIZ 8
+#define MEMLAT 2
+
+#define start r15
+#define saved_pr r17
+#define saved_lc r18
+#define dest r19
+#define src r20
+#define len r21
+#define asrc r22
+#define tmp r23
+#define value1 r24
+#define value2 r25
+#define sh2 r28
+#define sh1 r29
+#define loopcnt r30
+
+ENTRY(memcmp)
+ .prologue
+ alloc r2 = ar.pfs, 3, 37, 0, 40
+
+ .rotr r[MEMLAT + 2], q[MEMLAT + 5], tmp1[4], tmp2[4], val[2]
+ .rotp p[MEMLAT + 4 + 1]
+
+ mov ret0 = r0 // by default return value = 0
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicate registers
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .body
+ mov dest = in0 // dest
+ mov src = in1 // src
+ mov len = in2 // len
+ sub tmp = r0, in0 // tmp = -dest
+ ;;
+ and loopcnt = 7, tmp // loopcnt = -dest % 8
+ cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
+(p6) br.cond.spnt .cmpfew // compare byte by byte
+ ;;
+ cmp.eq p6, p0 = loopcnt, r0
+(p6) br.cond.sptk .dest_aligned
+ sub len = len, loopcnt // len -= -dest % 8
+ adds loopcnt = -1, loopcnt // --loopcnt
+ ;;
+ mov ar.lc = loopcnt
+.l1: // copy -dest % 8 bytes
+ ld1 value1 = [src], 1 // value = *src++
+ ld1 value2 = [dest], 1
+ ;;
+ cmp.ne p6, p0 = value1, value2
+(p6) br.cond.spnt .done
+ br.cloop.dptk .l1
+.dest_aligned:
+ and sh1 = 7, src // sh1 = src % 8
+ and tmp = -8, len // tmp = len & -OPSIZ
+ and asrc = -8, src // asrc = src & -OPSIZ -- align src
+ shr.u loopcnt = len, 3 // loopcnt = len / 8
+ and len = 7, len ;; // len = len % 8
+ shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
+ adds loopcnt = -1, loopcnt // --loopcnt
+ mov pr.rot = 1 << 16 ;; // set rotating predicates
+ sub sh2 = 64, sh1 // sh2 = 64 - sh1
+ mov ar.lc = loopcnt // set LC
+ cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+(p6) br.cond.sptk .src_aligned
+ add src = src, tmp // src += len & -OPSIZ
+ mov ar.ec = MEMLAT + 4 + 1 // four more passes needed
+ ld8 r[1] = [asrc], 8 ;; // r[1] = w0
+ .align 32
+
+// We enter this loop with p6 cleared by the above comparison
+
+.l2:
+(p[0]) ld8 r[0] = [asrc], 8 // r[0] = w1
+(p[0]) ld8 q[0] = [dest], 8
+(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1
+(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2
+(p[MEMLAT+4]) cmp.ne p6, p0 = q[MEMLAT + 4], val[1]
+(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2
+(p6) br.cond.spnt .l2exit
+ br.ctop.sptk .l2
+ br.cond.sptk .cmpfew
+.l3exit:
+ mux1 value1 = r[MEMLAT], @rev
+ mux1 value2 = q[MEMLAT], @rev
+ cmp.ne p6, p0 = r0, r0 ;; // clear p6
+.l2exit:
+(p6) mux1 value1 = val[1], @rev
+(p6) mux1 value2 = q[MEMLAT + 4], @rev ;;
+ cmp.ltu p6, p7 = value2, value1 ;;
+(p6) mov ret0 = -1
+(p7) mov ret0 = 1
+ mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+.src_aligned:
+ cmp.ne p6, p0 = r0, r0 // clear p6
+ mov ar.ec = MEMLAT + 1 ;; // set EC
+.l3:
+(p[0]) ld8 r[0] = [src], 8
+(p[0]) ld8 q[0] = [dest], 8
+(p[MEMLAT]) cmp.ne p6, p0 = r[MEMLAT], q[MEMLAT]
+(p6) br.cond.spnt .l3exit
+ br.ctop.dptk .l3 ;;
+.cmpfew:
+ cmp.eq p6, p0 = len, r0 // is len == 0 ?
+ adds len = -1, len // --len;
+(p6) br.cond.spnt .restore_and_exit ;;
+ mov ar.lc = len
+.l4:
+ ld1 value1 = [src], 1
+ ld1 value2 = [dest], 1
+ ;;
+ cmp.ne p6, p0 = value1, value2
+(p6) br.cond.spnt .done
+ br.cloop.dptk .l4 ;;
+.done:
+(p6) sub ret0 = value2, value1 // don't execute it if falling thru
+.restore_and_exit:
+ mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+END(memcmp)
+
+weak_alias (memcmp, bcmp)
+libc_hidden_def (memcmp)
diff --git a/libc/string/ia64/memcpy.S b/libc/string/ia64/memcpy.S
new file mode 100644
index 000000000..db019f860
--- /dev/null
+++ b/libc/string/ia64/memcpy.S
@@ -0,0 +1,436 @@
+/* Optimized version of the standard memcpy() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>.
+ Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch>
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: src
+ in2: byte count
+
+ An assembly implementation of the algorithm used by the generic C
+ version from glibc. The case when source and sest are aligned is
+ treated separately, for extra performance.
+
+ In this form, memcpy assumes little endian mode. For big endian mode,
+ sh1 must be computed using an extra instruction: sub sh1 = 64, sh1
+ and the order of r[MEMLAT] and r[MEMLAT+1] must be reverted in the
+ shrp instruction. */
+
+#define USE_LFETCH
+#define USE_FLP
+#include "sysdep.h"
+#undef ret
+
+#define LFETCH_DIST 500
+
+#define ALIGN_UNROLL_no 4 // no. of elements
+#define ALIGN_UNROLL_sh 2 // (shift amount)
+
+#define MEMLAT 8
+#define Nrot ((4*(MEMLAT+2) + 7) & ~7)
+
+#define OP_T_THRES 16
+#define OPSIZ 8
+
+#define loopcnt r14
+#define elemcnt r15
+#define saved_pr r16
+#define saved_lc r17
+#define adest r18
+#define dest r19
+#define asrc r20
+#define src r21
+#define len r22
+#define tmp2 r23
+#define tmp3 r24
+#define tmp4 r25
+#define ptable r26
+#define ploop56 r27
+#define loopaddr r28
+#define sh1 r29
+#define ptr1 r30
+#define ptr2 r31
+
+#define movi0 mov
+
+#define p_scr p6
+#define p_xtr p7
+#define p_nxtr p8
+#define p_few p9
+
+#if defined(USE_FLP)
+#define load ldf8
+#define store stf8
+#define tempreg f6
+#define the_r fr
+#define the_s fs
+#define the_t ft
+#define the_q fq
+#define the_w fw
+#define the_x fx
+#define the_y fy
+#define the_z fz
+#elif defined(USE_INT)
+#define load ld8
+#define store st8
+#define tempreg tmp2
+#define the_r r
+#define the_s s
+#define the_t t
+#define the_q q
+#define the_w w
+#define the_x x
+#define the_y y
+#define the_z z
+#endif
+
+#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
+/* Manually force proper loop-alignment. Note: be sure to
+ double-check the code-layout after making any changes to
+ this routine! */
+# define ALIGN(n) { nop 0 }
+#else
+# define ALIGN(n) .align n
+#endif
+
+#if defined(USE_LFETCH)
+#define LOOP(shift) \
+ ALIGN(32); \
+.loop##shift##: \
+{ .mmb \
+(p[0]) ld8.nt1 r[0] = [asrc], 8 ; \
+(p[0]) lfetch.nt1 [ptr1], 16 ; \
+ nop.b 0 ; \
+} { .mib \
+(p[MEMLAT+1]) st8 [dest] = tmp3, 8 ; \
+(p[MEMLAT]) shrp tmp3 = r[MEMLAT], s[MEMLAT+1], shift ; \
+ nop.b 0 ;; \
+ } { .mmb \
+(p[0]) ld8.nt1 s[0] = [asrc], 8 ; \
+(p[0]) lfetch.nt1 [ptr2], 16 ; \
+ nop.b 0 ; \
+} { .mib \
+(p[MEMLAT+1]) st8 [dest] = tmp4, 8 ; \
+(p[MEMLAT]) shrp tmp4 = s[MEMLAT], r[MEMLAT], shift ; \
+ br.ctop.sptk.many .loop##shift \
+;; } \
+{ .mib \
+ br.cond.sptk.many .copy_bytes ; /* deal with the remaining bytes */ \
+}
+#else
+#define LOOP(shift) \
+ ALIGN(32); \
+.loop##shift##: \
+{ .mmb \
+(p[0]) ld8.nt1 r[0] = [asrc], 8 ; \
+ nop.b 0 ; \
+} { .mib \
+(p[MEMLAT+1]) st8 [dest] = tmp3, 8 ; \
+(p[MEMLAT]) shrp tmp3 = r[MEMLAT], s[MEMLAT+1], shift ; \
+ nop.b 0 ;; \
+ } { .mmb \
+(p[0]) ld8.nt1 s[0] = [asrc], 8 ; \
+ nop.b 0 ; \
+} { .mib \
+(p[MEMLAT+1]) st8 [dest] = tmp4, 8 ; \
+(p[MEMLAT]) shrp tmp4 = s[MEMLAT], r[MEMLAT], shift ; \
+ br.ctop.sptk.many .loop##shift \
+;; } \
+{ .mib \
+ br.cond.sptk.many .copy_bytes ; /* deal with the remaining bytes */ \
+}
+#endif
+
+
+ENTRY(memcpy)
+{ .mmi
+ .prologue
+ alloc r2 = ar.pfs, 3, Nrot - 3, 0, Nrot
+ .rotr r[MEMLAT+1], s[MEMLAT+2], q[MEMLAT+1], t[MEMLAT+1]
+ .rotp p[MEMLAT+2]
+ .rotf fr[MEMLAT+1], fq[MEMLAT+1], fs[MEMLAT+1], ft[MEMLAT+1]
+ mov ret0 = in0 // return tmp2 = dest
+ .save pr, saved_pr
+ movi0 saved_pr = pr // save the predicate registers
+} { .mmi
+ and tmp4 = 7, in0 // check if destination is aligned
+ mov dest = in0 // dest
+ mov src = in1 // src
+;; }
+{ .mii
+ cmp.eq p_scr, p0 = in2, r0 // if (len == 0)
+ .save ar.lc, saved_lc
+ movi0 saved_lc = ar.lc // save the loop counter
+ .body
+ cmp.ge p_few, p0 = OP_T_THRES, in2 // is len <= OP_T_THRESH
+} { .mbb
+ mov len = in2 // len
+(p_scr) br.cond.dpnt.few .restore_and_exit // Branch no. 1: return dest
+(p_few) br.cond.dpnt.many .copy_bytes // Branch no. 2: copy byte by byte
+;; }
+{ .mmi
+#if defined(USE_LFETCH)
+ lfetch.nt1 [dest] //
+ lfetch.nt1 [src] //
+#endif
+ shr.u elemcnt = len, 3 // elemcnt = len / 8
+} { .mib
+ cmp.eq p_scr, p0 = tmp4, r0 // is destination aligned?
+ sub loopcnt = 7, tmp4 //
+(p_scr) br.cond.dptk.many .dest_aligned
+;; }
+{ .mmi
+ ld1 tmp2 = [src], 1 //
+ sub len = len, loopcnt, 1 // reduce len
+ movi0 ar.lc = loopcnt //
+} { .mib
+ cmp.ne p_scr, p0 = 0, loopcnt // avoid loading beyond end-point
+;; }
+
+.l0: // ---------------------------- // L0: Align src on 8-byte boundary
+{ .mmi
+ st1 [dest] = tmp2, 1 //
+(p_scr) ld1 tmp2 = [src], 1 //
+} { .mib
+ cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ add loopcnt = -1, loopcnt
+ br.cloop.dptk.few .l0 //
+;; }
+
+.dest_aligned:
+{ .mmi
+ and tmp4 = 7, src // ready for alignment check
+ shr.u elemcnt = len, 3 // elemcnt = len / 8
+;; }
+{ .mib
+ cmp.ne p_scr, p0 = tmp4, r0 // is source also aligned
+ tbit.nz p_xtr, p_nxtr = src, 3 // prepare a separate move if src
+} { .mib // is not 16B aligned
+ add ptr2 = LFETCH_DIST, dest // prefetch address
+ add ptr1 = LFETCH_DIST, src
+(p_scr) br.cond.dptk.many .src_not_aligned
+;; }
+
+// The optimal case, when dest, and src are aligned
+
+.both_aligned:
+{ .mmi
+ .pred.rel "mutex",p_xtr,p_nxtr
+(p_xtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no+1, elemcnt // Need N + 1 to qualify
+(p_nxtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no, elemcnt // Need only N to qualify
+ movi0 pr.rot = 1 << 16 // set rotating predicates
+} { .mib
+(p_scr) br.cond.dpnt.many .copy_full_words
+;; }
+
+{ .mmi
+(p_xtr) load tempreg = [src], 8
+(p_xtr) add elemcnt = -1, elemcnt
+ movi0 ar.ec = MEMLAT + 1 // set the epilog counter
+;; }
+{ .mmi
+(p_xtr) add len = -8, len //
+ add asrc = 16, src // one bank apart (for USE_INT)
+ shr.u loopcnt = elemcnt, ALIGN_UNROLL_sh // cater for unrolling
+;;}
+{ .mmi
+ add loopcnt = -1, loopcnt
+(p_xtr) store [dest] = tempreg, 8 // copy the "extra" word
+ nop.i 0
+;; }
+{ .mib
+ add adest = 16, dest
+ movi0 ar.lc = loopcnt // set the loop counter
+;; }
+
+#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
+ { nop 0 }
+#else
+ .align 32
+#endif
+#if defined(USE_FLP)
+.l1: // ------------------------------- // L1: Everything a multiple of 8
+{ .mmi
+#if defined(USE_LFETCH)
+(p[0]) lfetch.nt1 [ptr2],32
+#endif
+(p[0]) ldfp8 the_r[0],the_q[0] = [src], 16
+(p[0]) add len = -32, len
+} {.mmb
+(p[MEMLAT]) store [dest] = the_r[MEMLAT], 8
+(p[MEMLAT]) store [adest] = the_s[MEMLAT], 8
+;; }
+{ .mmi
+#if defined(USE_LFETCH)
+(p[0]) lfetch.nt1 [ptr1],32
+#endif
+(p[0]) ldfp8 the_s[0], the_t[0] = [src], 16
+} {.mmb
+(p[MEMLAT]) store [dest] = the_q[MEMLAT], 24
+(p[MEMLAT]) store [adest] = the_t[MEMLAT], 24
+ br.ctop.dptk.many .l1
+;; }
+#elif defined(USE_INT)
+.l1: // ------------------------------- // L1: Everything a multiple of 8
+{ .mmi
+(p[0]) load the_r[0] = [src], 8
+(p[0]) load the_q[0] = [asrc], 8
+(p[0]) add len = -32, len
+} {.mmb
+(p[MEMLAT]) store [dest] = the_r[MEMLAT], 8
+(p[MEMLAT]) store [adest] = the_q[MEMLAT], 8
+;; }
+{ .mmi
+(p[0]) load the_s[0] = [src], 24
+(p[0]) load the_t[0] = [asrc], 24
+} {.mmb
+(p[MEMLAT]) store [dest] = the_s[MEMLAT], 24
+(p[MEMLAT]) store [adest] = the_t[MEMLAT], 24
+#if defined(USE_LFETCH)
+;; }
+{ .mmb
+(p[0]) lfetch.nt1 [ptr2],32
+(p[0]) lfetch.nt1 [ptr1],32
+#endif
+ br.ctop.dptk.many .l1
+;; }
+#endif
+
+.copy_full_words:
+{ .mib
+ cmp.gt p_scr, p0 = 8, len //
+ shr.u elemcnt = len, 3 //
+(p_scr) br.cond.dpnt.many .copy_bytes
+;; }
+{ .mii
+ load tempreg = [src], 8
+ add loopcnt = -1, elemcnt //
+;; }
+{ .mii
+ cmp.ne p_scr, p0 = 0, loopcnt //
+ mov ar.lc = loopcnt //
+;; }
+
+.l2: // ------------------------------- // L2: Max 4 words copied separately
+{ .mmi
+ store [dest] = tempreg, 8
+(p_scr) load tempreg = [src], 8 //
+ add len = -8, len
+} { .mib
+ cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ add loopcnt = -1, loopcnt
+ br.cloop.dptk.few .l2
+;; }
+
+.copy_bytes:
+{ .mib
+ cmp.eq p_scr, p0 = len, r0 // is len == 0 ?
+ add loopcnt = -1, len // len--;
+(p_scr) br.cond.spnt .restore_and_exit
+;; }
+{ .mii
+ ld1 tmp2 = [src], 1
+ movi0 ar.lc = loopcnt
+ cmp.ne p_scr, p0 = 0, loopcnt // avoid load beyond end-point
+;; }
+
+.l3: // ------------------------------- // L3: Final byte move
+{ .mmi
+ st1 [dest] = tmp2, 1
+(p_scr) ld1 tmp2 = [src], 1
+} { .mib
+ cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ add loopcnt = -1, loopcnt
+ br.cloop.dptk.few .l3
+;; }
+
+.restore_and_exit:
+{ .mmi
+ movi0 pr = saved_pr, -1 // restore the predicate registers
+;; }
+{ .mib
+ movi0 ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+;; }
+
+
+.src_not_aligned:
+{ .mmi
+ cmp.gt p_scr, p0 = 16, len
+ and sh1 = 7, src // sh1 = src % 8
+ shr.u loopcnt = len, 4 // element-cnt = len / 16
+} { .mib
+ add tmp4 = @ltoff(.table), gp
+ add tmp3 = @ltoff(.loop56), gp
+(p_scr) br.cond.dpnt.many .copy_bytes // do byte by byte if too few
+;; }
+{ .mmi
+ and asrc = -8, src // asrc = (-8) -- align src for loop
+ add loopcnt = -1, loopcnt // loopcnt--
+ shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
+} { .mmi
+ ld8 ptable = [tmp4] // ptable = &table
+ ld8 ploop56 = [tmp3] // ploop56 = &loop56
+ and tmp2 = -16, len // tmp2 = len & -OPSIZ
+;; }
+{ .mmi
+ add tmp3 = ptable, sh1 // tmp3 = &table + sh1
+ add src = src, tmp2 // src += len & (-16)
+ movi0 ar.lc = loopcnt // set LC
+;; }
+{ .mmi
+ ld8 tmp4 = [tmp3] // tmp4 = loop offset
+ sub len = len, tmp2 // len -= len & (-16)
+ movi0 ar.ec = MEMLAT + 2 // one more pass needed
+;; }
+{ .mmi
+ ld8 s[1] = [asrc], 8 // preload
+ sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset
+ movi0 pr.rot = 1 << 16 // set rotating predicates
+;; }
+{ .mib
+ nop.m 0
+ movi0 b6 = loopaddr
+ br b6 // jump to the appropriate loop
+;; }
+
+ LOOP(8)
+ LOOP(16)
+ LOOP(24)
+ LOOP(32)
+ LOOP(40)
+ LOOP(48)
+ LOOP(56)
+END(memcpy)
+libc_hidden_def (memcpy)
+
+ .rodata
+ .align 8
+.table:
+ data8 0 // dummy entry
+ data8 .loop56 - .loop8
+ data8 .loop56 - .loop16
+ data8 .loop56 - .loop24
+ data8 .loop56 - .loop32
+ data8 .loop56 - .loop40
+ data8 .loop56 - .loop48
+ data8 .loop56 - .loop56
diff --git a/libc/string/ia64/memmove.S b/libc/string/ia64/memmove.S
new file mode 100644
index 000000000..0328f84de
--- /dev/null
+++ b/libc/string/ia64/memmove.S
@@ -0,0 +1,251 @@
+/* Optimized version of the standard memmove() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: src
+ in2: byte count
+
+ The core of the function is the memcpy implementation used in memcpy.S.
+ When bytes have to be copied backwards, only the easy case, when
+ all arguments are multiples of 8, is optimised.
+
+ In this form, it assumes little endian mode. For big endian mode,
+ sh1 must be computed using an extra instruction: sub sh1 = 64, sh1
+ or the UM.be bit should be cleared at the beginning and set at the end. */
+
+#include "sysdep.h"
+#undef ret
+
+#define OP_T_THRES 16
+#define OPSIZ 8
+
+#define adest r15
+#define saved_pr r17
+#define saved_lc r18
+#define dest r19
+#define src r20
+#define len r21
+#define asrc r22
+#define tmp2 r23
+#define tmp3 r24
+#define tmp4 r25
+#define ptable r26
+#define ploop56 r27
+#define loopaddr r28
+#define sh1 r29
+#define loopcnt r30
+#define value r31
+
+#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
+# define ALIGN(n) { nop 0 }
+#else
+# define ALIGN(n) .align n
+#endif
+
+#define LOOP(shift) \
+ ALIGN(32); \
+.loop##shift##: \
+(p[0]) ld8 r[0] = [asrc], 8 ; /* w1 */ \
+(p[MEMLAT+1]) st8 [dest] = value, 8 ; \
+(p[MEMLAT]) shrp value = r[MEMLAT], r[MEMLAT+1], shift ; \
+ nop.b 0 ; \
+ nop.b 0 ; \
+ br.ctop.sptk .loop##shift ; \
+ br.cond.sptk .cpyfew ; /* deal with the remaining bytes */
+
+#define MEMLAT 21
+#define Nrot (((2*MEMLAT+3) + 7) & ~7)
+
+ENTRY(memmove)
+ .prologue
+ alloc r2 = ar.pfs, 3, Nrot - 3, 0, Nrot
+ .rotr r[MEMLAT + 2], q[MEMLAT + 1]
+ .rotp p[MEMLAT + 2]
+ mov ret0 = in0 // return value = dest
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicate registers
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .body
+ or tmp3 = in0, in1 ;; // tmp3 = dest | src
+ or tmp3 = tmp3, in2 // tmp3 = dest | src | len
+ mov dest = in0 // dest
+ mov src = in1 // src
+ mov len = in2 // len
+ sub tmp2 = r0, in0 // tmp2 = -dest
+ cmp.eq p6, p0 = in2, r0 // if (len == 0)
+(p6) br.cond.spnt .restore_and_exit;;// return dest;
+ and tmp4 = 7, tmp3 // tmp4 = (dest | src | len) & 7
+ cmp.le p6, p0 = dest, src // if dest <= src it's always safe
+(p6) br.cond.spnt .forward // to copy forward
+ add tmp3 = src, len;;
+ cmp.lt p6, p0 = dest, tmp3 // if dest > src && dest < src + len
+(p6) br.cond.spnt .backward // we have to copy backward
+
+.forward:
+ shr.u loopcnt = len, 4 ;; // loopcnt = len / 16
+ cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0)
+(p6) br.cond.sptk .next // goto next;
+
+// The optimal case, when dest, src and len are all multiples of 8
+
+ and tmp3 = 0xf, len
+ mov pr.rot = 1 << 16 // set rotating predicates
+ mov ar.ec = MEMLAT + 1 ;; // set the epilog counter
+ cmp.ne p6, p0 = tmp3, r0 // do we have to copy an extra word?
+ adds loopcnt = -1, loopcnt;; // --loopcnt
+(p6) ld8 value = [src], 8;;
+(p6) st8 [dest] = value, 8 // copy the "odd" word
+ mov ar.lc = loopcnt // set the loop counter
+ cmp.eq p6, p0 = 8, len
+(p6) br.cond.spnt .restore_and_exit;;// the one-word special case
+ adds adest = 8, dest // set adest one word ahead of dest
+ adds asrc = 8, src ;; // set asrc one word ahead of src
+ nop.b 0 // get the "golden" alignment for
+ nop.b 0 // the next loop
+.l0:
+(p[0]) ld8 r[0] = [src], 16
+(p[0]) ld8 q[0] = [asrc], 16
+(p[MEMLAT]) st8 [dest] = r[MEMLAT], 16
+(p[MEMLAT]) st8 [adest] = q[MEMLAT], 16
+ br.ctop.dptk .l0 ;;
+
+ mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+.next:
+ cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
+ and loopcnt = 7, tmp2 // loopcnt = -dest % 8
+(p6) br.cond.spnt .cpyfew // copy byte by byte
+ ;;
+ cmp.eq p6, p0 = loopcnt, r0
+(p6) br.cond.sptk .dest_aligned
+ sub len = len, loopcnt // len -= -dest % 8
+ adds loopcnt = -1, loopcnt // --loopcnt
+ ;;
+ mov ar.lc = loopcnt
+.l1: // copy -dest % 8 bytes
+ ld1 value = [src], 1 // value = *src++
+ ;;
+ st1 [dest] = value, 1 // *dest++ = value
+ br.cloop.dptk .l1
+.dest_aligned:
+ and sh1 = 7, src // sh1 = src % 8
+ and tmp2 = -8, len // tmp2 = len & -OPSIZ
+ and asrc = -8, src // asrc = src & -OPSIZ -- align src
+ shr.u loopcnt = len, 3 // loopcnt = len / 8
+ and len = 7, len;; // len = len % 8
+ adds loopcnt = -1, loopcnt // --loopcnt
+ addl tmp4 = @ltoff(.table), gp
+ addl tmp3 = @ltoff(.loop56), gp
+ mov ar.ec = MEMLAT + 1 // set EC
+ mov pr.rot = 1 << 16;; // set rotating predicates
+ mov ar.lc = loopcnt // set LC
+ cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+(p6) br.cond.sptk .src_aligned
+ add src = src, tmp2 // src += len & -OPSIZ
+ shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
+ ld8 ploop56 = [tmp3] // ploop56 = &loop56
+ ld8 ptable = [tmp4];; // ptable = &table
+ add tmp3 = ptable, sh1;; // tmp3 = &table + sh1
+ mov ar.ec = MEMLAT + 1 + 1 // one more pass needed
+ ld8 tmp4 = [tmp3];; // tmp4 = loop offset
+ sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset
+ ld8 r[1] = [asrc], 8;; // w0
+ mov b6 = loopaddr;;
+ br b6 // jump to the appropriate loop
+
+ LOOP(8)
+ LOOP(16)
+ LOOP(24)
+ LOOP(32)
+ LOOP(40)
+ LOOP(48)
+ LOOP(56)
+
+.src_aligned:
+.l3:
+(p[0]) ld8 r[0] = [src], 8
+(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8
+ br.ctop.dptk .l3
+.cpyfew:
+ cmp.eq p6, p0 = len, r0 // is len == 0 ?
+ adds len = -1, len // --len;
+(p6) br.cond.spnt .restore_and_exit ;;
+ mov ar.lc = len
+.l4:
+ ld1 value = [src], 1
+ ;;
+ st1 [dest] = value, 1
+ br.cloop.dptk .l4 ;;
+.restore_and_exit:
+ mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+
+// In the case of a backward copy, optimise only the case when everything
+// is a multiple of 8, otherwise copy byte by byte. The backward copy is
+// used only when the blocks are overlapping and dest > src.
+
+.backward:
+ shr.u loopcnt = len, 3 // loopcnt = len / 8
+ add src = src, len // src points one byte past the end
+ add dest = dest, len ;; // dest points one byte past the end
+ mov ar.ec = MEMLAT + 1 // set the epilog counter
+ mov pr.rot = 1 << 16 // set rotating predicates
+ adds loopcnt = -1, loopcnt // --loopcnt
+ cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0)
+(p6) br.cond.sptk .bytecopy ;; // copy byte by byte backward
+ adds src = -8, src // src points to the last word
+ adds dest = -8, dest // dest points to the last word
+ mov ar.lc = loopcnt;; // set the loop counter
+.l5:
+(p[0]) ld8 r[0] = [src], -8
+(p[MEMLAT]) st8 [dest] = r[MEMLAT], -8
+ br.ctop.dptk .l5
+ br.cond.sptk .restore_and_exit
+.bytecopy:
+ adds src = -1, src // src points to the last byte
+ adds dest = -1, dest // dest points to the last byte
+ adds loopcnt = -1, len;; // loopcnt = len - 1
+ mov ar.lc = loopcnt;; // set the loop counter
+.l6:
+(p[0]) ld1 r[0] = [src], -1
+(p[MEMLAT]) st1 [dest] = r[MEMLAT], -1
+ br.ctop.dptk .l6
+ br.cond.sptk .restore_and_exit
+END(memmove)
+
+ .rodata
+ .align 8
+.table:
+ data8 0 // dummy entry
+ data8 .loop56 - .loop8
+ data8 .loop56 - .loop16
+ data8 .loop56 - .loop24
+ data8 .loop56 - .loop32
+ data8 .loop56 - .loop40
+ data8 .loop56 - .loop48
+ data8 .loop56 - .loop56
+
+libc_hidden_def (memmove)
diff --git a/libc/string/ia64/memset.S b/libc/string/ia64/memset.S
new file mode 100644
index 000000000..ed27f3f31
--- /dev/null
+++ b/libc/string/ia64/memset.S
@@ -0,0 +1,400 @@
+/* Optimized version of the standard memset() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>.
+ Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch>
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: value
+ in2: count
+
+ The algorithm is fairly straightforward: set byte by byte until we
+ we get to a 16B-aligned address, then loop on 128 B chunks using an
+ early store as prefetching, then loop on 32B chucks, then clear remaining
+ words, finally clear remaining bytes.
+ Since a stf.spill f0 can store 16B in one go, we use this instruction
+ to get peak speed when value = 0. */
+
+#include "sysdep.h"
+#undef ret
+
+#define dest in0
+#define value in1
+#define cnt in2
+
+#define tmp r31
+#define save_lc r30
+#define ptr0 r29
+#define ptr1 r28
+#define ptr2 r27
+#define ptr3 r26
+#define ptr9 r24
+#define loopcnt r23
+#define linecnt r22
+#define bytecnt r21
+
+#define fvalue f6
+
+// This routine uses only scratch predicate registers (p6 - p15)
+#define p_scr p6 // default register for same-cycle branches
+#define p_nz p7
+#define p_zr p8
+#define p_unalgn p9
+#define p_y p11
+#define p_n p12
+#define p_yy p13
+#define p_nn p14
+
+#define movi0 mov
+
+#define MIN1 15
+#define MIN1P1HALF 8
+#define LINE_SIZE 128
+#define LSIZE_SH 7 // shift amount
+#define PREF_AHEAD 8
+
+#define USE_FLP
+#if defined(USE_INT)
+#define store st8
+#define myval value
+#elif defined(USE_FLP)
+#define store stf8
+#define myval fvalue
+#endif
+
+.align 64
+ENTRY(memset)
+{ .mmi
+ .prologue
+ alloc tmp = ar.pfs, 3, 0, 0, 0
+ lfetch.nt1 [dest]
+ .save ar.lc, save_lc
+ movi0 save_lc = ar.lc
+} { .mmi
+ .body
+ mov ret0 = dest // return value
+ cmp.ne p_nz, p_zr = value, r0 // use stf.spill if value is zero
+ cmp.eq p_scr, p0 = cnt, r0
+;; }
+{ .mmi
+ and ptr2 = -(MIN1+1), dest // aligned address
+ and tmp = MIN1, dest // prepare to check for alignment
+ tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U)
+} { .mib
+ mov ptr1 = dest
+ mux1 value = value, @brcst // create 8 identical bytes in word
+(p_scr) br.ret.dpnt.many rp // return immediately if count = 0
+;; }
+{ .mib
+ cmp.ne p_unalgn, p0 = tmp, r0
+} { .mib // NB: # of bytes to move is 1 higher
+ sub bytecnt = (MIN1+1), tmp // than loopcnt
+ cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task?
+(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U)
+;; }
+{ .mmi
+(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment
+(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ?
+;; }
+{ .mib
+(p_y) add cnt = -8, cnt
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ?
+} { .mib
+(p_y) st8 [ptr2] = value, -4
+(p_n) add ptr2 = 4, ptr2
+;; }
+{ .mib
+(p_yy) add cnt = -4, cnt
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ?
+} { .mib
+(p_yy) st4 [ptr2] = value, -2
+(p_nn) add ptr2 = 2, ptr2
+;; }
+{ .mmi
+ mov tmp = LINE_SIZE+1 // for compare
+(p_y) add cnt = -2, cnt
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ?
+} { .mmi
+ setf.sig fvalue=value // transfer value to FLP side
+(p_y) st2 [ptr2] = value, -1
+(p_n) add ptr2 = 1, ptr2
+;; }
+
+{ .mmi
+(p_yy) st1 [ptr2] = value
+ cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task?
+} { .mbb
+(p_yy) add cnt = -1, cnt
+(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few
+;; }
+
+{ .mib
+ nop.m 0
+ shr.u linecnt = cnt, LSIZE_SH
+(p_zr) br.cond.dptk.many .l1b // Jump to use stf.spill
+;; }
+
+#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO
+ .align 32 // -------- // L1A: store ahead into cache lines; fill later
+#endif
+{ .mmi
+ and tmp = -(LINE_SIZE), cnt // compute end of range
+ mov ptr9 = ptr1 // used for prefetching
+ and cnt = (LINE_SIZE-1), cnt // remainder
+} { .mmi
+ mov loopcnt = PREF_AHEAD-1 // default prefetch loop
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+;; }
+{ .mmi
+(p_scr) add loopcnt = -1, linecnt // start of stores
+ add ptr2 = 8, ptr1 // (beyond prefetch stores)
+ add ptr1 = tmp, ptr1 // first address beyond total
+;; } // range
+{ .mmi
+ add tmp = -1, linecnt // next loop count
+ movi0 ar.lc = loopcnt
+;; }
+.pref_l1a:
+{ .mib
+ store [ptr9] = myval, 128 // Do stores one cache line apart
+ nop.i 0
+ br.cloop.dptk.few .pref_l1a
+;; }
+{ .mmi
+ add ptr0 = 16, ptr2 // Two stores in parallel
+ movi0 ar.lc = tmp
+;; }
+.l1ax:
+ { .mmi
+ store [ptr2] = myval, 8
+ store [ptr0] = myval, 8
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 24
+ store [ptr0] = myval, 24
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 8
+ store [ptr0] = myval, 8
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 24
+ store [ptr0] = myval, 24
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 8
+ store [ptr0] = myval, 8
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 24
+ store [ptr0] = myval, 24
+ ;; }
+ { .mmi
+ store [ptr2] = myval, 8
+ store [ptr0] = myval, 32
+ cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ ;; }
+{ .mmb
+ store [ptr2] = myval, 24
+(p_scr) store [ptr9] = myval, 128
+ br.cloop.dptk.few .l1ax
+;; }
+{ .mbb
+ cmp.le p_scr, p0 = 8, cnt // just a few bytes left ?
+(p_scr) br.cond.dpnt.many .fraction_of_line // Branch no. 2
+ br.cond.dpnt.many .move_bytes_from_alignment // Branch no. 3
+;; }
+
+#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
+ { nop 0 }
+#else
+ .align 32
+#endif
+.l1b: // ------------------ // L1B: store ahead into cache lines; fill later
+{ .mmi
+ and tmp = -(LINE_SIZE), cnt // compute end of range
+ mov ptr9 = ptr1 // used for prefetching
+ and cnt = (LINE_SIZE-1), cnt // remainder
+} { .mmi
+ mov loopcnt = PREF_AHEAD-1 // default prefetch loop
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+;; }
+{ .mmi
+(p_scr) add loopcnt = -1, linecnt
+ add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores)
+ add ptr1 = tmp, ptr1 // first address beyond total range
+;; }
+{ .mmi
+ add tmp = -1, linecnt // next loop count
+ movi0 ar.lc = loopcnt
+;; }
+.pref_l1b:
+{ .mib
+ stf.spill [ptr9] = f0, 128 // Do stores one cache line apart
+ nop.i 0
+ br.cloop.dptk.few .pref_l1b
+;; }
+{ .mmi
+ add ptr0 = 16, ptr2 // Two stores in parallel
+ movi0 ar.lc = tmp
+;; }
+.l1bx:
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 32
+ ;; }
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 32
+ ;; }
+ { .mmi
+ stf.spill [ptr2] = f0, 32
+ stf.spill [ptr0] = f0, 64
+ cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ ;; }
+{ .mmb
+ stf.spill [ptr2] = f0, 32
+(p_scr) stf.spill [ptr9] = f0, 128
+ br.cloop.dptk.few .l1bx
+;; }
+{ .mib
+ cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment
+;; }
+
+.fraction_of_line:
+{ .mib
+ add ptr2 = 16, ptr1
+ shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32
+;; }
+{ .mib
+ cmp.eq p_scr, p0 = loopcnt, r0
+ add loopcnt = -1, loopcnt
+(p_scr) br.cond.dpnt.many store_words
+;; }
+{ .mib
+ and cnt = 0x1f, cnt // compute the remaining cnt
+ movi0 ar.lc = loopcnt
+;; }
+#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO
+ .align 32
+#endif
+.l2: // ---------------------------- // L2A: store 32B in 2 cycles
+{ .mmb
+ store [ptr1] = myval, 8
+ store [ptr2] = myval, 8
+;; } { .mmb
+ store [ptr1] = myval, 24
+ store [ptr2] = myval, 24
+ br.cloop.dptk.many .l2
+;; }
+store_words:
+{ .mib
+ cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch
+;; }
+
+{ .mmi
+ store [ptr1] = myval, 8 // store
+ cmp.le p_y, p_n = 16, cnt //
+ add cnt = -8, cnt // subtract
+;; }
+{ .mmi
+(p_y) store [ptr1] = myval, 8 // store
+(p_y) cmp.le.unc p_yy, p_nn = 16, cnt //
+(p_y) add cnt = -8, cnt // subtract
+;; }
+{ .mmi // store
+(p_yy) store [ptr1] = myval, 8 //
+(p_yy) add cnt = -8, cnt // subtract
+;; }
+
+.move_bytes_from_alignment:
+{ .mib
+ cmp.eq p_scr, p0 = cnt, r0
+ tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ?
+(p_scr) br.cond.dpnt.few .restore_and_exit
+;; }
+{ .mib
+(p_y) st4 [ptr1] = value, 4
+ tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ?
+;; }
+{ .mib
+(p_yy) st2 [ptr1] = value, 2
+ tbit.nz.unc p_y, p0 = cnt, 0
+;; }
+
+{ .mib
+(p_y) st1 [ptr1] = value
+;; }
+.restore_and_exit:
+{ .mib
+ nop.m 0
+ movi0 ar.lc = save_lc
+ br.ret.sptk.many rp
+;; }
+
+.move_bytes_unaligned:
+{ .mmi
+ .pred.rel "mutex",p_y, p_n
+ .pred.rel "mutex",p_yy, p_nn
+(p_n) cmp.le p_yy, p_nn = 4, cnt
+(p_y) cmp.le p_yy, p_nn = 5, cnt
+(p_n) add ptr2 = 2, ptr1
+} { .mmi
+(p_y) add ptr2 = 3, ptr1
+(p_y) st1 [ptr1] = value, 1 // fill 1 (odd-aligned) byte
+(p_y) add cnt = -1, cnt // [15, 14 (or less) left]
+;; }
+{ .mmi
+(p_yy) cmp.le.unc p_y, p0 = 8, cnt
+ add ptr3 = ptr1, cnt // prepare last store
+ movi0 ar.lc = save_lc
+} { .mmi
+(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
+(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
+(p_yy) add cnt = -4, cnt // [11, 10 (o less) left]
+;; }
+{ .mmi
+(p_y) cmp.le.unc p_yy, p0 = 8, cnt
+ add ptr3 = -1, ptr3 // last store
+ tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ?
+} { .mmi
+(p_y) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
+(p_y) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
+(p_y) add cnt = -4, cnt // [7, 6 (or less) left]
+;; }
+{ .mmi
+(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
+(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
+ // [3, 2 (or less) left]
+ tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ?
+} { .mmi
+(p_yy) add cnt = -4, cnt
+;; }
+{ .mmb
+(p_scr) st2 [ptr1] = value // fill 2 (aligned) bytes
+(p_y) st1 [ptr3] = value // fill last byte (using ptr3)
+ br.ret.sptk.many rp
+;; }
+END(memset)
+libc_hidden_def (memset)
diff --git a/libc/string/ia64/softpipe.h b/libc/string/ia64/softpipe.h
new file mode 100644
index 000000000..cf0eb5355
--- /dev/null
+++ b/libc/string/ia64/softpipe.h
@@ -0,0 +1,29 @@
+/* This file is part of the GNU C Library.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+
+ 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. */
+
+/* The latency of a memory load assumed by the assembly implementation
+ of the mem and str functions. Since we don't have any clue about
+ where the data might be, let's assume it's in the L2 cache.
+ Assuming L3 would be too pessimistic :-)
+
+ Some functions define MEMLAT as 2, because they expect their data
+ to be in the L1D cache. */
+
+#ifndef MEMLAT
+# define MEMLAT 6
+#endif
diff --git a/libc/string/ia64/strchr.S b/libc/string/ia64/strchr.S
new file mode 100644
index 000000000..7d1a0834e
--- /dev/null
+++ b/libc/string/ia64/strchr.S
@@ -0,0 +1,112 @@
+/* Optimized version of the standard strchr() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the address of the first occurence of chr in str or NULL
+
+ Inputs:
+ in0: str
+ in1: chr
+
+ A modified version of memchr.S, the search ends when the character is
+ found or the terminating null character is encountered.
+
+ This implementation assumes little endian mode. For big endian mode,
+ the instruction czx1.r should be replaced by czx1.l. */
+
+#include "sysdep.h"
+#undef ret
+
+#define saved_lc r18
+#define poschr r19
+#define pos0 r20
+#define val1 r21
+#define val2 r22
+#define tmp r24
+#define chrx8 r25
+#define loopcnt r30
+
+#define str in0
+#define chr in1
+
+ENTRY(strchr)
+ .prologue
+ alloc r2 = ar.pfs, 2, 0, 0, 0
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .body
+ mov ret0 = str
+ and tmp = 7, str // tmp = str % 8
+ mux1 chrx8 = chr, @brcst
+ extr.u chr = chr, 0, 8 // retain only the last byte
+ cmp.ne p8, p0 = r0, r0 // clear p8
+ ;;
+ sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ cmp.eq p6, p0 = tmp, r0
+(p6) br.cond.sptk .str_aligned;;
+ adds loopcnt = -1, loopcnt;;
+ mov ar.lc = loopcnt
+.l1:
+ ld1 val2 = [ret0], 1
+ ;;
+ cmp.eq p6, p0 = val2, chr
+ cmp.eq p7, p0 = val2, r0
+(p6) br.cond.spnt .restore_and_exit
+(p7) br.cond.spnt .notfound
+ br.cloop.sptk .l1
+.str_aligned:
+ ld8 val1 = [ret0], 8;;
+ nop.b 0
+ nop.b 0
+.l2:
+ ld8.s val2 = [ret0], 8 // don't bomb out here
+ czx1.r pos0 = val1
+ xor tmp = val1, chrx8 // if val1 contains chr, tmp will
+ ;; // contain a zero in its position
+ czx1.r poschr = tmp
+ cmp.ne p6, p0 = 8, pos0
+ ;;
+ cmp.ne p7, p0 = 8, poschr
+(p7) br.cond.spnt .foundit
+(p6) br.cond.spnt .notfound
+ chk.s val2, .recovery
+.back:
+ mov val1 = val2
+ br.cond.dptk .l2
+.foundit:
+(p6) cmp.lt p8, p0 = pos0, poschr // we found chr and null in the word
+(p8) br.cond.spnt .notfound // null was found before chr
+ add ret0 = ret0, poschr ;;
+ adds ret0 = -15, ret0 ;; // should be -16, but we decrement
+.restore_and_exit: // ret0 in the next instruction
+ adds ret0 = -1, ret0 // ret0 was pointing 1 char too far
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+.notfound:
+ mov ret0 = r0 // return NULL if null was found
+ mov ar.lc = saved_lc
+ br.ret.sptk.many b0
+.recovery:
+ adds ret0 = -8, ret0;;
+ ld8 val2 = [ret0], 8 // bomb out here
+ br.cond.sptk .back
+END(strchr)
+
+weak_alias (strchr, index)
+libc_hidden_def (strchr)
diff --git a/libc/string/ia64/strcmp.S b/libc/string/ia64/strcmp.S
new file mode 100644
index 000000000..d3b41e642
--- /dev/null
+++ b/libc/string/ia64/strcmp.S
@@ -0,0 +1,59 @@
+/* Optimized version of the standard strcmp() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the result of the comparison
+
+ Inputs:
+ in0: s1
+ in1: s2
+
+ Unlike memcmp(), this function is optimized for mismatches within the
+ first few characters. */
+
+#include "sysdep.h"
+#undef ret
+
+#define s1 in0
+#define s2 in1
+
+#define val1 r15
+#define val2 r16
+
+
+ENTRY(strcmp)
+ alloc r2 = ar.pfs, 2, 0, 0, 0
+.loop:
+ ld1 val1 = [s1], 1
+ ld1 val2 = [s2], 1
+ cmp.eq p6, p0 = r0, r0 // set p6
+ ;;
+ cmp.ne.and p6, p0 = val1, r0
+ cmp.ne.and p6, p0 = val2, r0
+ cmp.eq.and p6, p0 = val1, val2
+(p6) br.cond.sptk .loop
+ sub ret0 = val1, val2
+ br.ret.sptk.many b0
+END(strcmp)
+libc_hidden_def (strcmp)
+
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/ia64/strcpy.S b/libc/string/ia64/strcpy.S
new file mode 100644
index 000000000..e4a9915ca
--- /dev/null
+++ b/libc/string/ia64/strcpy.S
@@ -0,0 +1,145 @@
+/* Optimized version of the standard strcpy() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: src
+
+ In this form, it assumes little endian mode. For big endian mode, the
+ the two shifts in .l2 must be inverted:
+
+ shl value = r[1], sh1 // value = w0 << sh1
+ shr.u tmp = r[0], sh2 // tmp = w1 >> sh2
+ */
+
+#include "sysdep.h"
+#undef ret
+
+#define saved_lc r15
+#define saved_pr r16
+#define thresh r17
+#define dest r19
+#define src r20
+#define len r21
+#define asrc r22
+#define tmp r23
+#define pos r24
+#define w0 r25
+#define w1 r26
+#define c r27
+#define sh2 r28
+#define sh1 r29
+#define loopcnt r30
+#define value r31
+
+ENTRY(strcpy)
+ .prologue
+ alloc r2 = ar.pfs, 2, 0, 30, 32
+
+#define MEMLAT 2
+ .rotr r[MEMLAT + 2]
+ .rotp p[MEMLAT + 1]
+
+ mov ret0 = in0 // return value = dest
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicate registers
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .body
+ sub tmp = r0, in0 ;; // tmp = -dest
+ mov dest = in0 // dest
+ mov src = in1 // src
+ and loopcnt = 7, tmp ;; // loopcnt = -dest % 8
+ cmp.eq p6, p0 = loopcnt, r0
+ adds loopcnt = -1, loopcnt // --loopcnt
+(p6) br.cond.sptk .dest_aligned ;;
+ mov ar.lc = loopcnt
+.l1: // copy -dest % 8 bytes
+ ld1 c = [src], 1 // c = *src++
+ ;;
+ st1 [dest] = c, 1 // *dest++ = c
+ cmp.eq p6, p0 = c, r0
+(p6) br.cond.dpnt .restore_and_exit
+ br.cloop.dptk .l1 ;;
+.dest_aligned:
+ and sh1 = 7, src // sh1 = src % 8
+ mov ar.lc = -1 // "infinite" loop
+ and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src
+ sub thresh = 8, sh1
+ mov pr.rot = 1 << 16 // set rotating predicates
+ cmp.ne p7, p0 = r0, r0 // clear p7
+ shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8)
+ sub sh2 = 64, sh1 // sh2 = 64 - sh1
+ cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+(p6) br.cond.sptk .src_aligned ;;
+ ld8 r[1] = [asrc],8 ;;
+
+ .align 32
+.l2:
+ ld8.s r[0] = [asrc], 8
+ shr.u value = r[1], sh1 ;; // value = w0 >> sh1
+ czx1.r pos = value ;; // do we have an "early" zero
+ cmp.lt p7, p0 = pos, thresh // in w0 >> sh1?
+(p7) br.cond.dpnt .found0
+ chk.s r[0], .recovery2 // it is safe to do that only
+.back2: // after the previous test
+ shl tmp = r[0], sh2 // tmp = w1 << sh2
+ ;;
+ or value = value, tmp ;; // value |= tmp
+ czx1.r pos = value ;;
+ cmp.ne p7, p0 = 8, pos
+(p7) br.cond.dpnt .found0
+ st8 [dest] = value, 8 // store val to dest
+ br.ctop.dptk .l2 ;;
+.src_aligned:
+.l3:
+(p[0]) ld8.s r[0] = [src], 8
+(p[MEMLAT]) chk.s r[MEMLAT], .recovery3
+.back3:
+(p[MEMLAT]) mov value = r[MEMLAT]
+(p[MEMLAT]) czx1.r pos = r[MEMLAT] ;;
+(p[MEMLAT]) cmp.ne p7, p0 = 8, pos
+(p7) br.cond.dpnt .found0
+(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8
+ br.ctop.dptk .l3 ;;
+.found0:
+ mov ar.lc = pos
+.l4:
+ extr.u c = value, 0, 8 // c = value & 0xff
+ shr.u value = value, 8
+ ;;
+ st1 [dest] = c, 1
+ br.cloop.dptk .l4 ;;
+.restore_and_exit:
+ mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 // restore the predicate registers
+ br.ret.sptk.many b0
+.recovery2:
+ add tmp = -8, asrc ;;
+ ld8 r[0] = [tmp]
+ br.cond.sptk .back2
+.recovery3:
+ add tmp = -(MEMLAT + 1) * 8, src ;;
+ ld8 r[MEMLAT] = [tmp]
+ br.cond.sptk .back3
+END(strcpy)
+libc_hidden_def (strcpy)
diff --git a/libc/string/ia64/strlen.S b/libc/string/ia64/strlen.S
new file mode 100644
index 000000000..9b27a2d1b
--- /dev/null
+++ b/libc/string/ia64/strlen.S
@@ -0,0 +1,98 @@
+/* Optimized version of the standard strlen() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the length of the input string
+
+ Input:
+ in0: str
+
+ Look for the null character byte by byte, until we reach a word aligned
+ address, then search word by word, using the czx instruction. We're
+ also doing one word of read ahead, which could cause problems if the
+ null character is on the last word of a page and the next page is not
+ mapped in the process address space. Hence the use of the speculative
+ load.
+
+ This implementation assumes little endian mode. For big endian mode,
+ the instruction czx1.r should be replaced by czx1.l. */
+
+#include "sysdep.h"
+#undef ret
+
+#define saved_lc r18
+#define str r19
+#define pos0 r20
+#define val1 r21
+#define val2 r22
+#define origadd r23
+#define tmp r24
+#define loopcnt r30
+#define len ret0
+
+ENTRY(strlen)
+ .prologue
+ alloc r2 = ar.pfs, 1, 0, 0, 0
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ .body
+ mov str = in0
+ mov len = r0 // len = 0
+ and tmp = 7, in0 // tmp = str % 8
+ ;;
+ sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ cmp.eq p6, p0 = tmp, r0
+(p6) br.cond.sptk .str_aligned;;
+ adds loopcnt = -1, loopcnt;;
+ mov ar.lc = loopcnt
+.l1:
+ ld1 val2 = [str], 1
+ ;;
+ cmp.eq p6, p0 = val2, r0
+(p6) br.cond.spnt .restore_and_exit
+ adds len = 1, len
+ br.cloop.dptk .l1
+.str_aligned:
+ mov origadd = str // origadd = orig
+ ld8 val1 = [str], 8;;
+ nop.b 0
+ nop.b 0
+.l2: ld8.s val2 = [str], 8 // don't bomb out here
+ czx1.r pos0 = val1
+ ;;
+ cmp.ne p6, p0 = 8, pos0
+(p6) br.cond.spnt .foundit
+ chk.s val2, .recovery
+.back:
+ mov val1 = val2
+ br.cond.dptk .l2
+.foundit:
+ sub tmp = str, origadd // tmp = crt address - orig
+ add len = len, pos0;;
+ add len = len, tmp;;
+ adds len = -16, len
+.restore_and_exit:
+ mov ar.lc = saved_lc // restore the loop counter
+ br.ret.sptk.many b0
+.recovery:
+ adds str = -8, str;;
+ ld8 val2 = [str], 8 // bomb out here
+ br.cond.sptk .back
+END(strlen)
+libc_hidden_def (strlen)
diff --git a/libc/string/ia64/strncmp.S b/libc/string/ia64/strncmp.S
new file mode 100644
index 000000000..74011650c
--- /dev/null
+++ b/libc/string/ia64/strncmp.S
@@ -0,0 +1,62 @@
+/* Optimized version of the standard strncmp() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>.
+
+ 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. */
+
+/* Return: the result of the comparison
+
+ Inputs:
+ in0: s1
+ in1: s2
+ in2: n
+
+ Unlike memcmp(), this function is optimized for mismatches within the
+ first few characters. */
+
+#include "sysdep.h"
+#undef ret
+
+#define s1 in0
+#define s2 in1
+#define n in2
+
+#define val1 r15
+#define val2 r16
+
+
+ENTRY(strncmp)
+ alloc r2 = ar.pfs, 3, 0, 0, 0
+ mov ret0 = r0
+ cmp.eq p6, p0 = r0, r0 // set p6
+ cmp.eq p7, p0 = n, r0 // return immediately if n == 0
+(p7) br.cond.spnt .restore_and_exit ;;
+.loop:
+ ld1 val1 = [s1], 1
+ ld1 val2 = [s2], 1
+ adds n = -1, n // n--
+ ;;
+ cmp.ne.and p6, p0 = val1, r0
+ cmp.ne.and p6, p0 = val2, r0
+ cmp.ne.and p6, p0 = n, r0
+ cmp.eq.and p6, p0 = val1, val2
+(p6) br.cond.sptk .loop
+ sub ret0 = val1, val2
+.restore_and_exit:
+ br.ret.sptk.many b0
+END(strncmp)
+libc_hidden_def (strncmp)
diff --git a/libc/string/ia64/strncpy.S b/libc/string/ia64/strncpy.S
new file mode 100644
index 000000000..4f1129350
--- /dev/null
+++ b/libc/string/ia64/strncpy.S
@@ -0,0 +1,232 @@
+/* Optimized version of the standard strncpy() function.
+ This file is part of the GNU C Library.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Contributed by Dan Pop <Dan.Pop@cern.ch>
+ and Jakub Jelinek <jakub@redhat.com>.
+
+ 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. */
+
+/* Return: dest
+
+ Inputs:
+ in0: dest
+ in1: src
+ in2: len
+
+ In this form, it assumes little endian mode.
+ */
+
+#include "sysdep.h"
+#undef ret
+
+#define saved_lc r15
+#define saved_pr r16
+#define thresh r17
+#define dest r18
+#define dest2 r19
+#define src r20
+#define len r21
+#define asrc r22
+#define tmp r23
+#define pos r24
+#define w0 r25
+#define w1 r26
+#define c r27
+#define sh2 r28
+#define sh1 r29
+#define loopcnt r30
+#define value r31
+
+ENTRY(strncpy)
+ .prologue
+ alloc r2 = ar.pfs, 3, 0, 29, 32
+
+#define MEMLAT 2
+ .rotr r[MEMLAT + 2]
+ .rotp p[MEMLAT + 1]
+
+ mov ret0 = in0 // return value = dest
+ .save pr, saved_pr
+ mov saved_pr = pr // save the predicate registers
+ .save ar.lc, saved_lc
+ mov saved_lc = ar.lc // save the loop counter
+ mov ar.ec = 0 // ec is not guaranteed to
+ // be zero upon function entry
+ .body
+ cmp.geu p6, p5 = 24, in2
+(p6) br.cond.spnt .short_len
+ sub tmp = r0, in0 ;; // tmp = -dest
+ mov len = in2 // len
+ mov dest = in0 // dest
+ mov src = in1 // src
+ and tmp = 7, tmp ;; // loopcnt = -dest % 8
+ cmp.eq p6, p7 = tmp, r0
+ adds loopcnt = -1, tmp // --loopcnt
+(p6) br.cond.sptk .dest_aligned ;;
+ sub len = len, tmp // len -= -dest % 8
+ mov ar.lc = loopcnt
+.l1: // copy -dest % 8 bytes
+(p5) ld1 c = [src], 1 // c = *src++
+ ;;
+ st1 [dest] = c, 1 // *dest++ = c
+ cmp.ne p5, p7 = c, r0
+ br.cloop.dptk .l1 ;;
+(p7) br.cond.dpnt .found0_align
+
+.dest_aligned: // p7 should be cleared here
+ shr.u c = len, 3 // c = len / 8
+ and sh1 = 7, src // sh1 = src % 8
+ and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src
+ adds c = (MEMLAT-1), c // c = (len / 8) + MEMLAT - 1
+ sub thresh = 8, sh1
+ mov pr.rot = 1 << 16 // set rotating predicates
+ shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8)
+ mov ar.lc = c // "infinite" loop
+ sub sh2 = 64, sh1 // sh2 = 64 - sh1
+ cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+(p6) br.cond.sptk .src_aligned
+ adds c = -(MEMLAT-1), c ;; // c = (len / 8)
+ ld8 r[1] = [asrc],8
+ mov ar.lc = c ;;
+
+ .align 32
+.l2:
+(p6) st8 [dest] = value, 8 // store val to dest
+ ld8.s r[0] = [asrc], 8
+ shr.u value = r[1], sh1 ;; // value = w0 >> sh1
+ czx1.r pos = value ;; // do we have an "early" zero
+ cmp.lt p7, p0 = pos, thresh // in w0 >> sh1?
+ adds len = -8, len // len -= 8
+(p7) br.cond.dpnt .nonalign_found0
+ chk.s r[0], .recovery2 // it is safe to do that only
+.back2: // after the previous test
+ shl tmp = r[0], sh2 // tmp = w1 << sh2
+ ;;
+ or value = value, tmp ;; // value |= tmp
+ czx1.r pos = value ;;
+ cmp.ne p7, p6 = 8, pos
+(p7) br.cond.dpnt .nonalign_found0
+ br.ctop.dptk .l2 ;;
+ adds len = 8, len
+ br.cond.sptk .not_found0 ;;
+.nonalign_found0:
+ cmp.gtu p6, p0 = -8, len
+(p6) br.cond.dptk .found0
+ adds len = 8, len
+ br.cond.sptk .not_found0 ;;
+
+ .align 32
+.src_aligned:
+.l3:
+(p[0]) ld8.s r[0] = [src], 8
+(p[MEMLAT]) chk.s r[MEMLAT], .recovery3
+.back3:
+(p[MEMLAT]) mov value = r[MEMLAT]
+(p[MEMLAT]) czx1.r pos = r[MEMLAT] ;;
+(p[MEMLAT]) cmp.ne p7, p0 = 8, pos
+(p[MEMLAT]) adds len = -8, len // len -= 8
+(p7) br.cond.dpnt .found0
+(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8
+ br.ctop.dptk .l3 ;;
+
+ chk.s r[MEMLAT-1], .recovery4
+.back4:
+ mov value = r[MEMLAT-1]
+
+.not_found0:
+ cmp.eq p5, p6 = len, r0
+ adds len = -1, len
+(p5) br.cond.dptk .restore_and_exit ;;
+ mov ar.lc = len
+.l4:
+(p6) extr.u c = value, 0, 8 // c = value & 0xff
+(p6) shr.u value = value, 8 ;;
+ st1 [dest] = c, 1
+ cmp.ne p6, p0 = c, r0
+ br.cloop.dptk .l4
+ br.cond.sptk .restore_and_exit
+
+.found0_align:
+ mov pos = 0
+ adds len = -8, len
+ mov value = 0 ;;
+.found0:
+ shl tmp = pos, 3
+ shr.u loopcnt = len, 4 // loopcnt = len / 16
+ mov c = -1 ;;
+ cmp.eq p6, p0 = loopcnt, r0
+ adds loopcnt = -1, loopcnt
+ shl c = c, tmp ;;
+ and len = 0xf, len
+ andcm value = value, c
+ mov ar.lc = loopcnt ;;
+ cmp.le p7, p0 = 8, len
+ adds dest2 = 16, dest
+ st8 [dest] = value, 8
+ and len = 0x7, len
+(p6) br.cond.dpnt .l6 ;;
+.l5:
+ st8 [dest] = r0, 16
+ st8 [dest2] = r0, 16
+ br.cloop.dptk .l5 ;;
+.l6:
+(p7) st8 [dest] = r0, 8
+ cmp.eq p5, p0 = len, r0
+ adds len = -1, len
+(p5) br.cond.dptk .restore_and_exit ;;
+ mov ar.lc = len ;;
+.l7:
+ st1 [dest] = r0, 1
+ br.cloop.dptk .l7 ;;
+.restore_and_exit:
+ mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 // restore the predicate registers
+ br.ret.sptk.many b0
+
+.short_len:
+ cmp.eq p5, p0 = in2, r0
+ adds loopcnt = -1, in2
+(p5) br.cond.spnt .restore_and_exit ;;
+ mov ar.lc = loopcnt // p6 should be set when we get here
+.l8:
+(p6) ld1 c = [in1], 1 // c = *src++
+ ;;
+ st1 [in0] = c, 1 // *dest++ = c
+(p6) cmp.ne p6, p0 = c, r0
+ br.cloop.dptk .l8
+ ;;
+ mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 // restore the predicate registers
+ br.ret.sptk.many b0
+.recovery2:
+ add c = 8, len
+ add tmp = -8, asrc ;;
+ cmp.gtu p8, p5 = c, thresh ;;
+(p8) ld8 r[0] = [tmp]
+(p5) mov r[0] = r0
+ br.cond.sptk .back2
+.recovery3:
+ add tmp = -(MEMLAT + 1) * 8, src ;;
+ ld8 r[MEMLAT] = [tmp]
+ br.cond.sptk .back3
+.recovery4:
+ cmp.eq p5, p6 = len, r0
+ add tmp = -MEMLAT * 8, src ;;
+(p6) ld8 r[MEMLAT - 1] = [tmp]
+(p5) mov r[MEMLAT - 1] = r0
+ br.cond.sptk .back4
+END(strncpy)
+libc_hidden_def (strncpy)
diff --git a/libc/string/ia64/sysdep.h b/libc/string/ia64/sysdep.h
new file mode 100644
index 000000000..03e74360d
--- /dev/null
+++ b/libc/string/ia64/sysdep.h
@@ -0,0 +1,168 @@
+/* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
+ Based on code originally written by David Mosberger-Tang
+
+ 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 _LINUX_IA64_SYSDEP_H
+#define _LINUX_IA64_SYSDEP_H 1
+
+#include <features.h>
+#include <asm/unistd.h>
+
+#ifdef __ASSEMBLER__
+
+/* Macros to help writing .prologue directives in assembly code. */
+#define ASM_UNW_PRLG_RP 0x8
+#define ASM_UNW_PRLG_PFS 0x4
+#define ASM_UNW_PRLG_PSP 0x2
+#define ASM_UNW_PRLG_PR 0x1
+#define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
+
+#ifdef __STDC__
+#define C_LABEL(name) name##:
+#else
+#define C_LABEL(name) name/**/:
+#endif
+
+#define CALL_MCOUNT
+
+#define ENTRY(name) \
+ .text; \
+ .align 32; \
+ .proc C_SYMBOL_NAME(name); \
+ .global C_SYMBOL_NAME(name); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#define LEAF(name) \
+ .text; \
+ .align 32; \
+ .proc C_SYMBOL_NAME(name); \
+ .global name; \
+ C_LABEL(name)
+
+/* Mark the end of function SYM. */
+#undef END
+#define END(sym) .endp C_SYMBOL_NAME(sym)
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+/* Linux uses a negative return value to indicate syscall errors, unlike
+ most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be negative
+ even if the call succeeded. E.g., the `lseek' system call might return
+ a large offset. Therefore we must not anymore test for < 0, but test
+ for a real error by making sure the value in %d0 is a real error
+ number. Linus said he will make sure the no syscall returns a value
+ in -1 .. -4095 as a valid result so we can savely test with -4095. */
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#define SYSCALL_ERROR_LABEL __syscall_error
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY(name) \
+ DO_CALL (SYS_ify(syscall_name)); \
+ cmp.eq p6,p0=-1,r10; \
+(p6) br.cond.spnt.few __syscall_error;
+
+#define DO_CALL_VIA_BREAK(num) \
+ mov r15=num; \
+ break __BREAK_SYSCALL
+
+#ifdef IA64_USE_NEW_STUB
+# ifdef SHARED
+# define DO_CALL(num) \
+ .prologue; \
+ adds r2 = SYSINFO_OFFSET, r13;; \
+ ld8 r2 = [r2]; \
+ .save ar.pfs, r11; \
+ mov r11 = ar.pfs;; \
+ .body; \
+ mov r15 = num; \
+ mov b7 = r2; \
+ br.call.sptk.many b6 = b7;; \
+ .restore sp; \
+ mov ar.pfs = r11; \
+ .prologue; \
+ .body
+# else /* !SHARED */
+# define DO_CALL(num) \
+ .prologue; \
+ mov r15 = num; \
+ movl r2 = _dl_sysinfo;; \
+ ld8 r2 = [r2]; \
+ .save ar.pfs, r11; \
+ mov r11 = ar.pfs;; \
+ .body; \
+ mov b7 = r2; \
+ br.call.sptk.many b6 = b7;; \
+ .restore sp; \
+ mov ar.pfs = r11; \
+ .prologue; \
+ .body
+# endif
+#else
+# define DO_CALL(num) DO_CALL_VIA_BREAK(num)
+#endif
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ ENTRY(name) \
+ DO_CALL (SYS_ify(syscall_name));
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
+
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ ENTRY(name) \
+ DO_CALL (SYS_ify(syscall_name)); \
+ cmp.eq p6,p0=-1,r10; \
+(p6) mov r10=r8;
+
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
+
+#undef END
+#define END(name) \
+ .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
+ .endp C_SYMBOL_NAME(name)
+
+#define ret br.ret.sptk.few b0
+#define ret_NOERRNO ret
+#define ret_ERRVAL ret
+
+#endif /* not __ASSEMBLER__ */
+
+#endif /* linux/ia64/sysdep.h */
diff --git a/libc/string/memccpy.c b/libc/string/memccpy.c
index 81d20b19c..fe5a76a4d 100644
--- a/libc/string/memccpy.c
+++ b/libc/string/memccpy.c
@@ -9,7 +9,7 @@
#include "_string.h"
-void attribute_hidden *__memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n)
+void *memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n)
{
register char *r1 = s1;
register const char *r2 = s2;
@@ -18,5 +18,3 @@ void attribute_hidden *__memccpy(void * __restrict s1, const void * __restrict s
return (n == (size_t) -1) ? NULL : r1;
}
-
-strong_alias(__memccpy,memccpy)
diff --git a/libc/string/memchr.c b/libc/string/memchr.c
index 288bd9748..413999722 100644
--- a/libc/string/memchr.c
+++ b/libc/string/memchr.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmemchr __wmemchr
# define Wmemchr wmemchr
#else
-# define __Wmemchr __memchr
# define Wmemchr memchr
#endif
-Wvoid attribute_hidden *__Wmemchr(const Wvoid *s, Wint c, size_t n)
+libc_hidden_proto(Wmemchr)
+
+Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
{
register const Wuchar *r = (const Wuchar *) s;
#ifdef __BCC__
@@ -37,4 +37,4 @@ Wvoid attribute_hidden *__Wmemchr(const Wvoid *s, Wint c, size_t n)
}
#undef np
-strong_alias(__Wmemchr,Wmemchr)
+libc_hidden_def(Wmemchr)
diff --git a/libc/string/memcmp.c b/libc/string/memcmp.c
index 9808b3785..9de28c234 100644
--- a/libc/string/memcmp.c
+++ b/libc/string/memcmp.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmemcmp __wmemcmp
# define Wmemcmp wmemcmp
#else
-# define __Wmemcmp __memcmp
+libc_hidden_proto(memcmp)
# define Wmemcmp memcmp
#endif
-int attribute_hidden __Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n)
+int Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n)
{
register const Wuchar *r1 = (const Wuchar *) s1;
register const Wuchar *r2 = (const Wuchar *) s2;
@@ -37,7 +36,7 @@ int attribute_hidden __Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n)
#endif
}
-strong_alias(__Wmemcmp,Wmemcmp)
#ifndef WANT_WIDE
-strong_alias(__memcmp,bcmp)
+libc_hidden_def(memcmp)
+strong_alias(memcmp,bcmp)
#endif
diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c
index abfe1b4ef..dc2986778 100644
--- a/libc/string/memcpy.c
+++ b/libc/string/memcpy.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmemcpy __wmemcpy
# define Wmemcpy wmemcpy
#else
-# define __Wmemcpy __memcpy
# define Wmemcpy memcpy
#endif
-Wvoid attribute_hidden *__Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
+libc_hidden_proto(Wmemcpy)
+
+Wvoid *Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
{
register Wchar *r1 = s1;
register const Wchar *r2 = s2;
@@ -33,5 +33,4 @@ Wvoid attribute_hidden *__Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restric
return s1;
}
-
-strong_alias(__Wmemcpy,Wmemcpy)
+libc_hidden_def(Wmemcpy)
diff --git a/libc/string/memmem.c b/libc/string/memmem.c
index a42176181..f57733c4a 100644
--- a/libc/string/memmem.c
+++ b/libc/string/memmem.c
@@ -7,7 +7,7 @@
#include "_string.h"
-void attribute_hidden *__memmem(const void *haystack, size_t haystacklen,
+void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen)
{
register const char *ph;
@@ -36,5 +36,3 @@ void attribute_hidden *__memmem(const void *haystack, size_t haystacklen,
return NULL;
}
-
-strong_alias(__memmem,memmem)
diff --git a/libc/string/memmove.c b/libc/string/memmove.c
index 9e50cf5a9..3cdcca116 100644
--- a/libc/string/memmove.c
+++ b/libc/string/memmove.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmemmove __wmemmove
# define Wmemmove wmemmove
#else
-# define __Wmemmove __memmove
+libc_hidden_proto(memmove)
# define Wmemmove memmove
#endif
-Wvoid attribute_hidden *__Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
+Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
{
#ifdef __BCC__
register Wchar *s = (Wchar *) s1;
@@ -54,4 +53,6 @@ Wvoid attribute_hidden *__Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
#endif
}
-strong_alias(__Wmemmove,Wmemmove)
+#ifndef WANT_WIDE
+libc_hidden_def(Wmemmove)
+#endif
diff --git a/libc/string/mempcpy.c b/libc/string/mempcpy.c
index aed37d03a..70626f24a 100644
--- a/libc/string/mempcpy.c
+++ b/libc/string/mempcpy.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmempcpy __wmempcpy
# define Wmempcpy wmempcpy
#else
-# define __Wmempcpy __mempcpy
# define Wmempcpy mempcpy
#endif
-Wvoid attribute_hidden *__Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
+libc_hidden_proto(Wmempcpy)
+
+Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
{
register Wchar *r1 = s1;
register const Wchar *r2 = s2;
@@ -34,4 +34,4 @@ Wvoid attribute_hidden *__Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restri
return r1;
}
-strong_alias(__Wmempcpy,Wmempcpy)
+libc_hidden_def(Wmempcpy)
diff --git a/libc/string/memrchr.c b/libc/string/memrchr.c
index fb696bc6d..0bb67b2e5 100644
--- a/libc/string/memrchr.c
+++ b/libc/string/memrchr.c
@@ -7,7 +7,9 @@
#include "_string.h"
-void attribute_hidden *__memrchr(const void *s, int c, size_t n)
+libc_hidden_proto(memrchr)
+
+void *memrchr(const void *s, int c, size_t n)
{
register const unsigned char *r;
#ifdef __BCC__
@@ -30,4 +32,4 @@ void attribute_hidden *__memrchr(const void *s, int c, size_t n)
}
#undef np
-strong_alias(__memrchr,memrchr)
+libc_hidden_def(memrchr)
diff --git a/libc/string/memset.c b/libc/string/memset.c
index cb97dbce8..2f3fc271d 100644
--- a/libc/string/memset.c
+++ b/libc/string/memset.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wmemset __wmemset
# define Wmemset wmemset
#else
-# define __Wmemset __memset
+libc_hidden_proto(memset)
# define Wmemset memset
#endif
-Wvoid attribute_hidden *__Wmemset(Wvoid *s, Wint c, size_t n)
+Wvoid *Wmemset(Wvoid *s, Wint c, size_t n)
{
register Wuchar *p = (Wuchar *) s;
#ifdef __BCC__
@@ -34,4 +33,6 @@ Wvoid attribute_hidden *__Wmemset(Wvoid *s, Wint c, size_t n)
}
#undef np
-strong_alias(__Wmemset,Wmemset)
+#ifndef WANT_WIDE
+libc_hidden_def(memset)
+#endif
diff --git a/libc/string/mips/Makefile b/libc/string/mips/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/mips/Makefile
+++ b/libc/string/mips/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/mips/Makefile.arch b/libc/string/mips/Makefile.arch
deleted file mode 100644
index a110c291e..000000000
--- a/libc/string/mips/Makefile.arch
+++ /dev/null
@@ -1,26 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-SSRC:=memcpy.S memset.S
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/mips
-STRING_ARCH_OUT:=$(top_builddir)libc/string/mips
-
-STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC))
-STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S
index 991b44eb4..155bc1128 100644
--- a/libc/string/mips/memcpy.S
+++ b/libc/string/mips/memcpy.S
@@ -17,8 +17,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <sysdep.h>
+#include <features.h>
+/*#include <sysdep.h>*/
#include <endian.h>
+#include "sysdep.h"
#ifdef __mips64
#error mips32 code being compiled for mips64!
@@ -38,7 +40,7 @@
# define SWLO swl /* low part is left in little-endian */
#endif
-ENTRY (__memcpy)
+ENTRY (memcpy)
.set noreorder
slti t0, a2, 8 # Less than 8?
@@ -135,6 +137,6 @@ L(shfth):
move a2, t0
.set reorder
-END (__memcpy)
+END (memcpy)
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S
index 8e814a49b..9169ad58a 100644
--- a/libc/string/mips/memset.S
+++ b/libc/string/mips/memset.S
@@ -17,8 +17,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <sysdep.h>
+#include <features.h>
+/*#include <sysdep.h>*/
#include <endian.h>
+#include "sysdep.h"
#ifdef __mips64
#error mips32 code being compiled for mips64!
@@ -32,7 +34,7 @@
# define SWHI swr /* high part is right in little-endian */
#endif
-ENTRY (__memset)
+ENTRY (memset)
.set noreorder
slti t1, a2, 8 # Less than 8?
@@ -85,6 +87,6 @@ L(exit):
nop
.set reorder
-END (__memset)
+END (memset)
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/mips/sysdep.h b/libc/string/mips/sysdep.h
new file mode 100644
index 000000000..96f088c94
--- /dev/null
+++ b/libc/string/mips/sysdep.h
@@ -0,0 +1,45 @@
+/* Adapted from glibc's sysdeps/unix/mips/sysdep.h */
+
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ 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. */
+
+#ifdef __ASSEMBLER__
+
+#include <sgidefs.h>
+#include <sys/regdef.h>
+
+#define ENTRY(name) \
+ .globl name; \
+ .align 2; \
+ .ent name,0; \
+ name##:
+
+#undef END
+#define END(function) \
+ .end function; \
+ .size function,.-function
+
+#if _MIPS_SIM == _MIPS_SIM_ABI32 || _MIPS_SIM == _MIPS_SIM_ABIO64
+# define L(label) $L ## label
+#else
+# define L(label) .L ## label
+#endif
+
+#endif
diff --git a/libc/string/powerpc/Makefile b/libc/string/powerpc/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/powerpc/Makefile
+++ b/libc/string/powerpc/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/powerpc/Makefile.arch b/libc/string/powerpc/Makefile.arch
deleted file mode 100644
index 47a8dac1d..000000000
--- a/libc/string/powerpc/Makefile.arch
+++ /dev/null
@@ -1,24 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/powerpc
-STRING_ARCH_OUT:=$(top_builddir)libc/string/powerpc
-
-STRING_ARCH_CSRC:=$(wildcard $(STRING_ARCH_DIR)/*.c)
-STRING_ARCH_COBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_CSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_COBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_CSRC)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/powerpc/memcpy.c b/libc/string/powerpc/memcpy.c
index 5af96869b..ed8022313 100644
--- a/libc/string/powerpc/memcpy.c
+++ b/libc/string/powerpc/memcpy.c
@@ -21,7 +21,8 @@
#include <string.h>
-void attribute_hidden *__memcpy(void *to, const void *from, size_t n)
+libc_hidden_proto(memcpy)
+void *memcpy(void *to, const void *from, size_t n)
/* PPC can do pre increment and load/store, but not post increment and load/store.
Therefore use *++ptr instead of *ptr++. */
{
@@ -76,5 +77,4 @@ void attribute_hidden *__memcpy(void *to, const void *from, size_t n)
goto copy_chunks;
goto lessthan8;
}
-
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/powerpc/memmove.c b/libc/string/powerpc/memmove.c
index 1d513a966..327161116 100644
--- a/libc/string/powerpc/memmove.c
+++ b/libc/string/powerpc/memmove.c
@@ -21,14 +21,17 @@
#include <string.h>
-void attribute_hidden *__memmove(void *to, const void *from, size_t n)
+libc_hidden_proto(memcpy)
+
+libc_hidden_proto(memmove)
+void *memmove(void *to, const void *from, size_t n)
{
unsigned long rem, chunks, tmp1, tmp2;
unsigned char *tmp_to;
unsigned char *tmp_from = (unsigned char *)from;
if (tmp_from >= (unsigned char *)to)
- return __memcpy(to, from, n);
+ return memcpy(to, from, n);
chunks = n / 8;
tmp_from += n;
tmp_to = to + n;
@@ -72,5 +75,4 @@ void attribute_hidden *__memmove(void *to, const void *from, size_t n)
goto copy_chunks;
goto lessthan8;
}
-
-strong_alias(__memmove,memmove)
+libc_hidden_def(memmove)
diff --git a/libc/string/powerpc/memset.c b/libc/string/powerpc/memset.c
index f6cda9579..891e0b8aa 100644
--- a/libc/string/powerpc/memset.c
+++ b/libc/string/powerpc/memset.c
@@ -21,6 +21,8 @@
#include <string.h>
+libc_hidden_proto(memset)
+
static inline int expand_byte_word(int c){
/* this does:
c = c << 8 | c;
@@ -32,7 +34,7 @@ static inline int expand_byte_word(int c){
return c;
}
-void attribute_hidden *__memset(void *to, int c, size_t n)
+void *memset(void *to, int c, size_t n)
{
unsigned long rem, chunks;
unsigned char *tmp_to;
@@ -78,5 +80,4 @@ void attribute_hidden *__memset(void *to, int c, size_t n)
goto copy_chunks;
goto lessthan8;
}
-
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/psignal.c b/libc/string/psignal.c
index b6d6a30c0..a852e6047 100644
--- a/libc/string/psignal.c
+++ b/libc/string/psignal.c
@@ -8,8 +8,11 @@
#include <features.h>
#include <stdio.h>
#include <string.h>
+#include <signal.h>
-extern char *__strsignal (int __sig) __THROW attribute_hidden;
+libc_hidden_proto(fprintf)
+libc_hidden_proto(strsignal)
+libc_hidden_proto(stderr)
/* TODO: make this threadsafe with a reentrant version of strsignal? */
@@ -26,5 +29,5 @@ void psignal(int signum, register const char *message)
message = (sep += 2); /* or passed an empty string. */
}
- fprintf(stderr, "%s%s%s\n", message, sep, __strsignal(signum));
+ fprintf(stderr, "%s%s%s\n", message, sep, strsignal(signum));
}
diff --git a/libc/string/rawmemchr.c b/libc/string/rawmemchr.c
index 81d578a0f..754a34e18 100644
--- a/libc/string/rawmemchr.c
+++ b/libc/string/rawmemchr.c
@@ -7,7 +7,9 @@
#include "_string.h"
-void attribute_hidden *__rawmemchr(const void *s, int c)
+libc_hidden_proto(rawmemchr)
+
+void *rawmemchr(const void *s, int c)
{
register const unsigned char *r = s;
@@ -15,5 +17,4 @@ void attribute_hidden *__rawmemchr(const void *s, int c)
return (void *) r; /* silence the warning */
}
-
-strong_alias(__rawmemchr,rawmemchr)
+libc_hidden_def(rawmemchr)
diff --git a/libc/string/sh64/Makefile b/libc/string/sh64/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/sh64/Makefile
+++ b/libc/string/sh64/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/sh64/Makefile.arch b/libc/string/sh64/Makefile.arch
deleted file mode 100644
index f246864f6..000000000
--- a/libc/string/sh64/Makefile.arch
+++ /dev/null
@@ -1,27 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-SSRC:=memcpy.S memset.S strcpy.S strlen.S
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/sh64
-STRING_ARCH_OUT:=$(top_builddir)libc/string/sh64
-
-STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC))
-STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/sh64/memcpy.S b/libc/string/sh64/memcpy.S
index d74980613..3c0ea0c0d 100644
--- a/libc/string/sh64/memcpy.S
+++ b/libc/string/sh64/memcpy.S
@@ -39,12 +39,11 @@
#include <features.h>
.section .text..SHmedia32,"ax"
- .globl __memcpy
- .hidden __memcpy
- .type __memcpy, @function
+ .globl memcpy
+ .type memcpy, @function
.align 5
-__memcpy:
+memcpy:
#define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1
#define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1
@@ -201,6 +200,6 @@ Loop_ua:
stlo.q r5, 8, r1
blink tr1, r63
- .size __memcpy,.-__memcpy
+ .size memcpy,.-memcpy
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/sh64/memset.S b/libc/string/sh64/memset.S
index cd2ad7998..f588323f0 100644
--- a/libc/string/sh64/memset.S
+++ b/libc/string/sh64/memset.S
@@ -21,13 +21,12 @@
#endif
.section .text..SHmedia32,"ax"
- .globl __memset
- .hidden __memset
- .type __memset, @function
+ .globl memset
+ .type memset, @function
.align 5
-__memset:
+memset:
pta/l multiquad, tr0
andi r2, 7, r22
ptabs r18, tr2
@@ -92,6 +91,6 @@ loop:
sthi.q r5, -1, r3
blink tr2,r63
- .size __memset,.-__memset
+ .size memset,.-memset
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
diff --git a/libc/string/sh64/strcpy.S b/libc/string/sh64/strcpy.S
index 2ce998257..da79d5143 100644
--- a/libc/string/sh64/strcpy.S
+++ b/libc/string/sh64/strcpy.S
@@ -18,12 +18,11 @@
#endif
.section .text..SHmedia32,"ax"
- .globl __strcpy
- .hidden __strcpy
- .type __strcpy, @function
+ .globl strcpy
+ .type strcpy, @function
.align 5
-__strcpy:
+strcpy:
pta/l shortstring,tr1
ldlo.q r3,0,r4
@@ -98,6 +97,6 @@ loop:
addi r0, 8, r0
blink tr1, r63 // shortstring
- .size __strcpy,.-__strcpy
+ .size strcpy,.-strcpy
-strong_alias(__strcpy,strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/sh64/strlen.S b/libc/string/sh64/strlen.S
index 673a34dbd..18f4164ff 100644
--- a/libc/string/sh64/strlen.S
+++ b/libc/string/sh64/strlen.S
@@ -33,12 +33,11 @@
#include <features.h>
.section .text..SHmedia32,"ax"
- .globl __strlen
- .hidden __strlen
- .type __strlen,@function
+ .globl strlen
+ .type strlen,@function
.balign 16
-__strlen:
+strlen:
ptabs r18, tr4
/*
@@ -59,6 +58,6 @@ loop:
or r0, r63, r2
blink tr4, r63
- .size __strlen,.-__strlen
+ .size strlen,.-strlen
-strong_alias(__strlen,strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/sparc/Makefile b/libc/string/sparc/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/sparc/Makefile
+++ b/libc/string/sparc/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/sparc/Makefile.arch b/libc/string/sparc/Makefile.arch
deleted file mode 100644
index 1acd93ad9..000000000
--- a/libc/string/sparc/Makefile.arch
+++ /dev/null
@@ -1,28 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/sparc
-STRING_ARCH_OUT:=$(top_builddir)libc/string/sparc
-
-STRING_ARCH_SRC:=$(wildcard $(STRING_ARCH_DIR)/*.c)
-STRING_ARCH_OBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC))
-
-STRING_ARCH_SSRC:=$(wildcard $(STRING_ARCH_DIR)/*.S)
-STRING_ARCH_SOBJ:=$(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SRC)
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SOBJ)
-
-objclean-y+=string_arch_objclean
-
-string_arch_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/sparc/_glibc_inc.h b/libc/string/sparc/_glibc_inc.h
index 6ef1dbde6..4eb4d755c 100644
--- a/libc/string/sparc/_glibc_inc.h
+++ b/libc/string/sparc/_glibc_inc.h
@@ -14,7 +14,6 @@
#define ENTRY(sym) \
.global sym; \
- .hidden sym; \
.align ENTRY_ALIGN; \
.type sym,%function; \
sym:
diff --git a/libc/string/sparc/sparc32/memchr.S b/libc/string/sparc/sparc32/memchr.S
index e012844ba..4d57a553b 100644
--- a/libc/string/sparc/sparc32/memchr.S
+++ b/libc/string/sparc/sparc32/memchr.S
@@ -63,7 +63,7 @@
1: retl
sub %o0, 1, %o0
-ENTRY(__memchr)
+ENTRY(memchr)
andcc %o1, 0xff, %o1
sll %o1, 8, %g6
andcc %o0, 3, %g0
@@ -136,9 +136,9 @@ ENTRY(__memchr)
sub %o0, 3, %o0
4: retl
sub %o0, 4, %o0
-END(__memchr)
-strong_alias(__memchr,memchr)
+END(memchr)
+libc_hidden_def(memchr)
#if !__BOUNDED_POINTERS__
-weak_alias(__memchr,__ubp_memchr)
+weak_alias(memchr,__ubp_memchr)
#endif
diff --git a/libc/string/sparc/sparc32/memcpy.S b/libc/string/sparc/sparc32/memcpy.S
index a1dd246e6..fb79a601a 100644
--- a/libc/string/sparc/sparc32/memcpy.S
+++ b/libc/string/sparc/sparc32/memcpy.S
@@ -161,14 +161,13 @@
b 3f
sub %o0, 2, %o0
-ENTRY(__bcopy)
+ENTRY(bcopy)
mov %o0, %o3
mov %o1, %o0
mov %o3, %o1
-END(__bcopy)
-strong_alias(__bcopy,bcopy)
+END(bcopy)
-ENTRY(__memmove)
+ENTRY(memmove)
cmp %o0, %o1
st %o0, [%sp + 64]
bleu 9f
@@ -448,10 +447,10 @@ ENTRY(__memmove)
sub %o2, 2, %o2
b 3f
add %o0, 2, %o0
-END(__memmove)
-strong_alias(__memmove,memmove)
+END(memmove)
+libc_hidden_def(memmove)
-ENTRY(__memcpy) /* %o0=dst %o1=src %o2=len */
+ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
sub %o0, %o1, %o4
st %o0, [%sp + 64]
9: andcc %o4, 3, %o5
@@ -966,5 +965,5 @@ ENTRY(__memcpy) /* %o0=dst %o1=src %o2=len */
sub %o7, %o4, %o5
110: retl
sub %o7, %g6, %o5
-END(__memcpy)
-strong_alias(__memcpy,memcpy)
+END(memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/sparc/sparc32/memset.S b/libc/string/sparc/sparc32/memset.S
index b60b881be..d5e1350f2 100644
--- a/libc/string/sparc/sparc32/memset.S
+++ b/libc/string/sparc/sparc32/memset.S
@@ -43,7 +43,7 @@
.text
.align 4
-ENTRY(__bzero)
+ENTRY(bzero)
b 1f
mov %g0, %g3
@@ -60,10 +60,9 @@ ENTRY(__bzero)
add %o1, %o2, %o1
b 4f
sub %o0, %o2, %o0
-END(__bzero)
-strong_alias(__bzero,bzero)
+END(bzero)
-ENTRY(__memset)
+ENTRY(memset)
and %o1, 0xff, %g3
sll %g3, 8, %g2
or %g3, %g2, %g3
@@ -148,5 +147,5 @@ ENTRY(__memset)
stb %g3, [%o0 + 6]
0: retl
nop
-END(__memset)
-strong_alias(__memset,memset)
+END(memset)
+libc_hidden_def(memset)
diff --git a/libc/string/sparc/sparc32/stpcpy.S b/libc/string/sparc/sparc32/stpcpy.S
index 26d2fecbd..daf116eb1 100644
--- a/libc/string/sparc/sparc32/stpcpy.S
+++ b/libc/string/sparc/sparc32/stpcpy.S
@@ -65,7 +65,7 @@
1: retl
add %o0, -1, %o0
-ENTRY(__stpcpy)
+ENTRY(stpcpy)
andcc %o1, 3, %g0
bne 10b
sethi %hi(0x80808080), %o4
@@ -156,6 +156,6 @@ ENTRY(__stpcpy)
add %o0, 1, %o0
19: retl
nop
-END(__stpcpy)
+END(stpcpy)
-strong_alias(__stpcpy,stpcpy)
+libc_hidden_def(stpcpy)
diff --git a/libc/string/sparc/sparc32/strcat.S b/libc/string/sparc/sparc32/strcat.S
index 2ee630b23..eda029a16 100644
--- a/libc/string/sparc/sparc32/strcat.S
+++ b/libc/string/sparc/sparc32/strcat.S
@@ -91,7 +91,7 @@
b 3f
sub %o0, 1, %o0
-ENTRY(__strcat)
+ENTRY(strcat)
mov %o0, %g2
andcc %o0, 3, %g0
bne 11b
@@ -343,6 +343,6 @@ ENTRY(__strcat)
srl %o5, 16, %o4
retl
mov %g2, %o0
-END(__strcat)
+END(strcat)
-strong_alias(__strcat,strcat)
+libc_hidden_def(strcat)
diff --git a/libc/string/sparc/sparc32/strchr.S b/libc/string/sparc/sparc32/strchr.S
index 69360c53a..d06bbe3cc 100644
--- a/libc/string/sparc/sparc32/strchr.S
+++ b/libc/string/sparc/sparc32/strchr.S
@@ -67,7 +67,7 @@
1: retl
sub %o0, 1, %o0
-ENTRY(__strchr)
+ENTRY(strchr)
andcc %o1, 0xff, %o1
be 12f
sll %o1, 8, %o2
@@ -215,11 +215,11 @@ ENTRY(__strchr)
1: or %o4, %lo(0x01010101), %o2
b 7f
ld [%o0], %g4
-END(__strchr)
-strong_alias(__strchr,strchr)
-strong_alias(__strchr,index)
+END(strchr)
+libc_hidden_def(strchr)
+strong_alias(strchr,index)
-ENTRY(__strrchr)
+ENTRY(strrchr)
andcc %o1, 0xff, %o1
clr %o5
be 12b
@@ -276,6 +276,6 @@ ENTRY(__strrchr)
ld [%o0], %g4
9: retl
mov %o5, %o0
-END(__strrchr)
-strong_alias(__strrchr,strrchr)
-strong_alias(__strrchr,rindex)
+END(strrchr)
+libc_hidden_def(strrchr)
+strong_alias(strrchr,rindex)
diff --git a/libc/string/sparc/sparc32/strcmp.S b/libc/string/sparc/sparc32/strcmp.S
index 6a807e08a..d43883de6 100644
--- a/libc/string/sparc/sparc32/strcmp.S
+++ b/libc/string/sparc/sparc32/strcmp.S
@@ -74,7 +74,7 @@
2: retl
mov %o4, %o0
-ENTRY(__strcmp)
+ENTRY(strcmp)
andcc %o0, 3, %g0
bne 10b
sethi %hi(0x80808080), %g1
@@ -252,6 +252,5 @@ ENTRY(__strcmp)
ld [%i0], %i4
jmpl %i7 + 8, %g0
restore %g4, %g0, %o0
-END(__strcmp)
-
-strong_alias(__strcmp,strcmp)
+END(strcmp)
+libc_hidden_def(strcmp)
diff --git a/libc/string/sparc/sparc32/strcpy.S b/libc/string/sparc/sparc32/strcpy.S
index ab57e00a5..4d7742ebc 100644
--- a/libc/string/sparc/sparc32/strcpy.S
+++ b/libc/string/sparc/sparc32/strcpy.S
@@ -63,7 +63,7 @@
b 6f
andcc %o0, 3, %g3
-ENTRY(__strcpy)
+ENTRY(strcpy)
mov %o0, %g2
andcc %o1, 3, %g0
bne 1b
@@ -269,6 +269,5 @@ ENTRY(__strcpy)
srl %o5, 16, %o4
retl
mov %g2, %o0
-END(__strcpy)
-
-strong_alias(__strcpy,strcpy)
+END(strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/sparc/sparc32/strlen.S b/libc/string/sparc/sparc32/strlen.S
index 81beb7f62..4edfe7e78 100644
--- a/libc/string/sparc/sparc32/strlen.S
+++ b/libc/string/sparc/sparc32/strlen.S
@@ -63,7 +63,7 @@
3: retl
mov 2, %o0
-ENTRY(__strlen)
+ENTRY(strlen)
mov %o0, %o1
andcc %o0, 3, %g0
bne 10b
@@ -98,6 +98,5 @@ ENTRY(__strlen)
add %o4, 1, %o4
13: retl
sub %o4, %o1, %o0
-END(__strlen)
-
-strong_alias(__strlen,strlen)
+END(strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/sparc/sparc64/memchr.S b/libc/string/sparc/sparc64/memchr.S
index 7017b5540..6096cc218 100644
--- a/libc/string/sparc/sparc64/memchr.S
+++ b/libc/string/sparc/sparc64/memchr.S
@@ -54,7 +54,7 @@
.text
.align 32
-ENTRY(__memchr)
+ENTRY(memchr)
and %o1, 0xff, %o1 /* IEU0 Group */
#ifdef USE_BPR
brz,pn %o2, 12f /* CTI+IEU1 */
@@ -253,9 +253,9 @@ ENTRY(__memchr)
23: retl /* CTI+IEU1 Group */
add %o0, -1, %o0 /* IEU0 */
-END(__memchr)
+END(memchr)
-strong_alias(__memchr,memchr)
+libc_hidden_def(memchr)
#if !__BOUNDED_POINTERS__
-weak_alias(__memchr,__ubp_memchr)
+weak_alias(memchr,__ubp_memchr)
#endif
diff --git a/libc/string/sparc/sparc64/memcpy.S b/libc/string/sparc/sparc64/memcpy.S
index 4201b5ec2..2fdff7b52 100644
--- a/libc/string/sparc/sparc64/memcpy.S
+++ b/libc/string/sparc/sparc64/memcpy.S
@@ -191,7 +191,7 @@
.text
.align 32
-ENTRY(__bcopy)
+ENTRY(bcopy)
sub %o1, %o0, %o4 /* IEU0 Group */
mov %o0, %g3 /* IEU1 */
cmp %o4, %o2 /* IEU1 Group */
@@ -205,8 +205,7 @@ ENTRY(__bcopy)
add %o0, %o2, %o0 /* IEU0 */
retl
nop
-END(__bcopy)
-strong_alias(__bcopy,bcopy)
+END(bcopy)
.align 32
200: be,pt %xcc, 201f /* CTI */
@@ -504,7 +503,7 @@ END(__align_cpy_16)
#endif
.align 32
-ENTRY(__memcpy)
+ENTRY(memcpy)
210:
#ifndef USE_BPR
srl %o2, 0, %o2 /* IEU1 Group */
@@ -695,8 +694,8 @@ ENTRY(__memcpy)
214: wr %g0, FPRS_FEF, %fprs
retl
mov %g4, %o0
-END(__memcpy)
-strong_alias(__memcpy,memcpy)
+END(memcpy)
+libc_hidden_def(memcpy)
.align 32
228: andcc %o2, 1, %g0 /* IEU1 Group */
@@ -721,7 +720,7 @@ strong_alias(__memcpy,memcpy)
nop
.align 32
-ENTRY(__memmove)
+ENTRY(memmove)
#ifndef USE_BPR
srl %o2, 0, %o2 /* IEU1 Group */
#endif
@@ -912,10 +911,10 @@ ENTRY(__memmove)
234: wr %g0, FPRS_FEF, %fprs
retl
mov %g4, %o0
-END(__memmove)
-strong_alias(__memmove,memmove)
+END(memmove)
+libc_hidden_def(memmove)
#ifdef USE_BPR
-weak_alias(__memcpy,__align_cpy_1)
-weak_alias(__memcpy,__align_cpy_2)
+weak_alias(memcpy,__align_cpy_1)
+weak_alias(memcpy,__align_cpy_2)
#endif
diff --git a/libc/string/sparc/sparc64/memset.S b/libc/string/sparc/sparc64/memset.S
index 6fb25d211..284713556 100644
--- a/libc/string/sparc/sparc64/memset.S
+++ b/libc/string/sparc/sparc64/memset.S
@@ -36,7 +36,7 @@
/* Well, memset is a lot easier to get right than bcopy... */
.text
.align 32
-ENTRY(__memset)
+ENTRY(memset)
andcc %o1, 0xff, %o1
mov %o0, %o5
be,a,pt %icc, 50f
@@ -176,8 +176,8 @@ ENTRY(__memset)
nop
ba,pt %xcc, 18b
ldd [%o0], %f0
-END(__memset)
-strong_alias(__memset,memset)
+END(memset)
+libc_hidden_def(memset)
#define ZERO_BLOCKS(base, offset, source) \
stx source, [base - offset - 0x38]; \
@@ -191,7 +191,7 @@ strong_alias(__memset,memset)
.text
.align 32
-ENTRY(__bzero)
+ENTRY(bzero)
#ifndef USE_BPR
srl %o1, 0, %o1
#endif
@@ -309,5 +309,4 @@ ENTRY(__bzero)
stb %g0, [%o0 - 1]
0: retl
mov %o5, %o0
-END(__bzero)
-strong_alias(__bzero,bzero)
+END(bzero)
diff --git a/libc/string/sparc/sparc64/sparcv9b/memcpy.S b/libc/string/sparc/sparc64/sparcv9b/memcpy.S
index dd381c7ef..b49c9cde9 100644
--- a/libc/string/sparc/sparc64/sparcv9b/memcpy.S
+++ b/libc/string/sparc/sparc64/sparcv9b/memcpy.S
@@ -36,7 +36,7 @@
.text
.align 32
-ENTRY(__bcopy)
+ENTRY(bcopy)
sub %o1, %o0, %o4
mov %o0, %g4
cmp %o4, %o2
@@ -50,8 +50,7 @@ ENTRY(__bcopy)
add %o0, %o2, %o0
retl
nop
-END(__bcopy)
-strong_alias(__bcopy,bcopy)
+END(bcopy)
/* Special/non-trivial issues of this code:
*
@@ -68,7 +67,7 @@ strong_alias(__bcopy,bcopy)
* of up to 2.4GB per second.
*/
.align 32
-ENTRY(__memcpy)
+ENTRY(memcpy)
100: /* %o0=dst, %o1=src, %o2=len */
mov %o0, %g5
@@ -329,8 +328,8 @@ small_copy_unaligned:
retl
mov %g5, %o0
-END(__memcpy)
-strong_alias(__memcpy,memcpy)
+END(memcpy)
+libc_hidden_def(memcpy)
#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
ldx [%src - offset - 0x20], %t0; \
@@ -405,7 +404,7 @@ strong_alias(__memcpy,memcpy)
mov %g4, %o0
.align 32
-ENTRY(__memmove)
+ENTRY(memmove)
mov %o0, %g5
#ifndef USE_BPR
srl %o2, 0, %o2 /* IEU1 Group */
@@ -597,8 +596,8 @@ ENTRY(__memmove)
234: wr %g0, FPRS_FEF, %fprs
retl
mov %g4, %o0
-END(__memmove)
-strong_alias(__memmove,memmove)
+END(memmove)
+libc_hidden_def(memmove)
#ifdef USE_BPR
weak_alias(memcpy,__align_cpy_1)
diff --git a/libc/string/sparc/sparc64/stpcpy.S b/libc/string/sparc/sparc64/stpcpy.S
index 6bd24cfee..8c26c6bec 100644
--- a/libc/string/sparc/sparc64/stpcpy.S
+++ b/libc/string/sparc/sparc64/stpcpy.S
@@ -45,7 +45,7 @@
.text
.align 32
-ENTRY(__stpcpy)
+ENTRY(stpcpy)
sethi %hi(0x01010101), %g1 /* IEU0 Group */
or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
andcc %o0, 7, %g0 /* IEU1 */
@@ -267,6 +267,5 @@ ENTRY(__stpcpy)
retl /* CTI+IEU1 Group */
mov %g6, %o0 /* IEU0 */
-END(__stpcpy)
-
-strong_alias(__stpcpy,stpcpy)
+END(stpcpy)
+libc_hidden_def(stpcpy)
diff --git a/libc/string/sparc/sparc64/strcat.S b/libc/string/sparc/sparc64/strcat.S
index fb3ad2d12..fcc4ba59c 100644
--- a/libc/string/sparc/sparc64/strcat.S
+++ b/libc/string/sparc/sparc64/strcat.S
@@ -47,7 +47,7 @@
.text
.align 32
-ENTRY(__strcat)
+ENTRY(strcat)
sethi %hi(0x01010101), %g1 /* IEU0 Group */
ldub [%o0], %o3 /* Load */
or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
@@ -335,6 +335,5 @@ ENTRY(__strcat)
stb %o4, [%o0 - 8] /* Store */
retl /* CTI+IEU1 Group */
mov %g6, %o0 /* IEU0 */
-END(__strcat)
-
-strong_alias(__strcat,strcat)
+END(strcat)
+libc_hidden_def(strcat)
diff --git a/libc/string/sparc/sparc64/strchr.S b/libc/string/sparc/sparc64/strchr.S
index 34c30df31..6a371352a 100644
--- a/libc/string/sparc/sparc64/strchr.S
+++ b/libc/string/sparc/sparc64/strchr.S
@@ -47,7 +47,7 @@
.text
.align 32
-ENTRY(__strchr)
+ENTRY(strchr)
andcc %o1, 0xff, %o1 /* IEU1 Group */
be,pn %icc, 17f /* CTI */
sllx %o1, 8, %g3 /* IEU0 Group */
@@ -327,12 +327,12 @@ ENTRY(__strchr)
lduba [%o0] ASI_PNF, %o3 /* Load */
retl /* CTI+IEU1 Group */
add %o0, -1, %o0 /* IEU0 */
-END(__strchr)
-strong_alias(__strchr,strchr)
-strong_alias(__strchr,index)
+END(strchr)
+libc_hidden_def(strchr)
+strong_alias(strchr,index)
.align 32
-ENTRY(__strrchr)
+ENTRY(strrchr)
andcc %o1, 0xff, %o1 /* IEU1 Group */
be,pn %icc, 17b /* CTI */
clr %g4 /* IEU0 */
@@ -476,6 +476,6 @@ ENTRY(__strrchr)
ba,pt %xcc, 1b /* CTI Group */
ldx [%o0], %o3 /* Load */
-END(__strrchr)
-strong_alias(__strrchr,strrchr)
-strong_alias(__strrchr,rindex)
+END(strrchr)
+libc_hidden_def(strrchr)
+strong_alias(strrchr,rindex)
diff --git a/libc/string/sparc/sparc64/strcmp.S b/libc/string/sparc/sparc64/strcmp.S
index 0e078e9ac..df9e69179 100644
--- a/libc/string/sparc/sparc64/strcmp.S
+++ b/libc/string/sparc/sparc64/strcmp.S
@@ -45,7 +45,7 @@
.text
.align 32
-ENTRY(__strcmp)
+ENTRY(strcmp)
sethi %hi(0x01010101), %g1 /* IEU0 Group */
andcc %o0, 7, %g0 /* IEU1 */
bne,pn %icc, 7f /* CTI */
@@ -275,6 +275,5 @@ ENTRY(__strcmp)
ba,pt %xcc, 11b /* CTI Group */
ldxa [%o1 + %o0] ASI_PNF, %g6 /* Load */
-END(__strcmp)
-
-strong_alias(__strcmp,strcmp)
+END(strcmp)
+libc_hidden_def(strcmp)
diff --git a/libc/string/sparc/sparc64/strcpy.S b/libc/string/sparc/sparc64/strcpy.S
index d9dff104a..1317d5489 100644
--- a/libc/string/sparc/sparc64/strcpy.S
+++ b/libc/string/sparc/sparc64/strcpy.S
@@ -45,7 +45,7 @@
.text
.align 32
-ENTRY(__strcpy)
+ENTRY(strcpy)
sethi %hi(0x01010101), %g1 /* IEU0 Group */
mov %o0, %g6 /* IEU1 */
or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
@@ -240,6 +240,6 @@ ENTRY(__strcpy)
stb %o4, [%o0 - 8] /* Store */
retl /* CTI+IEU1 Group */
mov %g6, %o0 /* IEU0 */
-END(__strcpy)
+END(strcpy)
-strong_alias(__strcpy,strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/sparc/sparc64/strlen.S b/libc/string/sparc/sparc64/strlen.S
index 3c1cfc0d8..1fe854961 100644
--- a/libc/string/sparc/sparc64/strlen.S
+++ b/libc/string/sparc/sparc64/strlen.S
@@ -39,7 +39,7 @@
.text
.align 32
-ENTRY(__strlen)
+ENTRY(strlen)
sethi %hi(0x01010101), %g1 /* IEU0 Group */
ldub [%o0], %o3 /* Load */
or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
@@ -169,6 +169,5 @@ ENTRY(__strlen)
add %o0, -1, %o0 /* IEU0 Group */
retl /* CTI+IEU1 Group */
sub %o0, %o1, %o0 /* IEU0 */
-END(__strlen)
-
-strong_alias(__strlen,strlen)
+END(strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/sparc/strcmp.S b/libc/string/sparc/strcmp.S
index f72ee4a14..556537ce3 100644
--- a/libc/string/sparc/strcmp.S
+++ b/libc/string/sparc/strcmp.S
@@ -11,3 +11,8 @@
#else
# include "sparc64/strcmp.S"
#endif
+
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/stpcpy.c b/libc/string/stpcpy.c
index 540d04831..f34b9f65a 100644
--- a/libc/string/stpcpy.c
+++ b/libc/string/stpcpy.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstpcpy __wcpcpy
# define Wstpcpy wcpcpy
#else
-# define __Wstpcpy __stpcpy
+libc_hidden_proto(stpcpy)
# define Wstpcpy stpcpy
#endif
-Wchar attribute_hidden *__Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2)
+Wchar *Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2)
{
#ifdef __BCC__
do {
@@ -28,4 +27,6 @@ Wchar attribute_hidden *__Wstpcpy(register Wchar * __restrict s1, const Wchar *
return s1 - 1;
}
-strong_alias(__Wstpcpy,Wstpcpy)
+#ifndef WANT_WIDE
+libc_hidden_def(stpcpy)
+#endif
diff --git a/libc/string/stpncpy.c b/libc/string/stpncpy.c
index 5b45d0ef9..2603d2bd0 100644
--- a/libc/string/stpncpy.c
+++ b/libc/string/stpncpy.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstpncpy __wcpncpy
# define Wstpncpy wcpncpy
#else
-# define __Wstpncpy __stpncpy
+libc_hidden_proto(stpncpy)
# define Wstpncpy stpncpy
#endif
-Wchar attribute_hidden *__Wstpncpy(register Wchar * __restrict s1,
+Wchar *Wstpncpy(register Wchar * __restrict s1,
register const Wchar * __restrict s2,
size_t n)
{
@@ -38,4 +37,6 @@ Wchar attribute_hidden *__Wstpncpy(register Wchar * __restrict s1,
#endif
}
-strong_alias(__Wstpncpy,Wstpncpy)
+#ifndef WANT_WIDE
+libc_hidden_def(stpncpy)
+#endif
diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c
index 1d758e2ca..ac3f562a7 100644
--- a/libc/string/strcasecmp.c
+++ b/libc/string/strcasecmp.c
@@ -9,44 +9,44 @@
#include <ctype.h>
#include <locale.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
- __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 3)) attribute_hidden;
-extern int __wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
- __locale_t __loc) __THROW attribute_hidden;
-#endif
-
#ifdef WANT_WIDE
# define strcasecmp wcscasecmp
-# define __strcasecmp __wcscasecmp
# define strcasecmp_l wcscasecmp_l
-# define __strcasecmp_l __wcscasecmp_l
# ifdef __UCLIBC_DO_XLOCALE
-# define TOLOWER(C) __towlower_l((C), locale_arg)
-extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW attribute_hidden;
+libc_hidden_proto(towlower_l)
+# define TOLOWER(C) towlower_l((C), locale_arg)
# else
-# define TOLOWER(C) __towlower((C))
+libc_hidden_proto(towlower)
+# define TOLOWER(C) towlower((C))
# endif
#else
# ifdef __UCLIBC_DO_XLOCALE
-# define TOLOWER(C) __tolower_l((C), locale_arg)
+libc_hidden_proto(tolower_l)
+# define TOLOWER(C) tolower_l((C), locale_arg)
# else
-# define TOLOWER(C) __tolower((C))
+#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower)
+#endif
+libc_hidden_proto(tolower)
+# define TOLOWER(C) tolower((C))
# endif
#endif
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-int attribute_hidden __strcasecmp(register const Wchar *s1, register const Wchar *s2)
+libc_hidden_proto(strcasecmp_l)
+
+libc_hidden_proto(strcasecmp)
+int strcasecmp(register const Wchar *s1, register const Wchar *s2)
{
- return __strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE);
+ return strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE);
}
-strong_alias(__strcasecmp,strcasecmp)
+libc_hidden_def(strcasecmp)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-int attribute_hidden __UCXL(strcasecmp)(register const Wchar *s1, register const Wchar *s2
+libc_hidden_proto(__XL_NPP(strcasecmp))
+int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2
__LOCALE_PARAM )
{
#ifdef WANT_WIDE
@@ -70,6 +70,6 @@ int attribute_hidden __UCXL(strcasecmp)(register const Wchar *s1, register const
return r;
#endif
}
-__UCXL_ALIAS(strcasecmp)
+libc_hidden_def(__XL_NPP(strcasecmp))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strcasestr.c b/libc/string/strcasestr.c
index 5222eda71..72c1e4702 100644
--- a/libc/string/strcasestr.c
+++ b/libc/string/strcasestr.c
@@ -8,7 +8,14 @@
#include "_string.h"
#include <ctype.h>
-char attribute_hidden *__strcasestr(const char *s1, const char *s2)
+#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower)
+#else
+libc_hidden_proto(__ctype_tolower_loc)
+#endif
+libc_hidden_proto(tolower)
+
+char *strcasestr(const char *s1, const char *s2)
{
register const char *s = s1;
register const char *p = s2;
@@ -19,7 +26,7 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2)
return (char *) s1;;
}
if ((*p == *s)
- || (__tolower(*((unsigned char *)p)) == __tolower(*((unsigned char *)s)))
+ || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s)))
) {
++p;
++s;
@@ -34,7 +41,7 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2)
#else
while (*p && *s) {
if ((*p == *s)
- || (__tolower(*((unsigned char *)p)) == __tolower(*((unsigned char *)s)))
+ || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s)))
) {
++p;
++s;
@@ -47,5 +54,3 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2)
return (*p) ? NULL : (char *) s1;
#endif
}
-
-strong_alias(__strcasestr,strcasestr)
diff --git a/libc/string/strcat.c b/libc/string/strcat.c
index 5288f93ed..40a9be111 100644
--- a/libc/string/strcat.c
+++ b/libc/string/strcat.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrcat __wcscat
# define Wstrcat wcscat
#else
-# define __Wstrcat __strcat
# define Wstrcat strcat
#endif
-Wchar attribute_hidden *__Wstrcat(Wchar * __restrict s1, register const Wchar * __restrict s2)
+libc_hidden_proto(Wstrcat)
+
+Wchar *Wstrcat(Wchar * __restrict s1, register const Wchar * __restrict s2)
{
register Wchar *s = s1;
@@ -25,5 +25,4 @@ Wchar attribute_hidden *__Wstrcat(Wchar * __restrict s1, register const Wchar *
return s1;
}
-
-strong_alias(__Wstrcat,Wstrcat)
+libc_hidden_def(Wstrcat)
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 93f394ab1..6bfd2077d 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrchr __wcschr
# define Wstrchr wcschr
#else
-# define __Wstrchr __strchr
# define Wstrchr strchr
#endif
-Wchar attribute_hidden *__Wstrchr(register const Wchar *s, Wint c)
+libc_hidden_proto(Wstrchr)
+
+Wchar *Wstrchr(register const Wchar *s, Wint c)
{
do {
if (*s == ((Wchar)c)) {
@@ -25,9 +25,8 @@ Wchar attribute_hidden *__Wstrchr(register const Wchar *s, Wint c)
return NULL;
}
-
-strong_alias(__Wstrchr,Wstrchr)
+libc_hidden_def(Wstrchr)
#ifndef WANT_WIDE
-strong_alias(__strchr,index)
+strong_alias(strchr,index)
#endif
diff --git a/libc/string/strchrnul.c b/libc/string/strchrnul.c
index c498532fd..cc3883402 100644
--- a/libc/string/strchrnul.c
+++ b/libc/string/strchrnul.c
@@ -8,18 +8,17 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrchrnul __wcschrnul
# define Wstrchrnul wcschrnul
#else
-# define __Wstrchrnul __strchrnul
# define Wstrchrnul strchrnul
#endif
-Wchar attribute_hidden *__Wstrchrnul(register const Wchar *s, Wint c)
+libc_hidden_proto(Wstrchrnul)
+
+Wchar *Wstrchrnul(register const Wchar *s, Wint c)
{
--s;
while (*++s && (*s != ((Wchar)c)));
return (Wchar *) s;
}
-
-strong_alias(__Wstrchrnul,Wstrchrnul)
+libc_hidden_def(Wstrchrnul)
diff --git a/libc/string/strcmp.c b/libc/string/strcmp.c
index 1fb8625ff..4a95ab882 100644
--- a/libc/string/strcmp.c
+++ b/libc/string/strcmp.c
@@ -8,14 +8,16 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrcmp __wcscmp
# define Wstrcmp wcscmp
+# define Wstrcoll wcscoll
#else
-# define __Wstrcmp __strcmp
# define Wstrcmp strcmp
+# define Wstrcoll strcoll
#endif
-int attribute_hidden __Wstrcmp(register const Wchar *s1, register const Wchar *s2)
+libc_hidden_proto(Wstrcmp)
+
+int Wstrcmp(register const Wchar *s1, register const Wchar *s2)
{
#ifdef WANT_WIDE
while (*((Wuchar *)s1) == *((Wuchar *)s2)) {
@@ -35,15 +37,10 @@ int attribute_hidden __Wstrcmp(register const Wchar *s1, register const Wchar *s
return r;
#endif
}
-
-strong_alias(__Wstrcmp,Wstrcmp)
+libc_hidden_def(Wstrcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-# ifdef WANT_WIDE
-hidden_strong_alias(__wcscmp,__wcscoll)
-strong_alias(__wcscmp,wcscoll)
-# else
-hidden_strong_alias(__strcmp,__strcoll)
-strong_alias(__strcmp,strcoll)
-# endif
+libc_hidden_proto(Wstrcoll)
+strong_alias(Wstrcmp,Wstrcoll)
+libc_hidden_def(Wstrcoll)
#endif
diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c
index 3b0e490eb..cda4094ac 100644
--- a/libc/string/strcpy.c
+++ b/libc/string/strcpy.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrcpy __wcscpy
# define Wstrcpy wcscpy
#else
-# define __Wstrcpy __strcpy
# define Wstrcpy strcpy
#endif
-Wchar attribute_hidden *__Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
+libc_hidden_proto(Wstrcpy)
+
+Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
{
register Wchar *s = s1;
@@ -29,5 +29,4 @@ Wchar attribute_hidden *__Wstrcpy(Wchar * __restrict s1, const Wchar * __restric
return s1;
}
-
-strong_alias(__Wstrcpy,Wstrcpy)
+libc_hidden_def(Wstrcpy)
diff --git a/libc/string/strcspn.c b/libc/string/strcspn.c
index 7a709a77f..75d2e081b 100644
--- a/libc/string/strcspn.c
+++ b/libc/string/strcspn.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrcspn __wcscspn
# define Wstrcspn wcscspn
#else
-# define __Wstrcspn __strcspn
+libc_hidden_proto(strcspn)
# define Wstrcspn strcspn
#endif
-size_t attribute_hidden __Wstrcspn(const Wchar *s1, const Wchar *s2)
+size_t Wstrcspn(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s;
register const Wchar *p;
@@ -29,4 +28,6 @@ size_t attribute_hidden __Wstrcspn(const Wchar *s1, const Wchar *s2)
return s - s1;
}
-strong_alias(__Wstrcspn,Wstrcspn)
+#ifndef WANT_WIDE
+libc_hidden_def(strcspn)
+#endif
diff --git a/libc/string/strdup.c b/libc/string/strdup.c
index e2ccead9d..dff5af60a 100644
--- a/libc/string/strdup.c
+++ b/libc/string/strdup.c
@@ -9,18 +9,21 @@
#include <stdlib.h>
#ifdef WANT_WIDE
-# define __Wstrdup __wcsdup
+libc_hidden_proto(wcslen)
+libc_hidden_proto(wcscpy)
# define Wstrdup wcsdup
-# define Wstrlen __wcslen
-# define Wstrcpy __wcscpy
+# define Wstrlen wcslen
+# define Wstrcpy wcscpy
#else
-# define __Wstrdup __strdup
+libc_hidden_proto(strdup)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcpy)
# define Wstrdup strdup
-# define Wstrlen __strlen
-# define Wstrcpy __strcpy
+# define Wstrlen strlen
+# define Wstrcpy strcpy
#endif
-Wchar attribute_hidden *__Wstrdup(register const Wchar *s1)
+Wchar *Wstrdup(register const Wchar *s1)
{
register Wchar *s;
@@ -31,4 +34,6 @@ Wchar attribute_hidden *__Wstrdup(register const Wchar *s1)
return s;
}
-strong_alias(__Wstrdup,Wstrdup)
+#ifndef WANT_WIDE
+libc_hidden_def(strdup)
+#endif
diff --git a/libc/string/strerror.c b/libc/string/strerror.c
index a2f1f4833..1b5cb3ff2 100644
--- a/libc/string/strerror.c
+++ b/libc/string/strerror.c
@@ -9,13 +9,15 @@
#include <string.h>
#include "_syserrmsg.h"
-char attribute_hidden *__strerror(int errnum)
+libc_hidden_proto(strerror)
+libc_hidden_proto(__xpg_strerror_r)
+
+char *strerror(int errnum)
{
static char buf[_STRERROR_BUFSIZE];
- __xpg_strerror_r_internal(errnum, buf, sizeof(buf));
+ __xpg_strerror_r(errnum, buf, sizeof(buf));
return buf;
}
-
-strong_alias(__strerror,strerror)
+libc_hidden_def(strerror)
diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c
index 3920db083..e888b85b2 100644
--- a/libc/string/strlcpy.c
+++ b/libc/string/strlcpy.c
@@ -8,18 +8,25 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrlcpy __wcslcpy
-# define Wstrlcpy wcslcpy
+# define Wstrlcpy __wcslcpy
+# define Wstrxfrm wcsxfrm
#else
-# define __Wstrlcpy __strlcpy
+libc_hidden_proto(strlcpy)
# define Wstrlcpy strlcpy
+# define Wstrxfrm strxfrm
#endif
+
/* OpenBSD function:
* Copy at most n-1 chars from src to dst and nul-terminate dst.
* Returns strlen(src), so truncation occurred if the return value is >= n. */
-size_t attribute_hidden __Wstrlcpy(register Wchar *__restrict dst,
+#ifdef WANT_WIDE
+size_t Wstrlcpy(register Wchar *__restrict dst,
+ register const Wchar *__restrict src,
+ size_t n) attribute_hidden;
+#endif
+size_t Wstrlcpy(register Wchar *__restrict dst,
register const Wchar *__restrict src,
size_t n)
{
@@ -42,15 +49,15 @@ size_t attribute_hidden __Wstrlcpy(register Wchar *__restrict dst,
return src - src0;
}
-
-strong_alias(__Wstrlcpy,Wstrlcpy)
-
+#ifndef WANT_WIDE
+libc_hidden_def(strlcpy)
+#ifndef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(strxfrm)
+strong_alias(strlcpy,strxfrm)
+libc_hidden_def(strxfrm)
+#endif
+#else
#ifndef __UCLIBC_HAS_LOCALE__
-# ifdef WANT_WIDE
-hidden_strong_alias(__wcslcpy,__wcsxfrm)
strong_alias(__wcslcpy,wcsxfrm)
-# else
-hidden_strong_alias(__strlcpy,__strxfrm)
-strong_alias(__strlcpy,strxfrm)
-# endif
+#endif
#endif
diff --git a/libc/string/strlen.c b/libc/string/strlen.c
index 27cd8481c..bcb096b97 100644
--- a/libc/string/strlen.c
+++ b/libc/string/strlen.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrlen __wcslen
# define Wstrlen wcslen
#else
-# define __Wstrlen __strlen
# define Wstrlen strlen
#endif
-size_t attribute_hidden __Wstrlen(const Wchar *s)
+libc_hidden_proto(Wstrlen)
+
+size_t Wstrlen(const Wchar *s)
{
register const Wchar *p;
@@ -23,5 +23,4 @@ size_t attribute_hidden __Wstrlen(const Wchar *s)
return p - s;
}
-
-strong_alias(__Wstrlen,Wstrlen)
+libc_hidden_def(Wstrlen)
diff --git a/libc/string/strncasecmp.c b/libc/string/strncasecmp.c
index bfc865a8c..54de1b78c 100644
--- a/libc/string/strncasecmp.c
+++ b/libc/string/strncasecmp.c
@@ -9,44 +9,44 @@
#include <ctype.h>
#include <locale.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
- size_t __n, __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 4)) attribute_hidden;
-extern int __wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
- size_t __n, __locale_t __loc) __THROW attribute_hidden;
-#endif
-
#ifdef WANT_WIDE
# define strncasecmp wcsncasecmp
-# define __strncasecmp __wcsncasecmp
# define strncasecmp_l wcsncasecmp_l
-# define __strncasecmp_l __wcsncasecmp_l
# ifdef __UCLIBC_DO_XLOCALE
-# define TOLOWER(C) __towlower_l((C), locale_arg)
-extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW attribute_hidden;
+libc_hidden_proto(towlower_l)
+# define TOLOWER(C) towlower_l((C), locale_arg)
# else
-# define TOLOWER(C) __towlower((C))
+libc_hidden_proto(towlower)
+# define TOLOWER(C) towlower((C))
# endif
#else
# ifdef __UCLIBC_DO_XLOCALE
-# define TOLOWER(C) __tolower_l((C), locale_arg)
+libc_hidden_proto(tolower_l)
+# define TOLOWER(C) tolower_l((C), locale_arg)
# else
-# define TOLOWER(C) __tolower((C))
+#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower)
+#endif
+libc_hidden_proto(tolower)
+# define TOLOWER(C) tolower((C))
# endif
#endif
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-int attribute_hidden __strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
+libc_hidden_proto(strncasecmp_l)
+
+libc_hidden_proto(strncasecmp)
+int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
- return __strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
+ return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
}
-strong_alias(__strncasecmp,strncasecmp)
+libc_hidden_def(strncasecmp)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-int attribute_hidden __UCXL(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
+libc_hidden_proto(__XL_NPP(strncasecmp))
+int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
size_t n __LOCALE_PARAM )
{
#ifdef WANT_WIDE
@@ -73,6 +73,6 @@ int attribute_hidden __UCXL(strncasecmp)(register const Wchar *s1, register cons
return r;
#endif
}
-__UCXL_ALIAS(strncasecmp)
+libc_hidden_def(__XL_NPP(strncasecmp))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strncat.c b/libc/string/strncat.c
index 20fbcfa27..61170c369 100644
--- a/libc/string/strncat.c
+++ b/libc/string/strncat.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrncat __wcsncat
# define Wstrncat wcsncat
#else
-# define __Wstrncat __strncat
+libc_hidden_proto(strncat)
# define Wstrncat strncat
#endif
-Wchar attribute_hidden *__Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
+Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
size_t n)
{
register Wchar *s = s1;
@@ -35,4 +34,6 @@ Wchar attribute_hidden *__Wstrncat(Wchar * __restrict s1, register const Wchar *
return s1;
}
-strong_alias(__Wstrncat,Wstrncat)
+#ifndef WANT_WIDE
+libc_hidden_def(strncat)
+#endif
diff --git a/libc/string/strncmp.c b/libc/string/strncmp.c
index ad80ce8e5..7305cbaa5 100644
--- a/libc/string/strncmp.c
+++ b/libc/string/strncmp.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrncmp __wcsncmp
# define Wstrncmp wcsncmp
#else
-# define __Wstrncmp __strncmp
+libc_hidden_proto(strncmp)
# define Wstrncmp strncmp
#endif
-int attribute_hidden __Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n)
+int Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
#ifdef WANT_WIDE
while (n && (*((Wuchar *)s1) == *((Wuchar *)s2))) {
@@ -38,5 +37,6 @@ int attribute_hidden __Wstrncmp(register const Wchar *s1, register const Wchar *
return r;
#endif
}
-
-strong_alias(__Wstrncmp,Wstrncmp)
+#ifndef WANT_WIDE
+libc_hidden_def(strncmp)
+#endif
diff --git a/libc/string/strncpy.c b/libc/string/strncpy.c
index 09124ac99..40da93dac 100644
--- a/libc/string/strncpy.c
+++ b/libc/string/strncpy.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrncpy __wcsncpy
# define Wstrncpy wcsncpy
#else
-# define __Wstrncpy __strncpy
+libc_hidden_proto(strncpy)
# define Wstrncpy strncpy
#endif
-Wchar attribute_hidden *__Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2,
+Wchar *Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2,
size_t n)
{
register Wchar *s = s1;
@@ -35,5 +34,6 @@ Wchar attribute_hidden *__Wstrncpy(Wchar * __restrict s1, register const Wchar *
return s1;
}
-
-strong_alias(__Wstrncpy,Wstrncpy)
+#ifndef WANT_WIDE
+libc_hidden_def(strncpy)
+#endif
diff --git a/libc/string/strndup.c b/libc/string/strndup.c
index 5cee0272d..89c58ccec 100644
--- a/libc/string/strndup.c
+++ b/libc/string/strndup.c
@@ -8,18 +8,21 @@
#include "_string.h"
#include <stdlib.h>
-char attribute_hidden *__strndup(register const char *s1, size_t n)
+libc_hidden_proto(strndup)
+libc_hidden_proto(strnlen)
+libc_hidden_proto(memcpy)
+
+char *strndup(register const char *s1, size_t n)
{
register char *s;
- n = __strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */
+ n = strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */
if ((s = malloc(n + 1)) != NULL) {
- __memcpy(s, s1, n);
+ memcpy(s, s1, n);
s[n] = 0;
}
return s;
}
-
-strong_alias(__strndup,strndup)
+libc_hidden_def(strndup)
diff --git a/libc/string/strnlen.c b/libc/string/strnlen.c
index 6732cc532..547dd23b2 100644
--- a/libc/string/strnlen.c
+++ b/libc/string/strnlen.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrnlen __wcsnlen
# define Wstrnlen wcsnlen
#else
-# define __Wstrnlen __strnlen
# define Wstrnlen strnlen
#endif
-size_t attribute_hidden __Wstrnlen(const Wchar *s, size_t max)
+libc_hidden_proto(Wstrnlen)
+
+size_t Wstrnlen(const Wchar *s, size_t max)
{
register const Wchar *p = s;
#ifdef __BCC__
@@ -34,4 +34,4 @@ size_t attribute_hidden __Wstrnlen(const Wchar *s, size_t max)
}
#undef maxp
-strong_alias(__Wstrnlen,Wstrnlen)
+libc_hidden_def(Wstrnlen)
diff --git a/libc/string/strpbrk.c b/libc/string/strpbrk.c
index 704b1bc71..abeb84380 100644
--- a/libc/string/strpbrk.c
+++ b/libc/string/strpbrk.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrpbrk __wcspbrk
# define Wstrpbrk wcspbrk
#else
-# define __Wstrpbrk __strpbrk
# define Wstrpbrk strpbrk
#endif
-Wchar attribute_hidden *__Wstrpbrk(const Wchar *s1, const Wchar *s2)
+libc_hidden_proto(Wstrpbrk)
+
+Wchar *Wstrpbrk(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s;
register const Wchar *p;
@@ -27,5 +27,4 @@ Wchar attribute_hidden *__Wstrpbrk(const Wchar *s1, const Wchar *s2)
}
return NULL;
}
-
-strong_alias(__Wstrpbrk,Wstrpbrk)
+libc_hidden_def(Wstrpbrk)
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c
index cb30afea7..8a9184f9f 100644
--- a/libc/string/strrchr.c
+++ b/libc/string/strrchr.c
@@ -8,14 +8,13 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrrchr __wcsrchr
# define Wstrrchr wcsrchr
#else
-# define __Wstrrchr __strrchr
+libc_hidden_proto(strrchr)
# define Wstrrchr strrchr
#endif
-Wchar attribute_hidden *__Wstrrchr(register const Wchar *s, Wint c)
+Wchar *Wstrrchr(register const Wchar *s, Wint c)
{
register const Wchar *p;
@@ -28,8 +27,7 @@ Wchar attribute_hidden *__Wstrrchr(register const Wchar *s, Wint c)
return (Wchar *) p; /* silence the warning */
}
-
-strong_alias(__Wstrrchr,Wstrrchr)
#ifndef WANT_WIDE
-strong_alias(__strrchr,rindex)
+libc_hidden_def(strrchr)
+strong_alias(strrchr,rindex)
#endif
diff --git a/libc/string/strsep.c b/libc/string/strsep.c
index 993fafecb..7f421891e 100644
--- a/libc/string/strsep.c
+++ b/libc/string/strsep.c
@@ -7,18 +7,22 @@
#include "_string.h"
-char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s2)
+libc_hidden_proto(strsep)
+libc_hidden_proto(strpbrk)
+libc_hidden_proto(strcspn)
+
+char *strsep(char ** __restrict s1, const char * __restrict s2)
{
register char *s = *s1;
register char *p;
#if 1
p = NULL;
- if (s && *s && (p = __strpbrk(s, s2))) {
+ if (s && *s && (p = strpbrk(s, s2))) {
*p++ = 0;
}
#else
- if (s && *s && *(p = s + __strcspn(s, s2))) {
+ if (s && *s && *(p = s + strcspn(s, s2))) {
*p++ = 0;
} else {
p = NULL;
@@ -27,5 +31,4 @@ char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s
*s1 = p;
return s;
}
-
-strong_alias(__strsep,strsep)
+libc_hidden_def(strsep)
diff --git a/libc/string/strsignal.c b/libc/string/strsignal.c
index 7d7f613fe..f8b6a9e9f 100644
--- a/libc/string/strsignal.c
+++ b/libc/string/strsignal.c
@@ -13,12 +13,14 @@
/* TODO: make a threadsafe version? */
-#define _GNU_SOURCE
#include <features.h>
#include <string.h>
#include <bits/uClibc_uintmaxtostr.h>
#include <signal.h>
+libc_hidden_proto(strsignal)
+libc_hidden_proto(memcpy)
+
#define _SYS_NSIG 32
#ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__
@@ -35,7 +37,7 @@
#ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__
-extern const char _string_syssigmsgs[];
+extern const char _string_syssigmsgs[] attribute_hidden;
#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__)
static const unsigned char sstridx[] = {
@@ -55,10 +57,10 @@ static const unsigned char sstridx[] = {
SIGPIPE,
SIGALRM,
SIGTERM,
-#if defined(__alpha__) || defined(__mips__) || defined(__sparc__)
- 0,
-#else
+#if defined SIGSTKFLT
SIGSTKFLT,
+#else
+ 0,
#endif
SIGCHLD,
SIGCONT,
@@ -75,13 +77,13 @@ static const unsigned char sstridx[] = {
SIGIO,
SIGPWR,
SIGSYS,
-#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__)
+#if defined SIGEMT
SIGEMT,
#endif
};
#endif
-char attribute_hidden *__strsignal(int signum)
+char *strsignal(int signum)
{
register char *s;
int i;
@@ -120,7 +122,7 @@ char attribute_hidden *__strsignal(int signum)
}
s = _int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown);
- __memcpy(s, unknown, sizeof(unknown));
+ memcpy(s, unknown, sizeof(unknown));
DONE:
return s;
@@ -128,18 +130,18 @@ char attribute_hidden *__strsignal(int signum)
#else /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */
-char attribute_hidden *__strsignal(int signum)
+char *strsignal(int signum)
{
static char buf[_STRSIGNAL_BUFSIZE];
static const char unknown[] = {
'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' '
};
- return (char *) __memcpy(_int10tostr(buf+sizeof(buf)-1, signum)
+ return (char *) memcpy(_int10tostr(buf+sizeof(buf)-1, signum)
- sizeof(unknown),
unknown, sizeof(unknown));
}
#endif /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */
-strong_alias(__strsignal,strsignal)
+libc_hidden_def(strsignal)
diff --git a/libc/string/strspn.c b/libc/string/strspn.c
index 9074c13ad..ca83ef900 100644
--- a/libc/string/strspn.c
+++ b/libc/string/strspn.c
@@ -8,14 +8,14 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrspn __wcsspn
# define Wstrspn wcsspn
#else
-# define __Wstrspn __strspn
# define Wstrspn strspn
#endif
-size_t attribute_hidden __Wstrspn(const Wchar *s1, const Wchar *s2)
+libc_hidden_proto(Wstrspn)
+
+size_t Wstrspn(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s = s1;
register const Wchar *p = s2;
@@ -28,5 +28,4 @@ size_t attribute_hidden __Wstrspn(const Wchar *s1, const Wchar *s2)
}
return s - s1;
}
-
-strong_alias(__Wstrspn,Wstrspn)
+libc_hidden_def(Wstrspn)
diff --git a/libc/string/strstr.c b/libc/string/strstr.c
index 7256b9da2..685a2f83c 100644
--- a/libc/string/strstr.c
+++ b/libc/string/strstr.c
@@ -8,16 +8,15 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrstr __wcsstr
# define Wstrstr wcsstr
#else
-# define __Wstrstr __strstr
+libc_hidden_proto(strstr)
# define Wstrstr strstr
#endif
/* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach. */
-Wchar attribute_hidden *__Wstrstr(const Wchar *s1, const Wchar *s2)
+Wchar *Wstrstr(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s = s1;
register const Wchar *p = s2;
@@ -38,8 +37,8 @@ Wchar attribute_hidden *__Wstrstr(const Wchar *s1, const Wchar *s2)
}
} while (1);
}
-
-strong_alias(__Wstrstr,Wstrstr)
-#ifdef WANT_WIDE
-strong_alias(__wcsstr,wcswcs)
+#ifndef WANT_WIDE
+libc_hidden_def(strstr)
+#else
+strong_alias(wcsstr,wcswcs)
#endif
diff --git a/libc/string/strtok.c b/libc/string/strtok.c
index 4b8aef6b5..127497c9d 100644
--- a/libc/string/strtok.c
+++ b/libc/string/strtok.c
@@ -9,12 +9,14 @@
#if 0 /*def WANT_WIDE*/
# define Wstrtok wcstok
-# define Wstrtok_r __wcstok_r
+# define Wstrtok_r wcstok_r
#else
# define Wstrtok strtok
-# define Wstrtok_r __strtok_r
+# define Wstrtok_r strtok_r
#endif
+libc_hidden_proto(Wstrtok_r)
+
Wchar *Wstrtok(Wchar * __restrict s1, const Wchar * __restrict s2)
{
static Wchar *next_start; /* Initialized to 0 since in bss. */
diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c
index c8ba588eb..bda56d71c 100644
--- a/libc/string/strtok_r.c
+++ b/libc/string/strtok_r.c
@@ -8,18 +8,21 @@
#include "_string.h"
#ifdef WANT_WIDE
-# define __Wstrtok_r __wcstok
+libc_hidden_proto(wcsspn)
+libc_hidden_proto(wcspbrk)
# define Wstrtok_r wcstok
-# define Wstrspn __wcsspn
-# define Wstrpbrk __wcspbrk
+# define Wstrspn wcsspn
+# define Wstrpbrk wcspbrk
#else
-# define __Wstrtok_r __strtok_r
+libc_hidden_proto(strtok_r)
+libc_hidden_proto(strspn)
+libc_hidden_proto(strpbrk)
# define Wstrtok_r strtok_r
-# define Wstrspn __strspn
-# define Wstrpbrk __strpbrk
+# define Wstrspn strspn
+# define Wstrpbrk strpbrk
#endif
-Wchar attribute_hidden *__Wstrtok_r(Wchar * __restrict s1, const Wchar * __restrict s2,
+Wchar *Wstrtok_r(Wchar * __restrict s1, const Wchar * __restrict s2,
Wchar ** __restrict next_start)
{
register Wchar *s;
@@ -52,4 +55,6 @@ Wchar attribute_hidden *__Wstrtok_r(Wchar * __restrict s1, const Wchar * __restr
#endif
}
-strong_alias(__Wstrtok_r,Wstrtok_r)
+#ifndef WANT_WIDE
+libc_hidden_def(strtok_r)
+#endif
diff --git a/libc/string/sys_errlist.c b/libc/string/sys_errlist.c
index a0b5e3b2f..17ed4d62c 100644
--- a/libc/string/sys_errlist.c
+++ b/libc/string/sys_errlist.c
@@ -8,7 +8,7 @@
#include <features.h>
#include <errno.h>
-extern const char _string_syserrmsgs[];
+extern const char _string_syserrmsgs[] attribute_hidden;
#ifdef __UCLIBC_HAS_SYS_ERRLIST__
diff --git a/libc/string/sys_siglist.c b/libc/string/sys_siglist.c
index 9337d00a9..844337536 100644
--- a/libc/string/sys_siglist.c
+++ b/libc/string/sys_siglist.c
@@ -10,7 +10,7 @@
#include <stddef.h>
#include <signal.h>
-extern const char _string_syssigmsgs[];
+extern const char _string_syssigmsgs[] attribute_hidden;
#ifdef __UCLIBC_HAS_SYS_SIGLIST__
@@ -31,7 +31,7 @@ const char *const sys_siglist[_NSIG] = {
[SIGPIPE] = _string_syssigmsgs + 178,
[SIGALRM] = _string_syssigmsgs + 190,
[SIGTERM] = _string_syssigmsgs + 202,
-#if !(defined(__alpha__) || defined(__mips__) || defined(__sparc__))
+#if defined SIGSTKFLT /* not all arches define this, yeah ! */
[SIGSTKFLT] = _string_syssigmsgs + 213,
#endif
[SIGCHLD] = _string_syssigmsgs + 225,
@@ -49,7 +49,7 @@ const char *const sys_siglist[_NSIG] = {
[SIGIO] = _string_syssigmsgs + 445,
[SIGPWR] = _string_syssigmsgs + 458,
[SIGSYS] = _string_syssigmsgs + 472,
-#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__)
+#if defined SIGEMT /* only some arches define this, yeah ! */
[SIGEMT] = _string_syssigmsgs + 488,
#endif
};
diff --git a/libc/string/x86_64/Makefile b/libc/string/x86_64/Makefile
index ac0063770..0a95346fd 100644
--- a/libc/string/x86_64/Makefile
+++ b/libc/string/x86_64/Makefile
@@ -5,9 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir=../../../
-top_builddir=../../../
+top_srcdir:=../../../
+top_builddir:=../../../
all: objs
include $(top_builddir)Rules.mak
-include Makefile.arch
+include ../Makefile.in
include $(top_srcdir)Makerules
diff --git a/libc/string/x86_64/Makefile.arch b/libc/string/x86_64/Makefile.arch
deleted file mode 100644
index 56e5a5165..000000000
--- a/libc/string/x86_64/Makefile.arch
+++ /dev/null
@@ -1,28 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-STRING_ARCH_DIR:=$(top_srcdir)libc/string/x86_64
-STRING_ARCH_OUT:=$(top_builddir)libc/string/x86_64
-
-STRING_ARCH_SRC:=$(wildcard $(STRING_ARCH_DIR)/*.c)
-STRING_ARCH_OBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC))
-
-STRING_ARCH_SSRC:=$(wildcard $(STRING_ARCH_DIR)/*.S)
-STRING_ARCH_SOBJ:=$(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC))
-
-STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ)
-
-libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS)
-libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SRC)
-libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SOBJ)
-
-objclean-y+=string_x86_64_objclean
-
-string_x86_64_objclean:
- $(RM) $(STRING_ARCH_OUT)/*.{o,os}
diff --git a/libc/string/x86_64/_glibc_inc.h b/libc/string/x86_64/_glibc_inc.h
index 3c31957db..88cef2ea3 100644
--- a/libc/string/x86_64/_glibc_inc.h
+++ b/libc/string/x86_64/_glibc_inc.h
@@ -14,7 +14,6 @@
#define ENTRY(sym) \
.global sym; \
- .hidden sym; \
.align ENTRY_ALIGN; \
.type sym,%function; \
sym:
diff --git a/libc/string/x86_64/bzero.S b/libc/string/x86_64/bzero.S
index 73ba75436..b6e41fb0f 100644
--- a/libc/string/x86_64/bzero.S
+++ b/libc/string/x86_64/bzero.S
@@ -1,3 +1,2 @@
-#define __memset __bzero
+#define memset bzero
#include "memset.S"
-strong_alias(__bzero,bzero)
diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S
index 973cd513f..b3bb0f96c 100644
--- a/libc/string/x86_64/memcpy.S
+++ b/libc/string/x86_64/memcpy.S
@@ -23,7 +23,7 @@
/* BEWARE: `#ifdef memcpy' means that memcpy is redefined as `mempcpy',
and the return value is the byte after the last one copied in
the destination. */
-#define MEMPCPY_P (defined __memcpy)
+#define MEMPCPY_P (defined memcpy)
.text
#if defined PIC && !defined NOT_IN_libc
@@ -32,7 +32,7 @@ ENTRY (__memcpy_chk)
jb HIDDEN_JUMPTARGET (__chk_fail)
END (__memcpy_chk)
#endif
-ENTRY (BP_SYM (__memcpy))
+ENTRY (BP_SYM (memcpy))
/* Cutoff for the big loop is a size of 32 bytes since otherwise
the loop will never be entered. */
cmpq $32, %rdx
@@ -92,7 +92,7 @@ ENTRY (BP_SYM (__memcpy))
#endif
ret
-END (BP_SYM (__memcpy))
+END (BP_SYM (memcpy))
#if !MEMPCPY_P
-strong_alias(__memcpy,memcpy)
+libc_hidden_def(memcpy)
#endif
diff --git a/libc/string/x86_64/mempcpy.S b/libc/string/x86_64/mempcpy.S
index 3a8e925fd..3816d9f72 100644
--- a/libc/string/x86_64/mempcpy.S
+++ b/libc/string/x86_64/mempcpy.S
@@ -1,3 +1,3 @@
-#define __memcpy __mempcpy
+#define memcpy mempcpy
#include "memcpy.S"
-strong_alias(__mempcpy,mempcpy)
+libc_hidden_def(mempcpy)
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S
index 923e1c208..d72d74468 100644
--- a/libc/string/x86_64/memset.S
+++ b/libc/string/x86_64/memset.S
@@ -22,7 +22,7 @@
#include "_glibc_inc.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
-#define BZERO_P (defined __memset)
+#define BZERO_P (defined memset)
/* This is somehow experimental and could made dependend on the cache
size. */
@@ -35,7 +35,7 @@ ENTRY (__memset_chk)
jb HIDDEN_JUMPTARGET (__chk_fail)
END (__memset_chk)
#endif
-ENTRY (__memset)
+ENTRY (memset)
#if BZERO_P
mov %rsi,%rdx /* Adjust parameter. */
xorl %esi,%esi /* Fill with 0s. */
@@ -131,9 +131,9 @@ ENTRY (__memset)
jne 11b
jmp 4b
-END (__memset)
+END (memset)
#if !BZERO_P
-strong_alias(__memset,memset)
+libc_hidden_def(memset)
#endif
#if !BZERO_P && defined PIC && !defined NOT_IN_libc
diff --git a/libc/string/x86_64/stpcpy.S b/libc/string/x86_64/stpcpy.S
index 075773371..138d0fb17 100644
--- a/libc/string/x86_64/stpcpy.S
+++ b/libc/string/x86_64/stpcpy.S
@@ -1,4 +1,4 @@
#define USE_AS_STPCPY
-#define STRCPY __stpcpy
+#define STRCPY stpcpy
#include "strcpy.S"
-strong_alias(__stpcpy,stpcpy)
+libc_hidden_def(stpcpy)
diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S
index 6c7189a21..9b0068981 100644
--- a/libc/string/x86_64/strcat.S
+++ b/libc/string/x86_64/strcat.S
@@ -23,7 +23,7 @@
.text
-ENTRY (BP_SYM (__strcat))
+ENTRY (BP_SYM (strcat))
movq %rdi, %rcx /* Dest. register. */
andl $7, %ecx /* mask alignment bits */
movq %rdi, %rax /* Duplicate destination pointer. */
@@ -253,6 +253,6 @@ ENTRY (BP_SYM (__strcat))
24:
movq %rdi, %rax /* Source is return value. */
retq
-END (BP_SYM (__strcat))
+END (BP_SYM (strcat))
-strong_alias(__strcat,strcat)
+libc_hidden_def(strcat)
diff --git a/libc/string/x86_64/strchr.S b/libc/string/x86_64/strchr.S
index 312d62b61..6f6635a39 100644
--- a/libc/string/x86_64/strchr.S
+++ b/libc/string/x86_64/strchr.S
@@ -22,7 +22,7 @@
.text
-ENTRY (BP_SYM (__strchr))
+ENTRY (BP_SYM (strchr))
/* Before we start with the main loop we process single bytes
until the source pointer is aligned. This has two reasons:
@@ -282,7 +282,7 @@ ENTRY (BP_SYM (__strchr))
6:
nop
retq
-END (BP_SYM (__strchr))
+END (BP_SYM (strchr))
-strong_alias(__strchr,strchr)
-strong_alias (BP_SYM (__strchr), BP_SYM (index))
+libc_hidden_def(strchr)
+strong_alias (BP_SYM (strchr), BP_SYM (index))
diff --git a/libc/string/x86_64/strcmp.S b/libc/string/x86_64/strcmp.S
index 1eaff1691..437e145bf 100644
--- a/libc/string/x86_64/strcmp.S
+++ b/libc/string/x86_64/strcmp.S
@@ -22,7 +22,7 @@
#include "_glibc_inc.h"
.text
-ENTRY (BP_SYM (__strcmp))
+ENTRY (BP_SYM (strcmp))
L(oop): movb (%rdi), %al
cmpb (%rsi), %al
jne L(neq)
@@ -38,6 +38,10 @@ L(neq): movl $1, %eax
movl $-1, %ecx
cmovbl %ecx, %eax
ret
-END (BP_SYM (__strcmp))
+END (BP_SYM (strcmp))
-strong_alias(__strcmp,strcmp)
+libc_hidden_def(strcmp)
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/x86_64/strcpy.S b/libc/string/x86_64/strcpy.S
index 0bd2a6471..d9a51b0bb 100644
--- a/libc/string/x86_64/strcpy.S
+++ b/libc/string/x86_64/strcpy.S
@@ -21,7 +21,7 @@
#include "_glibc_inc.h"
#ifndef USE_AS_STPCPY
-# define STRCPY __strcpy
+# define STRCPY strcpy
#endif
.text
@@ -152,5 +152,5 @@ ENTRY (BP_SYM (STRCPY))
retq
END (BP_SYM (STRCPY))
#ifndef USE_AS_STPCPY
-strong_alias(__strcpy,strcpy)
+libc_hidden_def(strcpy)
#endif
diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S
index 35959e500..fed12b5f6 100644
--- a/libc/string/x86_64/strcspn.S
+++ b/libc/string/x86_64/strcspn.S
@@ -26,10 +26,10 @@
#include "_glibc_inc.h"
/* BEWARE: `#ifdef strcspn' means that strcspn is redefined as `strpbrk' */
-#define STRPBRK_P (defined __strcspn)
+#define STRPBRK_P (defined strcspn)
.text
-ENTRY (__strcspn)
+ENTRY (strcspn)
movq %rdi, %rdx /* Save SRC. */
@@ -120,8 +120,8 @@ L(4): addq $256, %rsp /* remove skipset */
non-valid character */
#endif
ret
-END (__strcspn)
+END (strcspn)
#if !STRPBRK_P
-strong_alias(__strcspn,strcspn)
+libc_hidden_def(strcspn)
#endif
diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S
index 77aae71ba..0441dc46c 100644
--- a/libc/string/x86_64/strlen.S
+++ b/libc/string/x86_64/strlen.S
@@ -22,7 +22,7 @@
.text
-ENTRY (__strlen)
+ENTRY (strlen)
movq %rdi, %rcx /* Duplicate source pointer. */
andl $7, %ecx /* mask alignment bits */
movq %rdi, %rax /* duplicate destination. */
@@ -132,6 +132,6 @@ ENTRY (__strlen)
2:
subq %rdi, %rax /* compute difference to string start */
ret
-END (__strlen)
+END (strlen)
-strong_alias(__strlen,strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/x86_64/strpbrk.S b/libc/string/x86_64/strpbrk.S
index 94b14d091..db6cc24c7 100644
--- a/libc/string/x86_64/strpbrk.S
+++ b/libc/string/x86_64/strpbrk.S
@@ -1,3 +1,3 @@
-#define __strcspn __strpbrk
+#define strcspn strpbrk
#include "strcspn.S"
-strong_alias(__strpbrk,strpbrk)
+libc_hidden_def(strpbrk)
diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S
index ae5b4a1df..c126abd2e 100644
--- a/libc/string/x86_64/strspn.S
+++ b/libc/string/x86_64/strspn.S
@@ -26,7 +26,7 @@
#include "_glibc_inc.h"
.text
-ENTRY (__strspn)
+ENTRY (strspn)
movq %rdi, %rdx /* Save SRC. */
@@ -111,6 +111,6 @@ L(4): addq $256, %rsp /* remove stopset */
characters, so compute distance to first
non-valid character */
ret
-END (__strspn)
+END (strspn)
-strong_alias(__strspn,strspn)
+libc_hidden_def(strspn)