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
Branches
Tags
No related merge requests found
......@@ -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[.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment