Ticket #322: endianness

File endianness, 1.3 KB (added by Pini, 13 years ago)
Line 
1Index: navit/navit/data.h
2===================================================================
3--- navit.orig/navit/data.h     2009-03-19 23:46:32.000000000 +0100
4+++ navit/navit/data.h  2009-03-19 23:46:55.000000000 +0100
5@@ -20,6 +20,8 @@
6 #ifndef NAVIT_DATA_H
7 #define NAVIT_DATA_H
8 
9+#include "config.h"
10+
11 static inline unsigned char
12 get_u8(unsigned char **p)
13 {
14@@ -31,7 +33,11 @@
15        unsigned short ret;
16        ret=*((unsigned short *)*p);
17        *p+=sizeof(unsigned short);
18+#ifdef WORDS_BIGENDIAN
19+       return __bswap_16(ret);
20+#else
21        return ret;
22+#endif
23 }
24 
25 static inline unsigned short
26@@ -57,7 +63,11 @@
27        unsigned long ret;
28        ret=*((unsigned int *)*p);
29        *p+=sizeof(unsigned int);
30+#ifdef WORDS_BIGENDIAN
31+       return __bswap_32(ret);
32+#else
33        return ret;
34+#endif
35 }
36 
37 static inline unsigned int
38Index: navit/configure.in
39===================================================================
40--- navit.orig/configure.in     2009-03-19 23:46:31.000000000 +0100
41+++ navit/configure.in  2009-03-19 23:46:55.000000000 +0100
42@@ -85,6 +85,10 @@
43 AC_SUBST(CC_FOR_BUILD)
44 AC_SUBST(CCLD_FOR_BUILD)
45 
46+# Endianness
47+# defines WORDS_BIGENDIAN for big-endian systems
48+AC_C_BIGENDIAN
49+
50 AC_ARG_ENABLE(variant, [  --enable-variant=something          set variant], NAVIT_VARIANT=$enableval)
51 AC_SUBST(NAVIT_VARIANT)
52