Turn on unused-parameter checking for GCC.
* alloc.c (GC_try_to_collect_general): Add GC_ATTR_UNUSED attribute
to an argument.
* tests/test.c (tiny_reverse_test, thr_run_one_test): Likewise.
* backgraph.c (reset_back_edge, update_max_height): Replace ARGSUSED
annotation with GC_ATTR_UNUSED attribute for some arguments.
* checksums.c (GC_add_block): Likewise.
* dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change,
GC_check_heap_block): Likewise.
* finalize.c (GC_null_finalize_mark_proc): Likewise.
* gcj_mlc.c (GC_gcj_fake_mark_proc): Likewise.
* mark.c (GC_noop, clear_marks_for_block, GC_mark_and_push): Likewise.
* mark_rts.c (GC_push_conditional_with_exclusions,
GC_push_current_stack): Likewise.
* misc.c (GC_default_oom_fn, GC_do_blocking_inner): Likewise.
* os_dep.c (GC_fault_handler_openbsd, GC_fault_handler,
GC_remove_protection, GC_page_was_dirty, GC_page_was_ever_dirty):
Likewise.
* pthread_stop_world.c (GC_suspend_handler, GC_suspend_handler_inner):
Likewise.
* pthread_support.c (GC_do_blocking_inner): Likewise.
* stubborn.c (GC_change_stubborn, GC_end_stubborn_change): Likewise.
* tests/test.c (fail_proc1): Likewise.
* typd_mlc.c (GC_array_mark_proc): Likewise.
* win32_threads.c (GC_do_blocking_inner, DllMain): Likewise.
* include/private/gc_priv.h (GC_ATTR_UNUSED): Define new macro.
* cordxtra.c (CORD_ATTR_UNUSED): Likewise.
* cordxtra.c (CORD_nul_func, CORD_lf_close_proc): Replace ARGSUSED
annotation with CORD_ATTR_UNUSED attribute for an argument.
* mach_dep.c (GC_clear_stack_inner): Remove ARGSUSED annotation and
use "limit" argument in the function (to suppress compiler warning).
* misc.c (GC_clear_stack_inner): Remove ARGSUSED.
* tests/threadkey_test.c (on_thread_exit_inner, on_thread_exit):
Use all function arguments (to suppress compiler warning).
* configure.ac (CFLAGS): Remove "-Wno-unused-parameter" option.
win32-pthreads/cygwin: compile GC_Create/ExitThread as well (in addition to
GC_pthread_create); redirect the correspoding functions in gc.h.
-Use GC_ATTR_UNUSED across the whole project (replace ARGSUSED annotation);
-define GC_ATTR_UNUSED as empty for old GCC releases;
-remove -Wno-unused-parameter from configure.
-
configure.ac: Add option to build GC via extra/gc.c compilation.
Mac_files: Remove MacOS_config.h, MacOS_Test_config.h.
/* 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_bool force_unmap GC_ATTR_UNUSED)
{
GC_bool result;
# ifdef USE_MUNMAP
GC_apply_to_all_blocks(per_object_helper, (word)f);
}
-/*ARGSUSED*/
-static void reset_back_edge(ptr_t p, size_t n_bytes, word gc_descr)
+static void reset_back_edge(ptr_t p, size_t n_bytes GC_ATTR_UNUSED,
+ word gc_descr GC_ATTR_UNUSED)
{
/* Skip any free list links, or dropped blocks */
if (GC_HAS_DEBUG_INFO(p)) {
/* next GC. */
/* Set GC_max_height to be the maximum height we encounter, and */
/* GC_deepest_obj to be the corresponding object. */
-/*ARGSUSED*/
-static void update_max_height(ptr_t p, size_t n_bytes, word gc_descr)
+static void update_max_height(ptr_t p, size_t n_bytes GC_ATTR_UNUSED,
+ word gc_descr GC_ATTR_UNUSED)
{
if (GC_is_marked(p) && GC_HAS_DEBUG_INFO(p)) {
word p_height = 0;
word GC_bytes_in_used_blocks = 0;
-/*ARGSUSED*/
-STATIC void GC_add_block(struct hblk *h, word dummy)
+STATIC void GC_add_block(struct hblk *h, word dummy GC_ATTR_UNUSED)
{
hdr * hhdr = HDR(h);
size_t bytes = hhdr -> hb_sz;
esac
if test "$GCC" == yes; then
- CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter"
+ CFLAGS="$CFLAGS -Wall -Wextra"
fi
AC_MSG_CHECKING(for xlc)
# include <string.h>
# include <stdlib.h>
# include <stdarg.h>
+
# include "cord.h"
# include "ec.h"
+
# define I_HIDE_POINTERS /* So we get access to allocation lock. */
/* We use this for lazy file reading, */
- /* so that we remain independent */
- /* of the threads primitives. */
+ /* so that we remain independent */
+ /* of the threads primitives. */
# include "gc.h"
/* For now we assume that pointer reads and writes are atomic, */
/* i.e. another thread always sees the state before or after */
-/* a write. This might be false on a Motorola M68K with */
+/* a write. This might be false on a Motorola M68K with */
/* pointers that are not 32-bit aligned. But there probably */
-/* aren't too many threads packages running on those. */
+/* aren't too many threads packages running on those. */
# define ATOMIC_WRITE(x,y) (x) = (y)
# define ATOMIC_READ(x) (*(x))
# define SEEK_END 2
# endif
-# define BUFSZ 2048 /* Size of stack allocated buffers when */
- /* we want large buffers. */
+# define BUFSZ 2048 /* Size of stack allocated buffers when */
+ /* we want large buffers. */
typedef void (* oom_fn)(void);
ABORT("Out of memory\n"); }
# define ABORT(msg) { fprintf(stderr, "%s\n", msg); abort(); }
+#if __GNUC__ >= 4
+# define CORD_ATTR_UNUSED __attribute__((__unused__))
+#else
+# define CORD_ATTR_UNUSED /* empty */
+#endif
+
CORD CORD_cat_char(CORD x, char c)
{
register char * string;
x[0].ec_cord = CORD_cat(x[0].ec_cord, s);
}
-/*ARGSUSED*/
-char CORD_nul_func(size_t i, void * client_data)
+char CORD_nul_func(size_t i CORD_ATTR_UNUSED, void * client_data)
{
return((char)(unsigned long)client_data);
}
return(cl -> data[MOD_LINE_SZ(i)]);
}
-/*ARGSUSED*/
-void CORD_lf_close_proc(void * obj, void * client_data)
+void CORD_lf_close_proc(void * obj, void * client_data CORD_ATTR_UNUSED)
{
if (fclose(((lf_state *)obj) -> lf_file) != 0) {
ABORT("CORD_lf_close_proc: fclose failed");
return GC_debug_malloc(lb, OPT_RA s, i);
}
- /*ARGSUSED*/
- GC_API void GC_CALL GC_debug_change_stubborn(void *p) {}
+ GC_API void GC_CALL GC_debug_change_stubborn(void * p GC_ATTR_UNUSED) {}
- /*ARGSUSED*/
- GC_API void GC_CALL GC_debug_end_stubborn_change(void *p) {}
+ GC_API void GC_CALL GC_debug_end_stubborn_change(void * p GC_ATTR_UNUSED) {}
#endif /* !STUBBORN_ALLOC */
GC_API void * GC_CALL GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
/* Check all marked objects in the given block for validity */
/* Avoid GC_apply_to_each_object for performance reasons. */
-/*ARGSUSED*/
-STATIC void GC_check_heap_block(struct hblk *hbp, word dummy)
+STATIC void GC_check_heap_block(struct hblk *hbp, word dummy GC_ATTR_UNUSED)
{
struct hblkhdr * hhdr = HDR(hbp);
size_t sz = hhdr -> hb_sz;
}
}
-/*ARGSUSED*/
-STATIC void GC_null_finalize_mark_proc(ptr_t p) {}
+STATIC void GC_null_finalize_mark_proc(ptr_t p GC_ATTR_UNUSED) {}
/* Possible finalization_marker procedures. Note that mark stack */
/* overflow is handled by the caller, and is not a disaster. */
STATIC ptr_t * GC_gcjdebugobjfreelist = NULL;
-/*ARGSUSED*/
-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,
- word env)
+STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr GC_ATTR_UNUSED,
+ struct GC_ms_entry *mark_stack_ptr,
+ struct GC_ms_entry * mark_stack_limit GC_ATTR_UNUSED,
+ word env GC_ATTR_UNUSED)
{
ABORT("No client gcj mark proc is specified");
return mark_stack_ptr;
# include "gc_hdrs.h"
#endif
+#ifndef GC_ATTR_UNUSED
+# if __GNUC__ >= 4
+# define GC_ATTR_UNUSED __attribute__((__unused__))
+# else
+# define GC_ATTR_UNUSED /* empty */
+# endif
+#endif /* !GC_ATTR_UNUSED */
+
#if __GNUC__ >= 3 && !defined(LINT2)
# define EXPECT(expr, outcome) __builtin_expect(expr,outcome)
/* Equivalent to (expr), but predict that usually (expr)==outcome. */
#if defined(ASM_CLEAR_CODE)
# ifdef LINT
- /*ARGSUSED*/
ptr_t GC_clear_stack_inner(ptr_t arg, word limit)
{
- return(arg);
+ return limit ? arg : 0; /* use both arguments */
}
/* The real version is in a .S file */
# endif
/* We put this here to minimize the risk of inlining. */
/*VARARGS*/
#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__CC_ARM)
- /*ARGSUSED*/
- void GC_noop(void *p, ...) {}
+ void GC_noop(void * p GC_ATTR_UNUSED, ...) {}
#else
# ifdef __DMC__
void GC_noop(...) {}
/*
* Clear all mark bits associated with block h.
*/
-/*ARGSUSED*/
-static void clear_marks_for_block(struct hblk *h, word dummy)
+static void clear_marks_for_block(struct hblk *h, word dummy GC_ATTR_UNUSED)
{
register hdr * hhdr = HDR(h);
GC_PUSH_ONE_STACK(p, MARKED_FROM_REGISTER);
}
-/*ARGSUSED*/
GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj,
mse *mark_stack_ptr,
mse *mark_stack_limit,
- void **src)
+ void ** src GC_ATTR_UNUSED)
{
hdr * hhdr;
}
/* Invoke push_conditional on ranges that are not excluded. */
-/*ARGSUSED*/
STATIC void GC_push_conditional_with_exclusions(ptr_t bottom, ptr_t top,
- GC_bool all)
+ GC_bool all GC_ATTR_UNUSED)
{
struct exclusion * next;
ptr_t excl_start;
* seen.
* FIXME: Merge with per-thread stuff.
*/
-/*ARGSUSED*/
-STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void * context)
+STATIC void GC_push_current_stack(ptr_t cold_gc_frame,
+ void * context GC_ATTR_UNUSED)
{
# if defined(THREADS)
if (0 == cold_gc_frame) return;
GC_INNER long GC_large_alloc_warn_interval = GC_LARGE_ALLOC_WARN_INTERVAL;
/* Interval between unsuppressed warnings. */
-/*ARGSUSED*/
-STATIC void * GC_CALLBACK GC_default_oom_fn(size_t bytes_requested)
+STATIC void * GC_CALLBACK GC_default_oom_fn(
+ size_t bytes_requested GC_ATTR_UNUSED)
{
return(0);
}
/* Clear the stack up to about limit. Return arg. This function is */
/* not static because it could also be errorneously defined in .S */
/* file, so this error would be caught by the linker. */
- /*ARGSUSED*/
void * GC_clear_stack_inner(void *arg, ptr_t limit)
{
word dummy[CLEAR_SIZE];
}
/* This is nearly the same as in win32_threads.c */
-/*ARGSUSED*/
-STATIC void GC_do_blocking_inner(ptr_t data, void * context)
+STATIC void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED)
{
struct blocking_data * d = (struct blocking_data *) data;
GC_ASSERT(GC_is_initialized);
/* SIGSEGV and SIGPROF masked. Instead, use this custom one that */
/* works-around the issues. */
- /*ARGSUSED*/
- STATIC void GC_fault_handler_openbsd(int sig)
+ STATIC void GC_fault_handler_openbsd(int sig GC_ATTR_UNUSED)
{
siglongjmp(GC_jmp_buf_openbsd, 1);
}
/* Some tools to implement HEURISTIC2 */
# define MIN_PAGE_SIZE 256 /* Smallest conceivable page size, bytes */
- /*ARGSUSED*/
- STATIC void GC_fault_handler(int sig)
+ STATIC void GC_fault_handler(int sig GC_ATTR_UNUSED)
{
LONGJMP(GC_jmp_buf, 1);
}
# ifndef MPROTECT_VDB
/* Ignore write hints. They don't help us here. */
- /*ARGSUSED*/
- GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree) {}
+ GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED,
+ word nblocks GC_ATTR_UNUSED,
+ GC_bool is_ptrfree GC_ATTR_UNUSED) {}
# endif
#endif /* PROC_VDB || GWW_VDB */
/* If the actual page size is different, this returns TRUE if any */
/* of the pages overlapping h are dirty. This routine may err on the */
/* side of labeling pages as dirty (and this implementation does). */
- /*ARGSUSED*/
- GC_INNER GC_bool GC_page_was_dirty(struct hblk *h)
+ GC_INNER GC_bool GC_page_was_dirty(struct hblk * h GC_ATTR_UNUSED)
{
return(TRUE);
}
/* following default versions are adequate. */
# ifdef CHECKSUMS
/* Could any valid GC heap pointer ever have been written to this page? */
- /*ARGSUSED*/
- GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
+ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h GC_ATTR_UNUSED)
{
return(TRUE);
}
/* (II) may be essential if we need to ensure that */
/* pointer-free system call buffers in the heap are */
/* not protected. */
- /*ARGSUSED*/
- GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree) {}
+ GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED,
+ word nblocks GC_ATTR_UNUSED,
+ GC_bool is_ptrfree GC_ATTR_UNUSED) {}
#endif /* DEFAULT_VDB */
#ifdef MANUAL_VDB
async_set_pht_entry_from_index(GC_dirty_pages, index);
}
- /*ARGSUSED*/
- GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree) {}
+ GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED,
+ word nblocks GC_ATTR_UNUSED,
+ GC_bool is_ptrfree GC_ATTR_UNUSED) {}
# ifdef CHECKSUMS
/* Could any valid GC heap pointer ever have been written to this page? */
- /*ARGSUSED*/
- GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
+ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h GC_ATTR_UNUSED)
{
/* FIXME - implement me. */
return(TRUE);
# ifndef NO_GETCONTEXT
# include <ucontext.h>
# endif
- /*ARGSUSED*/
STATIC void GC_write_fault_handler(int sig, siginfo_t *si, void *raw_sc)
# else
# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode \
#endif /* 0 */
# ifdef CHECKSUMS
- /*ARGSUSED*/
- GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
+ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h GC_ATTR_UNUSED)
{
# if defined(GWW_VDB)
if (GC_GWW_AVAILABLE())
return(GC_grungy_bits[h - (struct hblk *)GC_vd_base] & PCR_VD_DB_dirtyBit);
}
-/*ARGSUSED*/
GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree)
+ GC_bool is_ptrfree GC_ATTR_UNUSED)
{
PCR_VD_WriteProtectDisable(h, nblocks*HBLKSIZE);
PCR_VD_WriteProtectEnable(h, nblocks*HBLKSIZE);
STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context);
#ifdef SA_SIGINFO
- /*ARGSUSED*/
- STATIC void GC_suspend_handler(int sig, siginfo_t *info, void *context)
+ STATIC void GC_suspend_handler(int sig, siginfo_t * info GC_ATTR_UNUSED,
+ void * context GC_ATTR_UNUSED)
#else
STATIC void GC_suspend_handler(int sig)
#endif
# endif
}
-/*ARGSUSED*/
-STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context)
+STATIC void GC_suspend_handler_inner(ptr_t sig_arg,
+ void * context GC_ATTR_UNUSED)
{
pthread_t self = pthread_self();
GC_thread me;
/* Wrapper for functions that are likely to block for an appreciable */
/* length of time. */
-/*ARGSUSED*/
-GC_INNER void GC_do_blocking_inner(ptr_t data, void * context)
+GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED)
{
struct blocking_data * d = (struct blocking_data *) data;
GC_thread me;
GC_dirty(p);
}
- /*ARGSUSED*/
- GC_API void GC_CALL GC_change_stubborn(void *p)
+ GC_API void GC_CALL GC_change_stubborn(void *p GC_ATTR_UNUSED)
{
}
return(GC_malloc(lb));
}
- /*ARGSUSED*/
- GC_API void GC_CALL GC_end_stubborn_change(void *p)
+ GC_API void GC_CALL GC_end_stubborn_change(void *p GC_ATTR_UNUSED)
{
}
- /*ARGSUSED*/
- GC_API void GC_CALL GC_change_stubborn(void *p)
+ GC_API void GC_CALL GC_change_stubborn(void *p GC_ATTR_UNUSED)
{
}
# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
DWORD __stdcall tiny_reverse_test(void * arg)
# else
- void * tiny_reverse_test(void * arg)
+ void * tiny_reverse_test(void * arg GC_ATTR_UNUSED)
# endif
{
int i;
int fail_count = 0;
-/*ARGSUSED*/
-void GC_CALLBACK fail_proc1(void * x)
+void GC_CALLBACK fail_proc1(void *x GC_ATTR_UNUSED)
{
fail_count++;
}
#endif
#if defined(GC_PTHREADS)
-void * thr_run_one_test(void * arg)
+void * thr_run_one_test(void * arg GC_ATTR_UNUSED)
{
run_one_test();
return(0);
if (res == GC_SUCCESS)
GC_unregister_my_thread ();
- return (void*)(GC_word)creation_res;
+ return arg ? (void*)(GC_word)creation_res : 0;
}
void on_thread_exit (void *v)
{
- GC_call_with_stack_base (on_thread_exit_inner, NULL);
+ GC_call_with_stack_base (on_thread_exit_inner, v);
}
void make_key (void)
}
}
-/*ARGSUSED*/
STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
- mse * mark_stack_limit, word env)
+ mse * mark_stack_limit,
+ word env GC_ATTR_UNUSED)
{
hdr * hhdr = HDR(addr);
size_t sz = hhdr -> hb_sz;
/* length of time. */
/* GC_do_blocking_inner() is nearly the same as in pthread_support.c */
-/*ARGSUSED*/
-GC_INNER void GC_do_blocking_inner(ptr_t data, void * context)
+GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED)
{
struct blocking_data * d = (struct blocking_data *) data;
DWORD thread_id = GetCurrentThreadId();
/* collector. (The alternative of initializing the collector here */
/* seems dangerous, since DllMain is limited in what it can do.) */
- /*ARGSUSED*/
- BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
+ BOOL WINAPI DllMain(HINSTANCE inst GC_ATTR_UNUSED, ULONG reason,
+ LPVOID reserved GC_ATTR_UNUSED)
{
struct GC_stack_base sb;
DWORD thread_id;