File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ else ()
83
83
set (BSON_HAVE_GMTIME_R 1 )
84
84
endif ()
85
85
86
+ CHECK_SYMBOL_EXISTS (arc4random_buf stdlib.h BSON_HAVE_ARC4RANDOM_BUF )
87
+ if (NOT BSON_HAVE_ARC4RANDOM_BUF )
88
+ set (BSON_HAVE_ARC4RANDOM_BUF 0 )
89
+ else ()
90
+ set (BSON_HAVE_ARC4RANDOM_BUF 1 )
91
+ endif ()
92
+
86
93
CHECK_FUNCTION_EXISTS (rand_r BSON_HAVE_RAND_R )
87
94
if (NOT BSON_HAVE_RAND_R )
88
95
set (BSON_HAVE_RAND_R 0 )
Original file line number Diff line number Diff line change 113
113
# undef BSON_HAVE_SYSCALL_TID
114
114
#endif
115
115
116
+
117
+ /*
118
+ * Define to 1 if you have arc4random_buf available on your platform.
119
+ */
120
+ #define BSON_HAVE_ARC4RANDOM_BUF @BSON_HAVE_ARC4RANDOM_BUF@
121
+ #if BSON_HAVE_ARC4RANDOM_BUF != 1
122
+ # undef BSON_HAVE_ARC4RANDOM_BUF
123
+ #endif
124
+
125
+
126
+ /*
127
+ * Define to 1 if you have rand_r available on your platform.
128
+ */
116
129
#define BSON_HAVE_RAND_R @BSON_HAVE_RAND_R@
117
130
#if BSON_HAVE_RAND_R != 1
118
131
# undef BSON_HAVE_RAND_R
119
132
#endif
120
133
134
+
135
+ /*
136
+ * Define to 1 if you have strlcpy available on your platform.
137
+ */
121
138
#define BSON_HAVE_STRLCPY @BSON_HAVE_STRLCPY@
122
139
#if BSON_HAVE_STRLCPY != 1
123
140
# undef BSON_HAVE_STRLCPY
Original file line number Diff line number Diff line change @@ -225,15 +225,14 @@ static int32_t
225
225
_get_rand (unsigned int * pseed )
226
226
{
227
227
int32_t result = 0 ;
228
- #ifndef BSON_HAVE_RAND_R
228
+ #ifdef BSON_HAVE_ARC4RANDOM_BUF
229
+ arc4random_buf (& result , sizeof (result ));
230
+ #elif defined(BSON_HAVE_RAND_R )
231
+ result = rand_r (pseed );
232
+ #else
229
233
/* ms's runtime is multithreaded by default, so no rand_r */
230
234
/* no rand_r on android either */
231
235
result = rand ();
232
- #elif defined(__FreeBSD__ ) || defined(__NetBSD__ ) || defined(__DragonFly__ ) || \
233
- defined(__OpenBSD__ ) || defined(__APPLE__ )
234
- arc4random_buf (& result , sizeof (result ));
235
- #else
236
- result = rand_r (pseed );
237
236
#endif
238
237
return result ;
239
238
}
You can’t perform that action at this time.
0 commit comments