diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-06-03 08:11:56 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-06-03 08:11:56 +0000 |
commit | 4cc4b30426c5e5a0ecf912791e3f27312438d10e (patch) | |
tree | 81c31f4bde953f135d9e63582b162c17cc173f10 /libc/inet | |
parent | 1f124eb0280a5009f1265a9dca49fdb0d95b845e (diff) |
- adds several config-options to allow for turning off certain features
like
o UCLIBC_HAS_GNU_ERROR
o UCLIBC_HAS_BSD_ERR
o UCLIBC_HAS_PTY
o UCLIBC_HAS_GETPT (1)
o UCLIBC_SYSCALL_STUBS
o UCLIBC_SYSCALL_STUB_WARNING
o UCLIBC_LINUX_SPECIFIC (2)
o UCLIBC_BSD_SPECIFIC (3)
o UCLIBC_NTP_LEGACY (4)
o UCLIBC_SV4_DEPRECATED (5)
o UCLIBC_HAVE_REALTIME (6)
o UCLIBC_HAVE_ADVANCED_REALTIME (7)
o UCLIBC_HAVE_EPOLL (8)
o UCLIBC_HAVE_XATTR (9)
o UCLIBC_HAVE_PROFILING (10)
(1) make non-standard getpt optional and implement standard posix_openpt
(2) fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(),
personality()
ppoll(), setresuid()
(3) mincore(), getdomainname(), setdomainname()
(4) ntp_adjtime(), ntp_gettime() aliases
(5) ustat() [use statfs(2) in your code instead]
(6) All marked as "(REALTIME)" in SUSv3
(7) All marked as "(ADVANCED REALTIME)" in SUSv3
(8) epoll_create(), epoll_ctl(), epoll_wait()
(9) all Extended Attributes
(10) helpers for gcc's -finstrument-functions
- Fixes _dl_exit()
- Implements sleep(3) for !UCLIBC_HAVE_REALTIME
- Implements usleep(3) for !UCLIBC_HAVE_REALTIME
- adds #warning about incorrect posix_fadvise{,64}()
- removes unused and unwanted uselib()
Net outcome is that an allnoconfig with HAVE_SHARED is now about 88k instead
of formerly 130k.
Diffstat (limited to 'libc/inet')
-rw-r--r-- | libc/inet/Makefile.in | 21 | ||||
-rw-r--r-- | libc/inet/getaddrinfo.c | 22 | ||||
-rw-r--r-- | libc/inet/hostid.c | 2 | ||||
-rw-r--r-- | libc/inet/if_index.c | 8 | ||||
-rw-r--r-- | libc/inet/resolv.c | 36 | ||||
-rw-r--r-- | libc/inet/socketcalls.c | 11 |
6 files changed, 65 insertions, 35 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index f3f65f4e7..493041ff6 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -10,14 +10,22 @@ include $(top_srcdir)libc/inet/rpc/Makefile.in INET_DIR := $(top_srcdir)libc/inet INET_OUT := $(top_builddir)libc/inet -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 +CSRC := +ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) +CSRC += getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \ + inet_net.c herror.c if_index.c gai_strerror.c getaddrinfo.c \ + ether_addr.c ntohl.c ifaddrs.c ntop.c +endif +ifeq ($(UCLIBC_HAS_IPV6),y) +CSRC += in6_addr.c +endif # multi source addr.c addr_CSRC := inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \ inet_lnaof.c inet_netof.c +ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) CSRC += $(addr_CSRC) +endif # multi source resolv.c resolv_CSRC += encodeh.c decodeh.c encoded.c decoded.c lengthd.c encodeq.c \ @@ -28,16 +36,21 @@ resolv_CSRC += encodeh.c decodeh.c encoded.c decoded.c lengthd.c encodeq.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 ethers.c +ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) CSRC += $(resolv_CSRC) # unused ATM CSRC += encodep.c decodep.c formquery.c +endif + # multi source socketcalls.c socketcalls_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 -CSRC += $(socketcalls_CSRC) +ifeq ($(UCLIBC_HAS_SOCKET),y) +CSRC += $(socketcalls_CSRC) opensock.c +endif INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC)) INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC)) diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 0b885afd2..e3caf6f0d 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -501,7 +501,7 @@ gaih_inet (const char *name, const struct gaih_service *service, return -EAI_FAMILY; } -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ if (at->family == AF_UNSPEC) { char *namebuf = strdupa (name); @@ -558,7 +558,7 @@ gaih_inet (const char *name, const struct gaih_service *service, * IPv6 addresses. */ -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6) gethosts (AF_INET6, struct in6_addr); #endif @@ -598,7 +598,7 @@ gaih_inet (const char *name, const struct gaih_service *service, memset (at->next, '\0', sizeof (struct gaih_addrtuple)); } -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ if (req->ai_family == 0 || req->ai_family == AF_INET6) { at->family = AF_INET6; @@ -680,19 +680,22 @@ gaih_inet (const char *name, const struct gaih_service *service, else namelen = 0; -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ if (at2->family == AF_INET6 || v4mapped) { family = AF_INET6; socklen = sizeof (struct sockaddr_in6); } +#endif +#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__ else #endif +#if defined __UCLIBC_HAS_IPV4__ { family = AF_INET; socklen = sizeof (struct sockaddr_in); } - +#endif for (st2 = st; st2 != NULL; st2 = st2->next) { *pai = malloc (sizeof (struct addrinfo) + socklen + namelen); @@ -710,7 +713,7 @@ gaih_inet (const char *name, const struct gaih_service *service, #endif /* SALEN */ (*pai)->ai_addr->sa_family = family; -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ if (family == AF_INET6) { struct sockaddr_in6 *sin6p = @@ -733,8 +736,11 @@ gaih_inet (const char *name, const struct gaih_service *service, sin6p->sin6_port = st2->port; sin6p->sin6_scope_id = at2->scopeid; } +#endif +#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__ else #endif +#if defined __UCLIBC_HAS_IPV4__ { struct sockaddr_in *sinp = (struct sockaddr_in *) (*pai)->ai_addr; @@ -744,7 +750,7 @@ gaih_inet (const char *name, const struct gaih_service *service, sinp->sin_port = st2->port; memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero)); } - +#endif if (c) { (*pai)->ai_canonname = ((void *) (*pai) + @@ -766,7 +772,7 @@ gaih_inet (const char *name, const struct gaih_service *service, static struct gaih gaih[] = { -#if __UCLIBC_HAS_IPV6__ +#if defined __UCLIBC_HAS_IPV6__ { PF_INET6, gaih_inet }, #endif { PF_INET, gaih_inet }, diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c index 170d87361..c11ab6c12 100644 --- a/libc/inet/hostid.c +++ b/libc/inet/hostid.c @@ -47,7 +47,7 @@ long int gethostid(void) char host[MAXHOSTNAMELEN + 1]; int fd, id; - /* If hostid was already set the we can return that value. + /* If hostid was already set then 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... */ diff --git a/libc/inet/if_index.c b/libc/inet/if_index.c index 03e7089cf..005d9d09e 100644 --- a/libc/inet/if_index.c +++ b/libc/inet/if_index.c @@ -287,14 +287,6 @@ if_nameindex (void) #endif libc_hidden_def(if_nameindex) -#if 0 -struct if_nameindex * -if_nameindex (void) -{ - return (if_nameindex_netlink () != NULL ? : if_nameindex_ioctl ()); -} -#endif - char * if_indextoname (unsigned int ifindex, char *ifname) { diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 9776fa4a7..ce19c8698 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -187,7 +187,6 @@ 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) @@ -218,11 +217,12 @@ libc_hidden_proto(fprintf) libc_hidden_proto(__h_errno_location) #ifdef __UCLIBC_HAS_XLOCALE__ libc_hidden_proto(__ctype_b_loc) -#elif __UCLIBC_HAS_CTYPE_TABLES__ +#elif defined __UCLIBC_HAS_CTYPE_TABLES__ libc_hidden_proto(__ctype_b) #endif libc_hidden_proto(__uc_malloc) - +int __libc_getdomainname(char *name, size_t len); +libc_hidden_proto(__libc_getdomainname) #define MAX_RECURSE 5 @@ -747,12 +747,14 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char unsigned char * packet = malloc(PACKETSZ); char *dns, *lookup = malloc(MAXDNAME); int variant = -1; - struct sockaddr_in sa; int local_ns = -1, local_id = -1; #ifdef __UCLIBC_HAS_IPV6__ bool v6; struct sockaddr_in6 sa6; #endif +#ifdef __UCLIBC_HAS_IPV4__ + struct sockaddr_in sa; +#endif fd = -1; @@ -840,6 +842,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char rc = connect(fd, (struct sockaddr *) &sa6, sizeof(sa6)); } else { #endif +#ifdef __UCLIBC_HAS_IPV4__ sa.sin_family = AF_INET; sa.sin_port = htons(NAMESERVER_PORT); __UCLIBC_MUTEX_LOCK(__resolv_lock); @@ -848,6 +851,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char sa.sin_addr.s_addr = inet_addr(dns); __UCLIBC_MUTEX_UNLOCK(__resolv_lock); rc = connect(fd, (struct sockaddr *) &sa, sizeof(sa)); +#endif #ifdef __UCLIBC_HAS_IPV6__ } #endif @@ -1853,15 +1857,19 @@ int getnameinfo(const struct sockaddr *sa, socklen_t addrlen, char *host, ok = sa->sa_family; if (ok == AF_LOCAL) /* valid */; +#ifdef __UCLIBC_HAS_IPV4__ else if (ok == AF_INET) { if (addrlen < sizeof (struct sockaddr_in)) goto BAD_FAM; + } +#endif #ifdef __UCLIBC_HAS_IPV6__ - } else if (ok == AF_INET6) { + else if (ok == AF_INET6) { if (addrlen < sizeof (struct sockaddr_in6)) goto BAD_FAM; + } #endif /* __UCLIBC_HAS_IPV6__ */ - } else + else BAD_FAM: return EAI_FAMILY; @@ -1878,15 +1886,19 @@ BAD_FAM: h = gethostbyaddr ((const void *) &(((const struct sockaddr_in6 *) sa)->sin6_addr), sizeof(struct in6_addr), AF_INET6); - else #endif /* __UCLIBC_HAS_IPV6__ */ +#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__ + else +#endif +#ifdef __UCLIBC_HAS_IPV4__ h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr), sizeof(struct in_addr), AF_INET); +#endif /* __UCLIBC_HAS_IPV4__ */ if (h) { char *c; if ((flags & NI_NOFQDN) - && (getdomainname (domain, sizeof(domain)) == 0) + && (__libc_getdomainname (domain, sizeof(domain)) == 0) && (c = strstr (h->h_name, domain)) && (c != h->h_name) && (*(--c) == '.')) { strncpy (host, h->h_name, @@ -1952,11 +1964,16 @@ BAD_FAM: memcpy (host + real_hostlen, scopebuf, scopelen + 1); } #endif - } else + } #endif /* __UCLIBC_HAS_IPV6__ */ +#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__ + else +#endif /* __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__ */ +#if defined __UCLIBC_HAS_IPV4__ c = inet_ntop (AF_INET, (const void *) &(((const struct sockaddr_in *) sa)->sin_addr), host, hostlen); +#endif /* __UCLIBC_HAS_IPV4__ */ if (c == NULL) { errno = serrno; @@ -2752,3 +2769,4 @@ int ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, } libc_hidden_def(ns_name_unpack) #endif /* L_ns_name */ +/* vi: set sw=4 ts=4: */ diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c index 9a6e2e151..ca93f6a18 100644 --- a/libc/inet/socketcalls.c +++ b/libc/inet/socketcalls.c @@ -168,7 +168,8 @@ libc_hidden_def(listen) 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); +_syscall4(ssize_t, __libc_recv, int, sockfd, __ptr_t, buffer, size_t, len, + int, flags); #elif defined(__NR_socketcall) /* recv, recvfrom added by bir7@leland.stanford.edu */ ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags) @@ -197,8 +198,8 @@ libc_hidden_weak(recv) 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, - struct sockaddr *, to, socklen_t *, tolen); +_syscall6(ssize_t, __libc_recvfrom, int, sockfd, __ptr_t, buffer, size_t, len, + int, flags, struct sockaddr *, to, socklen_t *, tolen); #elif defined(__NR_socketcall) /* recv, recvfrom added by bir7@leland.stanford.edu */ ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags, @@ -295,8 +296,8 @@ libc_hidden_weak(sendmsg) 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, - int, flags, const struct sockaddr *, to, socklen_t, tolen); +_syscall6(ssize_t, __libc_sendto, int, sockfd, const void *, buffer, + size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen); #elif defined(__NR_socketcall) /* send, sendto added by bir7@leland.stanford.edu */ ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags, |