/* -*-c-*-
*
- * $Id: bits.h,v 1.6 2000/07/16 12:28:28 mdw Exp $
+ * $Id: bits.h,v 1.9 2001/01/20 12:05:20 mdw Exp $
*
* Portable bit-level manipulation macros
*
/*----- Revision history --------------------------------------------------*
*
* $Log: bits.h,v $
+ * Revision 1.9 2001/01/20 12:05:20 mdw
+ * New hack for storing 64-bit numbers in tables.
+ *
+ * Revision 1.8 2000/10/08 11:06:30 mdw
+ * Shut later versions of GCC up about use of @long long@.
+ *
+ * Revision 1.7 2000/07/22 09:48:26 mdw
+ * Added macros for reading 64-bit values.
+ *
* Revision 1.6 2000/07/16 12:28:28 mdw
* Add 64-bit support, with faked arithmetic on 32-bit hosts.
*
/*----- Decide on some types ----------------------------------------------*/
+/* --- Make GNU C shut up --- */
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 91)
+# define MLIB_BITS_EXTENSION __extension__
+#else
+# define MLIB_BITS_EXTENSION
+#endif
+
/* --- Decide on a 32-bit type --- *
*
* I want a type which is capable of expressing 32-bit numbers. Because some
#endif
#if UINT_MAX >> 31 > 0xffffffff
-# define HAVE_UINT64
- typedef unsigned int uint64;
+# define HAVE_UINT64
+ typedef unsigned int uint64;
#elif ULONG_MAX >> 31 > 0xffffffff
-# define HAVE_UINT64
- typedef unsigned long uint64;
+# define HAVE_UINT64
+ typedef unsigned long uint64;
#elif defined(ULLONG_MAX)
-# define HAVE_UINT64
- typedef unsigned long long uint64;
+# define HAVE_UINT64
+ MLIB_BITS_EXTENSION typedef unsigned long long uint64;
#endif
#ifdef DEBUG64
#define MASK32 0xffffffffu
#ifdef HAVE_UINT64
-# define MASK64 0xffffffffffffffffull
+# define MASK64 MLIB_BITS_EXTENSION 0xffffffffffffffffu
#endif
/* --- Type coercions --- */
# define ASSIGN64(d, x) ((d).i = U64((x)))
# define HI64(x) U32((x).i >> 32)
# define LO64(x) U32((x).i)
+# define GET64(t, x) ((t)(x).i)
#else
# define SET64(d, h, l) ((d).hi = U32(h), (d).lo = U32(l))
# define ASSIGN64(d, x) \
((d).hi = ((x & ~MASK32) >> 16) >> 16, (d).lo = U32(x))
# define HI64(x) U32((x).hi)
# define LO64(x) U32((x).lo)
+# define GET64(t, x) (((((t)HI64(x) << 16) << 16) & ~MASK32) | (t)LO64(x))
#endif
#ifdef HAVE_UINT64
# define ZERO64(x) ((x).lo == 0 && (x).hi == 0)
#endif
+/* --- Storing integers in tables --- */
+
+#ifdef HAVE_UINT64
+# define X64(x, y) { 0x##x##y }
+#else
+# define X64(x, y) { 0x##x, 0x##y }
+#endif
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus