#if USE_LSB_TAG
-static int const VALMASK = -1 << GCTYPEBITS;
-#define TYPEMASK ((1 << GCTYPEBITS) - 1)
+enum lsb_bits
+ {
+ TYPEMASK = (1 << GCTYPEBITS) - 1,
+ VALMASK = ~ TYPEMASK
+ };
#define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK))
#define XINT(a) (XLI (a) >> INTTYPEBITS)
#define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS)
#define ASET(ARRAY, IDX, VAL) \
(eassert ((IDX) == (IDX)), \
eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \
- AREF ((ARRAY), (IDX)) = (VAL))
+ XVECTOR (ARRAY)->contents[IDX] = (VAL))
/* Convenience macros for dealing with Lisp strings. */
#define CHECK_TYPE(ok, Qxxxp, x) \
do { if (!(ok)) wrong_type_argument (Qxxxp, (x)); } while (0)
+/* Lisp fields are usually hidden from most code and accessed
+ via special macros. Only select pieces of code, like the GC,
+ are allowed to use INTERNAL_FIELD directly. Objects which
+ aren't using this convention should be fixed. */
+
+#define INTERNAL_FIELD(field) field ## _
-\f
/* See the macros in intervals.h. */
typedef struct interval *INTERVAL;
#define CHECK_STRING_OR_BUFFER(x) \
CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x)
-\f
-/* In a cons, the markbit of the car is the gc mark bit */
+/* Most code should use this macro to
+ access Lisp fields in struct Lisp_Cons. */
+
+#define CVAR(cons, field) ((cons)->INTERNAL_FIELD (field))
struct Lisp_Cons
{
- /* Please do not use the names of these elements in code other
- than the core lisp implementation. Use XCAR and XCDR below. */
- Lisp_Object car;
+ /* Car of this cons cell. */
+ Lisp_Object INTERNAL_FIELD (car);
+
union
{
- Lisp_Object cdr;
+ /* Cdr of this cons cell. */
+ Lisp_Object INTERNAL_FIELD (cdr);
+
+ /* Used to chain conses on a free list. */
struct Lisp_Cons *chain;
} u;
};
fields are not accessible as lvalues. (What if we want to switch to
a copying collector someday? Cached cons cell field addresses may be
invalidated at arbitrary points.) */
-#define XCAR_AS_LVALUE(c) (XCONS ((c))->car)
-#define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr)
+#define XCAR_AS_LVALUE(c) (CVAR (XCONS (c), car))
+#define XCDR_AS_LVALUE(c) (CVAR (XCONS (c), u.cdr))
/* Use these from normal code. */
#define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c))
would expose alloc.c internal details that we'd rather keep
private.
- This is a macros for use in static initializers, and a constant for
+ This is a macro for use in static initializers, and a constant for
visibility to GDB. The cast to ptrdiff_t ensures that
- STRING_BYTES_BOUND is signed. */
+ the macro is signed. */
static ptrdiff_t const STRING_BYTES_BOUND =
#define STRING_BYTES_BOUND \
- min (MOST_POSITIVE_FIXNUM, (ptrdiff_t) min (SIZE_MAX, PTRDIFF_MAX) - 1)
+ ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1))
STRING_BYTES_BOUND;
/* Mark STR as a unibyte string. */
SYMBOL_FORWARDED = 3
};
+/* Most code should use this macro to access
+ Lisp fields in struct Lisp_Symbol. */
+
+#define SVAR(sym, field) ((sym)->INTERNAL_FIELD (field))
+
struct Lisp_Symbol
{
unsigned gcmarkbit : 1;
/* The symbol's name, as a Lisp string.
The name "xname" is used to intentionally break code referring to
the old field "name" of type pointer to struct Lisp_String. */
- Lisp_Object xname;
+ Lisp_Object INTERNAL_FIELD (xname);
/* Value of the symbol or Qunbound if unbound. Which alternative of the
union is used depends on the `redirect' field above. */
union {
- Lisp_Object value;
+ Lisp_Object INTERNAL_FIELD (value);
struct Lisp_Symbol *alias;
struct Lisp_Buffer_Local_Value *blv;
union Lisp_Fwd *fwd;
} val;
/* Function value of the symbol or Qunbound if not fboundp. */
- Lisp_Object function;
+ Lisp_Object INTERNAL_FIELD (function);
/* The symbol's property list. */
- Lisp_Object plist;
+ Lisp_Object INTERNAL_FIELD (plist);
/* Next symbol in obarray bucket, if the symbol is interned. */
struct Lisp_Symbol *next;
/* Value is name of symbol. */
#define SYMBOL_VAL(sym) \
- (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value)
+ (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (sym, val.value))
#define SYMBOL_ALIAS(sym) \
(eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias)
#define SYMBOL_BLV(sym) \
#define SYMBOL_FWD(sym) \
(eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd)
#define SET_SYMBOL_VAL(sym, v) \
- (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v))
+ (eassert ((sym)->redirect == SYMBOL_PLAINVAL), SVAR (sym, val.value) = (v))
#define SET_SYMBOL_ALIAS(sym, v) \
(eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias = (v))
#define SET_SYMBOL_BLV(sym, v) \
(eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v))
#define SYMBOL_NAME(sym) \
- LISP_MAKE_RVALUE (XSYMBOL (sym)->xname)
+ LISP_MAKE_RVALUE (SVAR (XSYMBOL (sym), xname))
/* Value is non-zero if SYM is an interned symbol. */
#define DEFAULT_REHASH_SIZE 1.5
-\f
+/* Most code should use this macro to access
+ Lisp fields in a different misc objects. */
+
+#define MVAR(misc, field) ((misc)->INTERNAL_FIELD (field))
+
/* These structures are used for various misc types. */
struct Lisp_Misc_Any /* Supertype of all Misc types. */
unsigned gcmarkbit : 1;
int spacer : 15;
struct Lisp_Overlay *next;
- Lisp_Object start, end, plist;
+ Lisp_Object INTERNAL_FIELD (start);
+ Lisp_Object INTERNAL_FIELD (end);
+ Lisp_Object INTERNAL_FIELD (plist);
};
/* Hold a C pointer for later use.
CHAR_META = 0x8000000,
CHAR_MODIFIER_MASK =
- (CHAR_ALT | CHAR_SUPER | CHAR_HYPER | CHAR_SHIFT | CHAR_CTL | CHAR_META),
+ CHAR_ALT | CHAR_SUPER | CHAR_HYPER | CHAR_SHIFT | CHAR_CTL | CHAR_META,
/* Actually, the current Emacs uses 22 bits for the character value
itself. */
vchild, and hchild members are all nil. */
#define CHECK_LIVE_WINDOW(x) \
- CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), Qwindow_live_p, x)
+ CHECK_TYPE (WINDOWP (x) && !NILP (WVAR (XWINDOW (x), buffer)), \
+ Qwindow_live_p, x)
#define CHECK_PROCESS(x) \
CHECK_TYPE (PROCESSP (x), Qprocessp, x)
struct window;
struct frame;
+/* Simple access functions. */
+
+static inline Lisp_Object *
+aref_addr (Lisp_Object array, ptrdiff_t idx)
+{
+ return & XVECTOR (array)->contents[idx];
+}
+
+static inline void
+set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->key_and_value, 2 * idx, val);
+}
+
+static inline void
+set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->key_and_value, 2 * idx + 1, val);
+}
+
+static inline void
+set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->next, idx, val);
+}
+
+static inline void
+set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->hash, idx, val);
+}
+
+static inline void
+set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
+{
+ ASET (h->index, idx, val);
+}
+
/* Defined in data.c. */
extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
ATTRIBUTE_FORMAT_PRINTF (1, 0);
extern Lisp_Object un_autoload (Lisp_Object);
extern void init_eval_once (void);
-extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *);
+extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
extern void init_eval (void);
/* Set up the name of the machine we're running on. */
extern void init_system_name (void);
-/* Some systems (e.g., NT) use a different path separator than Unix,
- in addition to a device separator. Set the path separator
- to '/', and don't test for a device separator in IS_ANY_SEP. */
-
-#define DIRECTORY_SEP '/'
-#ifndef IS_DIRECTORY_SEP
-#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
-#endif
-#ifndef IS_DEVICE_SEP
-#ifndef DEVICE_SEP
-#define IS_DEVICE_SEP(_c_) 0
-#else
-#define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)
-#endif
-#endif
-#ifndef IS_ANY_SEP
-#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_))
-#endif
-
-#define SWITCH_ENUM_CAST(x) (x)
+static char const DIRECTORY_SEP = '/';
/* Use this to suppress gcc's warnings. */
#ifdef lint