|
From: <il...@us...> - 2003-11-27 01:21:20
|
Update of /cvsroot/meshdb/src/geo/compat
In directory sc8-pr-cvs1:/tmp/cvs-serv15949/geo/compat
Modified Files:
compat.h
Log Message:
Ensure the byte-swapping functions are properly defined across all platforms we're using (and likely to use).
Index: compat.h
===================================================================
RCS file: /cvsroot/meshdb/src/geo/compat/compat.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- compat.h 24 Nov 2003 07:23:58 -0000 1.5
+++ compat.h 27 Nov 2003 01:21:16 -0000 1.6
@@ -25,6 +25,10 @@
#include <unistd.h>
+#endif /* Sun */
+
+#if !defined(__OpenBSD__)
+
static inline u_int16_t
swap16(u_int16_t i)
{
@@ -55,13 +59,22 @@
return o;
}
-#define letoh16(x) swap16(x)
-#define letoh32(x) swap32(x)
-#define letoh64(x) swap64(x)
-#define betoh16(x) (x)
-#define betoh32(x) (x)
-#define betoh64(x) (x)
-
+#if defined(__powerpc__) || defined(__ppc__) || defined(__sparc__) || defined(__mips__) || defined(__mc68000__) || defined(__alpha__)
+# define letoh16(x) swap16(x)
+# define letoh32(x) swap32(x)
+# define letoh64(x) swap64(x)
+# define betoh16(x) (x)
+# define betoh32(x) (x)
+# define betoh64(x) (x)
+#else
+# define letoh16(x) (x)
+# define letoh32(x) (x)
+# define letoh64(x) (x)
+# define betoh16(x) swap16(x)
+# define betoh32(x) swap32(x)
+# define betoh64(x) swap64(x)
#endif
+
+#endif /* !OpenBSD */
#endif /* _h_compat_ */
|