(scm_random_solid_sphere_x): Use scm_c_generalized_vector_length
[bpt/guile.git] / libguile / async.c
index 56b2f17..35e8a5a 100644 (file)
@@ -1,46 +1,25 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004 Free Software Foundation, Inc.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * As a special exception, the Free Software Foundation gives permission
- * for additional uses of the text contained in its release of GUILE.
- *
- * The exception is that, if you link the GUILE library with other files
- * to produce an executable, this does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * Your use of that executable is in no way restricted on account of
- * linking the GUILE library code into it.
- *
- * This exception does not however invalidate any other reasons why
- * the executable file might be covered by the GNU General Public License.
- *
- * This exception applies only to the code released by the
- * Free Software Foundation under the name GUILE.  If you copy
- * code from other Free Software Foundation releases into a copy of
- * GUILE, as the General Public License permits, the exception does
- * not apply to the code that you add in this way.  To avoid misleading
- * anyone as to the status of such modified files, you must delete
- * this exception notice from them.
- *
- * If you write modifications of your own for GUILE, it is your choice
- * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.  */
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
 
 
 \f
+#if HAVE_CONFIG_H
+#  include <config.h>
+#endif
 
 #include <signal.h>
 #include "libguile/_scm.h"
 #include <unistd.h>
 #endif
 
-/* This is not used for anything except checking that DEFER_INTS and
-   ALLOW_INTS are used properly.
- */
-int scm_ints_disabled = 1;
-
 \f
 /* {Asynchronous Events}
  *
@@ -175,7 +149,7 @@ scm_async_click ()
   if (scm_root->block_asyncs == 0)
     {
       SCM asyncs;
-      while (!SCM_NULLP(asyncs = scm_root->active_asyncs))
+      while (!scm_is_null(asyncs = scm_root->active_asyncs))
        {
          scm_root->active_asyncs = SCM_EOL;
          do
@@ -183,12 +157,12 @@ scm_async_click ()
              scm_call_0 (SCM_CAR (asyncs));
              asyncs = SCM_CDR (asyncs);
            }
-         while (!SCM_NULLP(asyncs));
+         while (!scm_is_null(asyncs));
        }
-      for (asyncs = scm_root->signal_asyncs; !SCM_NULLP(asyncs);
+      for (asyncs = scm_root->signal_asyncs; !scm_is_null(asyncs);
           asyncs = SCM_CDR (asyncs))
        {
-         if (!SCM_FALSEP (SCM_CAR (asyncs)))
+         if (scm_is_true (SCM_CAR (asyncs)))
            {
              SCM proc = SCM_CAR (asyncs);
              SCM_SETCAR (asyncs, SCM_BOOL_F);
@@ -248,7 +222,6 @@ SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0,
            "signal handlers.")
 #define FUNC_NAME s_scm_system_async_mark_for_thread
 {
-#ifdef USE_THREADS
   if (SCM_UNBNDP (thread))
     thread = scm_current_thread ();
   else
@@ -259,9 +232,6 @@ SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0,
     }
   scm_i_queue_async_cell (scm_cons (proc, SCM_BOOL_F),
                          scm_i_thread_root (thread));
-#else
-  scm_i_queue_async_cell (scm_cons (proc, SCM_BOOL_F), scm_root);
-#endif
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
@@ -394,6 +364,24 @@ scm_c_call_with_unblocked_asyncs (void *(*proc) (void *data), void *data)
                                            data, NULL);
 }
 
+void
+scm_frame_block_asyncs ()
+{
+  scm_frame_rewind_handler (increase_block, NULL, SCM_F_WIND_EXPLICITLY);
+  scm_frame_unwind_handler (decrease_block, NULL, SCM_F_WIND_EXPLICITLY);
+}
+
+void
+scm_frame_unblock_asyncs ()
+{
+  if (scm_root->block_asyncs == 0)
+    scm_misc_error ("scm_with_unblocked_asyncs", 
+                   "asyncs already unblocked", SCM_EOL);
+  scm_frame_rewind_handler (decrease_block, NULL, SCM_F_WIND_EXPLICITLY);
+  scm_frame_unwind_handler (increase_block, NULL, SCM_F_WIND_EXPLICITLY);
+}
+
+
 \f
 
 void