Block system asyncs while 'overrides_lock' is held.
[bpt/guile.git] / libguile / tags.h
index d11bf68..c41543f 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef SCM_TAGS_H
 #define SCM_TAGS_H
 
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2008,2009,2010
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2008,2009,2010,2012
  * Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -74,10 +74,9 @@ typedef scm_t_uintptr scm_t_bits;
  * desired level of type checking, be defined in several ways:
  */
 #if (SCM_DEBUG_TYPING_STRICTNESS == 2)
-    typedef union { struct { scm_t_bits n; } n; } SCM;
-    static SCM scm_pack(scm_t_bits b) { SCM s; s.n.n = b; return s; }
+typedef union SCM { struct { scm_t_bits n; } n; } SCM;
 #   define SCM_UNPACK(x) ((x).n.n)
-#   define SCM_PACK(x) (scm_pack ((scm_t_bits) (x)))
+#   define SCM_PACK(x) ((SCM) { { (scm_t_bits) (x) } })
 #elif (SCM_DEBUG_TYPING_STRICTNESS == 1)
 /* This is the default, which provides an intermediate level of compile time
  * type checking while still resulting in very efficient code.
@@ -88,14 +87,15 @@ typedef scm_t_uintptr scm_t_bits;
   The 0?: constructions makes sure that the code is never executed,
   and that there is no performance hit.  However, the alternative is
   compiled, and does generate a warning when used with the wrong
-  pointer type.
+  pointer type.  We use a volatile pointer type to avoid warnings
+  from clang.
 
   The Tru64 and ia64-hp-hpux11.23 compilers fail on `case (0?0=0:x)'
   statements, so for them type-checking is disabled.  */
 #if defined __DECC || defined __HP_cc
 #   define SCM_UNPACK(x) ((scm_t_bits) (x))
 #else
-#   define SCM_UNPACK(x) ((scm_t_bits) (0? (*(SCM*)0=(x)): x))
+#   define SCM_UNPACK(x) ((scm_t_bits) (0? (*(volatile SCM *)0=(x)): x))
 #endif
 
 /*
@@ -258,8 +258,8 @@ typedef scm_t_uintptr scm_t_bits;
  *
  * If the cell holds a scheme pair, then we already know that the first
  * scm_t_bits variable of the cell will hold a scheme object with one of the
- * following tc3-codes: #b000 (non-immediate), #b010 (small integer), #b100
- * (small integer), #b110 (non-integer immediate).  All these tc3-codes have
+ * following tc3-codes: #b000 (non-immediate), #b010 (small integer), #b110
+ * (small integer), #b100 (non-integer immediate).  All these tc3-codes have
  * in common, that their least significant bit is #b0.  This fact is used by
  * the garbage collector to identify cells that hold pairs.  The remaining
  * tc3-codes are assigned as follows: #b001 (class instance or, more
@@ -411,7 +411,7 @@ typedef scm_t_uintptr scm_t_bits;
 #define scm_tc7_stringbuf       39
 #define scm_tc7_bytevector     77
 
-#define scm_tc7_foreign                31
+#define scm_tc7_pointer                31
 #define scm_tc7_hashtable      29
 #define scm_tc7_fluid          37
 #define scm_tc7_dynamic_state  45
@@ -425,8 +425,8 @@ typedef scm_t_uintptr scm_t_bits;
 #define scm_tc7_with_fluids    63
 #define scm_tc7_unused_19      69
 #define scm_tc7_program                79
-#define scm_tc7_unused_9       85
-#define scm_tc7_unused_10      87
+#define scm_tc7_array          85
+#define scm_tc7_bitvector      87
 #define scm_tc7_unused_20      93
 #define scm_tc7_unused_11      95
 #define scm_tc7_unused_12      101
@@ -465,7 +465,8 @@ enum scm_tc8_tags
 };
 
 #define SCM_ITAG8(X)           (SCM_UNPACK (X) & 0xff)
-#define SCM_MAKE_ITAG8(X, TAG) SCM_PACK (((X) << 8) + TAG)
+#define SCM_MAKE_ITAG8_BITS(X, TAG) (((X) << 8) + TAG)
+#define SCM_MAKE_ITAG8(X, TAG) (SCM_PACK (SCM_MAKE_ITAG8_BITS (X, TAG)))
 #define SCM_ITAG8_DATA(X)      (SCM_UNPACK (X) >> 8)
 
 \f
@@ -474,7 +475,7 @@ enum scm_tc8_tags
  * declarations in print.c: iflagnames.  */
 
 #define SCM_IFLAGP(n)    (SCM_ITAG8 (n) == scm_tc8_flag)
-#define SCM_MAKIFLAG(n)  SCM_MAKE_ITAG8 ((n), scm_tc8_flag)
+#define SCM_MAKIFLAG_BITS(n)  (SCM_MAKE_ITAG8_BITS ((n), scm_tc8_flag))
 #define SCM_IFLAGNUM(n)  (SCM_ITAG8_DATA (n))
 
 /*
@@ -508,25 +509,35 @@ enum scm_tc8_tags
  * defined below.  The properties are checked at compile-time using
  * `verify' macros near the top of boolean.c and pairs.c.
  */
-#define SCM_BOOL_F             SCM_MAKIFLAG (0)
-#define SCM_ELISP_NIL          SCM_MAKIFLAG (1)
+#define SCM_BOOL_F_BITS                SCM_MAKIFLAG_BITS (0)
+#define SCM_ELISP_NIL_BITS     SCM_MAKIFLAG_BITS (1)
+
+#define SCM_BOOL_F             SCM_PACK (SCM_BOOL_F_BITS)
+#define SCM_ELISP_NIL          SCM_PACK (SCM_ELISP_NIL_BITS)
 
 #ifdef BUILDING_LIBGUILE
-#define SCM_XXX_ANOTHER_LISP_FALSE_DONT_USE    SCM_MAKIFLAG (2)
+#define SCM_XXX_ANOTHER_LISP_FALSE_DONT_USE    SCM_MAKIFLAG_BITS (2)
 #endif
 
-#define SCM_EOL                        SCM_MAKIFLAG (3)
-#define SCM_BOOL_T             SCM_MAKIFLAG (4)
+#define SCM_EOL_BITS           SCM_MAKIFLAG_BITS (3)
+#define SCM_BOOL_T_BITS        SCM_MAKIFLAG_BITS (4)
+
+#define SCM_EOL                        SCM_PACK (SCM_EOL_BITS)
+#define SCM_BOOL_T             SCM_PACK (SCM_BOOL_T_BITS)
 
 #ifdef BUILDING_LIBGUILE
-#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0     SCM_MAKIFLAG (5)
-#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_1     SCM_MAKIFLAG (6)
-#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_2     SCM_MAKIFLAG (7)
+#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_0     SCM_MAKIFLAG_BITS (5)
+#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_1     SCM_MAKIFLAG_BITS (6)
+#define SCM_XXX_ANOTHER_BOOLEAN_DONT_USE_2     SCM_MAKIFLAG_BITS (7)
 #endif
 
-#define SCM_UNSPECIFIED                SCM_MAKIFLAG (8)
-#define SCM_UNDEFINED          SCM_MAKIFLAG (9)
-#define SCM_EOF_VAL            SCM_MAKIFLAG (10)
+#define SCM_UNSPECIFIED_BITS   SCM_MAKIFLAG_BITS (8)
+#define SCM_UNDEFINED_BITS     SCM_MAKIFLAG_BITS (9)
+#define SCM_EOF_VAL_BITS       SCM_MAKIFLAG_BITS (10)
+
+#define SCM_UNSPECIFIED                SCM_PACK (SCM_UNSPECIFIED_BITS)
+#define SCM_UNDEFINED          SCM_PACK (SCM_UNDEFINED_BITS)
+#define SCM_EOF_VAL            SCM_PACK (SCM_EOF_VAL_BITS)
 
 /* When a variable is unbound this is marked by the SCM_UNDEFINED
  * value.  The following is an unbound value which can be handled on
@@ -536,7 +547,8 @@ enum scm_tc8_tags
  * the code which handles this value in C so that SCM_UNDEFINED can be
  * used instead.  It is not ideal to let this kind of unique and
  * strange values loose on the Scheme level.  */
-#define SCM_UNBOUND            SCM_MAKIFLAG (11)
+#define SCM_UNBOUND_BITS       SCM_MAKIFLAG_BITS (11)
+#define SCM_UNBOUND            SCM_PACK (SCM_UNBOUND_BITS)
 
 #define SCM_UNBNDP(x)          (scm_is_eq ((x), SCM_UNDEFINED))
 
@@ -575,12 +587,12 @@ enum scm_tc8_tags
 #define SCM_HAS_EXACTLY_TWO_BITS_SET(x)                                        \
   (SCM_HAS_EXACTLY_ONE_BIT_SET (SCM_WITH_LEAST_SIGNIFICANT_1_BIT_CLEARED (x)))
 
-#define SCM_VALUES_DIFFER_IN_EXACTLY_ONE_BIT_POSITION(a,b)             \
-  (SCM_HAS_EXACTLY_ONE_BIT_SET (SCM_UNPACK(a) ^ SCM_UNPACK(b)))
-#define SCM_VALUES_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS(a,b,c,d)                \
-  (SCM_HAS_EXACTLY_TWO_BITS_SET ((SCM_UNPACK(a) ^ SCM_UNPACK(b)) |     \
-                                 (SCM_UNPACK(b) ^ SCM_UNPACK(c)) |     \
-                                 (SCM_UNPACK(c) ^ SCM_UNPACK(d))))
+#define SCM_BITS_DIFFER_IN_EXACTLY_ONE_BIT_POSITION(a,b)               \
+  (SCM_HAS_EXACTLY_ONE_BIT_SET ((a) ^ (b)))
+#define SCM_BITS_DIFFER_IN_EXACTLY_TWO_BIT_POSITIONS(a,b,c,d)          \
+  (SCM_HAS_EXACTLY_TWO_BITS_SET (((a) ^ (b)) |                          \
+                                 ((b) ^ (c)) |                          \
+                                 ((c) ^ (d))))
 #endif /* BUILDING_LIBGUILE */
 \f