diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-09-15 08:14:08 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-09-15 10:23:49 +0300 |
commit | 77c069df3ea02551fcf82e0ccd8ea2e68739ac3c (patch) | |
tree | 7b7e70499567fbf655fe102298c146315995571f | |
parent | a8e6d322879051cc4862d2055eeb2ffa5a3d0db4 (diff) | |
download | bdwgc-77c069df3ea02551fcf82e0ccd8ea2e68739ac3c.tar.gz |
Use cast to void instead of the attribute to indicate unused arguments
(refactoring)
* CMakeLists.txt [BORLAND] (add_compile_options): Remove "/w-par";
reorder options.
* CMakeLists.txt [!BORLAND && MSVC] (add_compile_options): Remove
"/wd4100"; update comment.
* NT_MAKEFILE (.c.obj): Likewise.
* allchblk.c [!NO_DEBUGGING || GC_ASSERTIONS] (add_hb_sz): Use
UNUSED_ARG() instead of GC_ATTR_UNUSED.
* allchblk.c [USE_MUNMAP] (GC_adjust_num_unmapped): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (pop_in_progress, reset_back_edge,
update_max_height): Likewise.
* checksums.c [CHECKSUMS] (GC_add_block): Likewise.
* darwin_stop_world.c (GC_stack_range_for): Likewise.
* dbg_mlc.c (GC_store_debug_info_inner, GC_debug_change_stubborn,
GC_check_heap_block): Likewise.
* finalize.c [!GC_NO_FINALIZATION] (GC_null_finalize_mark_proc):
Likewise.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_fake_mark_proc): Likewise.
* mallocx.c [!CPPCHECK] (GC_change_stubborn): Likewise.
* mark.c (GC_noop6, clear_marks_for_block): Likewise.
* mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__]
(mark_ex_handler): Likewise.
* mark.c [GC_DISABLE_INCREMENTAL] (GC_push_conditional): Likewise.
* mark_rts.c (GC_push_current_stack, GC_push_roots): Likewise.
* misc.c (GC_default_oom_fn, GC_set_handle_fork): Likewise.
* misc.c [THREADS && !SIGNAL_BASED_STOP_WORLD] (GC_set_suspend_signal,
GC_set_thr_restart_signal): Likewise.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): Likewise.
* misc.c [!THREADS] (GC_do_blocking_inner): Likewise.
* misc.c [!PARALLEL_MARK] (GC_set_markers_count): Likewise.
* os_dep.c [OPENBSD] (GC_fault_handler_openbsd): Likewise.
* os_dep.c [NEED_FIND_LIMIT || WRAP_MARK_SOME && !MSWIN32 && !MSWINCE
|| USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler): Likewise.
* os_dep.c [!HAVE_GET_STACK_BASE && !NEED_FIND_LIMIT]
(GC_get_stack_base): Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state,
catch_exception_raise_state_identity, catch_exception_raise): Likewise.
* pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS
&& !SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_sigaction): Likewise.
* pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS]
(GC_suspend_handler_inner): Likewise.
* pthread_support.c (GC_do_blocking_inner): Likewise.
* pthread_support.c [GC_ENABLE_SUSPEND_THREAD
&& SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise.
* tests/gctest.c [!DBG_HDRS_ALL] (fail_proc1): Likewise.
* tests/gctest.c [(MSWIN32 && !__MINGW32__ || MSWINCE)
&& !NO_WINMAIN_ENTRY] (WinMain): Likewise.
* tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS
&& CPPCHECK && RTEMS] (Init): Likewise.
* tests/gctest.c [GC_WIN32_THREADS && !GC_PTHREADS] (thr_run_one_test):
Likewise.
* tests/gctest.c [MSWINCE] (thr_window): Likewise.
* tests/gctest.c [GC_PTHREADS] (thr_run_one_test): Likewise.
* typd_mlc.c (GC_array_mark_proc): Likewise.
* win32_threads.c (GC_register_altstack, GC_do_blocking_inner):
Likewise.
* win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY]
(GC_DllMain): Likewise.
* cord/cordxtra.c (CORD_ATTR_UNUSED): Remove.
* include/private/gc_priv.h [!GC_ATTR_UNUSED] (GC_ATTR_UNUSED):
Likewise.
* cord/cordxtra.c (CORD_nul_func): Cast unused argument to void instead
of using CORD_ATTR_UNUSED.
* cord/cordxtra.c [!GC_NO_FINALIZATION] (CORD_lf_close_proc): Likewise.
* include/private/gc_priv.h [!UNUSED_ARG] (UNUSED_ARG): Define macro.
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | NT_MAKEFILE | 2 | ||||
-rw-r--r-- | allchblk.c | 10 | ||||
-rw-r--r-- | alloc.c | 4 | ||||
-rw-r--r-- | backgraph.c | 15 | ||||
-rw-r--r-- | checksums.c | 4 | ||||
-rw-r--r-- | cord/cordxtra.c | 12 | ||||
-rw-r--r-- | darwin_stop_world.c | 24 | ||||
-rw-r--r-- | dbg_mlc.c | 16 | ||||
-rw-r--r-- | finalize.c | 5 | ||||
-rw-r--r-- | gcj_mlc.c | 8 | ||||
-rw-r--r-- | include/private/gc_priv.h | 10 | ||||
-rw-r--r-- | mallocx.c | 4 | ||||
-rw-r--r-- | mark.c | 25 | ||||
-rw-r--r-- | mark_rts.c | 10 | ||||
-rw-r--r-- | misc.c | 32 | ||||
-rw-r--r-- | os_dep.c | 68 | ||||
-rw-r--r-- | pthread_stop_world.c | 11 | ||||
-rw-r--r-- | pthread_support.c | 7 | ||||
-rw-r--r-- | tests/gctest.c | 53 | ||||
-rw-r--r-- | typd_mlc.c | 3 | ||||
-rw-r--r-- | win32_threads.c | 20 |
22 files changed, 209 insertions, 141 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c2fc136a..29c31dde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,11 +130,10 @@ endif() # Output all warnings. if (BORLAND) # All warnings except for particular ones. - add_compile_options(/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch) + add_compile_options(/w /w-aus /w-ccc /w-inl /w-pro /w-rch) elseif (MSVC) - # All warnings but ignoring "unreferenced formal parameter" and - # "conditional expression is constant" ones. - add_compile_options(/W4 /wd4100 /wd4127) + # All warnings but ignoring "conditional expression is constant" one. + add_compile_options(/W4 /wd4127) # Disable crt security warnings, since unfortunately they warn about all # sorts of safe uses of strncpy. add_definitions("-D_CRT_SECURE_NO_DEPRECATE") diff --git a/NT_MAKEFILE b/NT_MAKEFILE index 0a1a4428..7ba8738b 100644 --- a/NT_MAKEFILE +++ b/NT_MAKEFILE @@ -111,7 +111,7 @@ check: check-deps cpptest.exe .c.obj: - $(cc) $(cdebug) $(cflags) $(CFLAGS_SPECIFIC) $(CORDFLAG) -Iinclude -I$(AO_INCLUDE_DIR) $(CFLAGS_DEFAULT) -D_CRT_SECURE_NO_DEPRECATE $(CFLAGS_EXTRA) $*.c /Fo$*.obj /wd4100 /wd4127 /wd4701 + $(cc) $(cdebug) $(cflags) $(CFLAGS_SPECIFIC) $(CORDFLAG) -Iinclude -I$(AO_INCLUDE_DIR) $(CFLAGS_DEFAULT) -D_CRT_SECURE_NO_DEPRECATE $(CFLAGS_EXTRA) $*.c /Fo$*.obj /wd4127 /wd4701 # Disable crt security warnings, since unfortunately they warn about all sorts # of safe uses of strncpy. It would be nice to leave the rest enabled. @@ -115,9 +115,9 @@ STATIC int GC_hblk_fl_from_blocks(word blocks_needed) # endif /* !USE_MUNMAP */ #if !defined(NO_DEBUGGING) || defined(GC_ASSERTIONS) - static void GC_CALLBACK add_hb_sz(struct hblk *h, int i GC_ATTR_UNUSED, - GC_word client_data) + static void GC_CALLBACK add_hb_sz(struct hblk *h, int i, GC_word client_data) { + UNUSED_ARG(i); *(word *)client_data += HDR(h) -> hb_sz; } @@ -465,11 +465,13 @@ STATIC void GC_add_to_fl(struct hblk *h, hdr *hhdr) /* Update GC_num_unmapped_regions assuming the block h changes */ /* from its current state of mapped/unmapped to the opposite state. */ -GC_INLINE void GC_adjust_num_unmapped(struct hblk *h GC_ATTR_UNUSED, - hdr *hhdr GC_ATTR_UNUSED) +GC_INLINE void GC_adjust_num_unmapped(struct hblk *h, hdr *hhdr) { # ifdef COUNT_UNMAPPED_REGIONS GC_num_unmapped_regions += calc_num_unmapped_regions_delta(h, hhdr); +# else + UNUSED_ARG(h); + UNUSED_ARG(hhdr); # endif } @@ -1253,7 +1253,7 @@ STATIC void GC_finish_collection(void) /* If stop_func == 0 then GC_default_stop_func is used instead. */ STATIC GC_bool GC_try_to_collect_general(GC_stop_func stop_func, - GC_bool force_unmap GC_ATTR_UNUSED) + GC_bool force_unmap) { GC_bool result; IF_USE_MUNMAP(int old_unmap_threshold;) @@ -1270,6 +1270,8 @@ STATIC GC_bool GC_try_to_collect_general(GC_stop_func stop_func, if (force_unmap || (GC_force_unmap_on_gcollect && old_unmap_threshold > 0)) GC_unmap_threshold = 1; /* unmap as much as possible */ +# else + UNUSED_ARG(force_unmap); # endif ENTER_GC(); /* Minimize junk left in my registers */ diff --git a/backgraph.c b/backgraph.c index 69b71218..f45eb505 100644 --- a/backgraph.c +++ b/backgraph.c @@ -175,8 +175,11 @@ static GC_bool is_in_progress(ptr_t p) return FALSE; } -GC_INLINE void pop_in_progress(ptr_t p GC_ATTR_UNUSED) +GC_INLINE void pop_in_progress(ptr_t p) { +# ifndef GC_ASSERTIONS + UNUSED_ARG(p); +# endif --n_in_progress; GC_ASSERT(in_progress_space[n_in_progress] == p); } @@ -302,9 +305,10 @@ GC_INLINE void GC_apply_to_each_object(per_object_func f) GC_apply_to_all_blocks(per_object_helper, (word)f); } -static void reset_back_edge(ptr_t p, size_t n_bytes GC_ATTR_UNUSED, - word gc_descr GC_ATTR_UNUSED) +static void reset_back_edge(ptr_t p, size_t n_bytes, word gc_descr) { + UNUSED_ARG(n_bytes); + UNUSED_ARG(gc_descr); /* Skip any free list links, or dropped blocks */ if (GC_HAS_DEBUG_INFO(p)) { ptr_t old_back_ptr = GET_OH_BG_PTR(p); @@ -453,9 +457,10 @@ STATIC ptr_t GC_deepest_obj = NULL; /* next GC. */ /* Set GC_max_height to be the maximum height we encounter, and */ /* GC_deepest_obj to be the corresponding object. */ -static void update_max_height(ptr_t p, size_t n_bytes GC_ATTR_UNUSED, - word gc_descr GC_ATTR_UNUSED) +static void update_max_height(ptr_t p, size_t n_bytes, word gc_descr) { + UNUSED_ARG(n_bytes); + UNUSED_ARG(gc_descr); if (GC_is_marked(p) && GC_HAS_DEBUG_INFO(p)) { word p_height = 0; ptr_t p_deepest_obj = 0; diff --git a/checksums.c b/checksums.c index f6188c75..01ee1610 100644 --- a/checksums.c +++ b/checksums.c @@ -114,11 +114,11 @@ STATIC void GC_update_check_page(struct hblk *h, int index) word GC_bytes_in_used_blocks = 0; -STATIC void GC_CALLBACK GC_add_block(struct hblk *h, - GC_word dummy GC_ATTR_UNUSED) +STATIC void GC_CALLBACK GC_add_block(struct hblk *h, GC_word dummy) { hdr * hhdr = HDR(h); + UNUSED_ARG(dummy); GC_bytes_in_used_blocks += (hhdr->hb_sz + HBLKSIZE-1) & ~(HBLKSIZE-1); } diff --git a/cord/cordxtra.c b/cord/cordxtra.c index a6d87579..7cd25cad 100644 --- a/cord/cordxtra.c +++ b/cord/cordxtra.c @@ -63,12 +63,6 @@ typedef void (* oom_fn)(void); ABORT("Out of memory"); } # define ABORT(msg) { fprintf(stderr, "%s\n", msg); abort(); } -#if GC_GNUC_PREREQ(3, 4) -# define CORD_ATTR_UNUSED __attribute__((__unused__)) -#else -# define CORD_ATTR_UNUSED /* empty */ -#endif - CORD CORD_cat_char(CORD x, char c) { char * string; @@ -427,8 +421,9 @@ void CORD_ec_append_cord(CORD_ec x, CORD s) x[0].ec_cord = CORD_cat(x[0].ec_cord, s); } -char CORD_nul_func(size_t i CORD_ATTR_UNUSED, void * client_data) +char CORD_nul_func(size_t i, void * client_data) { + (void)i; return (char)(GC_word)client_data; } @@ -552,8 +547,9 @@ char CORD_lf_func(size_t i, void * client_data) } #ifndef GC_NO_FINALIZATION - void CORD_lf_close_proc(void * obj, void * client_data CORD_ATTR_UNUSED) + void CORD_lf_close_proc(void * obj, void * client_data) { + (void)client_data; if (fclose(((lf_state *)obj) -> lf_file) != 0) ABORT("CORD_lf_close_proc: fclose failed"); } diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 7116dc46..b27a7627 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -139,7 +139,7 @@ GC_API void GC_CALL GC_use_threads_discovery(void) /* bound and sets *phi to the upper one. */ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p, mach_port_t my_thread, ptr_t *paltstack_lo, - ptr_t *paltstack_hi GC_ATTR_UNUSED) + ptr_t *paltstack_hi) { ptr_t lo; if (thread == my_thread) { @@ -319,20 +319,20 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p, # endif } /* thread != my_thread */ -# ifdef DARWIN_DONT_PARSE_STACK +# ifndef DARWIN_DONT_PARSE_STACK + /* TODO: Determine p and handle altstack if !DARWIN_DONT_PARSE_STACK */ + UNUSED_ARG(paltstack_hi); +# else /* p is guaranteed to be non-NULL regardless of GC_query_task_threads. */ *phi = (p->flags & MAIN_THREAD) != 0 ? GC_stackbottom : p->stack_end; -# endif - /* TODO: Determine p and handle altstack if !DARWIN_DONT_PARSE_STACK */ -# ifdef DARWIN_DONT_PARSE_STACK - if (p->altstack != NULL && (word)p->altstack <= (word)lo - && (word)lo <= (word)p->altstack + p->altstack_size) { - *paltstack_lo = lo; - *paltstack_hi = p->altstack + p->altstack_size; - lo = p->stack; - *phi = p->stack + p->stack_size; - } else + if (p->altstack != NULL && (word)p->altstack <= (word)lo + && (word)lo <= (word)p->altstack + p->altstack_size) { + *paltstack_lo = lo; + *paltstack_hi = p->altstack + p->altstack_size; + lo = p->stack; + *phi = p->stack + p->stack_size; + } else # endif /* else */ { *paltstack_lo = NULL; @@ -272,7 +272,7 @@ # define CROSSES_HBLK(p, sz) \ (((word)((p) + sizeof(oh) + (sz) - 1) ^ (word)(p)) >= HBLKSIZE) -GC_INNER void *GC_store_debug_info_inner(void *p, word sz GC_ATTR_UNUSED, +GC_INNER void *GC_store_debug_info_inner(void *p, word sz, const char *string, int linenum) { word * result = (word *)((oh *)p + 1); @@ -288,7 +288,9 @@ GC_INNER void *GC_store_debug_info_inner(void *p, word sz GC_ATTR_UNUSED, # endif ((oh *)p) -> oh_string = string; ((oh *)p) -> oh_int = linenum; -# ifndef SHORT_DBG_HDRS +# ifdef SHORT_DBG_HDRS + UNUSED_ARG(sz); +# else ((oh *)p) -> oh_sz = sz; ((oh *)p) -> oh_sf = START_FLAG ^ (word)result; ((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] = @@ -631,8 +633,10 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS) return GC_debug_malloc(lb, OPT_RA s, i); } - GC_API void GC_CALL GC_debug_change_stubborn( - const void * p GC_ATTR_UNUSED) {} + GC_API void GC_CALL GC_debug_change_stubborn(const void *p) + { + UNUSED_ARG(p); + } #endif /* !CPPCHECK */ GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p) @@ -983,14 +987,14 @@ STATIC void GC_print_all_smashed_proc(void) /* Check all marked objects in the given block for validity */ /* Avoid GC_apply_to_each_object for performance reasons. */ -STATIC void GC_CALLBACK GC_check_heap_block(struct hblk *hbp, - GC_word dummy GC_ATTR_UNUSED) +STATIC void GC_CALLBACK GC_check_heap_block(struct hblk *hbp, GC_word dummy) { struct hblkhdr * hhdr = HDR(hbp); word sz = hhdr -> hb_sz; word bit_no; char *p, *plim; + UNUSED_ARG(dummy); p = hbp->hb_body; if (sz > MAXOBJBYTES) { plim = p; @@ -654,7 +654,10 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p) } } -STATIC void GC_null_finalize_mark_proc(ptr_t p GC_ATTR_UNUSED) {} +STATIC void GC_null_finalize_mark_proc(ptr_t p) +{ + UNUSED_ARG(p); +} /* Possible finalization_marker procedures. Note that mark stack */ /* overflow is handled by the caller, and is not a disaster. */ @@ -46,11 +46,13 @@ int GC_gcj_debug_kind = 0; /* The kind of objects that is always marked */ /* with a mark proc call. */ -STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr GC_ATTR_UNUSED, +STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr, struct GC_ms_entry *mark_stack_ptr, - struct GC_ms_entry * mark_stack_limit GC_ATTR_UNUSED, - word env GC_ATTR_UNUSED) + struct GC_ms_entry * mark_stack_limit, word env) { + UNUSED_ARG(addr); + UNUSED_ARG(mark_stack_limit); + UNUSED_ARG(env); ABORT_RET("No client gcj mark proc is specified"); return mark_stack_ptr; } diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 5b49aead..acf6c318 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -221,13 +221,9 @@ typedef int GC_bool; # endif #endif /* !GC_ATTR_NO_SANITIZE_THREAD */ -#ifndef GC_ATTR_UNUSED -# if GC_GNUC_PREREQ(3, 4) -# define GC_ATTR_UNUSED __attribute__((__unused__)) -# else -# define GC_ATTR_UNUSED /* empty */ -# endif -#endif /* !GC_ATTR_UNUSED */ +#ifndef UNUSED_ARG +# define UNUSED_ARG(arg) ((void)(arg)) +#endif #ifdef HAVE_CONFIG_H /* The "inline" keyword is determined by Autoconf AC_C_INLINE. */ @@ -619,9 +619,9 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_strndup(const char *str, size_t size) return GC_malloc(lb); } - GC_API void GC_CALL GC_change_stubborn(const void *p GC_ATTR_UNUSED) + GC_API void GC_CALL GC_change_stubborn(const void *p) { - /* Empty. */ + UNUSED_ARG(p); } #endif /* !CPPCHECK */ @@ -36,10 +36,14 @@ /* Make arguments appear live to compiler. Put here to minimize the */ /* risk of inlining. Used to minimize junk left in registers. */ GC_ATTR_NOINLINE -void GC_noop6(word arg1 GC_ATTR_UNUSED, word arg2 GC_ATTR_UNUSED, - word arg3 GC_ATTR_UNUSED, word arg4 GC_ATTR_UNUSED, - word arg5 GC_ATTR_UNUSED, word arg6 GC_ATTR_UNUSED) +void GC_noop6(word arg1, word arg2, word arg3, word arg4, word arg5, word arg6) { + UNUSED_ARG(arg1); + UNUSED_ARG(arg2); + UNUSED_ARG(arg3); + UNUSED_ARG(arg4); + UNUSED_ARG(arg5); + UNUSED_ARG(arg6); /* Avoid GC_noop6 calls to be optimized away. */ # if defined(AO_HAVE_compiler_barrier) && !defined(BASE_ATOMIC_OPS_EMULATED) AO_compiler_barrier(); /* to serve as a special side-effect */ @@ -166,11 +170,11 @@ GC_INNER void GC_set_hdr_marks(hdr *hhdr) } /* Clear all mark bits associated with block h. */ -static void GC_CALLBACK clear_marks_for_block(struct hblk *h, - GC_word dummy GC_ATTR_UNUSED) +static void GC_CALLBACK clear_marks_for_block(struct hblk *h, GC_word dummy) { hdr * hhdr = HDR(h); + UNUSED_ARG(dummy); if (IS_UNCOLLECTABLE(hhdr -> hb_obj_kind)) return; /* Mark bit for these is cleared only once the object is */ /* explicitly deallocated. This either frees the block, or */ @@ -433,11 +437,10 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) } ext_ex_regn; static EXCEPTION_DISPOSITION mark_ex_handler( - struct _EXCEPTION_RECORD *ex_rec, - void *est_frame, - struct _CONTEXT *context, - void *disp_ctxt GC_ATTR_UNUSED) + struct _EXCEPTION_RECORD *ex_rec, void *est_frame, + struct _CONTEXT *context, void *disp_ctxt) { + UNUSED_ARG(disp_ctxt); if (ex_rec->ExceptionCode == STATUS_ACCESS_VIOLATION) { ext_ex_regn *xer = (ext_ex_regn *)est_frame; @@ -1442,9 +1445,9 @@ GC_API void GC_CALL GC_push_all(void *bottom, void *top) # endif /* !NO_VDB_FOR_STATIC_ROOTS */ #else - GC_API void GC_CALL GC_push_conditional(void *bottom, void *top, - int all GC_ATTR_UNUSED) + GC_API void GC_CALL GC_push_conditional(void *bottom, void *top, int all) { + UNUSED_ARG(all); GC_push_all(bottom, top); } #endif /* GC_DISABLE_INCREMENTAL */ @@ -790,9 +790,9 @@ STATIC void GC_push_all_stack_part_eager_sections(ptr_t lo, ptr_t hi, /* enough of the current stack to ensure that callee-save registers */ /* saved in collector frames have been seen. */ /* TODO: Merge it with per-thread stuff. */ -STATIC void GC_push_current_stack(ptr_t cold_gc_frame, - void * context GC_ATTR_UNUSED) +STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void *context) { + UNUSED_ARG(context); # if defined(THREADS) /* cold_gc_frame is non-NULL. */ # ifdef STACK_GROWS_DOWN @@ -880,7 +880,7 @@ STATIC void GC_push_regs_and_stack(ptr_t cold_gc_frame) /* altered values. Cold_gc_frame is an address inside a GC frame that */ /* remains valid until all marking is complete; a NULL value indicates */ /* that it is OK to miss some register values. */ -GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame GC_ATTR_UNUSED) +GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame) { int i; unsigned kind; @@ -945,7 +945,9 @@ GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame GC_ATTR_UNUSED) /* overflow the mark stack. This is usually done by saving */ /* the current context on the stack, and then just tracing */ /* from the stack. */ -# ifndef STACK_NOT_SCANNED +# ifdef STACK_NOT_SCANNED + UNUSED_ARG(cold_gc_frame); +# else GC_push_regs_and_stack(cold_gc_frame); # endif @@ -172,9 +172,9 @@ GC_finalizer_notifier_proc GC_finalizer_notifier = GC_INNER long GC_large_alloc_warn_interval = GC_LARGE_ALLOC_WARN_INTERVAL; /* Interval between unsuppressed warnings. */ -STATIC void * GC_CALLBACK GC_default_oom_fn( - size_t bytes_requested GC_ATTR_UNUSED) +STATIC void * GC_CALLBACK GC_default_oom_fn(size_t bytes_requested) { + UNUSED_ARG(bytes_requested); return NULL; } @@ -210,7 +210,7 @@ GC_oom_func GC_oom_fn = GC_default_oom_fn; /* Overrides the default automatic handle-fork mode. Has effect only */ /* if called before GC_INIT. */ -GC_API void GC_CALL GC_set_handle_fork(int value GC_ATTR_UNUSED) +GC_API void GC_CALL GC_set_handle_fork(int value) { # ifdef CAN_HANDLE_FORK if (!GC_is_initialized) @@ -229,6 +229,7 @@ GC_API void GC_CALL GC_set_handle_fork(int value GC_ATTR_UNUSED) } # else /* No at-fork handler is needed in the single-threaded mode. */ + UNUSED_ARG(value); # endif } @@ -620,14 +621,14 @@ GC_API void GC_CALL GC_get_heap_usage_safe(GC_word *pheap_size, #if defined(THREADS) && !defined(SIGNAL_BASED_STOP_WORLD) /* GC does not use signals to suspend and restart threads. */ - GC_API void GC_CALL GC_set_suspend_signal(int sig GC_ATTR_UNUSED) + GC_API void GC_CALL GC_set_suspend_signal(int sig) { - /* empty */ + UNUSED_ARG(sig); } - GC_API void GC_CALL GC_set_thr_restart_signal(int sig GC_ATTR_UNUSED) + GC_API void GC_CALL GC_set_thr_restart_signal(int sig) { - /* empty */ + UNUSED_ARG(sig); } GC_API int GC_CALL GC_get_suspend_signal(void) @@ -860,8 +861,11 @@ GC_API int GC_CALL GC_is_init_called(void) #endif /* MSGBOX_ON_ERROR */ #if defined(THREADS) && defined(UNIX_LIKE) && !defined(NO_GETCONTEXT) - static void callee_saves_pushed_dummy_fn(ptr_t data GC_ATTR_UNUSED, - void * context GC_ATTR_UNUSED) {} + static void callee_saves_pushed_dummy_fn(ptr_t data, void *context) + { + UNUSED_ARG(data); + UNUSED_ARG(context); + } #endif #ifndef SMALL_CONFIG @@ -2239,9 +2243,11 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn, } /* This is nearly the same as in win32_threads.c */ -STATIC void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED) +STATIC void GC_do_blocking_inner(ptr_t data, void *context) { - struct blocking_data * d = (struct blocking_data *) data; + struct blocking_data * d = (struct blocking_data *)data; + + UNUSED_ARG(context); GC_ASSERT(GC_is_initialized); GC_ASSERT(GC_blocked_sp == NULL); # ifdef SPARC @@ -2377,9 +2383,9 @@ GC_API GC_word GC_CALL GC_get_gc_no(void) } #ifndef PARALLEL_MARK - GC_API void GC_CALL GC_set_markers_count(unsigned markers GC_ATTR_UNUSED) + GC_API void GC_CALL GC_set_markers_count(unsigned markers) { - /* Nothing to do. */ + UNUSED_ARG(markers); } #endif @@ -524,8 +524,9 @@ GC_INNER const char * GC_get_maps(void) static struct sigaction old_segv_act; STATIC JMP_BUF GC_jmp_buf_openbsd; - STATIC void GC_fault_handler_openbsd(int sig GC_ATTR_UNUSED) + STATIC void GC_fault_handler_openbsd(int sig) { + UNUSED_ARG(sig); LONGJMP(GC_jmp_buf_openbsd, 1); } @@ -938,8 +939,9 @@ GC_INNER size_t GC_page_size = 0; GC_INNER JMP_BUF GC_jmp_buf; - STATIC void GC_fault_handler(int sig GC_ATTR_UNUSED) + STATIC void GC_fault_handler(int sig) { + UNUSED_ARG(sig); LONGJMP(GC_jmp_buf, 1); } @@ -1535,14 +1537,14 @@ GC_INNER size_t GC_page_size = 0; return GC_SUCCESS; } # else - GC_API int GC_CALL GC_get_stack_base( - struct GC_stack_base *b GC_ATTR_UNUSED) + GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b) { # if defined(GET_MAIN_STACKBASE_SPECIAL) && !defined(THREADS) \ && !defined(IA64) b->mem_base = GC_get_main_stack_base(); return GC_SUCCESS; # else + UNUSED_ARG(b); return GC_UNIMPLEMENTED; # endif } @@ -4373,25 +4375,46 @@ EXTERN_C_END /* These should never be called, but just in case... */ GC_API_OSCALL kern_return_t -catch_exception_raise_state(mach_port_name_t exception_port GC_ATTR_UNUSED, - int exception GC_ATTR_UNUSED, exception_data_t code GC_ATTR_UNUSED, - mach_msg_type_number_t codeCnt GC_ATTR_UNUSED, int flavor GC_ATTR_UNUSED, - thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED, - thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED) +catch_exception_raise_state(mach_port_name_t exception_port, int exception, + exception_data_t code, + mach_msg_type_number_t codeCnt, int flavor, + thread_state_t old_state, int old_stateCnt, + thread_state_t new_state, int new_stateCnt) { + UNUSED_ARG(exception_port); + UNUSED_ARG(exception); + UNUSED_ARG(code); + UNUSED_ARG(codeCnt); + UNUSED_ARG(flavor); + UNUSED_ARG(old_state); + UNUSED_ARG(old_stateCnt); + UNUSED_ARG(new_state); + UNUSED_ARG(new_stateCnt); ABORT_RET("Unexpected catch_exception_raise_state invocation"); return KERN_INVALID_ARGUMENT; } GC_API_OSCALL kern_return_t -catch_exception_raise_state_identity( - mach_port_name_t exception_port GC_ATTR_UNUSED, - mach_port_t thread GC_ATTR_UNUSED, mach_port_t task GC_ATTR_UNUSED, - int exception GC_ATTR_UNUSED, exception_data_t code GC_ATTR_UNUSED, - mach_msg_type_number_t codeCnt GC_ATTR_UNUSED, int flavor GC_ATTR_UNUSED, - thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED, - thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED) +catch_exception_raise_state_identity(mach_port_name_t exception_port, + mach_port_t thread, mach_port_t task, + int exception, exception_data_t code, + mach_msg_type_number_t codeCnt, + int flavor, thread_state_t old_state, + int old_stateCnt, + thread_state_t new_state, + int new_stateCnt) { + UNUSED_ARG(exception_port); + UNUSED_ARG(thread); + UNUSED_ARG(task); + UNUSED_ARG(exception); + UNUSED_ARG(code); + UNUSED_ARG(codeCnt); + UNUSED_ARG(flavor); + UNUSED_ARG(old_state); + UNUSED_ARG(old_stateCnt); + UNUSED_ARG(new_state); + UNUSED_ARG(new_stateCnt); ABORT_RET("Unexpected catch_exception_raise_state_identity invocation"); return KERN_INVALID_ARGUMENT; } @@ -4833,10 +4856,9 @@ STATIC kern_return_t GC_forward_exception(mach_port_t thread, mach_port_t task, /* call this. catch_exception_raise, catch_exception_raise_state and */ /* and catch_exception_raise_state_identity are called from OS. */ GC_API_OSCALL kern_return_t -catch_exception_raise(mach_port_t exception_port GC_ATTR_UNUSED, - mach_port_t thread, mach_port_t task GC_ATTR_UNUSED, - exception_type_t exception, exception_data_t code, - mach_msg_type_number_t code_count GC_ATTR_UNUSED) +catch_exception_raise(mach_port_t exception_port, mach_port_t thread, + mach_port_t task, exception_type_t exception, + exception_data_t code, mach_msg_type_number_t code_count) { kern_return_t r; char *addr; @@ -4844,12 +4866,16 @@ catch_exception_raise(mach_port_t exception_port GC_ATTR_UNUSED, mach_msg_type_number_t exc_state_count = DARWIN_EXC_STATE_COUNT; DARWIN_EXC_STATE_T exc_state; + UNUSED_ARG(exception_port); + UNUSED_ARG(task); if (exception != EXC_BAD_ACCESS || code[0] != KERN_PROTECTION_FAILURE) { # ifdef DEBUG_EXCEPTION_HANDLING /* We aren't interested, pass it on to the old handler */ GC_log_printf("Exception: 0x%x Code: 0x%x 0x%x in catch...\n", exception, code_count > 0 ? code[0] : -1, code_count > 1 ? code[1] : -1); +# else + UNUSED_ARG(code_count); # endif return FWD(); } @@ -4868,7 +4894,7 @@ catch_exception_raise(mach_port_t exception_port GC_ATTR_UNUSED, } /* This is the address that caused the fault */ - addr = (char*) exc_state.DARWIN_EXC_STATE_DAR; + addr = (char*)exc_state.DARWIN_EXC_STATE_DAR; if (!is_header_found_async(addr)) { /* Ugh... just like the SIGBUS problem above, it seems we get */ /* a bogus KERN_PROTECTION_FAILURE every once and a while. We wait */ diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 46d7cec5..77f4b77d 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -251,8 +251,7 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy, void *context); #ifdef SUSPEND_HANDLER_NO_CONTEXT STATIC void GC_suspend_handler(int sig) #else - STATIC void GC_suspend_sigaction(int sig, siginfo_t * info GC_ATTR_UNUSED, - void * context) + STATIC void GC_suspend_sigaction(int sig, siginfo_t *info, void *context) #endif { int old_errno = errno; @@ -271,9 +270,10 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy, void *context); return; GC_with_callee_saves_pushed(GC_suspend_handler_inner, NULL); # else + UNUSED_ARG(info); /* We believe that in this case the full context is already */ /* in the signal handler frame. */ - GC_suspend_handler_inner(NULL, context); + GC_suspend_handler_inner(NULL, context); # endif errno = old_errno; } @@ -321,8 +321,7 @@ GC_INLINE void GC_store_stack_ptr(GC_thread me) # endif } -STATIC void GC_suspend_handler_inner(ptr_t dummy GC_ATTR_UNUSED, - void * context GC_ATTR_UNUSED) +STATIC void GC_suspend_handler_inner(ptr_t dummy, void *context) { pthread_t self; GC_thread me; @@ -338,6 +337,8 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy GC_ATTR_UNUSED, /* After the barrier, this thread should see */ /* the actual content of GC_threads. */ + UNUSED_ARG(dummy); + UNUSED_ARG(context); if ((my_stop_count & THREAD_RESTARTED) != 0) return; /* Restarting the world. */ diff --git a/pthread_support.c b/pthread_support.c index a101baa4..a45368a8 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1582,13 +1582,14 @@ static void do_blocking_leave(GC_thread me, GC_bool topOfStackUnset) /* Wrapper for functions that are likely to block for an appreciable */ /* length of time. */ -GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED) +GC_INNER void GC_do_blocking_inner(ptr_t data, void *context) { struct blocking_data *d = (struct blocking_data *)data; GC_thread me; GC_bool topOfStackUnset; DCL_LOCK_STATE; + UNUSED_ARG(context); LOCK(); me = GC_lookup_thread(pthread_self()); topOfStackUnset = do_blocking_enter(me); @@ -1632,13 +1633,13 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED) #if defined(GC_ENABLE_SUSPEND_THREAD) && defined(SIGNAL_BASED_STOP_WORLD) /* Similar to GC_do_blocking_inner() but assuming the GC lock is held */ /* and fn is GC_suspend_self_inner. */ - GC_INNER void GC_suspend_self_blocked(ptr_t thread_me, - void * context GC_ATTR_UNUSED) + GC_INNER void GC_suspend_self_blocked(ptr_t thread_me, void *context) { GC_thread me = (GC_thread)thread_me; GC_bool topOfStackUnset; DCL_LOCK_STATE; + UNUSED_ARG(context); GC_ASSERT(I_HOLD_LOCK()); topOfStackUnset = do_blocking_enter(me); while ((me -> stop_info.ext_suspend_cnt & 1) != 0) { diff --git a/tests/gctest.c b/tests/gctest.c index b57c9181..2b2b86a2 100644 --- a/tests/gctest.c +++ b/tests/gctest.c @@ -1364,8 +1364,9 @@ void typed_test(void) #else volatile AO_t fail_count = 0; - void GC_CALLBACK fail_proc1(void *x GC_ATTR_UNUSED) + void GC_CALLBACK fail_proc1(void *arg) { + UNUSED_ARG(arg); AO_fetch_and_add1(&fail_count); } @@ -2056,10 +2057,8 @@ void enable_incremental_mode(void) #if ((defined(MSWIN32) && !defined(__MINGW32__)) || defined(MSWINCE)) \ && !defined(NO_WINMAIN_ENTRY) - int APIENTRY WinMain(HINSTANCE instance GC_ATTR_UNUSED, - HINSTANCE prev GC_ATTR_UNUSED, - WINMAIN_LPTSTR cmd GC_ATTR_UNUSED, - int n GC_ATTR_UNUSED) + int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, WINMAIN_LPTSTR cmd, + int n) #elif defined(RTEMS) # include <bsp.h> # define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER @@ -2075,11 +2074,20 @@ void enable_incremental_mode(void) #endif { CRTMEM_CHECK_INIT(); -# if defined(CPPCHECK) && !defined(NO_WINMAIN_ENTRY) \ - && ((defined(MSWIN32) && !defined(__MINGW32__)) || defined(MSWINCE)) - GC_noop1((GC_word)&WinMain); -# elif defined(CPPCHECK) && defined(RTEMS) - GC_noop1((GC_word)&Init); +# if ((defined(MSWIN32) && !defined(__MINGW32__)) || defined(MSWINCE)) \ + && !defined(NO_WINMAIN_ENTRY) + UNUSED_ARG(instance); + UNUSED_ARG(prev); + UNUSED_ARG(cmd); + UNUSED_ARG(n); +# if defined(CPPCHECK) + GC_noop1((GC_word)&WinMain); +# endif +# elif defined(RTEMS) + UNUSED_ARG(ignord); +# if defined(CPPCHECK) + GC_noop1((GC_word)&Init); +# endif # endif n_tests = 0; GC_clear_exclusion_table(); /* no-op as called before GC init */ @@ -2200,8 +2208,9 @@ void enable_incremental_mode(void) #if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) -DWORD __stdcall thr_run_one_test(void * arg GC_ATTR_UNUSED) +DWORD __stdcall thr_run_one_test(void *arg) { + UNUSED_ARG(arg); run_one_test(); return 0; } @@ -2234,7 +2243,7 @@ LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, return ret; } -DWORD __stdcall thr_window(void * arg GC_ATTR_UNUSED) +DWORD __stdcall thr_window(void *arg) { WNDCLASS win_class = { CS_NOCLOSE, @@ -2250,6 +2259,7 @@ DWORD __stdcall thr_window(void * arg GC_ATTR_UNUSED) }; MSG msg; + UNUSED_ARG(arg); if (!RegisterClass(&win_class)) FAIL; @@ -2282,10 +2292,8 @@ DWORD __stdcall thr_window(void * arg GC_ATTR_UNUSED) #endif #if !defined(NO_WINMAIN_ENTRY) - int APIENTRY WinMain(HINSTANCE instance GC_ATTR_UNUSED, - HINSTANCE prev GC_ATTR_UNUSED, - WINMAIN_LPTSTR cmd GC_ATTR_UNUSED, - int n GC_ATTR_UNUSED) + int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, WINMAIN_LPTSTR cmd, + int n) #else int main(void) #endif @@ -2299,8 +2307,14 @@ DWORD __stdcall thr_window(void * arg GC_ATTR_UNUSED) # endif DWORD thread_id; -# if defined(CPPCHECK) && !defined(NO_WINMAIN_ENTRY) - GC_noop1((GC_word)&WinMain); +# if !defined(NO_WINMAIN_ENTRY) + UNUSED_ARG(instance); + UNUSED_ARG(prev); + UNUSED_ARG(cmd); + UNUSED_ARG(n); +# if defined(CPPCHECK) + GC_noop1((GC_word)&WinMain); +# endif # endif # if defined(GC_DLL) && !defined(GC_NO_THREADS_DISCOVERY) \ && !defined(MSWINCE) && !defined(THREAD_LOCAL_ALLOC) @@ -2402,8 +2416,9 @@ int test(void) #if defined(GC_PTHREADS) # include <errno.h> /* for EAGAIN */ -void * thr_run_one_test(void * arg GC_ATTR_UNUSED) +void * thr_run_one_test(void *arg) { + UNUSED_ARG(arg); run_one_test(); return 0; } @@ -658,7 +658,7 @@ static complex_descriptor *get_complex_descr(word *addr, size_t nwords) /* Used by GC_calloc_explicitly_typed via GC_array_kind. */ STATIC mse *GC_array_mark_proc(word *addr, mse *mark_stack_ptr, - mse *mark_stack_limit, word env GC_ATTR_UNUSED) + mse *mark_stack_limit, word env) { hdr *hhdr = HDR(addr); word sz = hhdr -> hb_sz; @@ -667,6 +667,7 @@ STATIC mse *GC_array_mark_proc(word *addr, mse *mark_stack_ptr, mse *orig_mark_stack_ptr = mark_stack_ptr; mse *new_mark_stack_ptr; + UNUSED_ARG(env); if (NULL == complex_d) { /* Found a reference to a free list entry. Ignore it. */ return orig_mark_stack_ptr; diff --git a/win32_threads.c b/win32_threads.c index 584193a9..93afc47e 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -638,12 +638,14 @@ GC_API int GC_CALL GC_thread_is_registered(void) return me != NULL; } -GC_API void GC_CALL GC_register_altstack(void *stack GC_ATTR_UNUSED, - GC_word stack_size GC_ATTR_UNUSED, - void *altstack GC_ATTR_UNUSED, - GC_word altstack_size GC_ATTR_UNUSED) +GC_API void GC_CALL GC_register_altstack(void *stack, GC_word stack_size, + void *altstack, GC_word altstack_size) { /* TODO: Implement */ + UNUSED_ARG(stack); + UNUSED_ARG(stack_size); + UNUSED_ARG(altstack); + UNUSED_ARG(altstack_size); } /* Make sure thread descriptor t is not protected by the VDB */ @@ -903,9 +905,9 @@ GC_API int GC_CALL GC_unregister_my_thread(void) /* length of time. */ /* GC_do_blocking_inner() is nearly the same as in pthread_support.c */ -GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED) +GC_INNER void GC_do_blocking_inner(ptr_t data, void *context) { - struct blocking_data * d = (struct blocking_data *) data; + struct blocking_data * d = (struct blocking_data *)data; DWORD thread_id = GetCurrentThreadId(); GC_thread me; # ifdef IA64 @@ -913,6 +915,7 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED) # endif DCL_LOCK_STATE; + UNUSED_ARG(context); LOCK(); me = GC_lookup_thread_inner(thread_id); CHECK_LOOKUP_MY_THREAD(me); @@ -3135,11 +3138,12 @@ GC_INNER void GC_thr_init(void) # else # define GC_DllMain DllMain # endif - BOOL WINAPI GC_DllMain(HINSTANCE inst GC_ATTR_UNUSED, ULONG reason, - LPVOID reserved GC_ATTR_UNUSED) + BOOL WINAPI GC_DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved) { DWORD thread_id; + UNUSED_ARG(inst); + UNUSED_ARG(reserved); /* Note that GC_use_threads_discovery should be called by the */ /* client application at start-up to activate automatic thread */ /* registration (it is the default GC behavior); */ |