remove sigio blocking
[bpt/emacs.git] / src / eval.c
index 3d8573f..a2e9b0f 100644 (file)
@@ -225,7 +225,6 @@ make_catch_handler (Lisp_Object tag)
   c->body = Qnil;
   c->next = handlerlist;
   c->lisp_eval_depth = lisp_eval_depth;
-  c->poll_suppress_count = poll_suppress_count;
   c->interrupt_input_blocked = interrupt_input_blocked;
   c->ptag = make_prompt_tag ();
   return c;
@@ -242,7 +241,6 @@ make_condition_handler (Lisp_Object tag)
   c->body = Qnil;
   c->next = handlerlist;
   c->lisp_eval_depth = lisp_eval_depth;
-  c->poll_suppress_count = poll_suppress_count;
   c->interrupt_input_blocked = interrupt_input_blocked;
   c->ptag = make_prompt_tag ();
   return c;
@@ -1040,7 +1038,7 @@ definitions to shadow the loaded ones for use in file byte-compilation.  */)
          tem = Fassq (sym, environment);
          if (NILP (tem))
            {
-             def = XSYMBOL (sym)->function;
+             def = SYMBOL_FUNCTION (sym);
              if (!NILP (def))
                continue;
            }
@@ -1116,7 +1114,6 @@ static void
 restore_handler (void *data)
 {
   struct handler *c = data;
-  set_poll_suppress_count (c->poll_suppress_count);
   unblock_input_to (c->interrupt_input_blocked);
   immediate_quit = 0;
 }
@@ -1872,11 +1869,9 @@ then strings and vectors are not accepted.  */)
       fun = Fsymbol_function (fun);
     }
 
-  /* Emacs primitives are interactive if their DEFUN specifies an
-     interactive spec.  */
-  if (SUBRP (fun))
-    return XSUBR (fun)->intspec ? Qt : if_prop;
-
+  if (scm_is_true (scm_procedure_p (fun)))
+    return (scm_is_true (scm_procedure_property (fun, Qinteractive_form))
+            ? Qt : if_prop);
   /* Bytecode objects are interactive if they are long enough to
      have an element whose index is COMPILED_INTERACTIVE, which is
      where the interactive spec is stored.  */
@@ -1922,8 +1917,8 @@ this does nothing and returns nil.  */)
   CHECK_STRING (file);
 
   /* If function is defined and not as an autoload, don't override.  */
-  if (!NILP (XSYMBOL (function)->function)
-      && !AUTOLOADP (XSYMBOL (function)->function))
+  if (!NILP (SYMBOL_FUNCTION (function))
+      && !AUTOLOADP (SYMBOL_FUNCTION (function)))
     return Qnil;
 
   return Fdefalias (function,
@@ -2163,120 +2158,30 @@ eval_sub_1 (Lisp_Object form)
   fun = original_fun;
   if (!SYMBOLP (fun))
     fun = Ffunction (Fcons (fun, Qnil));
-  else if (!NILP (fun) && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+  else if (!NILP (fun) && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
 
-  if (SUBRP (fun))
+  if (scm_is_true (scm_procedure_p (fun)))
     {
-      Lisp_Object numargs;
-      Lisp_Object argvals[8];
-      Lisp_Object args_left;
-      register int i, maxargs;
-
-      args_left = original_args;
-      numargs = Flength (args_left);
-
-      if (XINT (numargs) < XSUBR (fun)->min_args
-         || (XSUBR (fun)->max_args >= 0
-             && XSUBR (fun)->max_args < XINT (numargs)))
-       xsignal2 (Qwrong_number_of_arguments, original_fun, numargs);
-
-      else if (XSUBR (fun)->max_args == UNEVALLED)
-       val = (XSUBR (fun)->function.aUNEVALLED) (args_left);
-      else if (XSUBR (fun)->max_args == MANY)
-       {
-         /* Pass a vector of evaluated arguments.  */
-         Lisp_Object *vals;
-         ptrdiff_t argnum = 0;
-         USE_SAFE_ALLOCA;
-
-         SAFE_ALLOCA_LISP (vals, XINT (numargs));
-
-         GCPRO3 (args_left, fun, fun);
-         gcpro3.var = vals;
-         gcpro3.nvars = 0;
-
-         while (!NILP (args_left))
-           {
-             vals[argnum++] = eval_sub (Fcar (args_left));
-             args_left = Fcdr (args_left);
-             gcpro3.nvars = argnum;
-           }
-
-         set_backtrace_args (specpdl_ptr - 1, vals);
-         set_backtrace_nargs (specpdl_ptr - 1, XINT (numargs));
-
-         val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals);
-         UNGCPRO;
-         SAFE_FREE ();
-       }
-      else
-       {
-         GCPRO3 (args_left, fun, fun);
-         gcpro3.var = argvals;
-         gcpro3.nvars = 0;
-
-         maxargs = XSUBR (fun)->max_args;
-         for (i = 0; i < maxargs; args_left = Fcdr (args_left))
-           {
-             argvals[i] = eval_sub (Fcar (args_left));
-             gcpro3.nvars = ++i;
-           }
-
-         UNGCPRO;
+      Lisp_Object args_left = original_args;
+      Lisp_Object nargs = Flength (args_left);
+      Lisp_Object *args;
+      size_t argnum = 0;
 
-         set_backtrace_args (specpdl_ptr - 1, argvals);
-         set_backtrace_nargs (specpdl_ptr - 1, XINT (numargs));
+      SAFE_ALLOCA_LISP (args, XINT (nargs));
 
-         switch (i)
-           {
-           case 0:
-             val = (XSUBR (fun)->function.a0 ());
-             break;
-           case 1:
-             val = (XSUBR (fun)->function.a1 (argvals[0]));
-             break;
-           case 2:
-             val = (XSUBR (fun)->function.a2 (argvals[0], argvals[1]));
-             break;
-           case 3:
-             val = (XSUBR (fun)->function.a3
-                    (argvals[0], argvals[1], argvals[2]));
-             break;
-           case 4:
-             val = (XSUBR (fun)->function.a4
-                    (argvals[0], argvals[1], argvals[2], argvals[3]));
-             break;
-           case 5:
-             val = (XSUBR (fun)->function.a5
-                    (argvals[0], argvals[1], argvals[2], argvals[3],
-                     argvals[4]));
-             break;
-           case 6:
-             val = (XSUBR (fun)->function.a6
-                    (argvals[0], argvals[1], argvals[2], argvals[3],
-                     argvals[4], argvals[5]));
-             break;
-           case 7:
-             val = (XSUBR (fun)->function.a7
-                    (argvals[0], argvals[1], argvals[2], argvals[3],
-                     argvals[4], argvals[5], argvals[6]));
-             break;
-
-           case 8:
-             val = (XSUBR (fun)->function.a8
-                    (argvals[0], argvals[1], argvals[2], argvals[3],
-                     argvals[4], argvals[5], argvals[6], argvals[7]));
-             break;
-
-           default:
-             /* Someone has created a subr that takes more arguments than
-                is supported by this code.  We need to either rewrite the
-                subr to use a different argument protocol, or add more
-                cases to this switch.  */
-             emacs_abort ();
-           }
-       }
+      while (! NILP (args_left))
+        {
+          args[argnum++] = eval_sub (Fcar (args_left));
+          args_left = Fcdr (args_left);
+        }
+      set_backtrace_args (specpdl_ptr - 1, args);
+      set_backtrace_nargs (specpdl_ptr - 1, argnum);
+      val = scm_call_n (fun, args, argnum);
+    }
+  else if (CONSP (fun) && EQ (XCAR (fun), Qspecial_operator))
+    {
+      val = scm_apply_0 (XCDR (fun), original_args);
     }
   else if (COMPILEDP (fun))
     val = apply_lambda (fun, original_args);
@@ -2357,6 +2262,18 @@ DEFUN ("values", Fvalues, Svalues, 0, MANY, 0,
   return scm_c_values (args, nargs);
 }
 \f
+DEFUN ("bind-symbol", Fbind_symbol, Sbind_symbol, 3, 3, 0,
+       doc: /* Bind symbol.  */)
+  (Lisp_Object symbol, Lisp_Object value, Lisp_Object thunk)
+{
+  Lisp_Object val;
+  dynwind_begin ();
+  specbind (symbol, value);
+  val = call0 (thunk);
+  dynwind_end ();
+  return val;
+}
+\f
 DEFUN ("apply", Fapply, Sapply, 1, MANY, 0,
        doc: /* Call FUNCTION with our remaining args, using our last arg as list of args.
 Then return the value FUNCTION returns.
@@ -2391,32 +2308,14 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
 
   /* Optimize for no indirection.  */
   if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+      && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
   if (NILP (fun))
     {
       /* Let funcall get the error.  */
       fun = args[0];
-      goto funcall;
     }
 
-  if (SUBRP (fun))
-    {
-      if (numargs < XSUBR (fun)->min_args
-         || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
-       goto funcall;           /* Let funcall get the error.  */
-      else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
-       {
-         /* Avoid making funcall cons up a yet another new vector of arguments
-            by explicitly supplying nil's for optional values.  */
-         SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args);
-         for (i = numargs; i < XSUBR (fun)->max_args;)
-           funcall_args[++i] = Qnil;
-         GCPRO1 (*funcall_args);
-         gcpro1.nvars = 1 + XSUBR (fun)->max_args;
-       }
-    }
- funcall:
   /* We add 1 to numargs because funcall_args includes the
      function itself as well as its arguments.  */
   if (!funcall_args)
@@ -2866,88 +2765,12 @@ usage: (funcall FUNCTION &rest ARGUMENTS)  */)
   /* Optimize for no indirection.  */
   fun = original_fun;
   if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+      && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
 
-  if (SUBRP (fun))
+  if (scm_is_true (scm_procedure_p (fun)))
     {
-      if (numargs < XSUBR (fun)->min_args
-         || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
-       {
-         XSETFASTINT (lisp_numargs, numargs);
-         xsignal2 (Qwrong_number_of_arguments, original_fun, lisp_numargs);
-       }
-
-      else if (XSUBR (fun)->max_args == UNEVALLED)
-       xsignal1 (Qinvalid_function, original_fun);
-
-      else if (XSUBR (fun)->max_args == MANY)
-       val = (XSUBR (fun)->function.aMANY) (numargs, args + 1);
-      else
-       {
-         if (XSUBR (fun)->max_args > numargs)
-           {
-             internal_args = alloca (XSUBR (fun)->max_args
-                                     * sizeof *internal_args);
-             memcpy (internal_args, args + 1, numargs * word_size);
-             for (i = numargs; i < XSUBR (fun)->max_args; i++)
-               internal_args[i] = Qnil;
-           }
-         else
-           internal_args = args + 1;
-         switch (XSUBR (fun)->max_args)
-           {
-           case 0:
-             val = (XSUBR (fun)->function.a0 ());
-             break;
-           case 1:
-             val = (XSUBR (fun)->function.a1 (internal_args[0]));
-             break;
-           case 2:
-             val = (XSUBR (fun)->function.a2
-                    (internal_args[0], internal_args[1]));
-             break;
-           case 3:
-             val = (XSUBR (fun)->function.a3
-                    (internal_args[0], internal_args[1], internal_args[2]));
-             break;
-           case 4:
-             val = (XSUBR (fun)->function.a4
-                    (internal_args[0], internal_args[1], internal_args[2],
-                    internal_args[3]));
-             break;
-           case 5:
-             val = (XSUBR (fun)->function.a5
-                    (internal_args[0], internal_args[1], internal_args[2],
-                     internal_args[3], internal_args[4]));
-             break;
-           case 6:
-             val = (XSUBR (fun)->function.a6
-                    (internal_args[0], internal_args[1], internal_args[2],
-                     internal_args[3], internal_args[4], internal_args[5]));
-             break;
-           case 7:
-             val = (XSUBR (fun)->function.a7
-                    (internal_args[0], internal_args[1], internal_args[2],
-                     internal_args[3], internal_args[4], internal_args[5],
-                     internal_args[6]));
-             break;
-
-           case 8:
-             val = (XSUBR (fun)->function.a8
-                    (internal_args[0], internal_args[1], internal_args[2],
-                     internal_args[3], internal_args[4], internal_args[5],
-                     internal_args[6], internal_args[7]));
-             break;
-
-           default:
-
-             /* If a subr takes more than 8 arguments without using MANY
-                or UNEVALLED, we need to extend this function to support it.
-                Until this is done, there is no way to call the function.  */
-             emacs_abort ();
-           }
-       }
+      val = scm_call_n (fun, args + 1, numargs);
     }
   else if (COMPILEDP (fun))
     val = funcall_lambda (fun, numargs, args + 1);