Hi,

Stefan Kangas wrote:
> Please see the below bug report regarding Gnulib compatibility with
> x86_64-pc-linux-uclibc.

When a system - in this case, uClibc - provides a header file that cannot
be included on its own, it's a bug in that system.

Gnulib can only provide a workaround.


2020-08-13  Bruno Haible  <br...@clisp.org>

        sys_random: Work around an uClibc bug.
        Reported by akater <nuclearsp...@gmail.com>
        via Stefan Kangas <ste...@marxist.se>
        in <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42236>.
        * lib/sys_random.in.h: On uClibc, include <stddef.h> first.
        * m4/sys_random_h.m4 (gl_HEADER_SYS_RANDOM): Update comment.
        * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise.
        * doc/glibc-headers/sys_random.texi: Mention the uClibc bug.

diff --git a/doc/glibc-headers/sys_random.texi 
b/doc/glibc-headers/sys_random.texi
index f533a7a..df5d684 100644
--- a/doc/glibc-headers/sys_random.texi
+++ b/doc/glibc-headers/sys_random.texi
@@ -25,7 +25,7 @@ This header file is missing on some platforms:
 glibc 2.24, NetBSD 9.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.11, IRIX 
6.5, Cygwin 2.6.x, mingw, MSVC 14.
 @item
 This header file is not self-contained on some platforms:
-Mac OS X 10.13.
+uClibc, Mac OS X 10.13.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index 290fa39..a8469cf 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -23,6 +23,10 @@
 
 #if @HAVE_SYS_RANDOM_H@
 
+/* On uClibc, <sys/random.h> assumes prior inclusion of <stddef.h>.  */
+# if defined __UCLIBC__
+#  include <stddef.h>
+# endif
 /* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
    On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
    includes <Availability.h>, such as <stdlib.h> or <unistd.h>.  */
diff --git a/m4/getrandom.m4 b/m4/getrandom.m4
index 424c2fa..d6da71a 100644
--- a/m4/getrandom.m4
+++ b/m4/getrandom.m4
@@ -1,4 +1,4 @@
-# getrandom.m4 serial 7
+# getrandom.m4 serial 8
 dnl Copyright 2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,8 @@ AC_DEFUN([gl_FUNC_GETRANDOM],
       [gl_cv_func_getrandom_ok],
       [AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM(
-            [[/* Additional includes are needed before <sys/random.h> on Mac 
OS X.  */
+            [[/* Additional includes are needed before <sys/random.h> on uClibc
+                 and Mac OS X.  */
               #include <sys/types.h>
               #include <stdlib.h>
               #include <sys/random.h>
diff --git a/m4/sys_random_h.m4 b/m4/sys_random_h.m4
index a964b15..8c5d537 100644
--- a/m4/sys_random_h.m4
+++ b/m4/sys_random_h.m4
@@ -1,4 +1,4 @@
-# sys_random_h.m4 serial 4
+# sys_random_h.m4 serial 5
 dnl Copyright (C) 2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,8 @@ AC_DEFUN([gl_HEADER_SYS_RANDOM],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[
 #if HAVE_SYS_RANDOM_H
-/* Additional includes are needed before <sys/random.h> on Mac OS X.  */
+/* Additional includes are needed before <sys/random.h> on uClibc
+   and Mac OS X.  */
 # include <sys/types.h>
 # include <stdlib.h>
 # include <sys/random.h>


Reply via email to