Problem: getrandom test does not check if it's working

Solution: check return value in autoconf and CMake. On some platforms
the function is available but not implemented (eg: GNU/Hurd).
This commit is contained in:
Luca Boccassi 2018-05-09 10:41:20 +01:00
parent 7aba6821ac
commit 4ff814f204
2 changed files with 4 additions and 2 deletions

View File

@ -883,7 +883,8 @@ AC_DEFUN([LIBZMQ_CHECK_GETRANDOM], [{
int main (int argc, char *argv []) int main (int argc, char *argv [])
{ {
char buf[4]; char buf[4];
getrandom(buf, 4, 0); int rc = getrandom(buf, 4, 0);
return rc == -1 ? 1 : 0;
} }
], ],
[libzmq_cv_getrandom="yes"], [libzmq_cv_getrandom="yes"],

View File

@ -287,7 +287,8 @@ macro(zmq_check_getrandom)
int main (int argc, char *argv []) int main (int argc, char *argv [])
{ {
char buf[4]; char buf[4];
getrandom(buf, 4, 0); int rc = getrandom(buf, 4, 0);
return rc == -1 ? 1 : 0;
} }
" "
ZMQ_HAVE_GETRANDOM) ZMQ_HAVE_GETRANDOM)