[PATCH] libosmocore[master]: Check for getrandom syscall directly

Max gerrit-no-reply at lists.osmocom.org
Tue Oct 10 10:30:36 UTC 2017


Review at  https://gerrit.osmocom.org/4193

Check for getrandom syscall directly

The ./configure check for SYS_getrandom fails on some systems for
unknown reason. Let's drop it and check for SYS_getrandom availability
directly.

Change-Id: I028724d41b3f5495a1a8adb51a5341de31ed0d82
---
M configure.ac
M src/gsm/gsm_utils.c
2 files changed, 2 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/4193/1

diff --git a/configure.ac b/configure.ac
index d9390cf..33c151e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,9 +73,6 @@
 AC_PATH_PROG(DOXYGEN,doxygen,false)
 AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false && test "x$doxygen" = "xyes")
 
-# check for syscal fallback on glibc < 2.25 - can be removed once glibc version requirement is bumped
-AC_CHECK_DECLS([SYS_getrandom], [], [], [[#include <sys/syscall.h>]])
-
 # The following test is taken from WebKit's webkit.m4
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fvisibility=hidden "
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c
index e3f792e..0c07a57 100644
--- a/src/gsm/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -99,7 +99,7 @@
 /* FIXME: this can be removed once we bump glibc requirements to 2.25: */
 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25)
 #include <linux/random.h>
-#elif HAVE_DECL_SYS_GETRANDOM
+#else
 #include <sys/syscall.h>
 #ifndef GRND_NONBLOCK
 #define GRND_NONBLOCK 0x0001
@@ -417,7 +417,7 @@
 
 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25)
 	rc = getrandom(out, len, GRND_NONBLOCK);
-#elif HAVE_DECL_SYS_GETRANDOM
+#elif defined SYS_getrandom
 #pragma message ("Using direct syscall access for getrandom(): consider upgrading to glibc >= 2.25")
 	/* FIXME: this can be removed once we bump glibc requirements to 2.25: */
 	rc = syscall(SYS_getrandom, out, len, GRND_NONBLOCK);

-- 
To view, visit https://gerrit.osmocom.org/4193
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I028724d41b3f5495a1a8adb51a5341de31ed0d82
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>


More information about the gerrit-log mailing list