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 <[EMAIL PROTECTED]>

---

Note: the set_nodemask_size() function is broken as well, it seems
to always set the nodemask size to "17" with the s2nbits implementation.
The fallback path in there looks correct.

--- a/libnuma.c 2008-12-04 14:25:30.000000000 +0100
+++ b/libnuma.c 2008-11-20 13:40:29.000000000 +0100
@@ -392,9 +372,9 @@ read_mask(char *s, struct bitmask *bmp)
 {
        char *end = s;
        char *prevend;
-       unsigned long *start = bmp->maskp;
-       unsigned long *p = start;
-       unsigned long *q;
+       unsigned int *start = (unsigned int *)bmp->maskp;
+       unsigned int *p = start;
+       unsigned int *q;
        unsigned int i;
        unsigned int n = 0;
 
@@ -431,14 +411,14 @@
        }
 
        /* Poor mans fls() */
-       for(i = sizeof(long) * 8 - 1; i >= 0; i--)
+       for(i = 31; i >= 0; i--)
                if (test_bit(i, start + n))
                        break;
 
        /*
         * Return the last bit set
         */
-       return ((sizeof(unsigned long)*8) * n) + i;
+       return ((sizeof(unsigned int)*8) * n) + i;
 }
 
 /*
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Reply via email to