diff --git a/src/random.h b/src/random.h index fb33bb2ef5fbe6ff8d395f111542fb9ca8312a09..832c95a884ae9ae624b3f7723f3b11bc6052f646 100644 --- a/src/random.h +++ b/src/random.h @@ -20,13 +20,10 @@ #ifndef SWIFT_RANDOM_H #define SWIFT_RANDOM_H -/* COde configuration */ +/* Code configuration */ #include "../config.h" /* Standard header */ -#include <errno.h> -#include <ieee754.h> -#include <limits.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -55,6 +52,12 @@ enum random_number_type { 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 functions are minor modifications, but functional equivalents, of their glibc counterparts. */ @@ -110,6 +113,17 @@ INLINE static double inl_erand48(uint16_t xsubi[3]) { 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[. *