Bladeren bron

Merge branch 'master' into nptl

Conflicts:
	libc/inet/Makefile.in
	libc/inet/hostid.c

Synchronise nptl branch with master branch @ c4b750195714ec7c10aa4de15610c5aae0751c1c

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Carmelo Amoroso 14 jaren geleden
bovenliggende
commit
74ca0c98cb

+ 2 - 2
Makefile.in

@@ -264,7 +264,7 @@ HEADERS_RM-$(UCLIBC_HAS_BSD_ERR)             += err.h
 HEADERS_RM-$(UCLIBC_HAS_CRYPT)               += crypt.h
 HEADERS_RM-$(UCLIBC_HAS_EPOLL)               += sys/epoll.h
 HEADERS_RM-$(UCLIBC_HAS_FENV)                += fenv.h bits/fenv.h bits/fenvinline.h
-HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW))  += ftw.h
+HEADERS_RM-$(if $(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)),,y) += ftw.h
 HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS)   += libintl.h
 HEADERS_RM-$(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF) += printf.h
 HEADERS_RM-$(UCLIBC_HAS_GLOB)                += glob.h
@@ -300,7 +300,7 @@ else
 endif
 
 # Installs development library links.
-install_dev: install_headers all
+install_dev: install_headers install_runtime
 	$(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
 	-$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
 ifeq ($(HAVE_SHARED),y)

+ 20 - 33
libc/inet/Makefile.in

@@ -12,61 +12,48 @@ include $(top_srcdir)libc/inet/rpc/Makefile.in
 INET_DIR := $(top_srcdir)libc/inet
 INET_OUT := $(top_builddir)libc/inet
 
-CSRC :=
-ifneq ($(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
+CFLAGS-inet := -DRESOLVER="\"resolv.c\""
+CSRC-y :=
 # des uses ntohl
-CSRC += ntohl.c
-endif
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC +=	getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
+CSRC-$(findstring y,$(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ntohl.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+	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 \
 	ifaddrs.c ntop.c
-endif
-ifeq ($(UCLIBC_HAS_IPV6),y)
-CSRC += in6_addr.c
-endif
-
+CSRC-$(UCLIBC_HAS_IPV6) += in6_addr.c
 # multi source addr.c
-addr_CSRC := \
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
 	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 += \
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
 	encodeh.c decodeh.c encoded.c decoded.c \
 	encodeq.c encodea.c \
+	read_etc_hosts_r.c \
 	dnslookup.c opennameservers.c closenameservers.c \
-	read_etc_hosts_r.c get_hosts_byaddr_r.c get_hosts_byname_r.c \
 	getnameinfo.c \
-	gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c gethostent_r.c \
-	gethostbyaddr.c gethostbyname.c gethostbyname2.c gethostent.c \
+	gethostent.c gethostent_r.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+	get_hosts_byaddr_r.c get_hosts_byname_r.c \
+	gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c \
+	gethostbyaddr.c gethostbyname.c gethostbyname2.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
 	res_init.c res_query.c res_comp.c ns_name.c \
 	_res_state.c
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += $(resolv_CSRC)
 ## # unused ATM
-## CSRC += encodep.c decodep.c formquery.c
-endif
-
+## CSRC-y += encodep.c decodep.c formquery.c
 
 # 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
-ifeq ($(UCLIBC_HAS_SOCKET),y)
-CSRC += $(socketcalls_CSRC) opensock.c
-endif
+CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC) opensock.c
 
-ifneq ($(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += ethers.c ether_addr.c
-endif
+CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ethers.c ether_addr.c
 
-INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC))
-INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC))
+INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC-y))
+INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC-y))
 
 libc-y += $(INET_OBJ)
 

+ 1 - 1
libc/inet/_res_state.c

@@ -5,4 +5,4 @@
  */
 
 #define L_res_state
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/closenameservers.c

@@ -5,4 +5,4 @@
  */
 
 #define L_closenameservers
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/decodea.c

@@ -5,4 +5,4 @@
  */
 
 #define L_decodea
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/decoded.c

@@ -5,4 +5,4 @@
  */
 
 #define L_decoded
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/decodeh.c

@@ -5,4 +5,4 @@
  */
 
 #define L_decodeh
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/decodep.c

@@ -5,4 +5,4 @@
  */
 
 #define L_decodep
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/decodeq.c

@@ -5,4 +5,4 @@
  */
 
 #define L_decodeq
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/dnslookup.c

@@ -5,4 +5,4 @@
  */
 
 #define L_dnslookup
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/encodea.c

@@ -5,4 +5,4 @@
  */
 
 #define L_encodea
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/encoded.c

@@ -5,4 +5,4 @@
  */
 
 #define L_encoded
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/encodeh.c

@@ -5,4 +5,4 @@
  */
 
 #define L_encodeh
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/encodep.c

@@ -5,4 +5,4 @@
  */
 
 #define L_encodep
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/encodeq.c

@@ -5,4 +5,4 @@
  */
 
 #define L_encodeq
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/formquery.c

@@ -5,4 +5,4 @@
  */
 
 #define L_formquery
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/get_hosts_byaddr_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_get_hosts_byaddr_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/get_hosts_byname_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_get_hosts_byname_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyaddr.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyaddr
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyaddr_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyaddr_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyname.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyname
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyname2.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyname2
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyname2_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyname2_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostbyname_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostbyname_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostent.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostent
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/gethostent_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_gethostent_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/getnameinfo.c

@@ -5,4 +5,4 @@
  */
 
 #define L_getnameinfo
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/getproto.c

@@ -144,7 +144,7 @@ int getprotoent_r(struct protoent *result_buf,
     }
 again:
     if ((p = fgets(line, BUFSIZ, protof)) == NULL) {
-	rv=TRY_AGAIN;
+	rv=ENOENT;
 	goto DONE;
     }
 

+ 26 - 41
libc/inet/hostid.c

@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
 /*
  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  *
@@ -6,17 +7,15 @@
 
 #define __FORCE_GLIBC
 #include <features.h>
-#include <stdio.h>
-#include <string.h>
 #include <errno.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <fcntl.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
 #include <not-cancel.h>
 
-
 #define HOSTID "/etc/hostid"
 
 #ifdef __USE_BSD
@@ -36,23 +35,23 @@ int sethostid(long int new_id)
 }
 #endif
 
+#define _addr(a) (((struct sockaddr_in*)a->ai_addr)->sin_addr.s_addr)
 long int gethostid(void)
 {
-	char host[MAXHOSTNAMELEN + 1];
-	int fd, id;
+	char host[HOST_NAME_MAX + 1];
+	int fd, id = 0;
 
 	/* 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...
 	 */
 	fd = open_not_cancel_2(HOSTID, O_RDONLY);
-	if (fd >= 0 && read_not_cancel(fd, &id, sizeof(id)))
-	{
-		close_not_cancel_no_status (fd);
-		return id;
+	if (fd >= 0) {
+		int i = read_not_cancel(fd, &id, sizeof(id));
+		close_not_cancel_no_status(fd);
+		if (i > 0)
+			return id;
 	}
-	if (fd >= 0) close_not_cancel_no_status (fd);
-
 	/* Try some methods of returning a unique 32 bit id. Clearly IP
 	 * numbers, if on the internet, will have a unique address. If they
 	 * are not on the internet then we can return 0 which means they should
@@ -64,32 +63,18 @@ long int gethostid(void)
 	 * setting one anyway.
 	 *						Mitch
 	 */
-	if (gethostname(host, MAXHOSTNAMELEN) >= 0 && *host) {
-		struct hostent *hp;
-		struct in_addr in;
-		struct hostent ghbn_h;
-		char ghbn_buf[sizeof(struct in_addr) +
-			sizeof(struct in_addr *)*2 +
-			sizeof(char *)*((2 + 5/*MAX_ALIASES*/ +
-						1)/*ALIAS_DIM*/) +
-			256/*namebuffer*/ + 32/* margin */];
-		int ghbn_errno;
-
-		/* replace gethostbyname() with gethostbyname_r() - ron@zing.net */
-		/*if ((hp = gethostbyname(host)) == (struct hostent *)NULL)*/
-		gethostbyname_r(host, &ghbn_h, ghbn_buf, sizeof(ghbn_buf), &hp, &ghbn_errno);
-
-		if (hp == NULL) {
-		/* This is not a error if we get here, as all it means is that
-		 * this host is not on a network and/or they have not
-		 * configured their network properly. So we return the unset
-		 * hostid which should be 0, meaning that they should set it !!
-		 */
-			return 0;
+	if (gethostname(host, HOST_NAME_MAX) >= 0 && *host) {
+		struct addrinfo hints, *results, *addr;
+		memset(&hints, 0, sizeof(struct addrinfo));
+		if (!getaddrinfo(host, NULL, &hints, &results)) {
+			for (addr = results; addr; addr = results->ai_next) {
+				/* Just so it doesn't look exactly like the
+				   IP addr */
+				id = _addr(addr) << 16 | _addr(addr) >> 16;
+				break;
+			}
+			freeaddrinfo(results);
 		}
-		memcpy(&in, 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);
 	}
-	return 0;
+	return id;
 }

+ 1 - 1
libc/inet/lengthd.c

@@ -5,4 +5,4 @@
  */
 
 #define L_lengthd
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/lengthq.c

@@ -5,4 +5,4 @@
  */
 
 #define L_lengthq
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/ns_name.c

@@ -5,4 +5,4 @@
  */
 
 #define L_ns_name
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/opennameservers.c

@@ -5,4 +5,4 @@
  */
 
 #define L_opennameservers
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/read_etc_hosts_r.c

@@ -5,4 +5,4 @@
  */
 
 #define L_read_etc_hosts_r
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/res_comp.c

@@ -5,4 +5,4 @@
  */
 
 #define L_res_comp
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/res_init.c

@@ -5,4 +5,4 @@
  */
 
 #define L_res_init
-#include "resolv.c"
+#include RESOLVER

+ 1 - 1
libc/inet/res_query.c

@@ -5,4 +5,4 @@
  */
 
 #define L_res_query
-#include "resolv.c"
+#include RESOLVER

+ 2 - 0
libc/inet/resolv.c

@@ -1539,7 +1539,9 @@ FILE * __open_etc_hosts(void)
 {
 	FILE * fp;
 	if ((fp = fopen("/etc/hosts", "r")) == NULL) {
+#ifdef FALLBACK_TO_CONFIG_RESOLVCONF
 		fp = fopen("/etc/config/hosts", "r");
+#endif
 	}
 	return fp;
 }

+ 2 - 1
libc/misc/glob/glob-susv3.c

@@ -183,7 +183,8 @@ int __glob_match_in_dir(const char *d, const char *p, int flags, int (*errfunc)(
 # ifndef BUILD_GLOB64
 static
 # endif
-int __glob_ignore_err(const char *path, int err)
+int __glob_ignore_err(const char * path attribute_unused,
+			int err attribute_unused)
 {
 	return 0;
 }

+ 3 - 2
libc/misc/internals/__uClibc_main.c

@@ -271,10 +271,11 @@ libc_hidden_def(__uClibc_fini)
  */
 void __uClibc_main(int (*main)(int, char **, char **), int argc,
 		    char **argv, void (*app_init)(void), void (*app_fini)(void),
-		    void (*rtld_fini)(void), void *stack_end) attribute_noreturn;
+		    void (*rtld_fini)(void),
+		    void *stack_end attribute_unused) attribute_noreturn;
 void __uClibc_main(int (*main)(int, char **, char **), int argc,
 		    char **argv, void (*app_init)(void), void (*app_fini)(void),
-		    void (*rtld_fini)(void), void *stack_end)
+		    void (*rtld_fini)(void), void *stack_end attribute_unused)
 {
 #ifndef __ARCH_HAS_NO_LDSO__
     unsigned long *aux_dat;

+ 1 - 1
libc/misc/regex/regex_old.c

@@ -8140,7 +8140,7 @@ libc_hidden_def(regexec)
 size_t
 regerror (
     int errcode,
-    const regex_t *preg,
+    const regex_t * preg attribute_unused,
     char *errbuf,
     size_t errbuf_size)
 {

+ 10 - 10
libc/misc/wchar/wchar.c

@@ -286,7 +286,7 @@ size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
 		s = empty_string;
 		n = 1;
 	} else if (*s == '\0') {
-    /* According to the ISO C 89 standard this is the expected behaviour.  */
+	/* According to the ISO C 89 standard this is the expected behaviour.  */
 		return 0;
 	} else if (!n) {
 		/* TODO: change error code? */
@@ -600,7 +600,7 @@ size_t attribute_hidden _wchar_wcsntoutf8s(char *__restrict s, size_t n,
 		if (!s) {
 			n = SIZE_MAX;
 		}
-	    s = buf;
+		s = buf;
 		store = 0;
 	}
 
@@ -1026,9 +1026,9 @@ static const signed char new_wtbl[] = {
 
 int wcswidth(const wchar_t *pwcs, size_t n)
 {
-    int h, l, m, count;
-    wchar_t wc;
-    unsigned char b;
+	int h, l, m, count;
+	wchar_t wc;
+	unsigned char b;
 
 	if (ENCODING == __ctype_encoding_7_bit) {
 		size_t i;
@@ -1064,7 +1064,7 @@ int wcswidth(const wchar_t *pwcs, size_t n)
 	}
 #endif /* __CTYPE_HAS_UTF_8_LOCALES */
 
-    for (count = 0 ; n && (wc = *pwcs++) ; n--) {
+	for (count = 0 ; n && (wc = *pwcs++) ; n--) {
 		if (wc <= 0xff) {
 			/* If we're here, wc != 0. */
 			if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) {
@@ -1114,9 +1114,9 @@ int wcswidth(const wchar_t *pwcs, size_t n)
 		}
 
 		++count;
-    }
+	}
 
-    return count;
+	return count;
 }
 
 #else  /*  __UCLIBC_HAS_LOCALE__ */
@@ -1133,7 +1133,7 @@ int wcswidth(const wchar_t *pwcs, size_t n)
 		}
 	}
 
-    for (count = 0 ; n && (wc = *pwcs++) ; n--) {
+	for (count = 0 ; n && (wc = *pwcs++) ; n--) {
 		if (wc <= 0xff) {
 			/* If we're here, wc != 0. */
 			if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) {
@@ -1160,7 +1160,7 @@ libc_hidden_def(wcswidth)
 
 int wcwidth(wchar_t wc)
 {
-    return wcswidth(&wc, 1);
+	return wcswidth(&wc, 1);
 }
 
 #endif

+ 2 - 2
libc/pwd_grp/lckpwdf.c

@@ -146,7 +146,7 @@ ulckpwdf (void)
 
 
 static void
-noop_handler (int sig)
-{
+noop_handler (int sig attribute_unused) {
+
   /* We simply return which makes the `fcntl' call return with an error.  */
 }

+ 3 - 1
libc/sysdeps/linux/common/sysctl.c

@@ -10,6 +10,7 @@
 #include <sys/syscall.h>
 #if defined __NR__sysctl && (defined __USE_GNU || defined __USE_BSD)
 
+/* psm: including sys/sysctl.h would depend on kernel headers */
 struct __sysctl_args {
 	int *name;
 	int nlen;
@@ -19,7 +20,8 @@ struct __sysctl_args {
 	size_t newlen;
 	unsigned long __unused[4];
 };
-
+extern int sysctl (int *__name, int __nlen, void *__oldval,
+				   size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
 int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp,
 		   void *newval, size_t newlen)
 {