From 85a40f3def8dbe3d549652c0b6d47fee19b07785 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Mon, 22 Apr 2024 16:59:28 +0200 Subject: [PATCH] Small changes need for GCC/Linux. * emacs.c (main): Call init_signals before init_igc; this avoids overwriting MPS's SIGSEGV handler. * fns.c: Remove spurios #include * igc.c: Minor changes to avoid GCC warnings. (igc_assert_fail): die() is already declared in lisp.h (igc_assert, IGC_CHECK_RES): Use the do { ... } while(0) idiom to avoid GCC warnings about empty statements. (scan_pure): Tell GCC that pure_bytes_used_lisp exists. (thread_ap): Abort for unhandled cases. (fix_image, igc_make_image): Add #ifdef HAVE_WINDOW_SYSTEM in places that need struct image. --- src/emacs.c | 4 ++-- src/fns.c | 1 - src/igc.c | 31 ++++++++++++++++++++++--------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 795d43e4d67..885708750da 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1425,6 +1425,8 @@ main (int argc, char **argv) ns_init_pool (); #endif + init_signals (); + #ifdef HAVE_MPS init_igc (); #endif @@ -1946,8 +1948,6 @@ main (int argc, char **argv) malloc_enable_thread (); #endif - init_signals (); - noninteractive1 = noninteractive; /* Perform basic initializations (not merely interning symbols). */ diff --git a/src/fns.c b/src/fns.c index 634f67e15ac..65994f45dcc 100644 --- a/src/fns.c +++ b/src/fns.c @@ -21,7 +21,6 @@ Copyright (C) 1985-2024 Free Software Foundation, Inc. #include #include -#include #include #include #include diff --git a/src/igc.c b/src/igc.c index ceddd66abdd..680f1a5ccb6 100644 --- a/src/igc.c +++ b/src/igc.c @@ -73,15 +73,19 @@ static void igc_assert_fail (const char *file, unsigned line, const char *msg) { - extern void die (const char *, const char *, int); die (msg, file, line); } #ifdef IGC_DEBUG -# define igc_assert(expr) \ - if (!(expr)) \ - igc_assert_fail (__FILE__, __LINE__, #expr); \ - else + +#define igc_assert(expr) \ + do \ + { \ + if (!(expr)) \ + igc_assert_fail (__FILE__, __LINE__, #expr); \ + } \ + while (0) \ + #else # define igc_assert(expr) (void) 9 #endif @@ -119,10 +123,13 @@ is_aligned (const mps_addr_t addr) return ((mps_word_t) addr & IGC_TAG_MASK) == 0; } -#define IGC_CHECK_RES(res) \ - if ((res) != MPS_RES_OK) \ - emacs_abort (); \ - else +#define IGC_CHECK_RES(res) \ + do \ + { \ + if ((res) != MPS_RES_OK) \ + emacs_abort (); \ + } \ + while (0) \ #define IGC_WITH_PARKED(gc) \ for (int i = (mps_arena_park (gc->arena), 1); i; \ @@ -802,6 +809,7 @@ scan_pure (mps_ss_t ss, void *start, void *end, void *closure) MPS_SCAN_BEGIN (ss) { igc_assert (start == (void *) pure); + extern ptrdiff_t pure_bytes_used_lisp; end = (char *) pure + pure_bytes_used_lisp; if (end > start) IGC_FIX_CALL (ss, scan_ambig (ss, start, end, NULL)); @@ -957,11 +965,13 @@ fix_image (mps_ss_t ss, struct image *i) { MPS_SCAN_BEGIN (ss) { +#ifdef HAVE_WINDOW_SYSTEM IGC_FIX12_OBJ (ss, &i->spec); IGC_FIX12_OBJ (ss, &i->dependencies); IGC_FIX12_OBJ (ss, &i->lisp_data); IGC_FIX12_RAW (ss, &i->next); IGC_FIX12_RAW (ss, &i->prev); +#endif } MPS_SCAN_END (ss); return MPS_RES_OK; @@ -2343,6 +2353,7 @@ thread_ap (enum igc_obj_type type) case IGC_OBJ_FLOAT: return t->d.leaf_ap; } + emacs_abort (); } /* Conditional breakpoints can be so slow that it is often more @@ -2573,12 +2584,14 @@ igc_make_itree_node (void) return n; } +#ifdef HAVE_WINDOW_SYSTEM struct image * igc_make_image (void) { struct image *img = alloc (sizeof *img, IGC_OBJ_IMAGE, PVEC_FREE); return img; } +#endif struct face * igc_make_face (void) -- 2.39.2