Correct mips arch in udpkg.
> Added missing alignment for array in endianess test.
What about this patch instead? Less code, and checking the endianness
at compile time.
Index: udpkg.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/udpkg/udpkg.c,v
retrieving revision 1.43
diff -u -3 -p -u -r1.43 udpkg.c
--- udpkg.c 1 Nov 2003 21:57:22 -0000 1.43
+++ udpkg.c 2 Nov 2003 23:37:11 -0000
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <utime.h>
#include <getopt.h>
+#include <endian.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>
@@ -17,23 +18,6 @@
static int force_configure = 0;
-/*
- * helper routine to correctly detect mips and mipsel
- */
-
-int is_little_endian()
-{
- unsigned char numarray[] __attribute__ ((aligned (8))) ={0x12,0x34,0x56,0x78};
- unsigned long value = *(unsigned long*) numarray;
- if (value == 0x78563412)
- {
- return(-1);
- } else {
- return(0);
- }
-}
-
-
/*
* Main udpkg implementation routines
*/
@@ -78,7 +62,7 @@ int dpkg_print_architecture()
/* uname gives "mips" for both mips and mipsel, so we need to */
/* distinguish between both by checking the actual endianess */
- if ((strcmp(name.machine, "mips") == 0) && is_little_endian())
+ if ((__BYTE_ORDER == __LITTLE_ENDIAN) && (strcmp(name.machine, "mips") == 0))
{
printf("mipsel\n");
} else {
I placed the call to strcmp() last, to make it easier for the compiler
to optimize away the call on big endian machines.
Reply to: