0001-fix-musl.patch 1.4 KB

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