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 @@ -81,6 +81,13 @@ else ()
8181 set (BSON_HAVE_GMTIME_R 1)
8282endif ()
8383
84+ CHECK_SYMBOL_EXISTS (arc4random_buf stdlib.h BSON_HAVE_ARC4RANDOM_BUF)
85+ if (NOT BSON_HAVE_ARC4RANDOM_BUF)
86+ set (BSON_HAVE_ARC4RANDOM_BUF 0)
87+ else ()
88+ set (BSON_HAVE_ARC4RANDOM_BUF 1)
89+ endif ()
90+
8491CHECK_FUNCTION_EXISTS (rand_r BSON_HAVE_RAND_R)
8592if (NOT BSON_HAVE_RAND_R)
8693 set (BSON_HAVE_RAND_R 0)
Original file line number Diff line number Diff line change 113113# undef BSON_HAVE_SYSCALL_TID
114114#endif
115115
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+ */
116129#define BSON_HAVE_RAND_R @BSON_HAVE_RAND_R@
117130#if BSON_HAVE_RAND_R != 1
118131# undef BSON_HAVE_RAND_R
119132#endif
120133
134+
135+ /*
136+ * Define to 1 if you have strlcpy available on your platform.
137+ */
121138#define BSON_HAVE_STRLCPY @BSON_HAVE_STRLCPY@
122139#if BSON_HAVE_STRLCPY != 1
123140# undef BSON_HAVE_STRLCPY
Original file line number Diff line number Diff line change @@ -225,15 +225,14 @@ static int32_t
225225_get_rand (unsigned int * pseed )
226226{
227227 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
229233 /* ms's runtime is multithreaded by default, so no rand_r */
230234 /* no rand_r on android either */
231235 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 );
237236#endif
238237 return result ;
239238}
You can’t perform that action at this time.
0 commit comments