Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
9473b71a
Commit
9473b71a
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/random.h
+18
-4
18 additions, 4 deletions
src/random.h
with
18 additions
and
4 deletions
src/random.h
+
18
−
4
View file @
9473b71a
...
@@ -20,13 +20,10 @@
...
@@ -20,13 +20,10 @@
#ifndef SWIFT_RANDOM_H
#ifndef SWIFT_RANDOM_H
#define SWIFT_RANDOM_H
#define SWIFT_RANDOM_H
/* C
O
de configuration */
/* C
o
de 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[.
*
*
...
...
This diff is collapsed.
Click to expand it.
Matthieu Schaller
@matthieu
mentioned in issue
#604 (closed)
·
6 years ago
mentioned in issue
#604 (closed)
mentioned in issue #604
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment