diff --git a/opal/mca/event/libevent2022/configure.m4 b/opal/mca/event/libevent2022/configure.m4 index 5ace9dc57d..66a5e778f1 100644 --- a/opal/mca/event/libevent2022/configure.m4 +++ b/opal/mca/event/libevent2022/configure.m4 @@ -159,8 +159,13 @@ AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[ AC_MSG_RESULT([$event_args]) + # We define "random" to be "opal_random" so that Libevent will not + # use random(3) internally (and potentially unexpectedly perturb + # values returned by rand(3) to the application). + + CPPFLAGS="$CPPFLAGS -Drandom=opal_random" OPAL_CONFIG_SUBDIR([$libevent_basedir/libevent], - [$event_args $opal_subdir_args], + [$event_args $opal_subdir_args 'CPPFLAGS=$CPPFLAGS'], [libevent_happy="yes"], [libevent_happy="no"]) if test "$libevent_happy" = "no"; then AC_MSG_WARN([Event library failed to configure]) diff --git a/opal/util/alfg.c b/opal/util/alfg.c index fc13f901f9..ccae7b5147 100644 --- a/opal/util/alfg.c +++ b/opal/util/alfg.c @@ -10,6 +10,8 @@ #include "opal_config.h" +#include + #include "alfg.h" /* Mask corresponding to the primitive polynomial @@ -52,6 +54,9 @@ static uint32_t galois(unsigned int *seed){ return lsb; } +/* OPAL global rng buffer */ +static opal_rng_buff_t alfg_buffer; + /** * @brief Routine to seed the ALFG register * @@ -80,6 +85,8 @@ int opal_srand(opal_rng_buff_t *buff, uint32_t seed) { buff->alfg[j] = buff->alfg[j] ^ ((galois(&seed_cpy))<