---
 libnuma.c |   42 ++++++++++++++++++++++++++++++++++++++----
 numaint.h |    1 +
 2 files changed, 39 insertions(+), 4 deletions(-)

Index: numactl-dev/libnuma.c
===================================================================
--- numactl-dev.orig/libnuma.c
+++ numactl-dev/libnuma.c
@@ -69,12 +69,37 @@ static int maxprocnode = -1;
 static int maxproccpu = -1;
 static int nodemask_sz = 0;
 static int cpumask_sz = 0;
+static int is_bigendian_64;
 
 int numa_exit_on_error = 0;
 int numa_exit_on_warn = 0;
 static void set_sizes(void);
 
 /*
+ * return 1 if this machine is big-endian 64-bit
+ */
+int
+big_endian64()
+{
+	union {
+		struct {
+			int a;
+			int b;
+		} ints;
+		struct {
+			long a;
+		} lng;
+	} ua;
+	if (sizeof(long) != 8)
+		return 0;
+	ua.ints.a = 0;
+	ua.ints.b = 3;
+	if (ua.lng.a == 3)
+		return 1;
+	return 0;
+}
+
+/*
  * There are two special functions, _init(void) and _fini(void), which
  * are called automatically by the dynamic loader whenever a library is loaded.
  *
@@ -91,6 +116,7 @@ numa_init(void)
         for (i = 0; i < max; i++)
                 nodemask_set_compat((nodemask_t *)&numa_all_nodes, i);
 	memset(&numa_no_nodes, 0, sizeof(numa_no_nodes));
+	is_bigendian_64 = big_endian64();
 }
 
 /*
@@ -103,10 +129,18 @@ numa_init(void)
 static unsigned int
 _getbit(const struct bitmask *bmp, unsigned int n)
 {
-	if (n < bmp->size)
-		return (bmp->maskp[n/bitsperlong] >> (n % bitsperlong)) & 1;
-	else
-		return 0;
+	unsigned int *ip;
+
+        if (n < bmp->size) {
+		if (is_bigendian_64) {
+			ip = (unsigned int *)bmp->maskp;
+                	return (ip[n/bitsperint] >>
+				(n % bitsperint)) & 1;
+		} else
+                	return (bmp->maskp[n/bitsperlong] >>
+				(n % bitsperlong)) & 1;
+        } else
+                return 0;
 }
 
 static void
Index: numactl-dev/numaint.h
===================================================================
--- numactl-dev.orig/numaint.h
+++ numactl-dev/numaint.h
@@ -33,5 +33,6 @@ enum numa_warn { 
 
 #define howmany(x,y) (((x)+((y)-1))/(y))
 #define bitsperlong (8 * sizeof(unsigned long))
+#define bitsperint (8 * sizeof(unsigned int))
 #define longsperbits(n) howmany(n, bitsperlong)
 #define bytesperbits(x) ((x+7)/8)
