]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxInt32 etc (FIXME for 64bit)
authorRobert Roebling <robert@roebling.de>
Fri, 4 Jun 1999 10:25:46 +0000 (10:25 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 4 Jun 1999 10:25:46 +0000 (10:25 +0000)
  Added byte swapping for BIG vs LITTLE endian

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

configure.in
include/wx/defs.h

index 8bf8d9181e731ab7d1dbf812d62187995128aa35..2ebec37e9bf2d21a091e3a6d5f99d188815ff9e6 100644 (file)
@@ -1046,6 +1046,8 @@ AC_C_INLINE
 dnl check the sizes of integral types (give some reasonable default values for
 dnl cross-compiling)
 dnl   defines the size of certain types of variables in SIZEOF_<TYPE>
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
 AC_CHECK_SIZEOF(int *, 4)
 AC_CHECK_SIZEOF(int, 4)
 AC_CHECK_SIZEOF(long, 4)
index 9f4da9c1a38565930422e125dbb5f86ba83a02d6..6601a8d52d9adb17470527b84d4d21bf9242f795 100644 (file)
     typedef unsigned int bool;
 #endif // bool
 
-typedef unsigned char wxByte;
 typedef short int WXTYPE;
 
 // special care should be taken with this type under Windows where the real
@@ -347,8 +346,133 @@ WXDLLEXPORT_DATA(extern const bool) wxFalse;
 // Callback function type definition
 typedef void (*wxFunction) (wxObject&, wxEvent&);
 
+// ----------------------------------------------------------------------------
+// machine specific settings
+// ----------------------------------------------------------------------------
+
+// fixed length types
+
+typedef  char    signed  wxInt8;
+typedef  char  unsigned  wxUint8;
+
+#ifdef __WIN16__
+typedef  int     signed  wxInt16;
+typedef  int   unsigned  wxUint16;
+typedef  long    signed  wxInt32;
+typedef  long  unsigned  wxUint32;
+#endif
+
+#ifdef __WIN32__
+typedef  short   signed  wxInt16;
+typedef  short unsigned  wxUint16;
+typedef  int     signed  wxInt32;
+typedef  int   unsigned  wxUint32;
+#endif
+
+#ifdef __WXMAC__
+typedef  short   signed  wxInt16;
+typedef  short unsigned  wxUint16;
+typedef  int     signed  wxInt32;
+typedef  int   unsigned  wxUint32;
+#endif
+
+#ifdef __WXOS2__
+typedef  short   signed  wxInt16;
+typedef  short unsigned  wxUint16;
+typedef  int     signed  wxInt32;
+typedef  int   unsigned  wxUint32;
+#endif
+
+#if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXOS2__)
+  #if defined(SIZEOF_INT)
+    #if (SIZEOF_SHORT == 2)
+      typedef  short   signed  wxInt16;
+      typedef  short unsigned  wxUint16;
+    #else
+      #error "FIXME"
+    #endif
+    #if (SIZEOF_INT == 4)
+      typedef  int     signed  wxInt32;
+      typedef  int   unsigned  wxUint32;
+    #else
+      #error "FIXME"
+    #endif
+  #else
+    typedef  short   signed  wxInt16;
+    typedef  short unsigned  wxUint16;
+    typedef  int     signed  wxInt32;
+    typedef  int   unsigned  wxUint32;
+  #endif
+#endif
+
+typedef  wxUint8         wxByte;
+typedef  wxUint16        wxWord;
+
+// byte sex
+
+#define  wxBIG_ENDIAN     4321
+#define  wxLITTLE_ENDIAN  1234
+#define  wxPDP_ENDIAN     3412
+
+#ifdef WORDS_BIGENDIAN
+#define  wxBYTE_ORDER  wxBIG_ENDIAN
+#else
+#define  wxBYTE_ORDER  wxLITTLE_ENDIAN
+#endif
+
+// byte swapping
+
+#define wxUINT16_SWAP_ALWAYS(val) \
+   ((wxUint16) ( \
+    (((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \
+    (((wxUint16) (val) & (wxUint16) 0xff00U) >> 8)))
+    
+#define wxINT16_SWAP_ALWAYS(val) \
+   ((wxInt16) ( \
+    (((wxInt16) (val) & (wxInt16) 0x00ffU) << 8) | \
+    (((wxInt16) (val) & (wxInt16) 0xff00U) >> 8)))
+    
+#define wxUINT32_SWAP_ALWAYS(val) \
+   ((wxUint32) ( \
+    (((wxUint32) (val) & (wxUint32) 0x000000ffU) << 24) | \
+    (((wxUint32) (val) & (wxUint32) 0x0000ff00U) <<  8) | \
+    (((wxUint32) (val) & (wxUint32) 0x00ff0000U) >>  8) | \
+    (((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24)))
+
+#define wxINT32_SWAP_ALWAYS(val) \
+   ((wxInt32) ( \
+    (((wxInt32) (val) & (wxInt32) 0x000000ffU) << 24) | \
+    (((wxInt32) (val) & (wxInt32) 0x0000ff00U) <<  8) | \
+    (((wxInt32) (val) & (wxInt32) 0x00ff0000U) >>  8) | \
+    (((wxInt32) (val) & (wxInt32) 0xff000000U) >> 24)))
+
+// machine specific byte swapping
+
+#ifdef WORDS_BIGENDIAN
+  #define wxUINT16_SWAP_FROM_LE(val)  wxUINT16_SWAP_ALWAYS(val)
+  #define wxINT16_SWAP_FROM_LE(val)   wxINT16_SWAP_ALWAYS(val)
+  #define wxUINT16_SWAP_FROM_BE(val)  (val)
+  #define wxINT16_SWAP_FROM_BE(val)   (val)
+  #define wxUINT32_SWAP_FROM_LE(val)  wxUINT32_SWAP_ALWAYS(val)
+  #define wxINT32_SWAP_FROM_LE(val)   wxINT32_SWAP_ALWAYS(val)
+  #define wxUINT32_SWAP_FROM_BE(val)  (val)
+  #define wxINT32_SWAP_FROM_BE(val)   (val)
+#else
+  #define wxUINT16_SWAP_FROM_BE(val)  wxUINT16_SWAP_ALWAYS(val)
+  #define wxINT16_SWAP_FROM_BE(val)   wxINT16_SWAP_ALWAYS(val)
+  #define wxUINT16_SWAP_FROM_LE(val)  (val)
+  #define wxINT16_SWAP_FROM_LE(val)   (val)
+  #define wxUINT32_SWAP_FROM_BE(val)  wxUINT32_SWAP_ALWAYS(val)
+  #define wxINT32_SWAP_FROM_BE(val)   wxINT32_SWAP_ALWAYS(val)
+  #define wxUINT32_SWAP_FROM_LE(val)  (val)
+  #define wxINT32_SWAP_FROM_LE(val)   (val)
+#endif
+
+// ----------------------------------------------------------------------------
+// Window style flags
+// ----------------------------------------------------------------------------
+
 /*
- * Window style flags.
  * Values are chosen so they can be |'ed in a bit list.
  * Some styles are used across more than one group,
  * so the values mustn't clash with others in the group.