Skip to content
Snippets Groups Projects
Commit 9473b71a authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

When compiling on OSX, do not inline the RNG glibc functions but use their official POSIX versions.

parent 981f1f7f
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,10 @@ ...@@ -20,13 +20,10 @@
#ifndef SWIFT_RANDOM_H #ifndef SWIFT_RANDOM_H
#define SWIFT_RANDOM_H #define SWIFT_RANDOM_H
/* COde configuration */ /* Code configuration */
#include "../config.h" #include "../config.h"
/* Standard header */ /* Standard header */
#include <errno.h>
#include <ieee754.h>
#include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -55,6 +52,12 @@ enum random_number_type { ...@@ -55,6 +52,12 @@ enum random_number_type {
random_number_BH_swallow = 4947009007LL random_number_BH_swallow = 4947009007LL
}; };
#ifndef __APPLE__
#include <errno.h>
#include <ieee754.h>
#include <limits.h>
/* Inline the default RNG functions to avoid costly function calls. These /* Inline the default RNG functions to avoid costly function calls. These
functions are minor modifications, but functional equivalents, of their glibc functions are minor modifications, but functional equivalents, of their glibc
counterparts. */ counterparts. */
...@@ -110,6 +113,17 @@ INLINE static double inl_erand48(uint16_t xsubi[3]) { ...@@ -110,6 +113,17 @@ INLINE static double inl_erand48(uint16_t xsubi[3]) {
return temp.d - 1.0; return temp.d - 1.0;
} }
#else
/* In the case of OSX, we default to the platform's
default implementation. */
INLINE static int inl_rand_r(uint32_t *seed) { return rand_r(seed); }
INLINE static double inl_erand48(uint16_t xsubi[3]) { return erand48(xsubi); }
#endif
/** /**
* @brief Returns a pseudo-random number in the range [0, 1[. * @brief Returns a pseudo-random number in the range [0, 1[.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment