blob: e369d5a8ae608befba6673ea86333ea734c3bc16 [file] [log] [blame]
From: Baruch Siach <baruch@tkos.co.il>
Date: Fri, 29 Sep 2017 10:06:52 +0300
Subject: [PATCH] Fix build with musl and older Linux kernel
The musl libc carries its own copy of Linux system calls. When building
with Linux headers older than v3.17, musl provides SYS_getrandom
definition, but not GRND_NONBLOCK. This causes build failure for
libressl and openntpd:
getentropy_linux.c: In function 'getentropy_getrandom':
getentropy_linux.c:205:42: error: 'GRND_NONBLOCK' undeclared (first use in this function)
ret = syscall(SYS_getrandom, buf, len, GRND_NONBLOCK);
^~~~~~~~~~~~~
Define GRND_NONBLOCK locally when its definition is missing to fix the
build. There should be no run-time effect. Older kernels return ENOSYS
for unsupported syscall().
[ from upstream pull request with file location changed ]
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
Upstream status: https://github.com/libressl-portable/openbsd/pull/82
diff -Nuar openntpd-6.2p2-orig/compat/getentropy_linux.c openntpd-6.2p2/compat/getentropy_linux.c
--- openntpd-6.2p2-orig/compat/getentropy_linux.c 2017-09-07 22:12:02.000000000 +0300
+++ openntpd-6.2p2/compat/getentropy_linux.c 2017-09-29 11:54:54.856245770 +0300
@@ -194,6 +194,11 @@
}
#ifdef SYS_getrandom
+
+#ifndef GRND_NONBLOCK
+#define GRND_NONBLOCK 0x0001
+#endif
+
static int
getentropy_getrandom(void *buf, size_t len)
{