Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit ffb8ac9

Browse files
committed
opal/alfg: have opal_random() wrapper always return a positive int
(cherry picked from commit open-mpi/ompi@13009aa)
1 parent 4860038 commit ffb8ac9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

opal/util/alfg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* Copyright (c) 2014 Mellanox Technologies, Inc.
33
* All rights reserved.
4+
* Copyright (c) 2016 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -128,5 +130,6 @@ uint32_t opal_rand(opal_rng_buff_t *buff){
128130
* @param[out] int, the same as normal rand(3)
129131
*/
130132
int opal_random(void){
131-
return (int)opal_rand(&alfg_buffer);
133+
/* always return a positive int */
134+
return (int)(opal_rand(&alfg_buffer) & 0x7FFFFFFF);
132135
}

0 commit comments

Comments
 (0)