about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/sys/sysmacros.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/sys/sysmacros.h')
-rw-r--r--sysdeps/unix/sysv/linux/sys/sysmacros.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/sysdeps/unix/sysv/linux/sys/sysmacros.h b/sysdeps/unix/sysv/linux/sys/sysmacros.h
index 63c1343284..35760e5e06 100644
--- a/sysdeps/unix/sysv/linux/sys/sysmacros.h
+++ b/sysdeps/unix/sysv/linux/sys/sysmacros.h
@@ -30,10 +30,20 @@
 # define makedev(major, minor) ((((unsigned int) (major)) << 8) \
 				| ((unsigned int) (minor)))
 #else
-# define major(dev) (((dev).__val[0] >> 8) & 0xff)
-# define minor(dev) ((dev).__val[0] & 0xff)
-# define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
-				  | ((unsigned int) (minor))), 0 }
+/* We need to know the word order here.  This assumes that the word order
+   is consistent with the byte order.  */
+# include <endian.h>
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define major(dev) (((dev).__val[1] >> 8) & 0xff)
+#  define minor(dev) ((dev).__val[1] & 0xff)
+#  define makedev(major, minor) { 0, ((((unsigned int) (major)) << 8) \
+				      | ((unsigned int) (minor))) }
+# else
+#  define major(dev) (((dev).__val[0] >> 8) & 0xff)
+#  define minor(dev) ((dev).__val[0] & 0xff)
+#  define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
+				   | ((unsigned int) (minor))), 0 }
+# endif
 #endif
 
 #endif /* sys/sysmacros.h */