Handle glibc partial header inclusions The glibc headers use selective inclusions through the __need_NAME mechanism to avoid circular dependencies. The problem is that if we are being overlaid, and have been requested a partial inclusion, when we pass control to the system header, then we might miss definitions needed by our own header, resulting in build failures. Workaround that by catching current partial requests, and skip the current inclusion.
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
diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
index 62d587f..960df1b 100644
--- a/include/bsd/stdio.h
+++ b/include/bsd/stdio.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2004, 2005, 2009, 2011 Guillem Jover <guillem@hadrons.org>
+ * Copyright © 2004-2005, 2009, 2011-2013 Guillem Jover <guillem@hadrons.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,12 +24,17 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if defined(__need_FILE) || defined(__need___FILE)
+#define LIBBSD_STDIO_H_SKIP
+#endif
+
#ifdef LIBBSD_OVERLAY
#include_next <stdio.h>
#else
#include <stdio.h>
#endif
+#ifndef LIBBSD_STDIO_H_SKIP
#ifndef LIBBSD_STDIO_H
#define LIBBSD_STDIO_H
@@ -45,3 +50,5 @@ int fpurge(FILE *fp);
__END_DECLS
#endif
+#endif
+#undef LIBBSD_STDIO_H_SKIP
diff --git a/include/bsd/wchar.h b/include/bsd/wchar.h
index a7e25bf..33a500e 100644
--- a/include/bsd/wchar.h
+++ b/include/bsd/wchar.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Guillem Jover <guillem@hadrons.org>
+ * Copyright © 2012-2013 Guillem Jover <guillem@hadrons.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,12 +24,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if defined(__need_wchar_t) || defined(__need_wint_t) || \
+ defined(__need_mbstate_t)
+#define LIBBSD_WCHAR_H_SKIP
+#endif
+
#ifdef LIBBSD_OVERLAY
#include_next <wchar.h>
#else
#include <wchar.h>
#endif
+#ifndef LIBBSD_WCHAR_H_SKIP
#ifndef LIBBSD_WCHAR_H
#define LIBBSD_WCHAR_H
@@ -45,3 +51,5 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
__END_DECLS
#endif
+#endif
+#undef LIBBSD_WCHAR_H_SKIP