[PATCH] headers: Fix build errors with latest glibc

Hans de Goede hdegoede at redhat.com
Wed Jul 2 12:14:54 PDT 2014


include/os.h defines protyptes for various non ansi-c str functions, such
as str[n]casecmp and strndup. The definition of the prototypes is guarded
by #ifndef HAVE_STRFOO, but HAVE_STRFOO is defined by xorg-server.h which
is not included by all users of os.h. E.g. glamor.h does not and should not
include xorg-server.h

This is a problem since the these prototype declarations clash with the libc
declarations when using the latest glibc:

In file included from /usr/include/xorg/misc.h:115:0,
                 from /usr/include/xorg/screenint.h:50,
                 from /usr/include/xorg/scrnintstr.h:50,
                 from /usr/include/xorg/glamor.h:32,
                 from conftest.c:61:
/usr/include/xorg/os.h:579:2: error: expected identifier or '(' before '__extension__'
 strndup(const char *str, size_t n);

To fix this, this commit moves the HAVE_STRFOO defines to their own
(generated) header called os-strfeatures.h, and unconditionally includes this
header from os.h .

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 configure.ac                |  2 ++
 include/Makefile.am         |  2 +-
 include/dix-config.h.in     | 18 ------------------
 include/os-strfeatures.h.in | 33 +++++++++++++++++++++++++++++++++
 include/os.h                |  1 +
 include/xorg-server.h.in    | 18 ------------------
 6 files changed, 37 insertions(+), 37 deletions(-)
 create mode 100644 include/os-strfeatures.h.in

diff --git a/configure.ac b/configure.ac
index 2daa6be..05ae8e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,8 @@ AC_CONFIG_HEADERS(include/kdrive-config.h)
 dnl version-config.h covers the version numbers so they can be bumped without
 dnl forcing an entire recompile.x
 AC_CONFIG_HEADERS(include/version-config.h)
+dnl os-strfeatures.h covers HAVE_STRFOO for non ansi-c string functions
+AC_CONFIG_HEADERS(include/os-strfeatures.h)
 
 AM_PROG_AS
 AC_PROG_LN_S
diff --git a/include/Makefile.am b/include/Makefile.am
index 6578038..b2ee27b 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -62,7 +62,7 @@ sdk_HEADERS =		\
 	xkbrules.h      \
 	xserver-properties.h
 
-nodist_sdk_HEADERS = xorg-server.h
+nodist_sdk_HEADERS = xorg-server.h os-strfeatures.h
 endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index f980a3d..f055b2c 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -175,30 +175,12 @@
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
-/* Define to 1 if you have the `strcasestr' function. */
-#undef HAVE_STRCASESTR
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strlcat' function. */
-#undef HAVE_STRLCAT
-
-/* Define to 1 if you have the `strlcpy' function. */
-#undef HAVE_STRLCPY
-
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the `strndup' function. */
-#undef HAVE_STRNDUP
-
 /* Define to 1 if libsystemd-daemon is available */
 #undef HAVE_SYSTEMD_DAEMON
 
diff --git a/include/os-strfeatures.h.in b/include/os-strfeatures.h.in
new file mode 100644
index 0000000..88c3b30
--- /dev/null
+++ b/include/os-strfeatures.h.in
@@ -0,0 +1,33 @@
+/* os-strfeatures.h.in						-*- c -*-
+ *
+ * This file is the template file for the os-strfeatures.h file which gets
+ * installed as part of the SDK.  The #defines in this file are HAVE_STRFOO
+ * defines which control whether os.h declares protype for non ansi-c
+ * string functions suchs as str[n]casecmp and strndup,
+ *
+ * Note this file is not generated by autoheader, so it needs to by synced
+ * manually with changes to configure.in where necessary.
+ */
+
+#ifndef OS_STRFEATURES_H
+#define OS_STRFEATURES_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strcasestr' function. */
+#undef HAVE_STRCASESTR
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
+/* Define to 1 if you have the `strndup' function. */
+#undef HAVE_STRNDUP
+
+#endif /* OS_STRFEATURES_H */
diff --git a/include/os.h b/include/os.h
index d26e399..54819f9 100644
--- a/include/os.h
+++ b/include/os.h
@@ -48,6 +48,7 @@ SOFTWARE.
 #define OS_H
 
 #include "misc.h"
+#include "os-strfeatures.h"
 #include <stdarg.h>
 #include <stdint.h>
 #include <string.h>
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index 8bf9d38..9daf0fa 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -43,24 +43,6 @@
 /* Define to 1 if you have the `ffs' function. */
 #undef HAVE_FFS
 
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
-/* Define to 1 if you have the `strcasestr' function. */
-#undef HAVE_STRCASESTR
-
-/* Define to 1 if you have the `strlcat' function. */
-#undef HAVE_STRLCAT
-
-/* Define to 1 if you have the `strlcpy' function. */
-#undef HAVE_STRLCPY
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strndup' function. */
-#undef HAVE_STRNDUP
-
 /* Support IPv6 for TCP connections */
 #undef IPv6
 
-- 
2.0.0



More information about the xorg-devel mailing list