From: Zbigniew Jędrzejewski-Szmek Date: Wed, 19 Apr 2017 20:13:27 +0000 (-0400) Subject: basic/random-util: add new header for getrandom() X-Git-Tag: v234~306^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5224c2c7068ea538d2523ad033172450ccac147d;p=platform%2Fupstream%2Fsystemd.git basic/random-util: add new header for getrandom() There's some confusion: older man pages specify that linux/random.h contains getrandom, but newer glibc has it in sys/random.h. Detect if the newer header is available and include it. We still need the older header for the flags. --- diff --git a/configure.ac b/configure.ac index 3436a9d..13e7583 100644 --- a/configure.ac +++ b/configure.ac @@ -328,7 +328,6 @@ AC_CHECK_DECLS([ pivot_root, name_to_handle_at, setns, - getrandom, renameat2, kcmp, keyctl, @@ -343,6 +342,13 @@ AC_CHECK_DECLS([ #include #include #include +]]) + +AC_CHECK_DECLS([getrandom], + [AC_DEFINE([USE_SYS_RANDOM_H], [], [sys/random.h is usable])], + [AC_CHECK_DECLS([getrandom], [], [], [[ +#include +]])], [[ #include ]]) diff --git a/src/basic/random-util.c b/src/basic/random-util.c index ad7b3ee..b216be5 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -27,7 +27,13 @@ #include #ifdef HAVE_SYS_AUXV_H -#include +# include +#endif + +#ifdef USE_SYS_RANDOM_H +# include +#else +# include #endif #include "fd-util.h"