summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/C/vector-aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Internal/C/vector-aux.c')
-rw-r--r--packages/base/src/Internal/C/vector-aux.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c
index dcd6c0b..73455a5 100644
--- a/packages/base/src/Internal/C/vector-aux.c
+++ b/packages/base/src/Internal/C/vector-aux.c
@@ -932,20 +932,33 @@ int vectorScan(char * file, int* n, double**pp){
932 932
933//////////////////////////////////////////////////////////////////////////////// 933////////////////////////////////////////////////////////////////////////////////
934 934
935#if defined (__APPLE__) || (__FreeBSD__) 935#if defined (__APPLE__) || (__FreeBSD__) || defined(NO_RANDOM_R) || defined(_WIN32) || defined(WIN32)
936/* FreeBSD and Mac OS X do not provide random_r(), thread safety cannot be 936/* Windows use thread-safe random
937 guaranteed. 937 See: http://stackoverflow.com/questions/143108/is-windows-rand-s-thread-safe
938*/
939#if defined (__APPLE__) || (__FreeBSD__) || defined(NO_RANDOM_R)
940
941/* For FreeBSD, Mac OS X, and other libcs (like `musl`) that do not provide
942 random_r(), or if the use of random_r() is explicitly disabled, thread safety
943 cannot be guaranteed.
944 As per current understanding, this should at worst lead to less "random"
945 numbers being generated, in particular
946 * if another thread somebody calls lcong48() at the same time as nrand48()
947 is called
948 * in addition to that, for glibc with NO_RANDOM_R enabled when ndrand48()
949 is called for the first time by multiple threads in parallel due to the
950 initialisation function placed within it
951 See: http://www.evanjones.ca/random-thread-safe.html
952
938 For FreeBSD and Mac OS X, nrand48() is much better than random(). 953 For FreeBSD and Mac OS X, nrand48() is much better than random().
939 See: http://www.evanjones.ca/random-thread-safe.html 954 See: http://www.evanjones.ca/random-thread-safe.html
940*/
941#pragma message "randomVector is not thread-safe in OSX and FreeBSD"
942#endif
943 955
944#if defined (__APPLE__) || (__FreeBSD__) || defined(_WIN32) || defined(WIN32) 956 TODO: As mentioned in the linked article, this could be fixed:
945/* Windows use thread-safe random 957 "the best solution for truly portable applications is to include
946 See: http://stackoverflow.com/questions/143108/is-windows-rand-s-thread-safe 958 your own random number generator implementation,
959 and not rely on the system's C library".
947*/ 960*/
948#if defined (__APPLE__) || (__FreeBSD__) 961#pragma message "randomVector is not thread-safe in OSX and FreeBSD or with NO_RANDOM_R; this likely leads to less random numbers at worst; see http://www.evanjones.ca/random-thread-safe.html"
949 962
950inline double urandom() { 963inline double urandom() {
951 /* the probalility of matching will be theoretically p^3(in fact, it is not) 964 /* the probalility of matching will be theoretically p^3(in fact, it is not)