Changeset

7934:485b9e66fedf

util.crand: Only include getrandom shiv with glibc older than 2.25
author Kim Alvefur <zash@zash.se>
date Thu, 02 Mar 2017 00:17:34 +0100
parents 7933:c91ec7689424
children 7935:96fa5ef5d613
files util-src/crand.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util-src/crand.c	Thu Mar 02 00:15:04 2017 +0100
+++ b/util-src/crand.c	Thu Mar 02 00:17:34 2017 +0100
@@ -28,17 +28,22 @@
 #include <errno.h>
 
 #if defined(WITH_GETRANDOM)
+
+#if ! __GLIBC_PREREQ(2,25)
 #include <unistd.h>
 #include <sys/syscall.h>
-#include <linux/random.h>
 
 #ifndef SYS_getrandom
 #error getrandom() requires Linux 3.17 or later
 #endif
 
+/* This wasn't present before glibc 2.25 */
 int getrandom(void *buf, size_t buflen, unsigned int flags) {
 	return syscall(SYS_getrandom, buf, buflen, flags);
 }
+#else
+#include <sys/random.h>
+#endif
 
 #elif defined(WITH_ARC4RANDOM)
 #include <stdlib.h>