]> code.delx.au - gnu-emacs/blobdiff - src/emacs-module.c
; Revert "Ensure undo-boundary after insert-file-contents."
[gnu-emacs] / src / emacs-module.c
index 5d1b4dc8d6aed59662e94ea4721e33e79050332f..eca5af739b92846c6be69e7d83435159e8f8035b 100644 (file)
@@ -1,13 +1,13 @@
 /* emacs-module.c - Module loading and runtime implementation
 
-Copyright (C) 2015 Free Software Foundation, Inc.
+Copyright (C) 2015-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs 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 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -35,8 +35,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 \f
 /* Feature tests.  */
 
-/* True if __attribute__ ((cleanup (...))) works, false otherwise.  */
-#ifdef HAVE_VAR_ATTRIBUTE_CLEANUP
+#if __has_attribute (cleanup)
 enum { module_has_cleanup = true };
 #else
 enum { module_has_cleanup = false };
@@ -65,6 +64,12 @@ enum
         && INTPTR_MAX == EMACS_INT_MAX)
   };
 
+/* Function prototype for module user-pointer finalizers.  These
+   should not throw C++ exceptions, so emacs-module.h declares the
+   corresponding interfaces with EMACS_NOEXCEPT.  There is only C code
+   in this module, though, so this constraint is not enforced here.  */
+typedef void (*emacs_finalizer_function) (void *);
+
 \f
 /* Private runtime and environment members.  */
 
@@ -86,7 +91,7 @@ struct emacs_env_private
 struct emacs_runtime_private
 {
   /* FIXME: Ideally, we would just define "struct emacs_runtime_private"
-   * as a synonym of "emacs_env", but I don't know how to do that in C.  */
+     as a synonym of "emacs_env", but I don't know how to do that in C.  */
   emacs_env pub;
 };
 \f
@@ -120,6 +125,9 @@ static emacs_value const module_nil = 0;
 \f
 /* Convenience macros for non-local exit handling.  */
 
+/* FIXME: The following implementation for non-local exit handling
+   does not support recovery from stack overflow, see sysdep.c.  */
+
 /* Emacs uses setjmp and longjmp for non-local exits, but
    module frames cannot be skipped because they are in general
    not prepared for long jumps (e.g., the behavior in C++ is undefined
@@ -325,8 +333,7 @@ module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data)
   struct emacs_env_private *p = env->private_members;
   if (p->pending_non_local_exit != emacs_funcall_exit_return)
     {
-      /* FIXME: We cannot call lisp_to_value here because that can
-         exit non-locally.  */
+      /* FIXME: lisp_to_value can exit non-locally.  */
       *sym = lisp_to_value (p->non_local_exit_symbol);
       *data = lisp_to_value (p->non_local_exit_data);
     }
@@ -436,7 +443,6 @@ module_is_not_nil (emacs_env *env, emacs_value value)
   check_main_thread ();
   if (module_non_local_exit_check (env) != emacs_funcall_exit_return)
     return false;
-  /* Assume that NILP never exits non-locally.  */
   return ! NILP (value_to_lisp (value));
 }
 
@@ -446,7 +452,6 @@ module_eq (emacs_env *env, emacs_value a, emacs_value b)
   check_main_thread ();
   if (module_non_local_exit_check (env) != emacs_funcall_exit_return)
     return false;
-  /* Assume that EQ never exits non-locally.  */
   return EQ (value_to_lisp (a), value_to_lisp (b));
 }
 
@@ -893,7 +898,7 @@ value_to_lisp_bits (emacs_value v)
 }
 
 /* If V was computed from lisp_to_value (O), then return O.
-   Must never fail or exit non-locally.  */
+   Exits non-locally only if the stack overflows.  */
 static Lisp_Object
 value_to_lisp (emacs_value v)
 {
@@ -923,7 +928,7 @@ enum { HAVE_STRUCT_ATTRIBUTE_ALIGNED = 0 };
 #endif
 
 /* Convert O to an emacs_value.  Allocate storage if needed; this can
-   signal if memory is exhausted.  Must be injective.  */
+   signal if memory is exhausted.  Must be an injective function.  */
 static emacs_value
 lisp_to_value (Lisp_Object o)
 {