Hello! linux/random.h uses __u32 types, which are defined through inclusion of linux/types.h header. On some older systems (e.g. CentOS 5.11) linux/random.h doesn't include linux/types.h by itself, and configure declares found linux/random.h as unusable.
Attached patch fixes detection by including linux/types.h in the configure check. 2018-01-18 Uros Bizjak <ubiz...@gmail.com> * configure.ac (AC_CHECK_HEADERS): Add linux/types.h. Conditionally include linux/types.h when checking linux/random.h header. * config.h.in: Regenerate. * configure: Ditto. * src/c++11/random.cc: Conditionally include linux/types.h. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32} CentOS 5.11 and Fedora 26. OK for mainline? Uros.
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index e31e054..5a0f067 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -270,6 +270,9 @@ /* Define to 1 if you have the <linux/random.h> header file. */ #undef HAVE_LINUX_RANDOM_H +/* Define to 1 if you have the <linux/types.h> header file. */ +#undef HAVE_LINUX_TYPES_H + /* Define to 1 if you have the <locale.h> header file. */ #undef HAVE_LOCALE_H diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index f5798d3..69845f4 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -21799,7 +21799,7 @@ for ac_header in endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \ locale.h machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \ strings.h sys/ipc.h sys/isa_defs.h sys/machine.h sys/param.h \ sys/resource.h sys/sem.h sys/stat.h sys/time.h sys/types.h unistd.h \ -wchar.h wctype.h linux/random.h +wchar.h wctype.h linux/types.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -21814,6 +21814,23 @@ fi done +for ac_header in linux/random.h +do : + ac_fn_c_check_header_compile "$LINENO" "linux/random.h" "ac_cv_header_linux_random_h" "#ifdef HAVE_LINUX_TYPES_H +# include <linux/types.h> +#endif + +" +if test "x$ac_cv_header_linux_random_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_RANDOM_H 1 +_ACEOF + +fi + +done + + # Only do link tests if native. Else, hardcode. if $GLIBCXX_IS_NATIVE; then diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index c90c509..e110f57 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -237,7 +237,13 @@ AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \ locale.h machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \ strings.h sys/ipc.h sys/isa_defs.h sys/machine.h sys/param.h \ sys/resource.h sys/sem.h sys/stat.h sys/time.h sys/types.h unistd.h \ -wchar.h wctype.h linux/random.h]) +wchar.h wctype.h linux/types.h]) + +AC_CHECK_HEADERS([linux/random.h], [], [], +[[#ifdef HAVE_LINUX_TYPES_H +# include <linux/types.h> +#endif +]]) # Only do link tests if native. Else, hardcode. if $GLIBCXX_IS_NATIVE; then diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc index 415f794..19daf6d 100644 --- a/libstdc++-v3/src/c++11/random.cc +++ b/libstdc++-v3/src/c++11/random.cc @@ -42,6 +42,10 @@ # include <sys/ioctl.h> #endif +#ifdef _GLIBCXX_HAVE_LINUX_TYPES_H +# include <linux/types.h> +#endif + #ifdef _GLIBCXX_HAVE_LINUX_RANDOM_H # include <linux/random.h> #endif