Skip to content

Commit 11ca680

Browse files
committed
Remove rand_r from cpfloat_binary32|64.h
1 parent 56bc797 commit 11ca680

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/cpfloat_binary32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static inline int cpf_fmaf(float *X, const float *A, const float *B,
312312
#define MAXRAND 0x7FFFFFFFU
313313
#ifdef _OPENMP
314314
#define INITRAND(seed) *seed = time(NULL);
315-
#define GEN_SINGLE_RAND(seed) ((INTTYPE)rand_r((unsigned int *)seed))
315+
#define GEN_SINGLE_RAND(seed) ((INTTYPE)thread_safe_rand((unsigned int *)seed))
316316
#else /*# ifdef _OPENMP */
317317
#define INITRAND(seed) srand(time(NULL));
318318
#define GEN_SINGLE_RAND(seed) ((INTTYPE)rand())

src/cpfloat_binary64.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ static inline int cpf_fma(double *X, const double *A, const double *B,
312312
#ifdef _OPENMP
313313
#define INITRAND(seed) *seed = time(NULL);
314314
#define GEN_SINGLE_RAND(seed) \
315-
((INTTYPE)rand_r((unsigned int *)seed) + \
316-
((INTTYPE)rand_r((unsigned int *)seed) << 31))
315+
((INTTYPE)thread_safe_rand((unsigned int *)seed) + \
316+
((INTTYPE)thread_safe_rand((unsigned int *)seed) << 31))
317317
#else /*# ifdef _OPENMP */
318318
#define INITRAND(seed) srand(time(NULL));
319-
#define GEN_SINGLE_RAND(seed) ((INTTYPE)rand() + ((INTTYPE)rand() << 31))
319+
#define GEN_SINGLE_RAND(seed) ((INTTYPE)thread_safe_rand((unsigned int *)seed) + \
320+
((INTTYPE)thread_safe_rand((unsigned int *)seed ) << 31))
320321
#endif /*# ifdef _OPENMP */
321322
#endif /* #ifdef PCG_VARIANTS_H_INCLUDED */
322323

0 commit comments

Comments
 (0)