meson: Test for random_r()

It's better to test for needed functions instead of using external
knowledge about presence in this or that C library.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
This commit is contained in:
Matt Turner 2019-07-24 18:44:35 -07:00
parent 9cc4311d86
commit c96407f37e
2 changed files with 2 additions and 2 deletions

View file

@ -1029,7 +1029,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h'
endif
endforeach
foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create', 'random_r']
if cc.has_function(f)
pre_args += '-DHAVE_@0@'.format(f.to_upper())
endif

View file

@ -88,7 +88,7 @@
#define HASH_ALLOC malloc
#define HASH_FREE free
#ifndef __GLIBC__
#ifndef HAVE_RANDOM_R
#define HASH_RANDOM_DECL char *ps, rs[256]
#define HASH_RANDOM_INIT(seed) ps = initstate(seed, rs, sizeof(rs))
#define HASH_RANDOM random()