]> code.delx.au - gnu-emacs/blobdiff - src/lisp.h
*** empty log message ***
[gnu-emacs] / src / lisp.h
index 64daefe464943fb640765df469bac3974ec3623f..3d9be2759312b222cc1c211b45517496aeb055c0 100644 (file)
@@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 /* Declare the prototype for a general external function.  */
-#if defined (__STDC__) || defined (WINDOWSNT)
+#if defined (PROTOTYPES) || defined (WINDOWSNT)
 #define P_(proto) proto
 #else
 #define P_(proto) ()
@@ -46,6 +46,35 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif
 
+/* Extra internal type checking?  */
+extern int suppress_checking;
+extern void die P_((const char *, const char *, int));
+
+#ifdef ENABLE_CHECKING
+
+#define CHECK(check,msg) ((check || suppress_checking          \
+                          ? 0                                  \
+                          : die (msg, __FILE__, __LINE__)),    \
+                         0)
+
+/* Let's get some compile-time checking too.  */
+#undef NO_UNION_TYPE
+
+#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.  */
@@ -395,9 +424,14 @@ extern int pure_size;
 #define XPNTR(a) ((a).u.val)
 
 #define XSET(var, vartype, ptr) \
-   (((var).s.type = ((char) (vartype))), ((var).s.val = ((int) (ptr))))
+   (((var).s.val = ((int) (ptr))), ((var).s.type = ((char) (vartype))))
 
+#if __GNUC__ >= 2 && defined (__OPTIMIZE__)
+#define make_number(N) \
+  (__extension__ ({ Lisp_Object _l; _l.s.val = (N); _l.s.type = Lisp_Int; _l; }))
+#else
 extern Lisp_Object make_number ();
+#endif
 
 /* During garbage collection, XGCTYPE must be used for extracting types
  so that the mark bit is ignored.  XMARKBIT access the markbit.
@@ -415,11 +449,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 +468,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 +528,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
@@ -562,16 +601,6 @@ struct Lisp_Cons
   : NILP ((c)) ? Qnil                          \
   : wrong_type_argument (Qlistp, (c)))
 
-/* Like a cons, but records info on where the text lives that it was read from */
-/* This is not really in use now */
-
-struct Lisp_Buffer_Cons
-  {
-    Lisp_Object car, cdr;
-    struct buffer *buffer;
-    int bufpos;
-  };
-
 /* Nonzero if STR is a multibyte string.  */
 #define STRING_MULTIBYTE(STR)  \
   (XSTRING (STR)->size_byte >= 0)
@@ -1902,6 +1931,7 @@ extern void init_syntax_once P_ ((void));
 extern void syms_of_syntax P_ ((void));
 
 /* Defined in fns.c */
+extern Lisp_Object larger_vector P_ ((Lisp_Object, int, Lisp_Object));
 extern void sweep_weak_hash_tables P_ ((void));
 extern Lisp_Object Qstring_lessp;
 extern Lisp_Object Vfeatures;
@@ -2087,12 +2117,8 @@ extern void syms_of_xdisp P_ ((void));
 extern void init_xdisp P_ ((void));
 
 /* Defined in vm-limit.c.  */
-#ifdef __STDC__
-extern void memory_warnings P_ ((void *, void (*warnfun) ()));
-#else
-extern void memory_warnings P_ ((char *, void (*warnfun) ()));
-#endif
-                               
+extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ()));
+
 /* Defined in alloc.c */
 extern void allocate_string_data P_ ((struct Lisp_String *, int, int));
 extern void uninterrupt_malloc P_ ((void));
@@ -2814,10 +2840,10 @@ extern void syms_of_xfns P_ ((void));
 extern void init_xfns P_ ((void));
 EXFUN (Fxw_display_color_p, 1);
 #ifdef HAVE_X_I18N
-extern void free_frame_xic P_ ((struct frame *))
+extern void free_frame_xic P_ ((struct frame *));
 #endif
 /* Fixme: x_defined_color needs declaring, but needs FRAME_PTR and XColor. */
-#endif
+#endif /* HAVE_X_WINDOWS */
 
 /* Defined in xselect.c */
 extern void syms_of_xselect P_ ((void));
@@ -2839,6 +2865,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 *));