]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Handle glibc partial header inclusions
authorGuillem Jover <guillem@hadrons.org>
Fri, 11 Oct 2013 03:11:42 +0000 (05:11 +0200)
committerGuillem Jover <guillem@hadrons.org>
Mon, 21 Oct 2013 03:35:17 +0000 (05:35 +0200)
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.

include/bsd/stdio.h
include/bsd/wchar.h

index 62d587f350aa08961e42db36df9db3461e6832f6..960df1bc8bd6bf9bedd4064f2cc301b4eef1e2f7 100644 (file)
@@ -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
  * 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
index a7e25bf6c3147712d6323b32fdfaeb01203541c4..33a500ee3ddc1518f2efa4f8cc434b4611b8024d 100644 (file)
@@ -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
  * 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