aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2019-03-19 12:37:13 -0700
committerPaul Eggert2019-03-19 12:37:36 -0700
commit53914a10558a0a579bb30d95da93d677901bc4a9 (patch)
tree7fc6c0c091b7d380fbfc9b7411b3b646eed59fde /src/lisp.h
parent3ed1621d843e057ad879fbed3605d32f55a065b9 (diff)
downloademacs-53914a10558a0a579bb30d95da93d677901bc4a9.tar.gz
emacs-53914a10558a0a579bb30d95da93d677901bc4a9.zip
Use ‘const’ to clarify GC marking
Add ‘const’ to make the GC marking code a bit clearer. This can also help the compiler in some cases, I think because GCC can now determine more often that the value of a static C variable can be cached when its address is now converted to ‘Lisp Object const *’ before escaping. * src/alloc.c (staticvec, mark_maybe_objects, mark_memory) (mark_stack, staticpro, mark_object_root_visitor) (garbage_collect_1): * src/pdumper.c (dump_ptr_referrer, dump_emacs_reloc_to_lv) (dump_emacs_reloc_to_emacs_ptr_raw, dump_root_visitor): * src/lisp.h (vcopy, struct gc_root_visitor): * src/sysdep.c (stack_overflow): * src/thread.c (mark_one_thread): * src/thread.h (struct thread_state): Use pointer-to-const instead of plain pointer in some GC-related places where either will do.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/lisp.h b/src/lisp.h
index cb142b9d8ad..8ec892f17b9 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -631,7 +631,8 @@ extern _Noreturn void wrong_type_argument (Lisp_Object, Lisp_Object);
631 subsequent starts. */ 631 subsequent starts. */
632extern bool initialized; 632extern bool initialized;
633 633
634extern struct gflags { 634extern struct gflags
635{
635 /* True means this Emacs instance was born to dump. */ 636 /* True means this Emacs instance was born to dump. */
636#if defined HAVE_PDUMPER || defined HAVE_UNEXEC 637#if defined HAVE_PDUMPER || defined HAVE_UNEXEC
637 bool will_dump_ : 1; 638 bool will_dump_ : 1;
@@ -3316,10 +3317,10 @@ extern Lisp_Object Vascii_canon_table;
3316 3317
3317/* Call staticpro (&var) to protect static variable `var'. */ 3318/* Call staticpro (&var) to protect static variable `var'. */
3318 3319
3319void staticpro (Lisp_Object *); 3320void staticpro (Lisp_Object const *);
3320 3321
3321enum { NSTATICS = 2048 }; 3322enum { NSTATICS = 2048 };
3322extern Lisp_Object *staticvec[NSTATICS]; 3323extern Lisp_Object const *staticvec[NSTATICS];
3323extern int staticidx; 3324extern int staticidx;
3324 3325
3325 3326
@@ -3341,7 +3342,8 @@ struct frame;
3341/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */ 3342/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */
3342 3343
3343INLINE void 3344INLINE void
3344vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count) 3345vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object const *args,
3346 ptrdiff_t count)
3345{ 3347{
3346 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v)); 3348 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
3347 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args); 3349 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
@@ -3771,8 +3773,8 @@ extern void refill_memory_reserve (void);
3771#endif 3773#endif
3772extern void alloc_unexec_pre (void); 3774extern void alloc_unexec_pre (void);
3773extern void alloc_unexec_post (void); 3775extern void alloc_unexec_post (void);
3774extern void mark_maybe_objects (Lisp_Object *, ptrdiff_t); 3776extern void mark_maybe_objects (Lisp_Object const *, ptrdiff_t);
3775extern void mark_stack (char *, char *); 3777extern void mark_stack (char const *, char const *);
3776extern void flush_stack_call_func (void (*func) (void *arg), void *arg); 3778extern void flush_stack_call_func (void (*func) (void *arg), void *arg);
3777extern void garbage_collect (void); 3779extern void garbage_collect (void);
3778extern const char *pending_malloc_warning; 3780extern const char *pending_malloc_warning;
@@ -3800,17 +3802,17 @@ extern Lisp_Object pure_listn (ptrdiff_t, Lisp_Object, ...);
3800#define pure_list(...) \ 3802#define pure_list(...) \
3801 pure_listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__) 3803 pure_listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__)
3802 3804
3803enum gc_root_type { 3805enum gc_root_type
3806{
3804 GC_ROOT_STATICPRO, 3807 GC_ROOT_STATICPRO,
3805 GC_ROOT_BUFFER_LOCAL_DEFAULT, 3808 GC_ROOT_BUFFER_LOCAL_DEFAULT,
3806 GC_ROOT_BUFFER_LOCAL_NAME, 3809 GC_ROOT_BUFFER_LOCAL_NAME,
3807 GC_ROOT_C_SYMBOL 3810 GC_ROOT_C_SYMBOL
3808}; 3811};
3809 3812
3810struct gc_root_visitor { 3813struct gc_root_visitor
3811 void (*visit)(Lisp_Object *root_ptr, 3814{
3812 enum gc_root_type type, 3815 void (*visit) (Lisp_Object const *, enum gc_root_type, void *);
3813 void *data);
3814 void *data; 3816 void *data;
3815}; 3817};
3816extern void visit_static_gc_roots (struct gc_root_visitor visitor); 3818extern void visit_static_gc_roots (struct gc_root_visitor visitor);