aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c72
-rw-r--r--src/eval.c17
-rw-r--r--src/lread.c4
3 files changed, 49 insertions, 44 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index b39ac7df057..166f6ddf93c 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -141,7 +141,7 @@ static void check_main_thread (void);
141static void finalize_environment (struct env_storage *); 141static void finalize_environment (struct env_storage *);
142static void initialize_environment (struct env_storage *); 142static void initialize_environment (struct env_storage *);
143static void module_args_out_of_range (emacs_env *, Lisp_Object, Lisp_Object); 143static void module_args_out_of_range (emacs_env *, Lisp_Object, Lisp_Object);
144static void module_handle_signal (emacs_env *, const Lisp_Object); 144static void module_handle_signal (emacs_env *, Lisp_Object);
145static void module_handle_throw (emacs_env *, Lisp_Object); 145static void module_handle_throw (emacs_env *, Lisp_Object);
146static void module_non_local_exit_signal_1 (emacs_env *, Lisp_Object, Lisp_Object); 146static void module_non_local_exit_signal_1 (emacs_env *, Lisp_Object, Lisp_Object);
147static void module_non_local_exit_throw_1 (emacs_env *, Lisp_Object, Lisp_Object); 147static void module_non_local_exit_throw_1 (emacs_env *, Lisp_Object, Lisp_Object);
@@ -201,7 +201,7 @@ static void module_wrong_type (emacs_env *, Lisp_Object, Lisp_Object);
201 return retval; \ 201 return retval; \
202 } \ 202 } \
203 verify (module_has_cleanup); \ 203 verify (module_has_cleanup); \
204 const int dummy __attribute__ ((cleanup (module_reset_handlerlist))); \ 204 int dummy __attribute__ ((cleanup (module_reset_handlerlist))); \
205 if (sys_setjmp (c->jmp)) \ 205 if (sys_setjmp (c->jmp)) \
206 { \ 206 { \
207 (handlerfunc) (env, c->val); \ 207 (handlerfunc) (env, c->val); \
@@ -263,7 +263,7 @@ module_make_global_ref (emacs_env *env, emacs_value ref)
263 { 263 {
264 Lisp_Object value = HASH_VALUE (h, i); 264 Lisp_Object value = HASH_VALUE (h, i);
265 eassert (NATNUMP (value)); 265 eassert (NATNUMP (value));
266 const EMACS_UINT refcount = XFASTINT (value); 266 EMACS_UINT refcount = XFASTINT (value);
267 if (refcount >= MOST_POSITIVE_FIXNUM) 267 if (refcount >= MOST_POSITIVE_FIXNUM)
268 { 268 {
269 module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil); 269 module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil);
@@ -297,7 +297,7 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
297 { 297 {
298 Lisp_Object value = HASH_VALUE (h, i); 298 Lisp_Object value = HASH_VALUE (h, i);
299 eassert (NATNUMP (value)); 299 eassert (NATNUMP (value));
300 const EMACS_UINT refcount = XFASTINT (value); 300 EMACS_UINT refcount = XFASTINT (value);
301 eassert (refcount > 0); 301 eassert (refcount > 0);
302 if (refcount > 1) 302 if (refcount > 1)
303 { 303 {
@@ -329,7 +329,7 @@ static enum emacs_funcall_exit
329module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data) 329module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data)
330{ 330{
331 check_main_thread (); 331 check_main_thread ();
332 struct emacs_env_private *const p = env->private_members; 332 struct emacs_env_private *p = env->private_members;
333 if (p->pending_non_local_exit != emacs_funcall_exit_return) 333 if (p->pending_non_local_exit != emacs_funcall_exit_return)
334 { 334 {
335 *sym = &p->non_local_exit_symbol; 335 *sym = &p->non_local_exit_symbol;
@@ -366,7 +366,7 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
366 366
367static emacs_value 367static emacs_value
368module_make_function (emacs_env *env, int min_arity, int max_arity, 368module_make_function (emacs_env *env, int min_arity, int max_arity,
369 emacs_subr subr, const char *const documentation, 369 emacs_subr subr, const char *documentation,
370 void *data) 370 void *data)
371{ 371{
372 check_main_thread (); 372 check_main_thread ();
@@ -456,7 +456,7 @@ module_extract_integer (emacs_env *env, emacs_value n)
456{ 456{
457 check_main_thread (); 457 check_main_thread ();
458 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 458 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
459 const Lisp_Object l = value_to_lisp (n); 459 Lisp_Object l = value_to_lisp (n);
460 if (! INTEGERP (l)) 460 if (! INTEGERP (l))
461 { 461 {
462 module_wrong_type (env, Qintegerp, l); 462 module_wrong_type (env, Qintegerp, l);
@@ -483,7 +483,7 @@ module_extract_float (emacs_env *env, emacs_value f)
483{ 483{
484 check_main_thread (); 484 check_main_thread ();
485 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 485 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
486 const Lisp_Object lisp = value_to_lisp (f); 486 Lisp_Object lisp = value_to_lisp (f);
487 if (! FLOATP (lisp)) 487 if (! FLOATP (lisp))
488 { 488 {
489 module_wrong_type (env, Qfloatp, lisp); 489 module_wrong_type (env, Qfloatp, lisp);
@@ -562,7 +562,7 @@ module_get_user_ptr (emacs_env *env, emacs_value uptr)
562{ 562{
563 check_main_thread (); 563 check_main_thread ();
564 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 564 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
565 const Lisp_Object lisp = value_to_lisp (uptr); 565 Lisp_Object lisp = value_to_lisp (uptr);
566 if (! USER_PTRP (lisp)) 566 if (! USER_PTRP (lisp))
567 { 567 {
568 module_wrong_type (env, Quser_ptr, lisp); 568 module_wrong_type (env, Quser_ptr, lisp);
@@ -576,8 +576,9 @@ module_set_user_ptr (emacs_env *env, emacs_value uptr, void *ptr)
576{ 576{
577 check_main_thread (); 577 check_main_thread ();
578 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 578 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
579 const Lisp_Object lisp = value_to_lisp (uptr); 579 Lisp_Object lisp = value_to_lisp (uptr);
580 if (! USER_PTRP (lisp)) module_wrong_type (env, Quser_ptr, lisp); 580 if (! USER_PTRP (lisp))
581 module_wrong_type (env, Quser_ptr, lisp);
581 XUSER_PTR (lisp)->p = ptr; 582 XUSER_PTR (lisp)->p = ptr;
582} 583}
583 584
@@ -586,7 +587,7 @@ module_get_user_finalizer (emacs_env *env, emacs_value uptr)
586{ 587{
587 check_main_thread (); 588 check_main_thread ();
588 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 589 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
589 const Lisp_Object lisp = value_to_lisp (uptr); 590 Lisp_Object lisp = value_to_lisp (uptr);
590 if (! USER_PTRP (lisp)) 591 if (! USER_PTRP (lisp))
591 { 592 {
592 module_wrong_type (env, Quser_ptr, lisp); 593 module_wrong_type (env, Quser_ptr, lisp);
@@ -601,8 +602,9 @@ module_set_user_finalizer (emacs_env *env, emacs_value uptr,
601{ 602{
602 check_main_thread (); 603 check_main_thread ();
603 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); 604 eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
604 const Lisp_Object lisp = value_to_lisp (uptr); 605 Lisp_Object lisp = value_to_lisp (uptr);
605 if (! USER_PTRP (lisp)) module_wrong_type (env, Quser_ptr, lisp); 606 if (! USER_PTRP (lisp))
607 module_wrong_type (env, Quser_ptr, lisp);
606 XUSER_PTR (lisp)->finalizer = fin; 608 XUSER_PTR (lisp)->finalizer = fin;
607} 609}
608 610
@@ -649,7 +651,7 @@ module_vec_get (emacs_env *env, emacs_value vec, size_t i)
649 return NULL; 651 return NULL;
650 } 652 }
651 /* Prevent error-prone comparison between types of different signedness. */ 653 /* Prevent error-prone comparison between types of different signedness. */
652 const size_t size = ASIZE (lvec); 654 size_t size = ASIZE (lvec);
653 eassert (size >= 0); 655 eassert (size >= 0);
654 if (i >= size) 656 if (i >= size)
655 { 657 {
@@ -734,8 +736,8 @@ ENVOBJ is a save pointer to a module_fun_env structure.
734ARGLIST is a list of arguments passed to SUBRPTR. */) 736ARGLIST is a list of arguments passed to SUBRPTR. */)
735 (Lisp_Object envobj, Lisp_Object arglist) 737 (Lisp_Object envobj, Lisp_Object arglist)
736{ 738{
737 const struct module_fun_env *const envptr = XSAVE_POINTER (envobj, 0); 739 struct module_fun_env *envptr = XSAVE_POINTER (envobj, 0);
738 const EMACS_INT len = XINT (Flength (arglist)); 740 EMACS_INT len = XINT (Flength (arglist));
739 eassert (len >= 0); 741 eassert (len >= 0);
740 if (len > MOST_POSITIVE_FIXNUM) 742 if (len > MOST_POSITIVE_FIXNUM)
741 xsignal0 (Qoverflow_error); 743 xsignal0 (Qoverflow_error);
@@ -771,14 +773,14 @@ ARGLIST is a list of arguments passed to SUBRPTR. */)
771 case emacs_funcall_exit_signal: 773 case emacs_funcall_exit_signal:
772 { 774 {
773 Lisp_Object symbol = value_to_lisp (&env.priv.non_local_exit_symbol); 775 Lisp_Object symbol = value_to_lisp (&env.priv.non_local_exit_symbol);
774 const Lisp_Object data = value_to_lisp (&env.priv.non_local_exit_data); 776 Lisp_Object data = value_to_lisp (&env.priv.non_local_exit_data);
775 finalize_environment (&env); 777 finalize_environment (&env);
776 xsignal (symbol, data); 778 xsignal (symbol, data);
777 } 779 }
778 case emacs_funcall_exit_throw: 780 case emacs_funcall_exit_throw:
779 { 781 {
780 const Lisp_Object tag = value_to_lisp (&env.priv.non_local_exit_symbol); 782 Lisp_Object tag = value_to_lisp (&env.priv.non_local_exit_symbol);
781 const Lisp_Object value = value_to_lisp (&env.priv.non_local_exit_data); 783 Lisp_Object value = value_to_lisp (&env.priv.non_local_exit_data);
782 finalize_environment (&env); 784 finalize_environment (&env);
783 Fthrow (tag, value); 785 Fthrow (tag, value);
784 } 786 }
@@ -810,7 +812,7 @@ static void
810module_non_local_exit_signal_1 (emacs_env *env, Lisp_Object sym, 812module_non_local_exit_signal_1 (emacs_env *env, Lisp_Object sym,
811 Lisp_Object data) 813 Lisp_Object data)
812{ 814{
813 struct emacs_env_private *const p = env->private_members; 815 struct emacs_env_private *p = env->private_members;
814 eassert (p->pending_non_local_exit == emacs_funcall_exit_return); 816 eassert (p->pending_non_local_exit == emacs_funcall_exit_return);
815 p->pending_non_local_exit = emacs_funcall_exit_signal; 817 p->pending_non_local_exit = emacs_funcall_exit_signal;
816 p->non_local_exit_symbol.v = sym; 818 p->non_local_exit_symbol.v = sym;
@@ -821,7 +823,7 @@ static void
821module_non_local_exit_throw_1 (emacs_env *env, Lisp_Object tag, 823module_non_local_exit_throw_1 (emacs_env *env, Lisp_Object tag,
822 Lisp_Object value) 824 Lisp_Object value)
823{ 825{
824 struct emacs_env_private *const p = env->private_members; 826 struct emacs_env_private *p = env->private_members;
825 eassert (p->pending_non_local_exit == emacs_funcall_exit_return); 827 eassert (p->pending_non_local_exit == emacs_funcall_exit_return);
826 p->pending_non_local_exit = emacs_funcall_exit_throw; 828 p->pending_non_local_exit = emacs_funcall_exit_throw;
827 p->non_local_exit_symbol.v = tag; 829 p->non_local_exit_symbol.v = tag;
@@ -869,7 +871,7 @@ value_to_lisp (emacs_value v)
869static emacs_value 871static emacs_value
870lisp_to_value (emacs_env *env, Lisp_Object o) 872lisp_to_value (emacs_env *env, Lisp_Object o)
871{ 873{
872 struct emacs_env_private *const p = env->private_members; 874 struct emacs_env_private *p = env->private_members;
873 if (p->pending_non_local_exit != emacs_funcall_exit_return) 875 if (p->pending_non_local_exit != emacs_funcall_exit_return)
874 return NULL; 876 return NULL;
875 return allocate_emacs_value (env, &p->storage, o); 877 return allocate_emacs_value (env, &p->storage, o);
@@ -903,7 +905,7 @@ finalize_storage (struct emacs_value_storage *storage)
903 struct emacs_value_frame *next = storage->initial.next; 905 struct emacs_value_frame *next = storage->initial.next;
904 while (next != NULL) 906 while (next != NULL)
905 { 907 {
906 struct emacs_value_frame *const current = next; 908 struct emacs_value_frame *current = next;
907 next = current->next; 909 next = current->next;
908 free (current); 910 free (current);
909 } 911 }
@@ -929,7 +931,7 @@ allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
929 initialize_frame (storage->current->next); 931 initialize_frame (storage->current->next);
930 storage->current = storage->current->next; 932 storage->current = storage->current->next;
931 } 933 }
932 const emacs_value value = storage->current->objects + storage->current->offset; 934 emacs_value value = storage->current->objects + storage->current->offset;
933 value->v = obj; 935 value->v = obj;
934 ++storage->current->offset; 936 ++storage->current->offset;
935 return value; 937 return value;
@@ -941,8 +943,8 @@ void mark_modules (void)
941{ 943{
942 for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem)) 944 for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem))
943 { 945 {
944 const struct env_storage *const env = XSAVE_POINTER (tem, 0); 946 struct env_storage *env = XSAVE_POINTER (tem, 0);
945 for (const struct emacs_value_frame *frame = &env->priv.storage.initial; 947 for (struct emacs_value_frame *frame = &env->priv.storage.initial;
946 frame != NULL; 948 frame != NULL;
947 frame = frame->next) 949 frame = frame->next)
948 for (size_t i = 0; i < frame->offset; ++i) 950 for (size_t i = 0; i < frame->offset; ++i)
@@ -1016,7 +1018,7 @@ module_reset_handlerlist (const int *dummy)
1016/* Called on `signal'. ERR is a pair (SYMBOL . DATA), which gets 1018/* Called on `signal'. ERR is a pair (SYMBOL . DATA), which gets
1017 stored in the environment. Set the pending non-local exit flag. */ 1019 stored in the environment. Set the pending non-local exit flag. */
1018static void 1020static void
1019module_handle_signal (emacs_env *const env, const Lisp_Object err) 1021module_handle_signal (emacs_env *env, Lisp_Object err)
1020{ 1022{
1021 module_non_local_exit_signal_1 (env, XCAR (err), XCDR (err)); 1023 module_non_local_exit_signal_1 (env, XCAR (err), XCDR (err));
1022} 1024}
@@ -1024,7 +1026,7 @@ module_handle_signal (emacs_env *const env, const Lisp_Object err)
1024/* Called on `throw'. TAG_VAL is a pair (TAG . VALUE), which gets 1026/* Called on `throw'. TAG_VAL is a pair (TAG . VALUE), which gets
1025 stored in the environment. Set the pending non-local exit flag. */ 1027 stored in the environment. Set the pending non-local exit flag. */
1026static void 1028static void
1027module_handle_throw (emacs_env *const env, const Lisp_Object tag_val) 1029module_handle_throw (emacs_env *env, Lisp_Object tag_val)
1028{ 1030{
1029 module_non_local_exit_throw_1 (env, XCAR (tag_val), XCDR (tag_val)); 1031 module_non_local_exit_throw_1 (env, XCAR (tag_val), XCDR (tag_val));
1030} 1032}
@@ -1035,14 +1037,14 @@ module_handle_throw (emacs_env *const env, const Lisp_Object tag_val)
1035/* Return a string object that contains a user-friendly 1037/* Return a string object that contains a user-friendly
1036 representation of the function environment. */ 1038 representation of the function environment. */
1037static Lisp_Object 1039static Lisp_Object
1038module_format_fun_env (const struct module_fun_env *const env) 1040module_format_fun_env (const struct module_fun_env *env)
1039{ 1041{
1040 /* Try to print a function name if possible. */ 1042 /* Try to print a function name if possible. */
1041 const char *path, *sym; 1043 const char *path, *sym;
1042 if (dynlib_addr (env->subr, &path, &sym)) 1044 if (dynlib_addr (env->subr, &path, &sym))
1043 { 1045 {
1044 const char *const format = "#<module function %s from %s>"; 1046 static char const format[] = "#<module function %s from %s>";
1045 const int size = snprintf (NULL, 0, format, sym, path); 1047 int size = snprintf (NULL, 0, format, sym, path);
1046 eassert (size > 0); 1048 eassert (size > 0);
1047 char buffer[size + 1]; 1049 char buffer[size + 1];
1048 snprintf (buffer, sizeof buffer, format, sym, path); 1050 snprintf (buffer, sizeof buffer, format, sym, path);
@@ -1050,9 +1052,9 @@ module_format_fun_env (const struct module_fun_env *const env)
1050 } 1052 }
1051 else 1053 else
1052 { 1054 {
1053 const char *const format = "#<module function at %p>"; 1055 static char const format[] = "#<module function at %p>";
1054 const void *const subr = env->subr; 1056 void *subr = env->subr;
1055 const int size = snprintf (NULL, 0, format, subr); 1057 int size = snprintf (NULL, 0, format, subr);
1056 eassert (size > 0); 1058 eassert (size > 0);
1057 char buffer[size + 1]; 1059 char buffer[size + 1];
1058 snprintf (buffer, sizeof buffer, format, subr); 1060 snprintf (buffer, sizeof buffer, format, subr);
diff --git a/src/eval.c b/src/eval.c
index 9c171473b43..22ee4d1afd1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1399,8 +1399,9 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1399static void init_handler (struct handler *c, Lisp_Object tag_ch_val, 1399static void init_handler (struct handler *c, Lisp_Object tag_ch_val,
1400 enum handlertype handlertype); 1400 enum handlertype handlertype);
1401 1401
1402void push_handler (struct handler **const c, const Lisp_Object tag_ch_val, 1402void
1403 const enum handlertype handlertype) 1403push_handler (struct handler **c, Lisp_Object tag_ch_val,
1404 enum handlertype handlertype)
1404{ 1405{
1405 if (handlerlist->nextfree) 1406 if (handlerlist->nextfree)
1406 *c = handlerlist->nextfree; 1407 *c = handlerlist->nextfree;
@@ -1413,14 +1414,15 @@ void push_handler (struct handler **const c, const Lisp_Object tag_ch_val,
1413 init_handler (*c, tag_ch_val, handlertype); 1414 init_handler (*c, tag_ch_val, handlertype);
1414} 1415}
1415 1416
1416bool push_handler_nosignal (struct handler **const c, const Lisp_Object tag_ch_val, 1417bool
1417 const enum handlertype handlertype) 1418push_handler_nosignal (struct handler **c, Lisp_Object tag_ch_val,
1419 enum handlertype handlertype)
1418{ 1420{
1419 if (handlerlist->nextfree) 1421 if (handlerlist->nextfree)
1420 *c = handlerlist->nextfree; 1422 *c = handlerlist->nextfree;
1421 else 1423 else
1422 { 1424 {
1423 struct handler *const h = malloc (sizeof (struct handler)); 1425 struct handler *h = malloc (sizeof (struct handler));
1424 if (! h) return false; 1426 if (! h) return false;
1425 *c = h; 1427 *c = h;
1426 h->nextfree = NULL; 1428 h->nextfree = NULL;
@@ -1430,8 +1432,9 @@ bool push_handler_nosignal (struct handler **const c, const Lisp_Object tag_ch_v
1430 return true; 1432 return true;
1431} 1433}
1432 1434
1433static void init_handler (struct handler *const c, const Lisp_Object tag_ch_val, 1435static void
1434 const enum handlertype handlertype) 1436init_handler (struct handler *c, Lisp_Object tag_ch_val,
1437 enum handlertype handlertype)
1435{ 1438{
1436 c->type = handlertype; 1439 c->type = handlertype;
1437 c->tag_or_ch = tag_ch_val; 1440 c->tag_or_ch = tag_ch_val;
diff --git a/src/lread.c b/src/lread.c
index c0fa0d06b9c..f7ce0daf1fa 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -979,8 +979,8 @@ This uses the variables `load-suffixes' and `load-file-rep-suffixes'. */)
979static bool 979static bool
980suffix_p (Lisp_Object string, const char *suffix) 980suffix_p (Lisp_Object string, const char *suffix)
981{ 981{
982 const size_t suffix_len = strlen (suffix); 982 size_t suffix_len = strlen (suffix);
983 const size_t string_len = SBYTES (string); 983 size_t string_len = SBYTES (string);
984 984
985 return string_len >= suffix_len && !strcmp (SSDATA (string) + string_len - suffix_len, suffix); 985 return string_len >= suffix_len && !strcmp (SSDATA (string) + string_len - suffix_len, suffix);
986} 986}