diff options
author | Po Lu <luangruo@yahoo.com> | 2023-05-18 09:04:57 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-05-18 09:04:57 +0800 |
commit | 074c0268fd32d6527e124cff386bb6b15cf90017 (patch) | |
tree | 62111c3c70d46a738f15514e988a707409ca45f4 /src/lisp.h | |
parent | db48eff8cf4a88393c0209f663ca194ee37fa747 (diff) | |
parent | 5ef169ed701fa4f850fdca5563cdd468207d5d4f (diff) | |
download | emacs-feature/android.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/androidfeature/android
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/lisp.h b/src/lisp.h index 79c96e11da8..e8cfda1be6e 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <alloca.h> #include <setjmp.h> #include <stdarg.h> +#include <stdckdint.h> #include <stddef.h> #include <string.h> #include <float.h> @@ -3911,18 +3912,11 @@ integer_to_uintmax (Lisp_Object num, uintmax_t *n) } /* Return floor (log2 (N)) as an int, where 0 < N <= ULLONG_MAX. */ -#if (201112 <= __STDC_VERSION__ && INT_MAX <= UINT_MAX \ - && LONG_MAX <= ULONG_MAX && LLONG_MAX <= ULLONG_MAX) -# define elogb(n) \ - _Generic (+(n), \ - int: UINT_WIDTH - 1 - count_leading_zeros (n), \ - unsigned int: UINT_WIDTH - 1 - count_leading_zeros (n), \ - long: ULONG_WIDTH - 1 - count_leading_zeros_l (n), \ - unsigned long: ULONG_WIDTH - 1 - count_leading_zeros_l (n), \ - default: ULLONG_WIDTH - 1 - count_leading_zeros_ll (n)) -#else -# define elogb(n) (ULLONG_WIDTH - 1 - count_leading_zeros_ll (n)) -#endif +INLINE int +elogb (unsigned long long int n) +{ + return ULLONG_WIDTH - 1 - count_leading_zeros_ll (n); +} /* A modification count. These are wide enough, and incremented rarely enough, so that they should never overflow a 60-bit counter @@ -3939,7 +3933,7 @@ modiff_incr (modiff_count *a, ptrdiff_t len) increasing it too much. */ verify (PTRDIFF_MAX <= ULLONG_MAX); int incr = len == 0 ? 1 : elogb (len) + 1; - bool modiff_overflow = INT_ADD_WRAPV (a0, incr, a); + bool modiff_overflow = ckd_add (a, a0, incr); eassert (!modiff_overflow && *a >> 30 >> 30 == 0); return a0; } @@ -5451,8 +5445,8 @@ safe_free_unbind_to (specpdl_ref count, specpdl_ref sa_count, Lisp_Object val) #define SAFE_ALLOCA_LISP_EXTRA(buf, nelt, extra) \ do { \ ptrdiff_t alloca_nbytes; \ - if (INT_MULTIPLY_WRAPV (nelt, word_size, &alloca_nbytes) \ - || INT_ADD_WRAPV (alloca_nbytes, extra, &alloca_nbytes) \ + if (ckd_mul (&alloca_nbytes, nelt, word_size) \ + || ckd_add (&alloca_nbytes, alloca_nbytes, extra) \ || SIZE_MAX < alloca_nbytes) \ memory_full (SIZE_MAX); \ else if (alloca_nbytes <= sa_avail) \ |