emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 4851616: Improve commentary for emacs-module.c


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 4851616: Improve commentary for emacs-module.c
Date: Sun, 20 Dec 2015 19:11:01 +0000

branch: emacs-25
commit 4851616b4d2e14cdf970b9029f0d4b00083a08f5
Author: Philipp Stephani <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Improve commentary for emacs-module.c
    
    * src/lisp.h: Document emacs-module.c assumptions about EQ and NILP.
    * src/emacs-module.c (module_non_local_exit_get): Document that we
    cannot use the current implementation.
    (module_is_not_nil, module_eq): Document assumptions about EQ and
    NILP.
---
 src/emacs-module.c |    8 ++++++--
 src/lisp.h         |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/emacs-module.c b/src/emacs-module.c
index ee97644..5d1b4dc 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -325,6 +325,8 @@ 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.  */
       *sym = lisp_to_value (p->non_local_exit_symbol);
       *data = lisp_to_value (p->non_local_exit_data);
     }
@@ -434,6 +436,7 @@ 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));
 }
 
@@ -443,6 +446,7 @@ 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));
 }
 
@@ -889,7 +893,7 @@ value_to_lisp_bits (emacs_value v)
 }
 
 /* If V was computed from lisp_to_value (O), then return O.
-   Never fails.  */
+   Must never fail or exit non-locally.  */
 static Lisp_Object
 value_to_lisp (emacs_value v)
 {
@@ -919,7 +923,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.  */
+   signal if memory is exhausted.  Must be injective.  */
 static emacs_value
 lisp_to_value (Lisp_Object o)
 {
diff --git a/src/lisp.h b/src/lisp.h
index 995760a..bcac4b6 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -329,11 +329,15 @@ error !;
 #define lisp_h_CHECK_TYPE(ok, predicate, x) \
    ((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x))
 #define lisp_h_CONSP(x) (XTYPE (x) == Lisp_Cons)
+/* lisp_h_EQ must never exit non-locally; emacs-module.c relies on
+   that.  */
 #define lisp_h_EQ(x, y) (XLI (x) == XLI (y))
 #define lisp_h_FLOATP(x) (XTYPE (x) == Lisp_Float)
 #define lisp_h_INTEGERP(x) ((XTYPE (x) & (Lisp_Int0 | ~Lisp_Int1)) == 
Lisp_Int0)
 #define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
 #define lisp_h_MISCP(x) (XTYPE (x) == Lisp_Misc)
+/* lisp_h_NILP must never exit non-locally; emacs-module.c relies on
+   that.  */
 #define lisp_h_NILP(x) EQ (x, Qnil)
 #define lisp_h_SET_SYMBOL_VAL(sym, v) \
    (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v))
@@ -382,11 +386,14 @@ error !;
 # define CHECK_SYMBOL(x) lisp_h_CHECK_SYMBOL (x)
 # define CHECK_TYPE(ok, predicate, x) lisp_h_CHECK_TYPE (ok, predicate, x)
 # define CONSP(x) lisp_h_CONSP (x)
+/* EQ must never exit non-locally; emacs-module.c relies on that.  */
 # define EQ(x, y) lisp_h_EQ (x, y)
 # define FLOATP(x) lisp_h_FLOATP (x)
 # define INTEGERP(x) lisp_h_INTEGERP (x)
 # define MARKERP(x) lisp_h_MARKERP (x)
 # define MISCP(x) lisp_h_MISCP (x)
+/* NILP must never exit non-locally; emacs-module.c relies on
+   that.  */
 # define NILP(x) lisp_h_NILP (x)
 # define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v)
 # define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym)
@@ -988,7 +995,8 @@ make_natnum (EMACS_INT n)
   return USE_LSB_TAG ? make_number (n) : XIL (n + (int0 << VALBITS));
 }
 
-/* Return true if X and Y are the same object.  */
+/* Return true if X and Y are the same object.  Must never exit
+   non-locally; emacs-module.c relies on that.  */
 
 INLINE bool
 (EQ) (Lisp_Object x, Lisp_Object y)
@@ -2565,6 +2573,9 @@ enum char_bits
 
 /* Data type checking.  */
 
+/* Checks whether X is null.  Must never exit non-locally;
+   emacs-module.c relies on that.  */
+
 INLINE bool
 (NILP) (Lisp_Object x)
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]