From 749096f87cecb2841ac0cb84a12ce0faf555f4ba Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 18 May 2010 08:44:56 -0500 Subject: [PATCH] Added macro to encode warning suppression --- src/racket/gc/dyn_load.c | 2 +- src/racket/gc/include/private/gc_priv.h | 6 ++++++ src/racket/gc/os_dep.c | 13 ++++++------- src/racket/gc/pthread_stop_world.c | 5 +++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/racket/gc/dyn_load.c b/src/racket/gc/dyn_load.c index 5fe133a0e8..57ddce8955 100644 --- a/src/racket/gc/dyn_load.c +++ b/src/racket/gc/dyn_load.c @@ -52,7 +52,7 @@ /* A user-supplied routine that is called to determine if a DSO must be scanned by the gc. */ -static int (*GC_has_static_roots)(const char *, void *, size_t); +MAYBE_UNUSED static int (*GC_has_static_roots)(const char *, void *, size_t); /* PLTSCHEME: added OPENBSD: */ #if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE)) \ diff --git a/src/racket/gc/include/private/gc_priv.h b/src/racket/gc/include/private/gc_priv.h index c50106a9e7..47275f815d 100644 --- a/src/racket/gc/include/private/gc_priv.h +++ b/src/racket/gc/include/private/gc_priv.h @@ -19,6 +19,12 @@ # ifndef GC_PRIVATE_H # define GC_PRIVATE_H +# ifdef __GNUC__ +# define MAYBE_UNUSED __attribute__((unused)) +# else +# define MAYBE_UNUSED +# endif + # include # if !(defined( sony_news ) ) # include diff --git a/src/racket/gc/os_dep.c b/src/racket/gc/os_dep.c index 0d94b73937..48f28569f4 100644 --- a/src/racket/gc/os_dep.c +++ b/src/racket/gc/os_dep.c @@ -1215,9 +1215,9 @@ ptr_t GC_get_main_stack_base(void) ptr_t GC_get_main_stack_base(void) { # if defined(HEURISTIC1) || defined(HEURISTIC2) - word dummy; + MAYBE_UNUSED word dummy; # endif - ptr_t result; + MAYBE_UNUSED ptr_t result; # define STACKBOTTOM_ALIGNMENT_M1 ((word)STACK_GRAN - 1) @@ -1360,7 +1360,7 @@ ptr_t GC_get_main_stack_base(void) /* FIXME - Implement better strategies here. */ int GC_get_stack_base(struct GC_stack_base *b) { - int dummy; + MAYBE_UNUSED int dummy; # ifdef NEED_FIND_LIMIT # ifdef STACK_GROWS_DOWN @@ -2920,9 +2920,8 @@ GC_bool GC_old_segv_handler_used_si; # endif /* MSWIN32 || MSWINCE */ { # if !defined(MSWIN32) && !defined(MSWINCE) - int code = si -> si_code; /* Ignore gcc unused var. warning. */ - ucontext_t * scp = (ucontext_t *)raw_sc; - /* Ignore gcc unused var. warning. */ + MAYBE_UNUSED int code = si -> si_code; + MAYBE_UNUSED ucontext_t * scp = (ucontext_t *)raw_sc; char *addr = si -> si_addr; # endif # if defined(MSWIN32) || defined(MSWINCE) @@ -3249,7 +3248,7 @@ GC_bool GC_page_was_dirty(struct hblk *h) * On other systems, SET_LOCK_HOLDER and friends must be suitably defined. */ -static GC_bool syscall_acquired_lock = FALSE; /* Protected by GC lock. */ +MAYBE_UNUSED static GC_bool syscall_acquired_lock = FALSE; /* Protected by GC lock. */ #if 0 void GC_begin_syscall(void) diff --git a/src/racket/gc/pthread_stop_world.c b/src/racket/gc/pthread_stop_world.c index 3e7bda65e4..2b8d644334 100644 --- a/src/racket/gc/pthread_stop_world.c +++ b/src/racket/gc/pthread_stop_world.c @@ -1,4 +1,5 @@ #include "private/pthread_support.h" +#include "private/gc_priv.h" #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && \ !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS) @@ -221,8 +222,8 @@ void GC_suspend_handler_inner(ptr_t sig_arg, void *context) void GC_restart_handler(int sig) { - pthread_t my_thread = pthread_self(); - GC_thread me; + MAYBE_UNUSED pthread_t my_thread = pthread_self(); + MAYBE_UNUSED GC_thread me; if (sig != SIG_THR_RESTART) ABORT("Bad signal in suspend_handler");