From: Arnd Bergmann Subject: Fix libnuma on big-endian 64-bit systems References: bnc #455977 The read-mask function assumes that it is running in 32-bit mode, by addressing the bitmask as a series of int values, instead of longs. This is broken as can easily be reproduced by running numademo on a bit-endian 64-bit system. Changing the addressing to use 'long' values fixes the problem. Reported-by: Mijo Safradin Signed-off-by: Arnd Bergmann Acked-by: Bernhard Walle --- libnuma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/libnuma.c +++ b/libnuma.c @@ -372,9 +372,9 @@ read_mask(char *s, struct bitmask *bmp) { char *end = s; char *prevend; - unsigned int *start = (unsigned int *)bmp->maskp; - unsigned int *p = start; - unsigned int *q; + unsigned long *start = bmp->maskp; + unsigned long *p = start; + unsigned long *q; unsigned int i; unsigned int n = 0; @@ -411,14 +411,14 @@ read_mask(char *s, struct bitmask *bmp) } /* Poor mans fls() */ - for(i = 31; i >= 0; i--) + for(i = sizeof(long) * 8 - 1; i >= 0; i--) if (test_bit(i, start + n)) break; /* * Return the last bit set */ - return ((sizeof(unsigned int)*8) * n) + i; + return ((sizeof(unsigned long)*8) * n) + i; } /*