Move overlay inclusions outside of header protection Glibc tends to include standard headers with special definitions that make few declarations or macros visible, this stomps over the overlay #include_next <> logic. Based-on-patch-by: Robert Millan <rmh@debian.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
diff --git a/include/bsd/err.h b/include/bsd/err.h
index def4ac3..11d1250 100644
--- a/include/bsd/err.h
+++ b/include/bsd/err.h
@@ -25,6 +25,12 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef LIBBSD_OVERLAY
+#include_next <err.h>
+#else
+#include <err.h>
+#endif
+
#ifndef LIBBSD_ERR_H
#define LIBBSD_ERR_H
@@ -32,12 +38,6 @@
#include <stdarg.h>
-#ifdef LIBBSD_OVERLAY
-#include_next <err.h>
-#else
-#include <err.h>
-#endif
-
__BEGIN_DECLS
extern void warnc (int code, const char *format, ...);
extern void vwarnc (int code, const char *format, va_list ap);
diff --git a/include/bsd/getopt.h b/include/bsd/getopt.h
index 52a8f9c..9fb2e7e 100644
--- a/include/bsd/getopt.h
+++ b/include/bsd/getopt.h
@@ -24,9 +24,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_GETOPT_H
-#define LIBBSD_GETOPT_H
-
#ifdef LIBBSD_OVERLAY
#include_next <getopt.h>
#include <unistd.h>
@@ -34,5 +31,3 @@
#include <getopt.h>
#include <bsd/unistd.h>
#endif
-
-#endif
diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
index db2823e..22e9d2c 100644
--- a/include/bsd/stdio.h
+++ b/include/bsd/stdio.h
@@ -24,18 +24,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_STDIO_H
-#define LIBBSD_STDIO_H
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
#ifdef LIBBSD_OVERLAY
#include_next <stdio.h>
#else
#include <stdio.h>
#endif
+#ifndef LIBBSD_STDIO_H
+#define LIBBSD_STDIO_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
__BEGIN_DECLS
const char *fmtcheck(const char *, const char *);
diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
index 5253183..5448011 100644
--- a/include/bsd/stdlib.h
+++ b/include/bsd/stdlib.h
@@ -26,13 +26,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_STDLIB_H
-#define LIBBSD_STDLIB_H
-
-#include <sys/cdefs.h>
-#include <sys/stat.h>
-#include <stdint.h>
-
#ifdef LIBBSD_OVERLAY
#include_next <stdlib.h>
#else
@@ -46,6 +39,13 @@
#include <bsd/libutil.h>
#endif
+#ifndef LIBBSD_STDLIB_H
+#define LIBBSD_STDLIB_H
+
+#include <sys/cdefs.h>
+#include <sys/stat.h>
+#include <stdint.h>
+
__BEGIN_DECLS
u_int32_t arc4random();
void arc4random_stir();
diff --git a/include/bsd/string.h b/include/bsd/string.h
index be811f3..ac2a5a5 100644
--- a/include/bsd/string.h
+++ b/include/bsd/string.h
@@ -24,18 +24,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_STRING_H
-#define LIBBSD_STRING_H
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
#ifdef LIBBSD_OVERLAY
#include_next <string.h>
#else
#include <string.h>
#endif
+#ifndef LIBBSD_STRING_H
+#define LIBBSD_STRING_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
__BEGIN_DECLS
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index 90b34c1..49bbeb5 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -24,15 +24,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_SYS_CDEFS_H
-#define LIBBSD_SYS_CDEFS_H
-
#ifdef LIBBSD_OVERLAY
#include_next <sys/cdefs.h>
#else
#include <sys/cdefs.h>
#endif
+#ifndef LIBBSD_SYS_CDEFS_H
+#define LIBBSD_SYS_CDEFS_H
+
/*
* Some kFreeBSD headers expect those macros to be set for sanity checks.
*/
diff --git a/include/bsd/sys/endian.h b/include/bsd/sys/endian.h
index cf8c884..3506cee 100644
--- a/include/bsd/sys/endian.h
+++ b/include/bsd/sys/endian.h
@@ -24,15 +24,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_SYS_ENDIAN_H
-#define LIBBSD_SYS_ENDIAN_H
-
#ifdef LIBBSD_OVERLAY
#include_next <endian.h>
#else
#include <endian.h>
#endif
+#ifndef LIBBSD_SYS_ENDIAN_H
+#define LIBBSD_SYS_ENDIAN_H
+
#ifndef _BYTE_ORDER
#define _BYTE_ORDER __BYTE_ORDER
#endif
diff --git a/include/bsd/sys/poll.h b/include/bsd/sys/poll.h
index 227effa..0e34103 100644
--- a/include/bsd/sys/poll.h
+++ b/include/bsd/sys/poll.h
@@ -24,15 +24,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_SYS_POLL_H
-#define LIBBSD_SYS_POLL_H
-
#ifdef LIBBSD_OVERLAY
#include_next <sys/poll.h>
#else
#include <sys/poll.h>
#endif
+#ifndef LIBBSD_SYS_POLL_H
+#define LIBBSD_SYS_POLL_H
+
#ifndef INFTIM
#define INFTIM (-1)
#endif
diff --git a/include/bsd/unistd.h b/include/bsd/unistd.h
index 713a8d7..e576b89 100644
--- a/include/bsd/unistd.h
+++ b/include/bsd/unistd.h
@@ -25,18 +25,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LIBBSD_UNISTD_H
-#define LIBBSD_UNISTD_H
-
-#include <sys/cdefs.h>
-#include <sys/stat.h>
-
#ifdef LIBBSD_OVERLAY
#include_next <unistd.h>
#else
#include <unistd.h>
#endif
+#ifndef LIBBSD_UNISTD_H
+#define LIBBSD_UNISTD_H
+
+#include <sys/cdefs.h>
+#include <sys/stat.h>
+
#ifndef S_ISTXT
#define S_ISTXT S_ISVTX
#endif