All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/9 v2] package/musl-compat-headers: provide compatibility headers not in musl
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 2/9 v2] package/rpcbind: fix musl build Yann E. MORIN
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

musl provides neither sys/queue.h nor sys/cdefs.h. Those two headers are
however quite widely used in a lot of packages (though they should at
least not use cdefs.h which is only full of mostly-legacy macros, and
which is mostly an internal header of glibc and was never really meant to
be exposed to, and used by packages).

But we don't live in an ideal world, so a lot of packages break when
those two headers are missing.

We already took care of sys/queue.h with the netbsd-queue package. But
the need for cdefs.h is getting more and more pressing.

We rename the netbsd-queue package into musl-compat-headers, and we
make it install sys/queue.h (from NetBSD) and sys/cdefs.h (a minimalist
one we bundle in Buildroot). We can't use the cdefs.h from NetBSD
because it includes machine-dependent headers; instead we bundle a very
minimalistic one, that covers only what we need.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: Arnout Vandecappelle <arnout@mind.be>

---
Changes v1 -> v2:
  - don't use a main download, just extra downloads  (Arnout)
  - add headers as license files  (Arnout)
  - fix my name in the cdefs.h copyright header  (Baruch)
  - typoes  (Arnout)
  - add __THROW and __NTH() as they are used by some packages (but
    currently patched-out)
---
 package/Config.in                                  |  2 +-
 package/musl-compat-headers/Config.in              |  2 +
 package/musl-compat-headers/cdefs.h                | 51 ++++++++++++++++++++++
 .../musl-compat-headers.hash}                      |  0
 package/musl-compat-headers/musl-compat-headers.mk | 34 +++++++++++++++
 package/musl/Config.in                             |  3 +-
 package/musl/musl.mk                               | 10 +++--
 package/netbsd-queue/Config.in                     |  2 -
 package/netbsd-queue/netbsd-queue.mk               | 24 ----------
 toolchain/toolchain-external/Config.in             |  3 +-
 toolchain/toolchain-external/toolchain-external.mk | 10 +++--
 11 files changed, 104 insertions(+), 37 deletions(-)
 create mode 100644 package/musl-compat-headers/Config.in
 create mode 100644 package/musl-compat-headers/cdefs.h
 rename package/{netbsd-queue/netbsd-queue.hash => musl-compat-headers/musl-compat-headers.hash} (100%)
 create mode 100644 package/musl-compat-headers/musl-compat-headers.mk
 delete mode 100644 package/netbsd-queue/Config.in
 delete mode 100644 package/netbsd-queue/netbsd-queue.mk

diff --git a/package/Config.in b/package/Config.in
index 645fa29..1e51a45 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1324,7 +1324,7 @@ endif
 	source "package/mpfr/Config.in"
 	source "package/msgpack/Config.in"
 	source "package/mtdev2tuio/Config.in"
-	source "package/netbsd-queue/Config.in"
+	source "package/musl-compat-headers/Config.in"
 	source "package/openblas/Config.in"
 	source "package/orc/Config.in"
 	source "package/p11-kit/Config.in"
diff --git a/package/musl-compat-headers/Config.in b/package/musl-compat-headers/Config.in
new file mode 100644
index 0000000..c672f9c
--- /dev/null
+++ b/package/musl-compat-headers/Config.in
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_MUSL_COMPAT_HEADERS
+	bool
diff --git a/package/musl-compat-headers/cdefs.h b/package/musl-compat-headers/cdefs.h
new file mode 100644
index 0000000..6fe7aa4
--- /dev/null
+++ b/package/musl-compat-headers/cdefs.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 2016 Yann E. MORIN <yann.morin.1998@free.fr>
+ *
+ * This file is in the Public Domain.
+ *
+ * For jurisdictions in which the Public Domain does not exist
+ * or it is not otherwise applicable, this file is licensed CC0
+ * (Creative Commons Zero).
+ */
+
+/* This file contains definitions for non-standard macros defined by
+ * glibc, but quite commonly used in packages.
+ *
+ * Because they are non-standard, musl does not define those macros.
+ * It does not provide cdefs.h either.
+ *
+ * This file is a compatibility header written from scratch, to be
+ * installed when the C library is musl.
+ *
+ * Not all macros from the glibc's cdefs.h are available, only the
+ * most commonly used ones.
+ *
+ * Please refer to the glibc documentation and source code for
+ * explanations about those macros.
+ */
+
+#ifndef BUILDROOT_SYS_CDEFS_H
+#define BUILDROOT_SYS_CDEFS_H
+
+/* Function prototypes. */
+#undef __P
+#define __P(arg) arg
+
+/* C declarations in C++ mode. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS   }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+/* Don't throw exceptions in C functions. */
+#ifndef __cplusplus
+# define __THROW  __attribute__ ((__nothrow__))
+# define __NTH(f) __attribute__ ((__nothrow__)) f
+#else
+# define __THROW
+# define __NTH(f) f
+#endif
+
+#endif /* ifndef BUILDROOT_SYS_CDEFS_H */
diff --git a/package/netbsd-queue/netbsd-queue.hash b/package/musl-compat-headers/musl-compat-headers.hash
similarity index 100%
rename from package/netbsd-queue/netbsd-queue.hash
rename to package/musl-compat-headers/musl-compat-headers.hash
diff --git a/package/musl-compat-headers/musl-compat-headers.mk b/package/musl-compat-headers/musl-compat-headers.mk
new file mode 100644
index 0000000..25e032c
--- /dev/null
+++ b/package/musl-compat-headers/musl-compat-headers.mk
@@ -0,0 +1,34 @@
+################################################################################
+#
+# musl-compat-headers
+#
+################################################################################
+
+# No main site, just using extra downloads
+MUSL_COMPAT_HEADERS_QUEUE_H = http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/queue.h?rev=1.70
+
+MUSL_COMPAT_HEADERS_EXTRA_DOWNLOADS = $(MUSL_COMPAT_HEADERS_QUEUE_H)
+
+MUSL_COMPAT_HEADERS_LICENSE = BSD-3c, Public Domain or CC0
+MUSL_COMPAT_HEADERS_LICENSE_FILES = queue.h cdefs.h
+
+MUSL_COMPAT_HEADERS_ADD_TOOLCHAIN_DEPENDENCY = NO
+
+# Only installs headers
+MUSL_COMPAT_HEADERS_INSTALL_TARGET = NO
+MUSL_COMPAT_HEADERS_INSTALL_STAGING = YES
+
+# Copying both headers so legal-info finds them (they are _LICENSE_FILES)
+define MUSL_COMPAT_HEADERS_EXTRACT_CMDS
+	$(INSTALL) -m 0644 -D $(DL_DIR)/$(notdir $(MUSL_COMPAT_HEADERS_QUEUE_H)) $(@D)/queue.h
+	$(INSTALL) -m 0644 -D $(MUSL_COMPAT_HEADERS_PKGDIR)/cdefs.h $(@D)/cdefs.h
+endef
+
+define MUSL_COMPAT_HEADERS_INSTALL_STAGING_CMDS
+	$(INSTALL) -D -m 0644 $(@D)/queue.h \
+		$(STAGING_DIR)/usr/include/sys/queue.h
+	$(INSTALL) -D -m 0644 $(@D)/cdefs.h \
+		$(STAGING_DIR)/usr/include/sys/cdefs.h
+endef
+
+$(eval $(generic-package))
diff --git a/package/musl/Config.in b/package/musl/Config.in
index c263006..18ae69d 100644
--- a/package/musl/Config.in
+++ b/package/musl/Config.in
@@ -3,5 +3,6 @@ config BR2_PACKAGE_MUSL
 	depends on BR2_TOOLCHAIN_USES_MUSL
 	default y
 	select BR2_PACKAGE_LINUX_HEADERS
-	select BR2_PACKAGE_NETBSD_QUEUE
 	select BR2_TOOLCHAIN_HAS_SSP
+	# Compatibility headers: cdefs.h, queue.h
+	select BR2_PACKAGE_MUSL_COMPAT_HEADERS
diff --git a/package/musl/musl.mk b/package/musl/musl.mk
index 920bbbf..ea1ce6d 100644
--- a/package/musl/musl.mk
+++ b/package/musl/musl.mk
@@ -13,10 +13,12 @@ MUSL_LICENSE_FILES = COPYRIGHT
 # cross-compiler and the kernel headers
 MUSL_DEPENDENCIES = host-gcc-initial linux-headers
 
-# musl does not provide a sys/queue.h implementation, so add the
-# netbsd-queue package that will install a sys/queue.h file in the
-# staging directory based on the NetBSD implementation.
-MUSL_DEPENDENCIES += netbsd-queue
+# musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
+# So, add the musl-compat-headers package that will install those files,
+# into the staging directory:
+#   sys/queue.h:  header from NetBSD
+#   sys/cdefs.h:  minimalist header bundled in Buildroot
+MUSL_DEPENDENCIES += musl-compat-headers
 
 # musl is part of the toolchain so disable the toolchain dependency
 MUSL_ADD_TOOLCHAIN_DEPENDENCY = NO
diff --git a/package/netbsd-queue/Config.in b/package/netbsd-queue/Config.in
deleted file mode 100644
index 7837f4c..0000000
--- a/package/netbsd-queue/Config.in
+++ /dev/null
@@ -1,2 +0,0 @@
-config BR2_PACKAGE_NETBSD_QUEUE
-	bool
diff --git a/package/netbsd-queue/netbsd-queue.mk b/package/netbsd-queue/netbsd-queue.mk
deleted file mode 100644
index 5fd926b..0000000
--- a/package/netbsd-queue/netbsd-queue.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-#
-# netbsd-queue
-#
-################################################################################
-
-NETBSD_QUEUE_VERSION = 1.70
-NETBSD_QUEUE_SITE = http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys
-NETBSD_QUEUE_SOURCE = queue.h?rev=$(NETBSD_QUEUE_VERSION)
-NETBSD_QUEUE_LICENSE = BSD-3c
-
-NETBSD_QUEUE_ADD_TOOLCHAIN_DEPENDENCY = NO
-NETBSD_QUEUE_INSTALL_STAGING = YES
-
-define NETBSD_QUEUE_EXTRACT_CMDS
-	cp $(DL_DIR)/$(NETBSD_QUEUE_SOURCE) $(@D)/queue.h
-endef
-
-define NETBSD_QUEUE_INSTALL_STAGING_CMDS
-	$(INSTALL) -D -m 0644 $(@D)/queue.h \
-		$(STAGING_DIR)/usr/include/sys/queue.h
-endef
-
-$(eval $(generic-package))
diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in
index f54fbee..63b7712 100644
--- a/toolchain/toolchain-external/Config.in
+++ b/toolchain/toolchain-external/Config.in
@@ -727,7 +727,8 @@ config BR2_TOOLCHAIN_EXTERNAL_UCLIBC
 config BR2_TOOLCHAIN_EXTERNAL_MUSL
 	bool
 	select BR2_TOOLCHAIN_USES_MUSL
-	select BR2_PACKAGE_NETBSD_QUEUE
+	# Compatibility headers: cdefs.h, queue.h
+	select BR2_PACKAGE_MUSL_COMPAT_HEADERS
 
 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
diff --git a/toolchain/toolchain-external/toolchain-external.mk b/toolchain/toolchain-external/toolchain-external.mk
index 29c1f36..8de3247 100644
--- a/toolchain/toolchain-external/toolchain-external.mk
+++ b/toolchain/toolchain-external/toolchain-external.mk
@@ -246,11 +246,13 @@ TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
 TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
 endif
 
-# musl does not provide a sys/queue.h implementation, so add the
-# netbsd-queue package that will install a sys/queue.h file in the
-# staging directory based on the NetBSD implementation.
+# musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
+# So, add the musl-compat-headers package that will install those files,
+# into the staging directory:
+#   sys/queue.h:  header from NetBSD
+#   sys/cdefs.h:  minimalist header bundled in Buildroot
 ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
-TOOLCHAIN_EXTERNAL_DEPENDENCIES += netbsd-queue
+TOOLCHAIN_EXTERNAL_DEPENDENCIES += musl-compat-headers
 endif
 
 # The Linaro toolchain expects the libraries in
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 2/9 v2] package/rpcbind: fix musl build
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 1/9 v2] package/musl-compat-headers: provide compatibility headers not in musl Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 3/9 v2] package/aircrack-ng: drop a musl-compatibility patch Yann E. MORIN
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

rpcbind uses the __P() macro defined in sys/cdefs.h but does not
includes it explicitly, relying on the glibc behaviour to include it
from its own headers.

But this macro does nothing but expands as its argument. In the past,
it did provide support for pre-ANSI compilers that did not support
function prototypes. Those are now gone, and glibc provides this macro
for legacy code.

Patch out the use of __P() altogether.

Fixes:
    http://autobuild.buildroot.org/results/346/346c5b562c244ddb039db2f86f71d670a01ed9ce/
    http://autobuild.buildroot.org/results/d77/d77454265c45539178c008c5d92509c441447675/
    and numerous such autobuild failures

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

---
Changes v1 -> v2:
  - don't include cdefs.h, remove use of __P() as it is what upstream
    prefers.
---
 .../0003-src-remove-use-of-the-__P-macro.patch     | 243 +++++++++++++++++++++
 1 file changed, 243 insertions(+)
 create mode 100644 package/rpcbind/0003-src-remove-use-of-the-__P-macro.patch

diff --git a/package/rpcbind/0003-src-remove-use-of-the-__P-macro.patch b/package/rpcbind/0003-src-remove-use-of-the-__P-macro.patch
new file mode 100644
index 0000000..72fda88
--- /dev/null
+++ b/package/rpcbind/0003-src-remove-use-of-the-__P-macro.patch
@@ -0,0 +1,243 @@
+From 2f7d15304e0544e4c693c86d8ab8b2f08b9e9886 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Date: Mon, 15 Aug 2016 16:36:40 +0200
+Subject: [PATCH] src: remove use of the __P() macro
+
+The __P() macro is a legacy compatibility macro aimed making pre-ANSI
+(i.e. K&R) compilers that do not support function prototypes happy,
+while still allowing such prototypes for ANSI-compliant compilers.
+
+Since virtually all compilers have been ANSI-compliant for a few decades
+now, use of __P() is totally useless.
+
+Furthermore, __P() is defined in the non-standard sys/cdefs.h header.
+This header is present in glibc and uClibc, and both have it included
+from many of their headers. So, sys/cdefs.h is automagically included in
+most cases and its macros are available.
+
+However, the musl C library does not provide this sys/cdefs.h header.
+Thus, the build breaks on musl.
+
+For all the above reasons, get rid of __P() wherever it is used; just
+always declare real function prototypes.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Cc: Chuck Lever <chuck.lever@oracle.com>
+Cc: Steve Dickson <SteveD@redhat.com>
+---
+ src/check_bound.c  |  2 +-
+ src/pmap_svc.c     | 10 +++++-----
+ src/rpcb_svc.c     | 10 +++++-----
+ src/rpcb_svc_4.c   | 14 ++++++--------
+ src/rpcb_svc_com.c | 46 +++++++++++++++++++++++-----------------------
+ src/rpcbind.c      | 12 ++++++------
+ src/util.c         |  2 +-
+ src/warmstart.c    |  4 ++--
+ 8 files changed, 49 insertions(+), 51 deletions(-)
+
+diff --git a/src/check_bound.c b/src/check_bound.c
+index c70b845..92bfd36 100644
+--- a/src/check_bound.c
++++ b/src/check_bound.c
+@@ -70,7 +70,7 @@ static struct fdlist *fdhead;	/* Link list of the check fd's */
+ static struct fdlist *fdtail;
+ static char *nullstring = "";
+ 
+-static bool_t check_bound __P((struct fdlist *, char *uaddr));
++static bool_t check_bound(struct fdlist *, char *uaddr);
+ 
+ /*
+  * Returns 1 if the given address is bound for the given addr & transport
+diff --git a/src/pmap_svc.c b/src/pmap_svc.c
+index ad28b93..4c744fe 100644
+--- a/src/pmap_svc.c
++++ b/src/pmap_svc.c
+@@ -60,11 +60,11 @@ static	char sccsid[] = "@(#)pmap_svc.c 1.23 89/04/05 Copyr 1984 Sun Micro";
+ #include "rpcbind.h"
+ #include "xlog.h"
+ #include <rpc/svc_soc.h> /* svc_getcaller routine definition */
+-static struct pmaplist *find_service_pmap __P((rpcprog_t, rpcvers_t,
+-					       rpcprot_t));
+-static bool_t pmapproc_change __P((struct svc_req *, SVCXPRT *, u_long));
+-static bool_t pmapproc_getport __P((struct svc_req *, SVCXPRT *));
+-static bool_t pmapproc_dump __P((struct svc_req *, SVCXPRT *));
++static struct pmaplist *find_service_pmap(rpcprog_t, rpcvers_t,
++					       rpcprot_t);
++static bool_t pmapproc_change(struct svc_req *, SVCXPRT *, u_long);
++static bool_t pmapproc_getport(struct svc_req *, SVCXPRT *);
++static bool_t pmapproc_dump(struct svc_req *, SVCXPRT *);
+ 
+ /*
+  * Called for all the version 2 inquiries.
+diff --git a/src/rpcb_svc.c b/src/rpcb_svc.c
+index bd92201..709e3fb 100644
+--- a/src/rpcb_svc.c
++++ b/src/rpcb_svc.c
+@@ -53,10 +53,10 @@
+ #include "rpcbind.h"
+ #include "xlog.h"
+ 
+-static void *rpcbproc_getaddr_3_local __P((void *, struct svc_req *, SVCXPRT *,
+-					   rpcvers_t));
+-static void *rpcbproc_dump_3_local __P((void *, struct svc_req *, SVCXPRT *,
+-					rpcvers_t));
++static void *rpcbproc_getaddr_3_local(void *, struct svc_req *, SVCXPRT *,
++					   rpcvers_t);
++static void *rpcbproc_dump_3_local(void *, struct svc_req *, SVCXPRT *,
++					rpcvers_t);
+ 
+ /*
+  * Called by svc_getreqset. There is a separate server handle for
+@@ -75,7 +75,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
+ 	} argument;
+ 	char *result;
+ 	xdrproc_t xdr_argument, xdr_result;
+-	void *(*local) __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
++	void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
+ 	rpcprog_t setprog = 0;
+ 
+ 	rpcbs_procinfo(RPCBVERS_3_STAT, rqstp->rq_proc);
+diff --git a/src/rpcb_svc_4.c b/src/rpcb_svc_4.c
+index b673452..5094879 100644
+--- a/src/rpcb_svc_4.c
++++ b/src/rpcb_svc_4.c
+@@ -54,13 +54,11 @@
+ #include "rpcbind.h"
+ #include "xlog.h"
+ 
+-static void *rpcbproc_getaddr_4_local __P((void *, struct svc_req *, SVCXPRT *,
+-				      rpcvers_t));
+-static void *rpcbproc_getversaddr_4_local __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
+-static void *rpcbproc_getaddrlist_4_local
+-	__P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
+-static void free_rpcb_entry_list __P((rpcb_entry_list_ptr *));
+-static void *rpcbproc_dump_4_local __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
++static void *rpcbproc_getaddr_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
++static void *rpcbproc_getversaddr_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
++static void *rpcbproc_getaddrlist_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
++static void free_rpcb_entry_list(rpcb_entry_list_ptr *);
++static void *rpcbproc_dump_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
+ 
+ /*
+  * Called by svc_getreqset. There is a separate server handle for
+@@ -78,7 +76,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
+ 	} argument;
+ 	char *result;
+ 	xdrproc_t xdr_argument, xdr_result;
+-	void *(*local) __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
++	void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
+ 	rpcprog_t setprog = 0;
+ 
+ 	rpcbs_procinfo(RPCBVERS_4_STAT, rqstp->rq_proc);
+diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
+index 148fe42..5862c26 100644
+--- a/src/rpcb_svc_com.c
++++ b/src/rpcb_svc_com.c
+@@ -100,29 +100,29 @@ struct finfo {
+ static struct finfo     FINFO[NFORWARD];
+ 
+ 
+-static bool_t xdr_encap_parms __P((XDR *, struct encap_parms *));
+-static bool_t xdr_rmtcall_args __P((XDR *, struct r_rmtcall_args *));
+-static bool_t xdr_rmtcall_result __P((XDR *, struct r_rmtcall_args *));
+-static bool_t xdr_opaque_parms __P((XDR *, struct r_rmtcall_args *));
+-static int find_rmtcallfd_by_netid __P((char *));
+-static SVCXPRT *find_rmtcallxprt_by_fd __P((int));
+-static int forward_register __P((u_int32_t, struct netbuf *, int, char *,
+-    rpcproc_t, rpcvers_t, u_int32_t *));
+-static struct finfo *forward_find __P((u_int32_t));
+-static int free_slot_by_xid __P((u_int32_t));
+-static int free_slot_by_index __P((int));
+-static int netbufcmp __P((struct netbuf *, struct netbuf *));
+-static struct netbuf *netbufdup __P((struct netbuf *));
+-static void netbuffree __P((struct netbuf *));
+-static int check_rmtcalls __P((struct pollfd *, int));
+-static void xprt_set_caller __P((SVCXPRT *, struct finfo *));
+-static void send_svcsyserr __P((SVCXPRT *, struct finfo *));
+-static void handle_reply __P((int, SVCXPRT *));
+-static void find_versions __P((rpcprog_t, char *, rpcvers_t *, rpcvers_t *));
+-static rpcblist_ptr find_service __P((rpcprog_t, rpcvers_t, char *));
+-static char *getowner __P((SVCXPRT *, char *, size_t));
+-static int add_pmaplist __P((RPCB *));
+-static int del_pmaplist __P((RPCB *));
++static bool_t xdr_encap_parms(XDR *, struct encap_parms *);
++static bool_t xdr_rmtcall_args(XDR *, struct r_rmtcall_args *);
++static bool_t xdr_rmtcall_result(XDR *, struct r_rmtcall_args *);
++static bool_t xdr_opaque_parms(XDR *, struct r_rmtcall_args *);
++static int find_rmtcallfd_by_netid(char *);
++static SVCXPRT *find_rmtcallxprt_by_fd(int);
++static int forward_register(u_int32_t, struct netbuf *, int, char *,
++    rpcproc_t, rpcvers_t, u_int32_t *);
++static struct finfo *forward_find(u_int32_t);
++static int free_slot_by_xid(u_int32_t);
++static int free_slot_by_index(int);
++static int netbufcmp(struct netbuf *, struct netbuf *);
++static struct netbuf *netbufdup(struct netbuf *);
++static void netbuffree(struct netbuf *);
++static int check_rmtcalls(struct pollfd *, int);
++static void xprt_set_caller(SVCXPRT *, struct finfo *);
++static void send_svcsyserr(SVCXPRT *, struct finfo *);
++static void handle_reply(int, SVCXPRT *);
++static void find_versions(rpcprog_t, char *, rpcvers_t *, rpcvers_t *);
++static rpcblist_ptr find_service(rpcprog_t, rpcvers_t, char *);
++static char *getowner(SVCXPRT *, char *, size_t);
++static int add_pmaplist(RPCB *);
++static int del_pmaplist(RPCB *);
+ 
+ /*
+  * Set a mapping of program, version, netid
+diff --git a/src/rpcbind.c b/src/rpcbind.c
+index c4265cd..87ccdc2 100644
+--- a/src/rpcbind.c
++++ b/src/rpcbind.c
+@@ -136,13 +136,13 @@ char *tcp_uaddr;	/* Universal TCP address */
+ static char servname[] = "rpcbind";
+ static char superuser[] = "superuser";
+ 
+-int main __P((int, char *[]));
++int main(int, char *[]);
+ 
+-static int init_transport __P((struct netconfig *));
+-static void rbllist_add __P((rpcprog_t, rpcvers_t, struct netconfig *,
+-			     struct netbuf *));
+-static void terminate __P((int));
+-static void parseargs __P((int, char *[]));
++static int init_transport(struct netconfig *);
++static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *,
++			     struct netbuf *);
++static void terminate(int);
++static void parseargs(int, char *[]);
+ 
+ int
+ main(int argc, char *argv[])
+diff --git a/src/util.c b/src/util.c
+index a6c835b..74b0284 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -70,7 +70,7 @@ static struct sockaddr_in *local_in4;
+ static struct sockaddr_in6 *local_in6;
+ #endif
+ 
+-static int bitmaskcmp __P((void *, void *, void *, int));
++static int bitmaskcmp(void *, void *, void *, int);
+ 
+ /*
+  * For all bits set in "mask", compare the corresponding bits in
+diff --git a/src/warmstart.c b/src/warmstart.c
+index b6eb73e..122a058 100644
+--- a/src/warmstart.c
++++ b/src/warmstart.c
+@@ -58,8 +58,8 @@
+ #define	PMAPFILE	RPCBIND_STATEDIR "/portmap.xdr"
+ #endif
+ 
+-static bool_t write_struct __P((char *, xdrproc_t, void *));
+-static bool_t read_struct __P((char *, xdrproc_t, void *));
++static bool_t write_struct(char *, xdrproc_t, void *);
++static bool_t read_struct(char *, xdrproc_t, void *);
+ 
+ static bool_t
+ write_struct(char *filename, xdrproc_t structproc, void *list)
+-- 
+2.7.4
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 3/9 v2] package/aircrack-ng: drop a musl-compatibility patch
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 1/9 v2] package/musl-compat-headers: provide compatibility headers not in musl Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 2/9 v2] package/rpcbind: fix musl build Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 4/9 v2] package/android-tools: drop musl-compatibility cdefs patching out Yann E. MORIN
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we can drop this patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/aircrack-ng/0004-fix-musl-build.patch | 53 ---------------------------
 1 file changed, 53 deletions(-)
 delete mode 100644 package/aircrack-ng/0004-fix-musl-build.patch

diff --git a/package/aircrack-ng/0004-fix-musl-build.patch b/package/aircrack-ng/0004-fix-musl-build.patch
deleted file mode 100644
index cc093d3..0000000
--- a/package/aircrack-ng/0004-fix-musl-build.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From da6e87670ad4639371da056f9e36201a9236dfa2 Mon Sep 17 00:00:00 2001
-From: Romain Naour <romain.naour@openwide.fr>
-Date: Wed, 29 Jul 2015 19:38:46 +0200
-Subject: [PATCH] fix musl build
-
-aircrack-ng doesn't build with a musl toolchain due to
-cdefs.h internal glibc header being used in internal
-ethernet.h [1].
-
-[1] http://wiki.musl-libc.org/wiki/FAQ
-
-Signed-off-by: Romain Naour <romain.naour@openwide.fr>
----
- src/include/ethernet.h | 20 +++++++++++---------
- 1 file changed, 11 insertions(+), 9 deletions(-)
-
-diff --git a/src/include/ethernet.h b/src/include/ethernet.h
-index 72d5e81..e9d9236 100644
---- a/src/include/ethernet.h
-+++ b/src/include/ethernet.h
-@@ -389,18 +389,20 @@ void	ether_vlan_mtap(struct bpf_if *, struct mbuf *,
- 
- #else /* _KERNEL */
- 
--#include <sys/cdefs.h>
--
- /*
-  * Ethernet address conversion/parsing routines.
-  */
--__BEGIN_DECLS
--struct	ether_addr *ether_aton(const char *);
--int	ether_hostton(const char *, struct ether_addr *);
--int	ether_line(const char *, struct ether_addr *, char *);
--char 	*ether_ntoa(const struct ether_addr *);
--int	ether_ntohost(char *, const struct ether_addr *);
--__END_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+	struct	ether_addr *ether_aton(const char *);
-+	int	ether_hostton(const char *, struct ether_addr *);
-+	int	ether_line(const char *, struct ether_addr *, char *);
-+	char 	*ether_ntoa(const struct ether_addr *);
-+	int	ether_ntohost(char *, const struct ether_addr *);
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* !_KERNEL */
- 
--- 
-2.4.3
-
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 4/9 v2] package/android-tools: drop musl-compatibility cdefs patching out
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (2 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 3/9 v2] package/aircrack-ng: drop a musl-compatibility patch Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 5/9 v2] package/bcusdk: drop a musl-compatibility patch Yann E. MORIN
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we no longer need to patch it out.

Simplify the patch by removing any hunk removing cdefs.h or the use of
__BEGIN_DECLS/__END_DECLS. However, it must be included when macros it
defines are being used.

Also, renumber patches to guarantee ordering (static patch was added
before big-endian one).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 .../0004-Fix-build-issue-with-musl.patch           | 181 +--------------------
 ...build.patch => 0006-fix-big-endian-build.patch} |   0
 .../0007-include-cdefs-h-when-needed.patch         |  41 +++++
 3 files changed, 43 insertions(+), 179 deletions(-)
 rename package/android-tools/{0005-fix-big-endian-build.patch => 0006-fix-big-endian-build.patch} (100%)
 create mode 100644 package/android-tools/0007-include-cdefs-h-when-needed.patch

diff --git a/package/android-tools/0004-Fix-build-issue-with-musl.patch b/package/android-tools/0004-Fix-build-issue-with-musl.patch
index e5ba0e6..964eb87 100644
--- a/package/android-tools/0004-Fix-build-issue-with-musl.patch
+++ b/package/android-tools/0004-Fix-build-issue-with-musl.patch
@@ -1,9 +1,6 @@
 [PATCH] Fix build issue with musl
 
-cdefs.h header doesn't exist in musl toolchains:
-http://wiki.musl-libc.org/wiki/FAQ
-
-Also arpa/nameser.h doesn't use the same macro name to avoid several
+arpa/nameser.h doesn't use the same macro name to avoid several
 inclusions.
 
 Finally had an issue with framebuffer_service.c since it was missing the
@@ -26,7 +23,7 @@ diff --git a/core/adbd/arpa_nameser.h b/core/adbd/arpa_nameser.h
 index 438dc04..b2a28d6 100644
 --- a/core/adbd/arpa_nameser.h
 +++ b/core/adbd/arpa_nameser.h
-@@ -52,11 +52,12 @@
+@@ -52,6 +52,8 @@
  
  #ifndef _ARPA_NAMESER_H_
  #define _ARPA_NAMESER_H_
@@ -35,51 +32,12 @@ index 438dc04..b2a28d6 100644
  
  #define BIND_4_COMPAT
  
- #include <sys/types.h>
--#include <sys/cdefs.h>
- 
- /*
-  * Revision information.  This is the release date in YYYYMMDD format.
-@@ -505,7 +506,9 @@ typedef enum __ns_cert_types {
- #define	ns_makecanon		__ns_makecanon
- #define	ns_samename		__ns_samename
- 
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- int		ns_msg_getflag(ns_msg, int);
- uint16_t	ns_get16(const u_char *);
- uint32_t	ns_get32(const u_char *);
-@@ -560,7 +563,9 @@ int		ns_samedomain(const char *, const char *);
- int		ns_subdomain(const char *, const char *);
- int		ns_makecanon(const char *, char *, size_t);
- int		ns_samename(const char *, const char *);
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #ifdef BIND_4_COMPAT
- #include "arpa_nameser_compat.h"
 @@ -574,4 +579,5 @@ __END_DECLS
  #define  XLOG(...)   do {} while (0)
  #endif
  
 +#endif /* !_ARPA_NAMESER_H */
  #endif /* !_ARPA_NAMESER_H_ */
-diff --git a/core/adbd/base64.c b/core/adbd/base64.c
-index 7270703..73725f5 100644
---- a/core/adbd/base64.c
-+++ b/core/adbd/base64.c
-@@ -42,7 +42,6 @@
-  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
-  */
- 
--#include <sys/cdefs.h>
- #if defined(LIBC_SCCS) && !defined(lint)
- __RCSID("$NetBSD: base64.c,v 1.8 2002/11/11 01:15:17 thorpej Exp $");
- #endif /* LIBC_SCCS and not lint */
 diff --git a/core/adbd/framebuffer_service.c b/core/adbd/framebuffer_service.c
 index 20c08d2..48e0241 100644
 --- a/core/adbd/framebuffer_service.c
@@ -92,140 +50,5 @@ index 20c08d2..48e0241 100644
  #include <linux/fb.h>
  #include <sys/ioctl.h>
  #include <sys/mman.h>
-diff --git a/core/adbd/qemu_pipe.h b/core/adbd/qemu_pipe.h
-index 1a67022..572a242 100644
---- a/core/adbd/qemu_pipe.h
-+++ b/core/adbd/qemu_pipe.h
-@@ -16,7 +16,6 @@
- #ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
- #define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
- 
--#include <sys/cdefs.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/mman.h>
-diff --git a/core/include/cutils/android_reboot.h b/core/include/cutils/android_reboot.h
-index 0c79be7..2ebe1cf 100644
---- a/core/include/cutils/android_reboot.h
-+++ b/core/include/cutils/android_reboot.h
-@@ -17,7 +17,9 @@
- #ifndef __CUTILS_ANDROID_REBOOT_H__
- #define __CUTILS_ANDROID_REBOOT_H__
- 
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- 
- /* Commands */
- #define ANDROID_RB_RESTART  0xDEAD0001
-@@ -30,6 +32,8 @@ __BEGIN_DECLS
- 
- int android_reboot(int cmd, int flags, char *arg);
- 
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* __CUTILS_ANDROID_REBOOT_H__ */
-diff --git a/core/include/cutils/bitops.h b/core/include/cutils/bitops.h
-index 1b3b762..a7c8cab 100644
---- a/core/include/cutils/bitops.h
-+++ b/core/include/cutils/bitops.h
-@@ -17,9 +17,9 @@
- #ifndef __CUTILS_BITOPS_H
- #define __CUTILS_BITOPS_H
- 
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- 
- static inline int popcount(unsigned int x)
- {
-@@ -36,6 +36,8 @@ static inline int popcountll(unsigned long long x)
-     return __builtin_popcountll(x);
- }
- 
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* __CUTILS_BITOPS_H */
-diff --git a/core/include/cutils/partition_utils.h b/core/include/cutils/partition_utils.h
-index 597df92..0da9d5b 100644
---- a/core/include/cutils/partition_utils.h
-+++ b/core/include/cutils/partition_utils.h
-@@ -17,11 +17,15 @@
- #ifndef __CUTILS_PARTITION_WIPED_H__
- #define __CUTILS_PARTITION_WIPED_H__
- 
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- 
- int partition_wiped(char *source);
- void erase_footer(const char *dev_path, long long size);
- 
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* __CUTILS_PARTITION_WIPED_H__ */
-diff --git a/extras/ext4_utils/sha1.c b/extras/ext4_utils/sha1.c
-index 463ec38..e2e29cf 100644
---- a/extras/ext4_utils/sha1.c
-+++ b/extras/ext4_utils/sha1.c
-@@ -17,9 +17,6 @@
- 
- #define SHA1HANDSOFF		/* Copies data before messing with it. */
- 
--#ifndef USE_MINGW
--#include <sys/cdefs.h>
--#endif
- #include <sys/types.h>
- #include <assert.h>
- #include <string.h>
-diff --git a/extras/ext4_utils/sha1.h b/extras/ext4_utils/sha1.h
-index 9a8f7e3..fe3217e 100644
---- a/extras/ext4_utils/sha1.h
-+++ b/extras/ext4_utils/sha1.h
-@@ -17,11 +17,6 @@ typedef unsigned char u_char;
- typedef unsigned int uint32_t;
- typedef unsigned int u_int32_t;
- typedef unsigned int u_int;
--
--#define __BEGIN_DECLS
--#define __END_DECLS
--#else
--#include <sys/cdefs.h>
- #endif
- 
- #define SHA1_DIGEST_LENGTH		20
-@@ -33,11 +28,15 @@ typedef struct {
- 	u_char buffer[64];
- } SHA1_CTX;
- 
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- void	SHA1Transform(uint32_t[5], const u_char[64]);
- void	SHA1Init(SHA1_CTX *);
- void	SHA1Update(SHA1_CTX *, const u_char *, u_int);
- void	SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *);
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* _SYS_SHA1_H_ */
 -- 
 2.6.1
-
diff --git a/package/android-tools/0005-fix-big-endian-build.patch b/package/android-tools/0006-fix-big-endian-build.patch
similarity index 100%
rename from package/android-tools/0005-fix-big-endian-build.patch
rename to package/android-tools/0006-fix-big-endian-build.patch
diff --git a/package/android-tools/0007-include-cdefs-h-when-needed.patch b/package/android-tools/0007-include-cdefs-h-when-needed.patch
new file mode 100644
index 0000000..da4ee13
--- /dev/null
+++ b/package/android-tools/0007-include-cdefs-h-when-needed.patch
@@ -0,0 +1,41 @@
+Include cdefs.h wherever it is needed
+
+cdefs.h is included from within a lot of glibc headers, so it almost
+invariably and automagically gets pulled in with glibc.
+
+However, this might not be the case with other C libraries. musl does
+not provide cdefs.h so it does not include it from its own headers
+(cdefs.h must be provided separately).
+
+So we must include it when we are going to use macros it provides.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+---
+ core/adbd/services.c                  |  1 +
+ core/libcutils/android_reboot.c       |  1 +
+ 2 files changed, 2 insertions(+), 0 deletion(-)
+
+diff --git a/core/adbd/services.c b/core/adbd/services.c
+index 20c08d2..48e0241 100644
+--- a/core/adbd/services.c
++++ b/core/adbd/services.c
+@@ -20,6 +20,7 @@
+ #include <string.h>
+ #include <errno.h>
+ #include <pwd.h>
++#include <sys/cdefs.h>
+ 
+ #include "sysdeps.h"
+ 
+diff --git a/core/libcutils/android_reboot.c b/core/libcutils/android_reboot.c
+index 20c08d2..48e0241 100644
+--- a/core/libcutils/android_reboot.c
++++ b/core/libcutils/android_reboot.c
+@@ -23,6 +23,7 @@
+ #include <string.h>
+ #include <linux/reboot.h>
+ #include <sys/syscall.h>
++#include <sys/cdefs.h>
+ 
+ #include <cutils/android_reboot.h>
+ 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs)
@ 2016-08-18 21:50 Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 1/9 v2] package/musl-compat-headers: provide compatibility headers not in musl Yann E. MORIN
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

Hello All!

This series is an ateempt at quiescing, once and for all, all the build
failures under musl, due to missing non-standard header cdefs.h.

sys/cdefs.h is a non-standrad header, originating from glibc. Its goal
is two fold:

  - first, it hides away legacy compiler specifities by providing macros
    to declare prototypes and so on; this is *really* legacy, and
    targets pre-ANSI compilers (that is, I was already born, but had no
    idea what ANSI was, nor what a compiler was, for that matters);

  - second, it provides macros to begin and end C declarations in
    headers that can be included from C++ code. This is so trivial that
    the need for a macro is not even obvious to begin with.

Of course, this header is totally non-standard, and the macros it
defines are definitely non-standard as well. However, it has started to
be used in more and more packages as time passed, so that, decades
later,
its use is so widespread that eradicating it is an impossible task.

But then enters musl, a strict standard-compliant C library, with as few
non-standard externsions as possible (if at all?). musl does not provide
a sys/cdefs.h headers, so a lot of code breaks with musl.

To make matters more intractable, sys/cdefs.h is included from inside
many other headers from glibc, making its macros available to a wide
audience without realizing they need a non-standard header.

Fixing all those bodies of code is nigh impossible, so instead we
provide a strictly-minimal sys/cdefs.h, that defines only the three
strictly-required macros:

  - __P() to declare function prototypes;
  - __BEGIN_DECLS and __END_DECLS to enclose C declarations.

When (if!) more are needed, they can be added later.

The basic idea was suggested by Thomas P. on IRC. Thanks! :-)

This then allows us to drop quite a few patches that were removing use
of cdefs.h. However, including sys/cdefs.h has been added to two
packages that were relying on other glibc headers to include it.


As a bonus, and certainly *not* for master, the last patch in the series
adds a paranoid-like check for the use of cdefs,h, so that we can catch
it. It defaults to not checking, so as to minimise the impact it would
have on picky packages. See the commit f orthat patch for more in depth
explanations.


Changes v1 -> v2:
  - only use extra downloads, in case we need to add more files in the
    future  (Arnout)
  - add headers a license files  (Arnout)
  - some typoes, as usual  (Arnout)
  - add more macros (__THROW and __NTH()) as they are quite often used
    even if we currently patch them out
  - fix the rpcbind patch as accepted upstream


Regards,
Yann E. MORIN.


The following changes since commit 0d68771e5493442443db3956b85ec0083f5facf4

  libconfuse: add optional dependency on gettext (2016-08-18 23:30:50 +0200)


are available in the git repository at:

  https://gitlab.com/ymorin/buildroot.git

for you to fetch changes up to 730ac6e801be3f22ed86d9c9b3752106cb990bf5

  build/advanced: add option to check for use of cdefs.h (2016-08-18 23:42:11 +0200)


----------------------------------------------------------------
Yann E. MORIN (9):
      package/musl-compat-headers: provide compatibility headers not in musl
      package/rpcbind: fix musl build
      package/aircrack-ng: drop a musl-compatibility patch
      package/android-tools: drop musl-compatibility cdefs patching out
      package/bcusdk: drop a musl-compatibility patch
      package/libsepol: drop a musl-compatibility patch
      package/linknx: drop a musl-compatibility patch
      package/qlibc: drop a musl-compatibility patch
      build/advanced: add option to check for use of cdefs.h

 Config.in                                          |   52 +
 package/Config.in                                  |    2 +-
 package/aircrack-ng/0004-fix-musl-build.patch      |   53 -
 .../0004-Fix-build-issue-with-musl.patch           |  181 +---
 ...build.patch => 0006-fix-big-endian-build.patch} |    0
 .../0007-include-cdefs-h-when-needed.patch         |   41 +
 ...t-use-the-non-standard-sys-cdefs.h-header.patch |   48 -
 ...d_set-requires-inclusion-of-sys-select.h.patch} |    0
 package/libsepol/0005-replace-cdefs.patch          | 1074 --------------------
 package/linknx/0002-musl-cdefs.patch               |   37 -
 package/musl-compat-headers/Config.in              |    2 +
 package/musl-compat-headers/cdefs.h.in             |   92 ++
 .../musl-compat-headers.hash}                      |    0
 package/musl-compat-headers/musl-compat-headers.mk |   40 +
 package/musl/Config.in                             |    3 +-
 package/musl/musl.mk                               |   10 +-
 package/netbsd-queue/Config.in                     |    2 -
 package/netbsd-queue/netbsd-queue.mk               |   24 -
 ...l-build-by-removing-usage-of-internal-gli.patch |   59 --
 .../0003-src-remove-use-of-the-__P-macro.patch     |  243 +++++
 toolchain/cdefs.h.in                               |    8 +
 toolchain/toolchain-external/Config.in             |    3 +-
 toolchain/toolchain-external/toolchain-external.mk |   10 +-
 toolchain/toolchain.mk                             |   30 +
 24 files changed, 527 insertions(+), 1487 deletions(-)
 delete mode 100644 package/aircrack-ng/0004-fix-musl-build.patch
 rename package/android-tools/{0005-fix-big-endian-build.patch => 0006-fix-big-endian-build.patch} (100%)
 create mode 100644 package/android-tools/0007-include-cdefs-h-when-needed.patch
 delete mode 100644 package/bcusdk/0001-Do-not-use-the-non-standard-sys-cdefs.h-header.patch
 rename package/bcusdk/{0002-fd_set-requires-inclusion-of-sys-select.h.patch => 0001-fd_set-requires-inclusion-of-sys-select.h.patch} (100%)
 delete mode 100644 package/libsepol/0005-replace-cdefs.patch
 delete mode 100644 package/linknx/0002-musl-cdefs.patch
 create mode 100644 package/musl-compat-headers/Config.in
 create mode 100644 package/musl-compat-headers/cdefs.h.in
 rename package/{netbsd-queue/netbsd-queue.hash => musl-compat-headers/musl-compat-headers.hash} (100%)
 create mode 100644 package/musl-compat-headers/musl-compat-headers.mk
 delete mode 100644 package/netbsd-queue/Config.in
 delete mode 100644 package/netbsd-queue/netbsd-queue.mk
 delete mode 100644 package/qlibc/0004-md5-fix-musl-build-by-removing-usage-of-internal-gli.patch
 create mode 100644 package/rpcbind/0003-src-remove-use-of-the-__P-macro.patch
 create mode 100644 toolchain/cdefs.h.in

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 5/9 v2] package/bcusdk: drop a musl-compatibility patch
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (3 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 4/9 v2] package/android-tools: drop musl-compatibility cdefs patching out Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 6/9 v2] package/libsepol: " Yann E. MORIN
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we can drop this patch.

Renumber remaining patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
Changes v1 -> v2:
  - commit log states remaining patch was renumbered  (Arnout)

---
Note that the patch was sent upstream, but it seems never acted upon.
---
 ...t-use-the-non-standard-sys-cdefs.h-header.patch | 48 ----------------------
 ...d_set-requires-inclusion-of-sys-select.h.patch} |  0
 2 files changed, 48 deletions(-)
 delete mode 100644 package/bcusdk/0001-Do-not-use-the-non-standard-sys-cdefs.h-header.patch
 rename package/bcusdk/{0002-fd_set-requires-inclusion-of-sys-select.h.patch => 0001-fd_set-requires-inclusion-of-sys-select.h.patch} (100%)

diff --git a/package/bcusdk/0001-Do-not-use-the-non-standard-sys-cdefs.h-header.patch b/package/bcusdk/0001-Do-not-use-the-non-standard-sys-cdefs.h-header.patch
deleted file mode 100644
index fc64386..0000000
--- a/package/bcusdk/0001-Do-not-use-the-non-standard-sys-cdefs.h-header.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From c36db3f798bf576f42d81a0c51198b17d7112e8c Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Date: Sat, 8 Aug 2015 17:43:28 +0200
-Subject: [PATCH] Do not use the non-standard <sys/cdefs.h> header
-
-<sys/cdefs.h> is glibc-specific, and should be used only internally by
-glibc, not by external libraries/programs. It is not available in all
-standard C libraries.
-
-Submitted upstream: https://sourceforge.net/p/bcusdk/patches/3/
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
----
- eibd/include/eibclient.h | 11 ++++++++---
- 1 file changed, 8 insertions(+), 3 deletions(-)
-
-diff --git a/eibd/include/eibclient.h b/eibd/include/eibclient.h
-index 2781878..b095a1c 100644
---- a/eibd/include/eibclient.h
-+++ b/eibd/include/eibclient.h
-@@ -27,10 +27,11 @@
- #ifndef EIBCLIENT_H
- #define EIBCLIENT_H
- 
--#include <sys/cdefs.h>
- #include <stdint.h>
- 
--__BEGIN_DECLS;
-+#ifdef	__cplusplus
-+extern "C" {
-+#endif
- 
- #include "eibloadresult.h"
- 
-@@ -889,5 +890,9 @@ int EIB_Cache_LastUpdates_async (EIBConnection * con, uint16_t start,
- 				 uint16_t * end);
- 
- 
--__END_DECLS
-+
-+#ifdef	__cplusplus
-+}
-+#endif
-+
- #endif
--- 
-2.5.0
-
diff --git a/package/bcusdk/0002-fd_set-requires-inclusion-of-sys-select.h.patch b/package/bcusdk/0001-fd_set-requires-inclusion-of-sys-select.h.patch
similarity index 100%
rename from package/bcusdk/0002-fd_set-requires-inclusion-of-sys-select.h.patch
rename to package/bcusdk/0001-fd_set-requires-inclusion-of-sys-select.h.patch
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 6/9 v2] package/libsepol: drop a musl-compatibility patch
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (4 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 5/9 v2] package/bcusdk: drop a musl-compatibility patch Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 7/9 v2] package/linknx: " Yann E. MORIN
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we can drop this patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/libsepol/0005-replace-cdefs.patch | 1074 -----------------------------
 1 file changed, 1074 deletions(-)
 delete mode 100644 package/libsepol/0005-replace-cdefs.patch

diff --git a/package/libsepol/0005-replace-cdefs.patch b/package/libsepol/0005-replace-cdefs.patch
deleted file mode 100644
index 2f76a74..0000000
--- a/package/libsepol/0005-replace-cdefs.patch
+++ /dev/null
@@ -1,1074 +0,0 @@
-Remove usage of <sys/cdefs.h>.
-
-This fixes autobuild issue: http://autobuild.buildroot.org/results/cbb/cbb2bac69aa0708e587ba9fcd1efcead82e42446/build-end.log
-Libsepol uses cdefs.h which is a internal glibc header.
-This header is not intended to be used by any program and will cause
-compiling against musl (and possibly other c libraries) to fail.
-This patch fixed this issue and replaces all references of
-#include <sys/cdefs.h> and __BEGIN/END_DECLS with the appropriate #ifdefs.
-
-This patch has also been submitted upstream to the selinux github repository.
-https://github.com/SELinuxProject/selinux/issues/19
-
-Signed-off-by: Adam Duskett <Aduskett@gmail.com>
-
-
-diff --git a/include/sepol/boolean_record.h b/include/sepol/boolean_record.h
-index 9af16be..09cd01f 100644
---- a/include/sepol/boolean_record.h
-+++ b/include/sepol/boolean_record.h
-@@ -3,9 +3,10 @@
-
- #include <stddef.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_bool;
- struct sepol_bool_key;
-@@ -51,5 +52,8 @@ extern int sepol_bool_clone(sepol_handle_t * handle,
-
- extern void sepol_bool_free(sepol_bool_t * boolean);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/booleans.h b/include/sepol/booleans.h
-index 7374dde..02356d1 100644
---- a/include/sepol/booleans.h
-+++ b/include/sepol/booleans.h
-@@ -5,9 +5,10 @@
- #include <sepol/policydb.h>
- #include <sepol/boolean_record.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*--------------compatibility--------------*/
-
-@@ -59,5 +60,8 @@ extern int sepol_bool_iterate(sepol_handle_t * handle,
- 			      int (*fn) (const sepol_bool_t * boolean,
- 					 void *fn_arg), void *arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/context.h b/include/sepol/context.h
-index a69e8c9..b3e5497 100644
---- a/include/sepol/context.h
-+++ b/include/sepol/context.h
-@@ -4,9 +4,10 @@
- #include <sepol/context_record.h>
- #include <sepol/policydb.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* -- Deprecated -- */
-
-@@ -26,5 +27,8 @@ extern int sepol_mls_contains(sepol_handle_t * handle,
- extern int sepol_mls_check(sepol_handle_t * handle,
- 			   const sepol_policydb_t * policydb, const char *mls);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/context_record.h b/include/sepol/context_record.h
-index c07da8f..1dcbebb 100644
---- a/include/sepol/context_record.h
-+++ b/include/sepol/context_record.h
-@@ -2,9 +2,10 @@
- #define _SEPOL_CONTEXT_RECORD_H_
-
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_context;
- typedef struct sepol_context sepol_context_t;
-@@ -53,5 +54,8 @@ extern int sepol_context_from_string(sepol_handle_t * handle,
- extern int sepol_context_to_string(sepol_handle_t * handle,
- 				   const sepol_context_t * con, char **str_ptr);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/debug.h b/include/sepol/debug.h
-index b852c8d..972a4de 100644
---- a/include/sepol/debug.h
-+++ b/include/sepol/debug.h
-@@ -2,9 +2,10 @@
- #define _SEPOL_DEBUG_H_
-
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Deprecated */
- extern void sepol_debug(int on);
-@@ -35,5 +36,8 @@ extern void sepol_msg_set_callback(sepol_handle_t * handle,
- 							 const char *fmt, ...),
- 				   void *msg_callback_arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/errcodes.h b/include/sepol/errcodes.h
-index eba7088..0136564 100644
---- a/include/sepol/errcodes.h
-+++ b/include/sepol/errcodes.h
-@@ -4,9 +4,10 @@
- #define __sepol_errno_h__
-
- #include <errno.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #define SEPOL_OK             0
-
-@@ -25,5 +26,8 @@ __BEGIN_DECLS
- #define SEPOL_EEXIST         -EEXIST
- #define SEPOL_ENOENT         -ENOENT
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/handle.h b/include/sepol/handle.h
-index 00ed0ed..27cbd6c 100644
---- a/include/sepol/handle.h
-+++ b/include/sepol/handle.h
-@@ -1,9 +1,9 @@
- #ifndef _SEPOL_HANDLE_H_
- #define _SEPOL_HANDLE_H_
-
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_handle;
- typedef struct sepol_handle sepol_handle_t;
-@@ -35,5 +35,8 @@ int sepol_get_preserve_tunables(sepol_handle_t * sh);
-  * 0 is default and discard such branch, 1 preserves them */
- void sepol_set_preserve_tunables(sepol_handle_t * sh, int preserve_tunables);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/iface_record.h b/include/sepol/iface_record.h
-index 81d7027..098bc77 100644
---- a/include/sepol/iface_record.h
-+++ b/include/sepol/iface_record.h
-@@ -3,9 +3,10 @@
-
- #include <sepol/handle.h>
- #include <sepol/context_record.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_iface;
- struct sepol_iface_key;
-@@ -59,5 +60,8 @@ extern int sepol_iface_clone(sepol_handle_t * handle,
-
- extern void sepol_iface_free(sepol_iface_t * iface);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/interfaces.h b/include/sepol/interfaces.h
-index 3cb5043..7ef23ce 100644
---- a/include/sepol/interfaces.h
-+++ b/include/sepol/interfaces.h
-@@ -4,9 +4,10 @@
- #include <sepol/policydb.h>
- #include <sepol/iface_record.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Return the number of interfaces */
- extern int sepol_iface_count(sepol_handle_t * handle,
-@@ -43,5 +44,8 @@ extern int sepol_iface_iterate(sepol_handle_t * handle,
- 			       int (*fn) (const sepol_iface_t * iface,
- 					  void *fn_arg), void *arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/module.h b/include/sepol/module.h
-index ff27f96..77114a1 100644
---- a/include/sepol/module.h
-+++ b/include/sepol/module.h
-@@ -7,9 +7,11 @@
-
- #include <sepol/handle.h>
- #include <sepol/policydb.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_module_package;
- typedef struct sepol_module_package sepol_module_package_t;
-@@ -82,5 +84,8 @@ extern int sepol_expand_module(sepol_handle_t * handle,
- 			       sepol_policydb_t * base,
- 			       sepol_policydb_t * out, int verbose, int check);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/module_to_cil.h b/include/sepol/module_to_cil.h
-index 18bb3bf..fe5eb5b 100644
---- a/include/sepol/module_to_cil.h
-+++ b/include/sepol/module_to_cil.h
-@@ -1,5 +1,4 @@
- #include <stdlib.h>
--
- #include <sepol/module.h>
- #include <sepol/policydb/policydb.h>
-
-diff --git a/include/sepol/node_record.h b/include/sepol/node_record.h
-index e2d3e6d..3873223 100644
---- a/include/sepol/node_record.h
-+++ b/include/sepol/node_record.h
-@@ -4,9 +4,10 @@
- #include <stddef.h>
- #include <sepol/context_record.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_node;
- struct sepol_node_key;
-@@ -92,5 +93,8 @@ extern int sepol_node_clone(sepol_handle_t * handle,
-
- extern void sepol_node_free(sepol_node_t * node);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/nodes.h b/include/sepol/nodes.h
-index 6fa534e..3cf99d2 100644
---- a/include/sepol/nodes.h
-+++ b/include/sepol/nodes.h
-@@ -4,9 +4,10 @@
- #include <sepol/handle.h>
- #include <sepol/policydb.h>
- #include <sepol/node_record.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Return the number of nodes */
- extern int sepol_node_count(sepol_handle_t * handle,
-@@ -40,5 +41,8 @@ extern int sepol_node_iterate(sepol_handle_t * handle,
- 			      int (*fn) (const sepol_node_t * node,
- 					 void *fn_arg), void *arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb.h b/include/sepol/policydb.h
-index c3943e9..6769b91 100644
---- a/include/sepol/policydb.h
-+++ b/include/sepol/policydb.h
-@@ -5,9 +5,10 @@
- #include <stdio.h>
-
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_policy_file;
- typedef struct sepol_policy_file sepol_policy_file_t;
-@@ -144,5 +145,8 @@ extern int sepol_policydb_mls_enabled(const sepol_policydb_t * p);
-  */
- extern int sepol_policydb_compat_net(const sepol_policydb_t * p);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/avrule_block.h b/include/sepol/policydb/avrule_block.h
-index ecd347b..57d6a8a 100644
---- a/include/sepol/policydb/avrule_block.h
-+++ b/include/sepol/policydb/avrule_block.h
-@@ -21,9 +21,11 @@
- #define _SEPOL_AVRULE_BLOCK_H_
-
- #include <sepol/policydb/policydb.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- extern avrule_block_t *avrule_block_create(void);
- extern void avrule_block_destroy(avrule_block_t * x);
-@@ -37,5 +39,7 @@ extern cond_list_t *get_decl_cond_list(policydb_t * p,
- extern int is_id_enabled(char *id, policydb_t * p, int symbol_table);
- extern int is_perm_enabled(char *class_id, char *perm_id, policydb_t * p);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- #endif
-diff --git a/include/sepol/policydb/avtab.h b/include/sepol/policydb/avtab.h
-index d3ea84e..74f97f8 100644
---- a/include/sepol/policydb/avtab.h
-+++ b/include/sepol/policydb/avtab.h
-@@ -40,11 +40,13 @@
- #ifndef _SEPOL_POLICYDB_AVTAB_H_
- #define _SEPOL_POLICYDB_AVTAB_H_
-
--#include <sys/cdefs.h>
-+
- #include <sys/types.h>
- #include <stdint.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- typedef struct avtab_key {
- 	uint16_t source_type;
-@@ -142,7 +144,9 @@ extern avtab_ptr_t avtab_search_node_next(avtab_ptr_t node, int specified);
- /* avtab_alloc uses one bucket per 2-4 elements, so adjust to get maximum buckets */
- #define MAX_AVTAB_SIZE (MAX_AVTAB_HASH_BUCKETS << 1)
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- #endif				/* _AVTAB_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/conditional.h b/include/sepol/policydb/conditional.h
-index cd2a9a9..52d6b31 100644
---- a/include/sepol/policydb/conditional.h
-+++ b/include/sepol/policydb/conditional.h
-@@ -25,9 +25,11 @@
- #include <sepol/policydb/avtab.h>
- #include <sepol/policydb/symtab.h>
- #include <sepol/policydb/policydb.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #define COND_EXPR_MAXDEPTH 10
-
-@@ -136,5 +138,7 @@ extern int cond_read_list(policydb_t * p, cond_list_t ** list, void *fp);
- extern void cond_compute_av(avtab_t * ctab, avtab_key_t * key,
- 			    struct sepol_av_decision *avd);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- #endif				/* _CONDITIONAL_H_ */
-diff --git a/include/sepol/policydb/constraint.h b/include/sepol/policydb/constraint.h
-index ae7034d..927bdc0 100644
---- a/include/sepol/policydb/constraint.h
-+++ b/include/sepol/policydb/constraint.h
-@@ -22,7 +22,9 @@
- #include <sepol/policydb/ebitmap.h>
- #include <sepol/policydb/flask_types.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #define CEXPR_MAXDEPTH 5
-
-@@ -73,7 +75,10 @@ struct policydb;
- extern int constraint_expr_init(constraint_expr_t * expr);
- extern void constraint_expr_destroy(constraint_expr_t * expr);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif				/* _CONSTRAINT_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/context.h b/include/sepol/policydb/context.h
-index dbb7c3e..aad3647 100644
---- a/include/sepol/policydb/context.h
-+++ b/include/sepol/policydb/context.h
-@@ -22,7 +22,9 @@
- #include <sepol/policydb/ebitmap.h>
- #include <sepol/policydb/mls_types.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*
-  * A security context consists of an authenticated user
-@@ -95,5 +97,8 @@ static inline int context_cmp(context_struct_t * c1, context_struct_t * c2)
- 		(c1->type == c2->type) && mls_context_cmp(c1, c2));
- }
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/ebitmap.h b/include/sepol/policydb/ebitmap.h
-index 7b3508d..b883597 100644
---- a/include/sepol/policydb/ebitmap.h
-+++ b/include/sepol/policydb/ebitmap.h
-@@ -19,9 +19,11 @@
-
- #include <stdint.h>
- #include <string.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #define MAPTYPE uint64_t	/* portion of bitmap in each node */
- #define MAPSIZE (sizeof(MAPTYPE) * 8)	/* number of bits in node bitmap */
-@@ -92,7 +94,9 @@ extern int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value);
- extern void ebitmap_destroy(ebitmap_t * e);
- extern int ebitmap_read(ebitmap_t * e, void *fp);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- #endif				/* _EBITMAP_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/expand.h b/include/sepol/policydb/expand.h
-index a8de41e..59151c1 100644
---- a/include/sepol/policydb/expand.h
-+++ b/include/sepol/policydb/expand.h
-@@ -28,9 +28,11 @@
- #include <stddef.h>
- #include <sepol/handle.h>
- #include <sepol/policydb/conditional.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*
-  * Expand only the avrules for a module. It is valid for this function
-@@ -79,5 +81,8 @@ extern int expand_avtab(policydb_t * p, avtab_t * a, avtab_t * expa);
- extern int expand_cond_av_list(policydb_t * p, cond_av_list_t * l,
- 			       cond_av_list_t ** newl, avtab_t * expa);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/flask_types.h b/include/sepol/policydb/flask_types.h
-index 2a59565..c41bd22 100644
---- a/include/sepol/policydb/flask_types.h
-+++ b/include/sepol/policydb/flask_types.h
-@@ -13,9 +13,11 @@
-
- #include <sys/types.h>
- #include <stdint.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*
-  * A security context is a set of security attributes 
-@@ -61,5 +63,8 @@ struct sepol_av_decision {
- 	uint32_t seqno;
- };
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/hashtab.h b/include/sepol/policydb/hashtab.h
-index 0afc59c..af72817 100644
---- a/include/sepol/policydb/hashtab.h
-+++ b/include/sepol/policydb/hashtab.h
-@@ -17,9 +17,11 @@
-
- #include <stdint.h>
- #include <stdio.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- typedef char *hashtab_key_t;	/* generic key type */
- typedef void *hashtab_datum_t;	/* generic datum type */
-@@ -136,5 +138,8 @@ extern void hashtab_map_remove_on_error(hashtab_t h,
-
- extern void hashtab_hash_eval(hashtab_t h, char *tag);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/hierarchy.h b/include/sepol/policydb/hierarchy.h
-index 88bc02e..27d140b 100644
---- a/include/sepol/policydb/hierarchy.h
-+++ b/include/sepol/policydb/hierarchy.h
-@@ -27,9 +27,11 @@
-
- #include <sepol/policydb/avtab.h>
- #include <sepol/policydb/policydb.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- extern int hierarchy_add_bounds(sepol_handle_t *handle, policydb_t *p);
-
-@@ -43,5 +45,8 @@ extern int bounds_check_types(sepol_handle_t *handle, policydb_t *p);
-
- extern int hierarchy_check_constraints(sepol_handle_t * handle, policydb_t * p);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/link.h b/include/sepol/policydb/link.h
-index 7c7c9be..545331d 100644
---- a/include/sepol/policydb/link.h
-+++ b/include/sepol/policydb/link.h
-@@ -12,13 +12,18 @@
-
-
- #include <stddef.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- extern int link_modules(sepol_handle_t * handle,
- 			policydb_t * b, policydb_t ** mods, int len,
- 			int verbose);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/mls_types.h b/include/sepol/policydb/mls_types.h
-index 4bf7367..52347a6 100644
---- a/include/sepol/policydb/mls_types.h
-+++ b/include/sepol/policydb/mls_types.h
-@@ -34,9 +34,11 @@
- #include <stdlib.h>
- #include <sepol/policydb/ebitmap.h>
- #include <sepol/policydb/flask_types.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- typedef struct mls_level {
- 	uint32_t sens;		/* sensitivity */
-@@ -152,5 +154,8 @@ extern void mls_semantic_range_init(mls_semantic_range_t *r);
- extern void mls_semantic_range_destroy(mls_semantic_range_t *r);
- extern int mls_semantic_range_cpy(mls_semantic_range_t *dst, mls_semantic_range_t *src);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/module.h b/include/sepol/policydb/module.h
-index 3fe560c..d0d2c7a 100644
---- a/include/sepol/policydb/module.h
-+++ b/include/sepol/policydb/module.h
-@@ -27,11 +27,12 @@
-
- #include <sepol/policydb/policydb.h>
- #include <sepol/policydb/conditional.h>
--#include <sys/cdefs.h>
-
- #define SEPOL_MODULE_PACKAGE_MAGIC 0xf97cff8f
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_module_package {
- 	sepol_policydb_t *policy;
-@@ -48,5 +49,8 @@ struct sepol_module_package {
-
- extern int sepol_module_package_init(sepol_module_package_t * p);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/polcaps.h b/include/sepol/policydb/polcaps.h
-index 74b7c9e..53d7994 100644
---- a/include/sepol/policydb/polcaps.h
-+++ b/include/sepol/policydb/polcaps.h
-@@ -1,9 +1,9 @@
- #ifndef _SEPOL_POLICYDB_POLCAPS_H_
- #define _SEPOL_POLICYDB_POLCAPS_H_
-
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Policy capabilities */
- enum {
-@@ -21,5 +21,8 @@ extern int sepol_polcap_getnum(const char *name);
- /* Convert a capability number to name. */
- extern const char *sepol_polcap_getname(int capnum);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif /* _SEPOL_POLICYDB_POLCAPS_H_ */
-diff --git a/include/sepol/policydb/policydb.h b/include/sepol/policydb/policydb.h
-index 26cec13..0d770bf 100644
---- a/include/sepol/policydb/policydb.h
-+++ b/include/sepol/policydb/policydb.h
-@@ -61,7 +61,6 @@
- #include <sepol/policydb/context.h>
- #include <sepol/policydb/constraint.h>
- #include <sepol/policydb/sidtab.h>
--#include <sys/cdefs.h>
-
- #define ERRMSG_LEN 1024
-
-@@ -69,7 +68,9 @@
- #define POLICYDB_ERROR       -1
- #define POLICYDB_UNSUPPORTED -2
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*
-  * A datum type is defined for each kind of symbol 
-@@ -768,7 +769,10 @@ extern int policydb_set_target_platform(policydb_t *p, int platform);
- #define POLICYDB_MOD_MAGIC SELINUX_MOD_MAGIC
- #define POLICYDB_MOD_STRING "SE Linux Module"
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif				/* _POLICYDB_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/services.h b/include/sepol/policydb/services.h
-index 8a5dc9a..29f57cf 100644
---- a/include/sepol/policydb/services.h
-+++ b/include/sepol/policydb/services.h
-@@ -15,9 +15,10 @@
- #include <sepol/policydb/flask_types.h>
- #include <sepol/policydb/policydb.h>
- #include <stddef.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Set the policydb and sidtab structures to be used by
-    the service functions.  If not set, then these default
-@@ -230,5 +231,8 @@ extern int sepol_genfs_sid(const char *fstype,	/* IN */
- 			   sepol_security_class_t sclass,	/* IN */
- 			   sepol_security_id_t * sid);	/* OUT  */
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/policydb/sidtab.h b/include/sepol/policydb/sidtab.h
-index 4b93567..2df1a50 100644
---- a/include/sepol/policydb/sidtab.h
-+++ b/include/sepol/policydb/sidtab.h
-@@ -11,9 +11,10 @@
- #define _SEPOL_POLICYDB_SIDTAB_H_
-
- #include <sepol/policydb/context.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- typedef struct sidtab_node {
- 	sepol_security_id_t sid;	/* security identifier */
-@@ -69,7 +70,10 @@ extern void sepol_sidtab_set(sidtab_t * dst, sidtab_t * src);
-
- extern void sepol_sidtab_shutdown(sidtab_t * s);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif				/* _SIDTAB_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/symtab.h b/include/sepol/policydb/symtab.h
-index e0da337..68b5ad4 100644
---- a/include/sepol/policydb/symtab.h
-+++ b/include/sepol/policydb/symtab.h
-@@ -14,9 +14,10 @@
- #define _SEPOL_POLICYDB_SYMTAB_H_
-
- #include <sepol/policydb/hashtab.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* The symtab_datum struct stores the common information for
-  * all symtab datums. It should the first element in every
-@@ -37,7 +38,10 @@ typedef struct {
- extern int symtab_init(symtab_t *, unsigned int size);
- extern void symtab_destroy(symtab_t *);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif				/* _SYMTAB_H_ */
-
- /* FLASK */
-diff --git a/include/sepol/policydb/util.h b/include/sepol/policydb/util.h
-index fa12661..ee236a2 100644
---- a/include/sepol/policydb/util.h
-+++ b/include/sepol/policydb/util.h
-@@ -23,9 +23,9 @@
- #ifndef __SEPOL_UTIL_H__
- #define __SEPOL_UTIL_H__
-
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- extern int add_i_to_a(uint32_t i, uint32_t * cnt, uint32_t ** a);
-
-@@ -40,5 +40,8 @@ char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
-  */
- extern int tokenize(char *line_buf, char delim, int num_args, ...);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/port_record.h b/include/sepol/port_record.h
-index 697cea4..3bb4039 100644
---- a/include/sepol/port_record.h
-+++ b/include/sepol/port_record.h
-@@ -3,9 +3,10 @@
-
- #include <sepol/context_record.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_port;
- struct sepol_port_key;
-@@ -66,5 +67,8 @@ extern int sepol_port_clone(sepol_handle_t * handle,
-
- extern void sepol_port_free(sepol_port_t * port);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/ports.h b/include/sepol/ports.h
-index b4622ba..cda246c 100644
---- a/include/sepol/ports.h
-+++ b/include/sepol/ports.h
-@@ -4,9 +4,10 @@
- #include <sepol/handle.h>
- #include <sepol/policydb.h>
- #include <sepol/port_record.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /* Return the number of ports */
- extern int sepol_port_count(sepol_handle_t * handle,
-@@ -40,5 +41,8 @@ extern int sepol_port_iterate(sepol_handle_t * handle,
- 			      int (*fn) (const sepol_port_t * port,
- 					 void *fn_arg), void *arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/roles.h b/include/sepol/roles.h
-index 89b3af2..e750078 100644
---- a/include/sepol/roles.h
-+++ b/include/sepol/roles.h
-@@ -1,9 +1,9 @@
- #ifndef _SEPOL_ROLES_H_
- #define _SEPOL_ROLES_H_
-
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- extern int sepol_role_exists(const sepol_policydb_t * policydb,
- 			     const char *role, int *response);
-@@ -11,5 +11,8 @@ extern int sepol_role_exists(const sepol_policydb_t * policydb,
- extern int sepol_role_list(const sepol_policydb_t * policydb,
- 			   char ***roles, unsigned int *nroles);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/sepol.h b/include/sepol/sepol.h
-index 00a2129..513f77d 100644
---- a/include/sepol/sepol.h
-+++ b/include/sepol/sepol.h
-@@ -3,9 +3,10 @@
-
- #include <stddef.h>
- #include <stdio.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #include <sepol/user_record.h>
- #include <sepol/context_record.h>
-@@ -28,5 +29,8 @@ __BEGIN_DECLS
- /* Set internal policydb from a file for subsequent service calls. */
- extern int sepol_set_policydb_from_file(FILE * fp);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/user_record.h b/include/sepol/user_record.h
-index 9a39526..d17a3db 100644
---- a/include/sepol/user_record.h
-+++ b/include/sepol/user_record.h
-@@ -3,9 +3,10 @@
-
- #include <stddef.h>
- #include <sepol/handle.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- struct sepol_user;
- struct sepol_user_key;
-@@ -76,5 +77,8 @@ extern int sepol_user_clone(sepol_handle_t * handle,
-
- extern void sepol_user_free(sepol_user_t * user);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-diff --git a/include/sepol/users.h b/include/sepol/users.h
-index 0e0f76e..ad23f89 100644
---- a/include/sepol/users.h
-+++ b/include/sepol/users.h
-@@ -5,9 +5,10 @@
- #include <sepol/user_record.h>
- #include <sepol/handle.h>
- #include <stddef.h>
--#include <sys/cdefs.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /*---------compatibility------------*/
-
-@@ -57,5 +58,8 @@ extern int sepol_user_iterate(sepol_handle_t * handle,
- 			      int (*fn) (const sepol_user_t * user,
- 					 void *fn_arg), void *arg);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 7/9 v2] package/linknx: drop a musl-compatibility patch
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (5 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 6/9 v2] package/libsepol: " Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 8/9 v2] package/qlibc: " Yann E. MORIN
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we can drop this patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/linknx/0002-musl-cdefs.patch | 37 ------------------------------------
 1 file changed, 37 deletions(-)
 delete mode 100644 package/linknx/0002-musl-cdefs.patch

diff --git a/package/linknx/0002-musl-cdefs.patch b/package/linknx/0002-musl-cdefs.patch
deleted file mode 100644
index 59e28ca..0000000
--- a/package/linknx/0002-musl-cdefs.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-Do not use the non-standard <sys/cdefs.h> header
-
-<sys/cdefs.h> is glibc-specific, and should be used only internally by
-glibc, not by external libraries/programs. It is not available in all
-standard C libraries.
-
-Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
-(Patch sent upstream: https://sourceforge.net/p/linknx/patches/21/)
-
-diff -uNr linknx-0.0.1.32.org/include/eibclient.h linknx-0.0.1.32/include/eibclient.h
---- linknx-0.0.1.32.org/include/eibclient.h	2007-10-11 01:55:33.000000000 +0200
-+++ linknx-0.0.1.32/include/eibclient.h	2016-01-23 23:21:17.315006629 +0100
-@@ -27,11 +27,12 @@
- #ifndef EIBCLIENT_H
- #define EIBCLIENT_H
- 
--#include "sys/cdefs.h"
- #include "stdint.h"
- #include <pthsem.h>
- 
--__BEGIN_DECLS;
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- 
- #include "eibloadresult.h"
- 
-@@ -705,5 +706,8 @@
-  */
- int EIB_LoadImage_async (EIBConnection * con, const uint8_t * image, int len);
- 
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-+
- #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 8/9 v2] package/qlibc: drop a musl-compatibility patch
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (6 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 7/9 v2] package/linknx: " Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-18 21:50 ` [Buildroot] [PATCH 9/9 v2] build/advanced: add option to check for use of cdefs.h Yann E. MORIN
  2016-08-19  9:40 ` [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Thomas Petazzoni
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We now always have a sys/cdefs.h, so we can drop this patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 ...l-build-by-removing-usage-of-internal-gli.patch | 59 ----------------------
 1 file changed, 59 deletions(-)
 delete mode 100644 package/qlibc/0004-md5-fix-musl-build-by-removing-usage-of-internal-gli.patch

diff --git a/package/qlibc/0004-md5-fix-musl-build-by-removing-usage-of-internal-gli.patch b/package/qlibc/0004-md5-fix-musl-build-by-removing-usage-of-internal-gli.patch
deleted file mode 100644
index a48b27f..0000000
--- a/package/qlibc/0004-md5-fix-musl-build-by-removing-usage-of-internal-gli.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From fe45b18f777b1414aee908f08f56a5730a00dbb5 Mon Sep 17 00:00:00 2001
-From: Bernd Kuhls <bernd.kuhls@t-online.de>
-Date: Sat, 21 May 2016 09:59:56 +0200
-Subject: [PATCH 1/1] md5: fix musl build by removing usage of internal glibc
- header sys/cdefs.h
-
-As suggested in musl FAQ:
-http://wiki.musl-libc.org/wiki/FAQ#Q:_I.27m_trying_to_compile_something_against_musl_and_I_get_error_messages_about_sys.2Fcdefs.h
-
-Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
-(Patch for master branch sent upstream:
- https://github.com/wolkykim/qlibc/pull/53)
----
- src/internal/md5/md5.h  | 10 ++++++----
- src/internal/md5/md5c.c |  1 -
- 2 files changed, 6 insertions(+), 5 deletions(-)
-
-diff --git a/src/internal/md5/md5.h b/src/internal/md5/md5.h
-index cbfa7ca..8e726fe 100644
---- a/src/internal/md5/md5.h
-+++ b/src/internal/md5/md5.h
-@@ -35,9 +35,9 @@ typedef struct MD5Context {
-     unsigned char buffer[64]; /* input buffer */
- } MD5_CTX;
- 
--#include <sys/cdefs.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
- void MD5Init(MD5_CTX *);
- void MD5Update(MD5_CTX *, const unsigned char *, unsigned int);
- void MD5Final(unsigned char[16], MD5_CTX *);
-@@ -45,6 +45,8 @@ char * MD5End(MD5_CTX *, char *);
- char * MD5File(const char *, char *);
- char * MD5FileChunk(const char *, char *, off_t, off_t);
- char * MD5Data(const unsigned char *, unsigned int, char *);
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
- 
- #endif /* Q_MD5_H */
-diff --git a/src/internal/md5/md5c.c b/src/internal/md5/md5c.c
-index de9e47f..040bf5e 100644
---- a/src/internal/md5/md5c.c
-+++ b/src/internal/md5/md5c.c
-@@ -26,7 +26,6 @@
-  * edited for clarity and style only.
-  */
- 
--#include <sys/cdefs.h>
- #include <sys/types.h>
- #include <string.h>
- #include "md5.h"
--- 
-2.8.1
-
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 9/9 v2] build/advanced: add option to check for use of cdefs.h
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (7 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 8/9 v2] package/qlibc: " Yann E. MORIN
@ 2016-08-18 21:50 ` Yann E. MORIN
  2016-08-19  9:40 ` [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Thomas Petazzoni
  9 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2016-08-18 21:50 UTC (permalink / raw)
  To: buildroot

We want to catch programs that directly include sys/cdefs.h so that
we can fix them not to. So, we want instrument sys/cdefs.h to emit a
warning when it is included.

However, there are two cases: musl and the other C libraries.

For musl, it is pretty trivial to do so, because we install our own
sys/cdefs.h header, so we are free to instrument it at will. Not content
to emit a warning when it is included, we can also instrument each macro
to emit its own warning on being used, so we can easily pinpoint what
macro is used and why cdefs.h is used at all.

This is made even easier because musl does not include sys/cdefs.h from
its own headers, so any inclusion of sys/cdefs.h is entirely due to an
explicit include by a package.

But for glibc and uClibc, the matter is a little bit different: there
are two problems we have to solve:

  - both glibc and uClibs install their own sys/cdefs.h, so we are not
    free to instrument it at will;

  - both include it from their own headers, so that the inclusion of it
    is not necessarily an explicit include by a package.

We solve these two problems in two ways:

  - the first point is solved by renaming the existing header, adding
    our own header that acts as a trampoline to the original one, after
    adding a #warning to warn about inclusion of sys/cdefs.h;

  - the second poitn is solved by changing all the headers installed by
    the toolchain todirectly include the original header instead of our
    trampoline.

This way, we can catch direct inclusion of sys/cdefs.h and ignore
indirect inclusions that are internal to the C library headers.

This also means that we are limited in what we can catch. We can not
instrument each macro individually, so all we know is that sys/cdefs.h
was included; we don't know what is being used from it.

Because instrumenting sys/cdefs.h to emit even just a warning has the
potential to break packages the hard way (e.g. those using -Werror that
would normally not have any warning), we make tht an advanced build
option that default to not instrumenting sys/cdefs.h.

When we are confident that the instrumentation of sys/cdefs.h has no
harmful side effects, we can change the default to emit the warning.

Beside no instrumentation and adding a warning, we add a third option,
to treat use of sys/cdefs.h as an error. This does break a lot of
things, so this is only available to actively track down the use of
sys/cdefs.h with the aim of removing its use from a pacakge.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
 Config.in                                          | 52 ++++++++++++
 package/musl-compat-headers/cdefs.h                | 51 ------------
 package/musl-compat-headers/cdefs.h.in             | 92 ++++++++++++++++++++++
 package/musl-compat-headers/musl-compat-headers.mk |  8 +-
 toolchain/cdefs.h.in                               |  8 ++
 toolchain/toolchain.mk                             | 30 +++++++
 6 files changed, 189 insertions(+), 52 deletions(-)
 delete mode 100644 package/musl-compat-headers/cdefs.h
 create mode 100644 package/musl-compat-headers/cdefs.h.in
 create mode 100644 toolchain/cdefs.h.in

diff --git a/Config.in b/Config.in
index 741a7ce..0da9af0 100644
--- a/Config.in
+++ b/Config.in
@@ -726,6 +726,58 @@ config BR2_COMPILER_PARANOID_UNSAFE_PATH
 	  toolchain (through the toolchain wrapper and binutils patches)
 	  and external toolchain backends (through the toolchain wrapper).
 
+choice
+	bool "paranoid check for use of cdefs.h"
+	default BR2_LEGACY_CDEFS_H_NONE
+	help
+	  sys/cdefs.h is a non-standard header, originating from glibc,
+	  that defines non-standard and legacy macros. This header is not
+	  always available (e.g. musl does not provide it, but Buildroot
+	  installs a surrogate, minimalist one in this case).
+
+	  Some packages use this header, which is wrong, as that makes
+	  then non-portable.
+
+	  By default, Buildroot does not detect the use of that header.
+	  In the future, this default may change to warning, or even to
+	  erroring out.
+
+config BR2_LEGACY_CDEFS_H_NONE
+	bool "don't check"
+	help
+	  Do not detect any use of sys/cdefs.h.
+
+config BR2_LEGACY_CDEFS_H_WARN
+	bool "check and emit warnings"
+	help
+	  Detect and warn about the use of sys/cdefs.h.
+
+	  When using the musl C library, this also warns for each of the
+	  legacy macros being used:
+		__P()
+		__BEGIN_DECLS
+		__END_DECLS
+		__THROW
+		__NTH()
+
+config BR2_LEGACY_CDEFS_H_ERROR
+	bool "check and exit in error"
+	help
+	  Same as BR2_LEGACY_CDEFS_H_WARN, above, but treated as
+	  an error.
+
+endchoice
+
+config BR2_LEGACY_CDEFS_H_PRAGMA_COND
+	int
+	default 0 if BR2_LEGACY_CDEFS_H_NONE
+	default 1
+
+config BR2_LEGACY_CDEFS_H_PRAGMA
+	string
+	default "warning" if BR2_LEGACY_CDEFS_H_WARN
+	default "error"   if BR2_LEGACY_CDEFS_H_ERROR
+
 endmenu
 
 config BR2_REPRODUCIBLE
diff --git a/package/musl-compat-headers/cdefs.h b/package/musl-compat-headers/cdefs.h
deleted file mode 100644
index 6fe7aa4..0000000
--- a/package/musl-compat-headers/cdefs.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (C) 2016 Yann E. MORIN <yann.morin.1998@free.fr>
- *
- * This file is in the Public Domain.
- *
- * For jurisdictions in which the Public Domain does not exist
- * or it is not otherwise applicable, this file is licensed CC0
- * (Creative Commons Zero).
- */
-
-/* This file contains definitions for non-standard macros defined by
- * glibc, but quite commonly used in packages.
- *
- * Because they are non-standard, musl does not define those macros.
- * It does not provide cdefs.h either.
- *
- * This file is a compatibility header written from scratch, to be
- * installed when the C library is musl.
- *
- * Not all macros from the glibc's cdefs.h are available, only the
- * most commonly used ones.
- *
- * Please refer to the glibc documentation and source code for
- * explanations about those macros.
- */
-
-#ifndef BUILDROOT_SYS_CDEFS_H
-#define BUILDROOT_SYS_CDEFS_H
-
-/* Function prototypes. */
-#undef __P
-#define __P(arg) arg
-
-/* C declarations in C++ mode. */
-#ifdef __cplusplus
-# define __BEGIN_DECLS extern "C" {
-# define __END_DECLS   }
-#else
-# define __BEGIN_DECLS
-# define __END_DECLS
-#endif
-
-/* Don't throw exceptions in C functions. */
-#ifndef __cplusplus
-# define __THROW  __attribute__ ((__nothrow__))
-# define __NTH(f) __attribute__ ((__nothrow__)) f
-#else
-# define __THROW
-# define __NTH(f) f
-#endif
-
-#endif /* ifndef BUILDROOT_SYS_CDEFS_H */
diff --git a/package/musl-compat-headers/cdefs.h.in b/package/musl-compat-headers/cdefs.h.in
new file mode 100644
index 0000000..44ab0e1
--- /dev/null
+++ b/package/musl-compat-headers/cdefs.h.in
@@ -0,0 +1,92 @@
+/* Copyright (C) 2016 Yann E. MORIN <yann.morin.1998@free.fr>
+ *
+ * This file is in the Public Domain.
+ *
+ * For jurisdictions in which the Public Domain does not exist
+ * or it is not otherwise applicable, this file is licensed CC0
+ * (Creative Commons Zero).
+ */
+
+/* This file contains definitions for non-standard macros defined by
+ * glibc, but quite commonly used in packages.
+ *
+ * Because they are non-standard, musl does not define those macros.
+ * It does not provide cdefs.h either.
+ *
+ * This file is a compatibility header written from scratch, to be
+ * installed when the C library is musl.
+ *
+ * Not all macros from the glibc's cdefs.h are available, only the
+ * most commonly used ones.
+ *
+ * Please refer to the glibc documentation and source code for
+ * explanations about those macros.
+ */
+
+#ifndef BUILDROOT_SYS_CDEFS_H
+#define BUILDROOT_SYS_CDEFS_H
+
+/* _Pragma() is a standard POSIX macro that allows one to embed pragmas
+ * in macro definitions (#pragma can't be used in a macro definition,
+ * because it contains a #).
+ *
+ * However, the gcc manual states (quoting):
+ *
+ *   The standard is unclear on where a _Pragma operator can appear. The
+ *   preprocessor does not accept it within a preprocessing conditional
+ *   directive like ?#if?. To be safe, you are probably best keeping it
+ *   out of directives other than ?#define?, and putting it on a line of
+ *   its own.
+ *
+ * https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
+ *
+ * So we abide by this suggestion.
+ */
+
+#if @pragma_cond@
+#@pragma@ Use of deprecated <sys/cdefs.h> header.
+#define BR_P(x) _Pragma(#x)
+#define BR_W(x) BR_P(GCC @pragma@ x)
+#else
+#define BR_P(x)
+#define BR_W(x)
+#endif
+
+/* Function prototypes. */
+#undef __P
+#define __P(arg) \
+            BR_W("Use of deprecated macro __P().") \
+            arg
+
+/* C declarations in C++ mode. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS \
+            BR_W("Use of deprecated macro __BEGIN_DECLS.") \
+            extern "C" {
+# define __END_DECLS \
+            BR_W("Use of deprecated macro __END_DECLS.") \
+            }
+#else
+# define __BEGIN_DECLS \
+            BR_W("Use of deprecated macro __BEGIN_DECLS.")
+# define __END_DECLS \
+            BR_W("Use of deprecated macro __END_DECLS.")
+#endif
+
+/* Don't throw exceptions in C functions. */
+#ifndef __cplusplus
+# define __THROW \
+            BR_W("Use of deprecated macro __THROW.") \
+            __attribute__ ((__nothrow__))
+# define __NTH(f) \
+            BR_W("Use of deprecated macro __NTH().") \
+            __attribute__ ((__nothrow__)) f
+#else
+# define __THROW \
+            BR_W("Use of deprecated macro __THROW.")
+# define __NTH(f) \
+            BR_W("Use of deprecated macro __NTH().") \
+            f
+#endif
+
+#endif /* ifndef BUILDROOT_SYS_CDEFS_H */
diff --git a/package/musl-compat-headers/musl-compat-headers.mk b/package/musl-compat-headers/musl-compat-headers.mk
index 25e032c..7879123 100644
--- a/package/musl-compat-headers/musl-compat-headers.mk
+++ b/package/musl-compat-headers/musl-compat-headers.mk
@@ -21,7 +21,13 @@ MUSL_COMPAT_HEADERS_INSTALL_STAGING = YES
 # Copying both headers so legal-info finds them (they are _LICENSE_FILES)
 define MUSL_COMPAT_HEADERS_EXTRACT_CMDS
 	$(INSTALL) -m 0644 -D $(DL_DIR)/$(notdir $(MUSL_COMPAT_HEADERS_QUEUE_H)) $(@D)/queue.h
-	$(INSTALL) -m 0644 -D $(MUSL_COMPAT_HEADERS_PKGDIR)/cdefs.h $(@D)/cdefs.h
+	$(INSTALL) -m 0644 -D $(MUSL_COMPAT_HEADERS_PKGDIR)/cdefs.h.in $(@D)/cdefs.h.in
+endef
+
+define MUSL_COMPAT_HEADERS_BUILD_CMDS
+	sed -r -e 's/@pragma_cond@/$(BR2_LEGACY_CDEFS_H_PRAGMA_COND)/' \
+	       -e 's/@pragma@/$(call qstrip,$(BR2_LEGACY_CDEFS_H_PRAGMA))/' \
+	       $(@D)/cdefs.h.in >$(@D)/cdefs.h
 endef
 
 define MUSL_COMPAT_HEADERS_INSTALL_STAGING_CMDS
diff --git a/toolchain/cdefs.h.in b/toolchain/cdefs.h.in
new file mode 100644
index 0000000..23bd3e8
--- /dev/null
+++ b/toolchain/cdefs.h.in
@@ -0,0 +1,8 @@
+#ifndef BUILDROOT_SYS_CDEFS_H_WRAPPER
+#define BUILDROOT_SYS_CDEFS_H_WRAPPER
+
+#@pragma@ Use of deprecated <sys/cdefs.h> header.
+
+#include <sys/cdefs.h.wrapped>
+
+#endif /* BUILDROOT_SYS_CDEFS_H_WRAPPER */
diff --git a/toolchain/toolchain.mk b/toolchain/toolchain.mk
index 59fc905..a3ca3cc 100644
--- a/toolchain/toolchain.mk
+++ b/toolchain/toolchain.mk
@@ -54,3 +54,33 @@ define COPY_GCONV_LIBS
 endef
 TOOLCHAIN_TARGET_FINALIZE_HOOKS += COPY_GCONV_LIBS
 endif
+
+# For non-musl toolchain, install our wrapper to sys/cdefs.h and
+# set the proper checking level. Also `fix' toolchain headers to
+# directly include the real sys/cdefs.h instead of our wrapper.
+#
+# This is a target post install hook, because the virtual package
+# "toolchain" is not `installed' to staging.
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),)
+ifneq ($(BR2_LEGACY_CDEFS_H_NONE),y)
+define TOOLCHAIN_WRAP_CDEFS_H
+	cdefs_h=$(STAGING_DIR)/usr/include/sys/cdefs.h; \
+	if [ ! -f $${cdefs_h} ]; then \
+		echo "*** Error: toolchain does not have <sys/cdefs.h>" >&2; \
+		exit 1; \
+	fi; \
+	if [ ! -f $${cdefs_h}.wrapped ]; then \
+		mv $${cdefs_h} $${cdefs_h}.wrapped || exit 1; \
+		$(INSTALL) -m 0644 -D toolchain/cdefs.h.in \
+			$${cdefs_h} || exit 1; \
+		$(SED) 's/@pragma_cond@/$(BR2_LEGACY_CDEFS_H_PRAGMA_COND)/' \
+			-e 's/@pragma@/$(call qstrip,$(BR2_LEGACY_CDEFS_H_PRAGMA))/' \
+			$${cdefs_h} || exit 1; \
+		find $(STAGING_DIR)/usr/include/ -type f -name '*.h' -exec \
+			sed -r -i -e 's:^(#[[:space:]]*include[[:space:]]+<sys/cdefs\.h)(>)$$:\1.wrapped\2 /* Redirected by Buildroot */:' \
+				{} + || exit 1; \
+	fi
+endef
+TOOLCHAIN_POST_INSTALL_TARGET_HOOKS += TOOLCHAIN_WRAP_CDEFS_H
+endif # CDEFS_H_NONE
+endif # USES_MUSL
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs)
  2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
                   ` (8 preceding siblings ...)
  2016-08-18 21:50 ` [Buildroot] [PATCH 9/9 v2] build/advanced: add option to check for use of cdefs.h Yann E. MORIN
@ 2016-08-19  9:40 ` Thomas Petazzoni
  2016-08-22  8:34   ` Peter Korsgaard
  9 siblings, 1 reply; 12+ messages in thread
From: Thomas Petazzoni @ 2016-08-19  9:40 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 18 Aug 2016 23:50:17 +0200, Yann E. MORIN wrote:

>       package/musl-compat-headers: provide compatibility headers not in musl
>       package/rpcbind: fix musl build
>       package/aircrack-ng: drop a musl-compatibility patch
>       package/android-tools: drop musl-compatibility cdefs patching out
>       package/bcusdk: drop a musl-compatibility patch
>       package/libsepol: drop a musl-compatibility patch
>       package/linknx: drop a musl-compatibility patch
>       package/qlibc: drop a musl-compatibility patch

I've applied those patches to master. It's a bit late to apply such a
change, but having this compatibility cdefs.h header can help solve a
number of remaining build issues, so let's have it.

>       build/advanced: add option to check for use of cdefs.h

This one, I am really really not sure. It's a whole lot of additional
complexity just to check a very specific problem. I'm not sure we want
to include such an additional complexity just for the sake of making
upstream packages "cdefs.h clean".

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs)
  2016-08-19  9:40 ` [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Thomas Petazzoni
@ 2016-08-22  8:34   ` Peter Korsgaard
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2016-08-22  8:34 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

 > This one, I am really really not sure. It's a whole lot of additional
 > complexity just to check a very specific problem. I'm not sure we want
 > to include such an additional complexity just for the sake of making
 > upstream packages "cdefs.h clean".

I agree, lets keep it KISS.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-08-22  8:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 21:50 [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 1/9 v2] package/musl-compat-headers: provide compatibility headers not in musl Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 2/9 v2] package/rpcbind: fix musl build Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 3/9 v2] package/aircrack-ng: drop a musl-compatibility patch Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 4/9 v2] package/android-tools: drop musl-compatibility cdefs patching out Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 5/9 v2] package/bcusdk: drop a musl-compatibility patch Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 6/9 v2] package/libsepol: " Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 7/9 v2] package/linknx: " Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 8/9 v2] package/qlibc: " Yann E. MORIN
2016-08-18 21:50 ` [Buildroot] [PATCH 9/9 v2] build/advanced: add option to check for use of cdefs.h Yann E. MORIN
2016-08-19  9:40 ` [Buildroot] [PATCH 0/9 v2] musl: add compatibility cdefs.h header (branch yem/cdefs) Thomas Petazzoni
2016-08-22  8:34   ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.