Skip to content

Commit 3e60e78

Browse files
authored
Correct the range for modulo (#7)
Since N is power of 2 (1 << 12), so (i % N) will be (i & N - 1) instead of (i & N).
1 parent f3273e0 commit 3e60e78

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mpmc/mpmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void *mpmc_find_cell(node_t *volatile *ptr, long i, handle_t *th)
160160
__asm("sfence" ::: "cc", "memory"); /* FIXME: x86-only */
161161

162162
/* now we get the needed cell, its' node is curr and index is i % N */
163-
return &curr->cells[i & N];
163+
return &curr->cells[i & NBITS];
164164
}
165165

166166
#include <linux/futex.h>

0 commit comments

Comments
 (0)