Skip to content

Commit b8ded44

Browse files
committed
fix: wasm32 size_t is 32-bit so we need to fix the definition of RNG_MAX
1 parent 69a9026 commit b8ded44

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/_igraph/random.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ typedef struct {
4444
} igraph_i_rng_Python_state_t;
4545

4646
#define RNG_BITS 32
47-
#define RNG_MAX ((((size_t) 1) << RNG_BITS) - 1)
47+
#ifdef __wasm32__
48+
/* size_t is 32-bit on wasm32 so we cannot use the shift trick */
49+
#define RNG_MAX 0xFFFFFFFF
50+
#else
51+
#define RNG_MAX ((((size_t) 1) << RNG_BITS) - 1)
52+
#endif
4853

4954
static igraph_i_rng_Python_state_t igraph_rng_Python_state = {0};
5055
static igraph_rng_t igraph_rng_Python = {

0 commit comments

Comments
 (0)