Port to C89.
[bpt/emacs.git] / src / bytecode.c
index 9773063..c790275 100644 (file)
@@ -1,5 +1,6 @@
 /* Execution of byte code produced by bytecomp.el.
-   Copyright (C) 1985-1988, 1993, 2000-2012 Free Software Foundation, Inc.
+   Copyright (C) 1985-1988, 1993, 2000-2013 Free Software Foundation,
+   Inc.
 
 This file is part of GNU Emacs.
 
@@ -33,7 +34,7 @@ by Hallvard:
  */
 
 #include <config.h>
-#include <setjmp.h>
+
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
@@ -58,7 +59,8 @@ by Hallvard:
    indirect threaded, using GCC's computed goto extension.  This code,
    as currently implemented, is incompatible with BYTE_CODE_SAFE and
    BYTE_CODE_METER.  */
-#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER)
+#if (defined __GNUC__ && !defined __STRICT_ANSI__ \
+     && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER)
 #define BYTE_CODE_THREADED
 #endif
 
@@ -87,8 +89,6 @@ Lisp_Object Qbyte_code_meter;
 #endif /* BYTE_CODE_METER */
 \f
 
-Lisp_Object Qbytecode;
-
 /*  Byte codes: */
 
 #define BYTE_CODES                                                     \
@@ -286,8 +286,10 @@ enum byte_code_op
 
 #ifdef BYTE_CODE_SAFE
     Bscan_buffer = 0153, /* No longer generated as of v18.  */
-    Bset_mark = 0163 /* this loser is no longer generated as of v18 */
+    Bset_mark = 0163, /* this loser is no longer generated as of v18 */
 #endif
+
+    B__dummy__ = 0  /* Pacify C89.  */
 };
 
 /* Whether to maintain a `top' and `bottom' field in the stack frame.  */
@@ -314,9 +316,11 @@ struct byte_stack
   Lisp_Object byte_string;
   const unsigned char *byte_string_start;
 
+#if BYTE_MARK_STACK
   /* The vector of constants used during byte-code execution.  Storing
      this here protects it from GC because mark_byte_stack marks it.  */
   Lisp_Object constants;
+#endif
 
   /* Next entry in byte_stack_list.  */
   struct byte_stack *next;
@@ -380,12 +384,12 @@ unmark_byte_stack (void)
 }
 
 \f
-/* Fetch the next byte from the bytecode stream */
+/* Fetch the next byte from the bytecode stream */
 
 #define FETCH *stack.pc++
 
 /* Fetch two bytes from the bytecode stream and make a 16-bit number
-   out of them */
+   out of them */
 
 #define FETCH2 (op = FETCH, op + (FETCH << 8))
 
@@ -405,7 +409,7 @@ unmark_byte_stack (void)
 #define DISCARD(n) (top -= (n))
 
 /* Get the value which is at the top of the execution stack, but don't
-   pop it. */
+   pop it.  */
 
 #define TOP (*top)
 
@@ -458,7 +462,8 @@ unmark_byte_stack (void)
        Fsignal (Qquit, Qnil);                          \
        AFTER_POTENTIAL_GC ();                          \
       }                                                        \
-    ELSE_PENDING_SIGNALS                               \
+    else if (pending_signals)                          \
+      process_pending_signals ();                      \
   } while (0)
 
 
@@ -535,7 +540,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
 
   stack.byte_string = bytestr;
   stack.pc = stack.byte_string_start = SDATA (bytestr);
+#if BYTE_MARK_STACK
   stack.constants = vector;
+#endif
   if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
     memory_full (SIZE_MAX);
   top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
@@ -656,9 +663,12 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
         the table clearer.  */
 #define LABEL(OP) [OP] = &&insn_ ## OP
 
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
 # pragma GCC diagnostic push
 # pragma GCC diagnostic ignored "-Woverride-init"
+#elif defined __clang__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Winitializer-overrides"
 #endif
 
       /* This is the dispatch table for the threaded interpreter.  */
@@ -672,7 +682,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
 #undef DEFINE
        };
 
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__
 # pragma GCC diagnostic pop
 #endif
 
@@ -751,7 +761,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
              {
                BEFORE_POTENTIAL_GC ();
                wrong_type_argument (Qlistp, v1);
-               AFTER_POTENTIAL_GC ();
              }
            NEXT;
          }
@@ -786,7 +795,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
              {
                BEFORE_POTENTIAL_GC ();
                wrong_type_argument (Qlistp, v1);
-               AFTER_POTENTIAL_GC ();
              }
            NEXT;
          }
@@ -1578,7 +1586,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
          NEXT;
 
        CASE (Binteractive_p):  /* Obsolete since 24.1.  */
-         PUSH (Finteractive_p ());
+         BEFORE_POTENTIAL_GC ();
+         PUSH (call0 (intern ("interactive-p")));
+         AFTER_POTENTIAL_GC ();
          NEXT;
 
        CASE (Bforward_char):
@@ -1629,7 +1639,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
            c = XFASTINT (TOP);
            if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
              MAKE_CHAR_MULTIBYTE (c);
-           XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]);
+           XSETFASTINT (TOP, syntax_code_spec[SYNTAX (c)]);
          }
          NEXT;
 
@@ -1875,7 +1885,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
          /* Actually this is Bstack_ref with offset 0, but we use Bdup
             for that instead.  */
          /* CASE (Bstack_ref): */
-         emacs_abort ();
+         error ("Invalid byte opcode");
 
          /* Handy byte-codes for lexical binding.  */
        CASE (Bstack_ref1):
@@ -1960,8 +1970,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
 void
 syms_of_bytecode (void)
 {
-  DEFSYM (Qbytecode, "byte-code");
-
   defsubr (&Sbyte_code);
 
 #ifdef BYTE_CODE_METER