summaryrefslogtreecommitdiff
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-08-03 13:55:27 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-08-03 13:55:27 -0700
commit8834c57aab03fb7ea9d92f9e995844ff7ce64b7b (patch)
treebfc986a2271505769d2daaaaacdd57891477c624 /src/lisp.h
parentef834897aaf3259cbf1b7286fe237fb39b2cdf6d (diff)
downloademacs-8834c57aab03fb7ea9d92f9e995844ff7ce64b7b.tar.gz
Improve fix for macroexp crash with debugging.
* lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to ARRAY_MARK_FLAG when checking subscripts, because ASET is not supposed to be invoked from the garbage collector. See Andreas Schwab in <http://bugs.gnu.org/12118#25>. (gc_aset): New function, which is like ASET but can be used in the garbage collector. (set_hash_key, set_hash_value, set_hash_next, set_hash_hash) (set_hash_index): Use it instead of ASET.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 3d00f4dde78..e77b76005cd 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -608,7 +608,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
/* The IDX==IDX tries to detect when the macro argument is side-effecting. */
#define ASET(ARRAY, IDX, VAL) \
(eassert ((IDX) == (IDX)), \
- eassert ((IDX) >= 0 && (IDX) < (ASIZE (ARRAY) & ~ARRAY_MARK_FLAG)), \
+ eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \
XVECTOR (ARRAY)->contents[IDX] = (VAL))
/* Convenience macros for dealing with Lisp strings. */
@@ -2356,33 +2356,41 @@ aref_addr (Lisp_Object array, ptrdiff_t idx)
}
LISP_INLINE void
+gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
+{
+ /* Like ASET, but also can be used in the garbage collector. */
+ eassert (0 <= idx && idx < (ASIZE (array) & ~ARRAY_MARK_FLAG));
+ XVECTOR (array)->contents[idx] = val;
+}
+
+LISP_INLINE void
set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
- ASET (h->key_and_value, 2 * idx, val);
+ gc_aset (h->key_and_value, 2 * idx, val);
}
LISP_INLINE void
set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
- ASET (h->key_and_value, 2 * idx + 1, val);
+ gc_aset (h->key_and_value, 2 * idx + 1, val);
}
LISP_INLINE void
set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
- ASET (h->next, idx, val);
+ gc_aset (h->next, idx, val);
}
LISP_INLINE void
set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
- ASET (h->hash, idx, val);
+ gc_aset (h->hash, idx, val);
}
LISP_INLINE void
set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
{
- ASET (h->index, idx, val);
+ gc_aset (h->index, idx, val);
}
/* Defined in data.c. */