diff --git a/lib_eio_linux/eio_stubs.c b/lib_eio_linux/eio_stubs.c index a1102607d..27df42697 100644 --- a/lib_eio_linux/eio_stubs.c +++ b/lib_eio_linux/eio_stubs.c @@ -4,7 +4,9 @@ #include #include #include +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 24 #include +#endif #include #include #include @@ -97,7 +99,11 @@ CAMLprim value caml_eio_getrandom(value v_ba, value v_off, value v_len) { do { void *buf = Caml_ba_data_val(v_ba) + off; caml_enter_blocking_section(); +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 24 ret = getrandom(buf, len, 0); +#else + ret = syscall(SYS_getrandom, buf, len, 0); +#endif caml_leave_blocking_section(); } while (ret == -1 && errno == EINTR); if (ret == -1) uerror("getrandom", Nothing); diff --git a/lib_eio_posix/eio_posix_stubs.c b/lib_eio_posix/eio_posix_stubs.c index 93a0f10c4..6b75d43bb 100644 --- a/lib_eio_posix/eio_posix_stubs.c +++ b/lib_eio_posix/eio_posix_stubs.c @@ -2,7 +2,11 @@ #include #ifdef __linux__ +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 24 #include +#else +#include +#endif #endif #include #include @@ -40,7 +44,11 @@ CAMLprim value caml_eio_posix_getrandom(value v_ba, value v_off, value v_len) { void *buf = (uint8_t *)Caml_ba_data_val(v_ba) + off; caml_enter_blocking_section(); #ifdef __linux__ +#if __GLIBC__ > 2 || __GLIBC_MINOR__ > 24 ret = getrandom(buf, len, 0); +#else + ret = syscall(SYS_getrandom, buf, len, 0); +#endif #else arc4random_buf(buf, len); ret = len;