From e9da224bce287653f96235bd6ae02da6f8f8b219 Mon Sep 17 00:00:00 2001 From: Niklas Hambüchen Date: Fri, 17 May 2019 02:50:03 +0200 Subject: Allow disabling random_r() usage manually. See #279. This allows building hmatrix against the musl libc, which allows easily linking Haskell programs statically. A feature-detection for random_r() would be even better, but this will do for now. --- packages/base/src/Internal/C/vector-aux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/base/src/Internal/C/vector-aux.c') diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c index dcd6c0b..08dc835 100644 --- a/packages/base/src/Internal/C/vector-aux.c +++ b/packages/base/src/Internal/C/vector-aux.c @@ -932,20 +932,20 @@ int vectorScan(char * file, int* n, double**pp){ //////////////////////////////////////////////////////////////////////////////// -#if defined (__APPLE__) || (__FreeBSD__) +#if defined (__APPLE__) || (__FreeBSD__) || defined(NO_RANDOM_R) /* FreeBSD and Mac OS X do not provide random_r(), thread safety cannot be guaranteed. For FreeBSD and Mac OS X, nrand48() is much better than random(). See: http://www.evanjones.ca/random-thread-safe.html */ -#pragma message "randomVector is not thread-safe in OSX and FreeBSD" +#pragma message "randomVector is not thread-safe in OSX and FreeBSD or with NO_RANDOM_R" #endif -#if defined (__APPLE__) || (__FreeBSD__) || defined(_WIN32) || defined(WIN32) +#if defined (__APPLE__) || (__FreeBSD__) || defined(NO_RANDOM_R) || defined(_WIN32) || defined(WIN32) /* Windows use thread-safe random See: http://stackoverflow.com/questions/143108/is-windows-rand-s-thread-safe */ -#if defined (__APPLE__) || (__FreeBSD__) +#if defined (__APPLE__) || (__FreeBSD__) || defined(NO_RANDOM_R) inline double urandom() { /* the probalility of matching will be theoretically p^3(in fact, it is not) -- cgit v1.2.3