]> err.no Git - util-linux/commitdiff
tests: add "byte-order" to helpers/test_sysinfo
authorKarel Zak <kzak@redhat.com>
Tue, 20 Jan 2009 12:18:22 +0000 (13:18 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:32:58 +0000 (23:32 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/helpers/test_sysinfo.c

index 4b71955c721d3fc3506d7217c17fe106313e6789..8ce1fe72d777ea53690caf6d95287b7a25c1f8b8 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-
+#include <endian.h>
 #include <limits.h>
 
+#if !defined __BYTE_ORDER || !(__BYTE_ORDER == __LITTLE_ENDIAN) && !(__BYTE_ORDER == __BIG_ENDIAN)
+#error missing __BYTE_ORDER
+#endif
+
 typedef struct {
        const char      *name;
        int             (*fnc)(void);
@@ -33,6 +37,18 @@ hlp_wordsize(void)
        return 0;
 }
 
+int
+hlp_endianness(void)
+{
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+       printf("LE\n");
+#else
+       printf("BE\n");
+#endif
+       return 0;
+}
+
+
 int
 hlp_pagesize(void)
 {
@@ -88,6 +104,7 @@ mntHlpfnc hlps[] =
        { "LONG_MAX",   hlp_long_max    },
        { "ULONG_MAX",  hlp_ulong_max   },
        { "ULONG_MAX32",hlp_ulong_max32 },
+       { "byte-order", hlp_endianness  },
        { NULL, NULL }
 };