configure.in added test for endianness
authorManish Singh <yosh@src.gnome.org>
Tue, 20 Oct 1998 10:43:39 +0000 (10:43 +0000)
committerManish Singh <yosh@src.gnome.org>
Tue, 20 Oct 1998 10:43:39 +0000 (10:43 +0000)
* configure.in
* acconfig.h: added test for endianness

* glib.h: #define endian macros for system and some conversions
between byte order

-Yosh

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
glib.h
glib/glib.h
glibconfig.h.in

index 505ad56..9bde88d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index 505ad56..9bde88d 100644 (file)
@@ -1,3 +1,11 @@
+Tue Oct 20 03:32:58 PDT 1998 Manish Singh <yosh@gimp.org>
+
+       * configure.in
+       * acconfig.h: added test for endianness
+
+       * glib.h: #define endian macros for system and some conversions
+       between byte order
+
 Thu Oct  8 06:47:27 1998  Tim Janik  <timj@gtk.org>
 
        * glib.h:
index bd97807..4ee4d47 100644 (file)
@@ -213,6 +213,8 @@ case x$glib_cv_hasinline in
 xyes) AC_DEFINE(G_HAVE_INLINE)
 esac
 
+dnl for bytesex stuff
+AC_C_BIGENDIAN
 
 dnl header file checks
 AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
diff --git a/glib.h b/glib.h
index fda3fed..3f668f7 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -455,6 +455,54 @@ extern "C" {
 #endif /* !G_DISABLE_CHECKS */
 
 
+/* Portable endian checks and conversions
+ */
+
+#define G_LITTLE_ENDIAN 1234
+#define G_BIG_ENDIAN    4321
+#define G_PDP_ENDIAN    3412   /       /* unused, need specific PDP check */   
+
+#ifdef WORDS_BIGENDIAN
+#define G_BYTE_ORDER G_BIG_ENDIAN
+#else
+#define G_BYTE_ORDER G_LITTLE_ENDIAN
+#endif
+
+#define GULONG_SWAP_LE_BE(long_val)     (((gulong) \
+    (((gulong) (long_val)) & 0x000000ffU) << 24) | \
+    (((gulong) (long_val)) & 0x0000ff00U) <<  8) | \
+    (((gulong) (long_val)) & 0x00ff0000U) >>  8) | \
+    (((gulong) (long_val)) & 0xff000000U) >> 24)))
+#define GULONG_SWAP_LE_PDP(long_val)    (((gulong) \
+    (((gulong) (long_val)) & 0x0000ffffU) << 16) | \
+    (((gulong) (long_val)) & 0xffff0000U) >> 16)))
+#define GULONG_SWAP_BE_PDP(long_val)    (((gulong) \
+    (((gulong) (long_val)) & 0x000000ffU) << 8) | \
+    (((gulong) (long_val)) & 0x0000ff00U) >> 8) | \
+    (((gulong) (long_val)) & 0x00ff0000U) << 8) | \
+    (((gulong) (long_val)) & 0xff000000U) >> 8)))
+
+#if     G_BYTE_ORDER == G_LITTLE_ENDIAN
+#  define GLONG_TO_LE(long_val)         ((glong) (long_val))
+#  define GULONG_TO_LE(long_val)        ((gulong) (long_val))
+#  define GLONG_TO_BE(long_val)         ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_TO_BE(long_val)        (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_FROM_LE(long_val)       ((glong) (long_val))
+#  define GULONG_FROM_LE(long_val)      ((gulong) (long_val))
+#  define GLONG_FROM_BE(long_val)       ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_FROM_BE(long_val)      (GULONG_SWAP_LE_BE (long_val))
+#elif   G_BYTE_ORDER == G_BIG_ENDIAN
+#  define GLONG_TO_LE(long_val)         ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_TO_LE(long_val)        (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_TO_BE(long_val)         ((glong) (long_val))
+#  define GULONG_TO_BE(long_val)        ((gulong) (long_val))
+#  define GLONG_FROM_LE(long_val)       ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_FROM_LE(long_val)      (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_FROM_BE(long_val)       ((glong) (long_val))
+#  define GULONG_FROM_BE(long_val)      ((gulong) (long_val))
+#endif
+
+
 /* Provide type definitions for commonly used types.
  *  These are useful because a "gint8" can be adjusted
  *  to be 1 byte (8 bits) on all platforms. Similarly and
index fda3fed..3f668f7 100644 (file)
@@ -455,6 +455,54 @@ extern "C" {
 #endif /* !G_DISABLE_CHECKS */
 
 
+/* Portable endian checks and conversions
+ */
+
+#define G_LITTLE_ENDIAN 1234
+#define G_BIG_ENDIAN    4321
+#define G_PDP_ENDIAN    3412   /       /* unused, need specific PDP check */   
+
+#ifdef WORDS_BIGENDIAN
+#define G_BYTE_ORDER G_BIG_ENDIAN
+#else
+#define G_BYTE_ORDER G_LITTLE_ENDIAN
+#endif
+
+#define GULONG_SWAP_LE_BE(long_val)     (((gulong) \
+    (((gulong) (long_val)) & 0x000000ffU) << 24) | \
+    (((gulong) (long_val)) & 0x0000ff00U) <<  8) | \
+    (((gulong) (long_val)) & 0x00ff0000U) >>  8) | \
+    (((gulong) (long_val)) & 0xff000000U) >> 24)))
+#define GULONG_SWAP_LE_PDP(long_val)    (((gulong) \
+    (((gulong) (long_val)) & 0x0000ffffU) << 16) | \
+    (((gulong) (long_val)) & 0xffff0000U) >> 16)))
+#define GULONG_SWAP_BE_PDP(long_val)    (((gulong) \
+    (((gulong) (long_val)) & 0x000000ffU) << 8) | \
+    (((gulong) (long_val)) & 0x0000ff00U) >> 8) | \
+    (((gulong) (long_val)) & 0x00ff0000U) << 8) | \
+    (((gulong) (long_val)) & 0xff000000U) >> 8)))
+
+#if     G_BYTE_ORDER == G_LITTLE_ENDIAN
+#  define GLONG_TO_LE(long_val)         ((glong) (long_val))
+#  define GULONG_TO_LE(long_val)        ((gulong) (long_val))
+#  define GLONG_TO_BE(long_val)         ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_TO_BE(long_val)        (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_FROM_LE(long_val)       ((glong) (long_val))
+#  define GULONG_FROM_LE(long_val)      ((gulong) (long_val))
+#  define GLONG_FROM_BE(long_val)       ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_FROM_BE(long_val)      (GULONG_SWAP_LE_BE (long_val))
+#elif   G_BYTE_ORDER == G_BIG_ENDIAN
+#  define GLONG_TO_LE(long_val)         ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_TO_LE(long_val)        (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_TO_BE(long_val)         ((glong) (long_val))
+#  define GULONG_TO_BE(long_val)        ((gulong) (long_val))
+#  define GLONG_FROM_LE(long_val)       ((glong) GULONG_SWAP_LE_BE (long_val))
+#  define GULONG_FROM_LE(long_val)      (GULONG_SWAP_LE_BE (long_val))
+#  define GLONG_FROM_BE(long_val)       ((glong) (long_val))
+#  define GULONG_FROM_BE(long_val)      ((gulong) (long_val))
+#endif
+
+
 /* Provide type definitions for commonly used types.
  *  These are useful because a "gint8" can be adjusted
  *  to be 1 byte (8 bits) on all platforms. Similarly and
index aef9bd0..4d0715f 100644 (file)
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+#undef WORDS_BIGENDIAN
+
 #undef ENABLE_MEM_CHECK
 #undef ENABLE_MEM_PROFILE