]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Gracefully handle lack of system <sys/cdefs.h>
authorGuillem Jover <guillem@hadrons.org>
Tue, 10 Jan 2017 03:27:25 +0000 (04:27 +0100)
committerGuillem Jover <guillem@hadrons.org>
Mon, 5 Jun 2017 03:52:07 +0000 (05:52 +0200)
This is the case on musl.

Fixes: https://bugs.debian.org/810589
include/bsd/sys/cdefs.h

index 75d395563c81c6e01aa758dfa96104662938bdcf..044f2218841f207c1d05edd3af0d7f541c271a85 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef __has_include
+#define __has_include 1
+#endif
+#ifndef __has_include_next
+#define __has_include_next 1
+#endif
+
 #ifdef LIBBSD_OVERLAY
+/*
+ * Some libc implementations do not have a <sys/cdefs.h>, in particular
+ * musl, try to handle this gracefully.
+ */
+#if __has_include_next(<sys/cdefs.h>)
 #include_next <sys/cdefs.h>
+#endif
 #else
+#if __has_include(<sys/cdefs.h>)
 #include <sys/cdefs.h>
 #endif
+#endif
 
 #ifndef LIBBSD_SYS_CDEFS_H
 #define LIBBSD_SYS_CDEFS_H
 
+#ifndef __BEGIN_DECLS
+#ifdef __cplusplus
+#define __BEGIN_DECLS  extern "C" {
+#define __END_DECLS    }
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+#endif
+
 /*
  * Some kFreeBSD headers expect those macros to be set for sanity checks.
  */