diff options
| author | Stefan Kangas | 2024-07-24 00:09:49 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2024-07-24 00:11:37 +0200 |
| commit | e25655756315ac398d15b308511a8e9abf20bb0e (patch) | |
| tree | 3e81a7dc0ab9abcfb9364b96f0f10559e61aef66 /src/emacs-module.c | |
| parent | 19a18e487b8e2f0c1627b9cc98e601327e884eb2 (diff) | |
| download | emacs-scratch/static_assert.tar.gz emacs-scratch/static_assert.zip | |
Prefer static_assert to verifyscratch/static_assert
Although static_assert is C11-specific, and Emacs remains on C99, it
has been backported to older compilers by Gnulib. Gnulib has already
changed to prefer static_assert, and we can do the same.
* lib-src/asset-directory-tool.c (main_2):
* src/alloc.c (BLOCK_ALIGN, aligned_alloc, lisp_align_malloc)
(vectorlike_nbytes, allocate_pseudovector):
* src/android.c (android_globalize_reference, android_set_dashes):
* src/android.h:
* src/androidfont.c (androidfont_draw, androidfont_text_extents):
* src/androidvfs.c:
* src/bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT)
(bidi_find_bracket_pairs):
* src/buffer.c (init_buffer_once):
* src/casefiddle.c (do_casify_multibyte_string):
* src/dispnew.c (scrolling_window, scrolling):
* src/editfns.c (styled_format):
* src/emacs-module.c (module_extract_big_integer):
* src/fileio.c (Fdo_auto_save):
* src/fns.c (next_almost_prime, hash_string):
* src/fringe.c (init_fringe):
* src/keyboard.h (kbd_buffer_store_event_hold):
* src/keymap.c:
* src/lisp.h (u, memclear, reduce_emacs_uint_to_hash_hash)
(modiff_incr):
* src/lread.c (skip_lazy_string):
* src/pdumper.c (dump_bignum, Fdump_emacs_portable)
(dump_do_dump_relocation, pdumper_load):
* src/process.c (make_process, Fmake_process)
(connect_network_socket):
* src/regex-emacs.c:
* src/sort.c (tim_sort):
* src/sysdep.c (init_random, SSIZE_MAX):
* src/thread.c:
* src/timefns.c (trillion_factor):
* src/unexelf.c:
* src/xterm.c (x_send_scroll_bar_event): Prefer static_assert to Gnulib
verify. Remove import of verify.h, except when used for other reasons.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 05aa0baef74..30063180d6c 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -94,7 +94,6 @@ To add a new module function, proceed as follows: | |||
| 94 | #include "thread.h" | 94 | #include "thread.h" |
| 95 | 95 | ||
| 96 | #include <intprops.h> | 96 | #include <intprops.h> |
| 97 | #include <verify.h> | ||
| 98 | 97 | ||
| 99 | /* Work around GCC bug 83162. */ | 98 | /* Work around GCC bug 83162. */ |
| 100 | #if GNUC_PREREQ (4, 3, 0) | 99 | #if GNUC_PREREQ (4, 3, 0) |
| @@ -1036,10 +1035,10 @@ import/export overhead on most platforms. | |||
| 1036 | 1035 | ||
| 1037 | /* Verify that emacs_limb_t indeed has unique object | 1036 | /* Verify that emacs_limb_t indeed has unique object |
| 1038 | representations. */ | 1037 | representations. */ |
| 1039 | verify (CHAR_BIT == 8); | 1038 | static_assert (CHAR_BIT == 8); |
| 1040 | verify ((sizeof (emacs_limb_t) == 4 && EMACS_LIMB_MAX == 0xFFFFFFFF) | 1039 | static_assert ((sizeof (emacs_limb_t) == 4 && EMACS_LIMB_MAX == 0xFFFFFFFF) |
| 1041 | || (sizeof (emacs_limb_t) == 8 | 1040 | || (sizeof (emacs_limb_t) == 8 |
| 1042 | && EMACS_LIMB_MAX == 0xFFFFFFFFFFFFFFFF)); | 1041 | && EMACS_LIMB_MAX == 0xFFFFFFFFFFFFFFFF)); |
| 1043 | 1042 | ||
| 1044 | static bool | 1043 | static bool |
| 1045 | module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign, | 1044 | module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign, |
| @@ -1077,7 +1076,7 @@ module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign, | |||
| 1077 | suffice. */ | 1076 | suffice. */ |
| 1078 | EMACS_UINT u; | 1077 | EMACS_UINT u; |
| 1079 | enum { required = (sizeof u + size - 1) / size }; | 1078 | enum { required = (sizeof u + size - 1) / size }; |
| 1080 | verify (0 < required && +required <= module_bignum_count_max); | 1079 | static_assert (0 < required && +required <= module_bignum_count_max); |
| 1081 | if (magnitude == NULL) | 1080 | if (magnitude == NULL) |
| 1082 | { | 1081 | { |
| 1083 | *count = required; | 1082 | *count = required; |
| @@ -1097,7 +1096,7 @@ module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign, | |||
| 1097 | u = (EMACS_UINT) x; | 1096 | u = (EMACS_UINT) x; |
| 1098 | else | 1097 | else |
| 1099 | u = -(EMACS_UINT) x; | 1098 | u = -(EMACS_UINT) x; |
| 1100 | verify (required * bits < PTRDIFF_MAX); | 1099 | static_assert (required * bits < PTRDIFF_MAX); |
| 1101 | for (ptrdiff_t i = 0; i < required; ++i) | 1100 | for (ptrdiff_t i = 0; i < required; ++i) |
| 1102 | magnitude[i] = (emacs_limb_t) (u >> (i * bits)); | 1101 | magnitude[i] = (emacs_limb_t) (u >> (i * bits)); |
| 1103 | MODULE_INTERNAL_CLEANUP (); | 1102 | MODULE_INTERNAL_CLEANUP (); |