diff options
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 5159f050a49..5a0de4b12c7 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3490,6 +3490,28 @@ integer_to_uintmax (Lisp_Object num, uintmax_t *n) } } +/* A modification count. These are wide enough, and incremented + rarely enough, so that they should never overflow a 60-bit counter + in practice, and the code below assumes this so a compiler can + generate better code if EMACS_INT is 64 bits. */ +typedef intmax_t modiff_count; + +INLINE modiff_count +modiff_incr (modiff_count *a) +{ + modiff_count a0 = *a; + bool modiff_overflow = INT_ADD_WRAPV (a0, 1, a); + eassert (!modiff_overflow && *a >> 30 >> 30 == 0); + return a0; +} + +INLINE Lisp_Object +modiff_to_integer (modiff_count a) +{ + eassume (0 <= a && a >> 30 >> 30 == 0); + return make_int (a); +} + /* Defined in data.c. */ extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object); extern void notify_variable_watchers (Lisp_Object, Lisp_Object, |