Merge from trunk.
[bpt/emacs.git] / src / lisp.h
index 7b1be98..648eb64 100644 (file)
@@ -168,6 +168,9 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
 #  if HAVE_ATTRIBUTE_ALIGNED
 #   define DECL_ALIGN(type, var) \
      type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
+#  elif defined(_MSC_VER)
+#   define DECL_ALIGN(type, var) \
+     type __declspec(align(1 << GCTYPEBITS)) var
 #  else
      /* What directives do other compilers use?  */
 #  endif
@@ -225,6 +228,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
 # endif
 #endif
 
+/* Stolen from GDB.  The only known compiler that doesn't support
+   enums in bitfields is MSVC.  */
+#ifdef _MSC_VER
+#define ENUM_BF(TYPE) unsigned int
+#else
+#define ENUM_BF(TYPE) enum TYPE
+#endif
+
+
 enum Lisp_Type
   {
     /* Integer.  XINT (obj) is the integer value.  */
@@ -315,12 +327,12 @@ union Lisp_Object
        /* Use explict signed, the signedness of a bit-field of type
           int is implementation defined.  */
        signed EMACS_INT val  : VALBITS;
-       enum Lisp_Type type : GCTYPEBITS;
+       ENUM_BF (Lisp_Type) type : GCTYPEBITS;
       } s;
     struct
       {
        EMACS_UINT val : VALBITS;
-       enum Lisp_Type type : GCTYPEBITS;
+       ENUM_BF (Lisp_Type) type : GCTYPEBITS;
       } u;
   }
 Lisp_Object;
@@ -336,14 +348,14 @@ union Lisp_Object
 
     struct
       {
-       enum Lisp_Type type : GCTYPEBITS;
+       ENUM_BF (Lisp_Type) type : GCTYPEBITS;
        /* Use explict signed, the signedness of a bit-field of type
           int is implementation defined.  */
        signed EMACS_INT val  : VALBITS;
       } s;
     struct
       {
-       enum Lisp_Type type : GCTYPEBITS;
+       ENUM_BF (Lisp_Type) type : GCTYPEBITS;
        EMACS_UINT val : VALBITS;
       } u;
   }
@@ -1101,7 +1113,7 @@ struct Lisp_Symbol
      1 : it's a varalias, the value is really in the `alias' symbol.
      2 : it's a localized var, the value is in the `blv' object.
      3 : it's a forwarding variable, the value is in `forward'.  */
-  enum symbol_redirect redirect : 3;
+  ENUM_BF (symbol_redirect) redirect : 3;
 
   /* Non-zero means symbol is constant, i.e. changing its value
      should signal an error.  If the value is 3, then the var
@@ -1314,7 +1326,7 @@ struct Lisp_Hash_Table
 
 struct Lisp_Misc_Any           /* Supertype of all Misc types.  */
 {
-  enum Lisp_Misc_Type type : 16;               /* = Lisp_Misc_??? */
+  ENUM_BF (Lisp_Misc_Type) type : 16;          /* = Lisp_Misc_??? */
   unsigned gcmarkbit : 1;
   int spacer : 15;
   /* Make it as long as "Lisp_Free without padding".  */
@@ -1323,7 +1335,7 @@ struct Lisp_Misc_Any              /* Supertype of all Misc types.  */
 
 struct Lisp_Marker
 {
-  enum Lisp_Misc_Type type : 16;               /* = Lisp_Misc_Marker */
+  ENUM_BF (Lisp_Misc_Type) type : 16;          /* = Lisp_Misc_Marker */
   unsigned gcmarkbit : 1;
   int spacer : 13;
   /* This flag is temporarily used in the functions
@@ -1473,7 +1485,7 @@ struct Lisp_Overlay
    I.e. 9words plus 2 bits, 3words of which are for external linked lists.
 */
   {
-    enum Lisp_Misc_Type type : 16;     /* = Lisp_Misc_Overlay */
+    ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Overlay */
     unsigned gcmarkbit : 1;
     int spacer : 15;
     struct Lisp_Overlay *next;
@@ -1492,7 +1504,7 @@ struct Lisp_Kboard_Objfwd
    This type of object is used in the arg to record_unwind_protect.  */
 struct Lisp_Save_Value
   {
-    enum Lisp_Misc_Type type : 16;     /* = Lisp_Misc_Save_Value */
+    ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Save_Value */
     unsigned gcmarkbit : 1;
     int spacer : 14;
     /* If DOGC is set, POINTER is the address of a memory
@@ -1506,7 +1518,7 @@ struct Lisp_Save_Value
 /* A miscellaneous object, when it's on the free list.  */
 struct Lisp_Free
   {
-    enum Lisp_Misc_Type type : 16;     /* = Lisp_Misc_Free */
+    ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Free */
     unsigned gcmarkbit : 1;
     int spacer : 15;
     union Lisp_Misc *chain;
@@ -1928,13 +1940,23 @@ typedef struct {
 
 /* This version of DEFUN declares a function prototype with the right
    arguments, so we can catch errors with maxargs at compile-time.  */
-#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
-  Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                          \
-  static DECL_ALIGN (struct Lisp_Subr, sname) =                                \
-    { PVEC_SUBR,                                                       \
-      { .a ## maxargs = fnname },                              \
-      minargs, maxargs, lname, intspec, 0};                            \
-  Lisp_Object fnname
+#ifdef _MSC_VER
+#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
+   Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                         \
+   static DECL_ALIGN (struct Lisp_Subr, sname) =                       \
+     { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),   \
+      { (Lisp_Object (__cdecl *)(void))fnname },                        \
+       minargs, maxargs, lname, intspec, 0};                           \
+   Lisp_Object fnname
+#else  /* not _MSC_VER */
+#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
+   Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                         \
+   static DECL_ALIGN (struct Lisp_Subr, sname) =                       \
+     { PVEC_SUBR,                                                      \
+      { .a ## maxargs = fnname },                                      \
+       minargs, maxargs, lname, intspec, 0};                           \
+   Lisp_Object fnname
+#endif
 
 /* Note that the weird token-substitution semantics of ANSI C makes
    this work for MANY and UNEVALLED.  */
@@ -3165,10 +3187,6 @@ extern void syms_of_fileio (void);
 extern Lisp_Object make_temp_name (Lisp_Object, int);
 extern Lisp_Object Qdelete_file;
 
-/* Defined in abbrev.c */
-
-extern void syms_of_abbrev (void);
-
 /* Defined in search.c */
 extern void shrink_regexp_cache (void);
 EXFUN (Fstring_match, 3);