* lisp.h (XCONS, XSTRING, XSYMBOL, XFLOAT, XPROCESS, XWINDOW, XSUBR, XBUFFER):
[bpt/emacs.git] / src / lisp.h
index af1ddb7..13e734a 100644 (file)
@@ -46,6 +46,23 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif
 
+/* Extra internal type checking?  */
+extern int suppress_checking;
+#ifdef ENABLE_CHECKING
+extern void die P_((const char *, const char *, int));
+#define CHECK(check,msg) ((check || suppress_checking ? 0 : die (msg, __FILE__, __LINE__)), 0)
+#else
+/* Produce same side effects and result, but don't complain.  */
+#define CHECK(check,msg) ((check),0)
+#endif
+/* Define an Emacs version of "assert", since some system ones are
+   flaky.  */
+#if defined (__GNUC__) && __GNUC__ >= 2 && defined (__STDC__)
+#define eassert(cond) CHECK(cond,"assertion failed: " #cond)
+#else
+#define eassert(cond) CHECK(cond,"assertion failed")
+#endif
+
 /* Define the fundamental Lisp data structures.  */
 
 /* This is the set of Lisp data types.  */
@@ -415,11 +432,11 @@ extern Lisp_Object make_number ();
 
 /* Extract a value or address from a Lisp_Object.  */
 
-#define XCONS(a) ((struct Lisp_Cons *) XPNTR(a))
+#define XCONS(a) (eassert (GC_CONSP(a)),(struct Lisp_Cons *) XPNTR(a))
 #define XVECTOR(a) ((struct Lisp_Vector *) XPNTR(a))
-#define XSTRING(a) ((struct Lisp_String *) XPNTR(a))
-#define XSYMBOL(a) ((struct Lisp_Symbol *) XPNTR(a))
-#define XFLOAT(a) ((struct Lisp_Float *) XPNTR(a))
+#define XSTRING(a) (eassert (GC_STRINGP(a)),(struct Lisp_String *) XPNTR(a))
+#define XSYMBOL(a) (eassert (GC_SYMBOLP(a)),(struct Lisp_Symbol *) XPNTR(a))
+#define XFLOAT(a) (eassert (GC_FLOATP(a)),(struct Lisp_Float *) XPNTR(a))
 
 /* Misc types.  */
 #define XMISC(a)   ((union Lisp_Misc *) XPNTR(a))
@@ -434,10 +451,10 @@ extern Lisp_Object make_number ();
 #define XKBOARD_OBJFWD(a) (&(XMISC(a)->u_kboard_objfwd))
 
 /* Pseudovector types.  */
-#define XPROCESS(a) ((struct Lisp_Process *) XPNTR(a))
-#define XWINDOW(a) ((struct window *) XPNTR(a))
-#define XSUBR(a) ((struct Lisp_Subr *) XPNTR(a))
-#define XBUFFER(a) ((struct buffer *) XPNTR(a))
+#define XPROCESS(a) (eassert (GC_PROCESSP(a)),(struct Lisp_Process *) XPNTR(a))
+#define XWINDOW(a) (eassert (GC_WINDOWP(a)),(struct window *) XPNTR(a))
+#define XSUBR(a) (eassert (GC_SUBRP(a)),(struct Lisp_Subr *) XPNTR(a))
+#define XBUFFER(a) (eassert (GC_BUFFERP(a)),(struct buffer *) XPNTR(a))
 #define XCHAR_TABLE(a) ((struct Lisp_Char_Table *) XPNTR(a))
 #define XBOOL_VECTOR(a) ((struct Lisp_Bool_Vector *) XPNTR(a))
 
@@ -494,17 +511,22 @@ struct interval
      You'd think we could store this information in the parent object
      somewhere (after all, that should be visited once and then
      ignored too, right?), but strings are GC'd strangely.  */
-  struct interval *parent;
+  union
+  {
+    struct interval *interval;
+    Lisp_Object obj;
+  } up;
+  unsigned int up_obj : 1;
 
   /* The remaining components are `properties' of the interval.
      The first four are duplicates for things which can be on the list,
      for purposes of speed.  */
 
-  unsigned char write_protect;     /* Non-zero means can't modify.  */
-  unsigned char visible;           /* Zero means don't display.  */
-  unsigned char front_sticky;      /* Non-zero means text inserted just
+  unsigned int write_protect : 1;    /* Non-zero means can't modify.  */
+  unsigned int visible : 1;        /* Zero means don't display.  */
+  unsigned int front_sticky : 1;    /* Non-zero means text inserted just
                                       before this interval goes into it.  */
-  unsigned char rear_sticky;       /* Likewise for just after it.  */
+  unsigned int rear_sticky : 1;            /* Likewise for just after it.  */
 
   /* Properties of this interval.
      The mark bit on this field says whether this particular interval
@@ -2835,6 +2857,7 @@ extern int immediate_quit;            /* Nonzero means ^G can quit instantly */
 extern char *getenv (), *ctime (), *getwd ();
 extern long *xmalloc (), *xrealloc ();
 extern void xfree ();
+extern char *xstrdup P_ ((char *));
 
 extern char *egetenv P_ ((char *));