[m-rev.] diff: fix more runtime issues identified by clang -Wall
Julien Fischer
jfischer at opturion.com
Fri Mar 21 14:53:36 AEDT 2014
Branches: 14.01, master.
-----------------------
Fix more issues in the runtime identified using clang -Wall.
runtime/mercury_wrapper.c:
Declare MR_usage to be a noreturn function. This avoids
warnings in other parts of this module.
runtime/mercury_context.c
Only define MR_write_out_profiling_parallel_execution if
MR_PROFILE_PARALLEL_EXECUTION_SUPPORT is defined; it is
otherwise unused.
Fix incorrect conversion specifiers in some calls to fprintf.
Only define the function action_shutdown_engine and friends
if MR_THREAD_SAFE is defined.
Do not define MR_checking_pending_contexts if MR_HIGHLEVEL_CODE
is defined.
runtime/mercury_debug.c:
Protect a group of function prototypes with MR_LOWLEVEL_DEBUG.
(The corresponding definitions were already protected by this
macro.)
runtime/mercury_label.c:
Delete the declaration of the function compare_entry_by_addr
as that function is not defined anywhere.
Delete an unused local variable.
runtime/mercury_make_type_info_body.h:
Delete an unused local variable.
runtime/mercury_memory.c:
Delete left over function prototypes for try_munprotect and
explain_context. (The functions were moved into the module
mercury_memory_handlers a long time ago.)
runtime/mercury_memory_handlers.c:
Protect functions that are only used in the low-level agc
grades by the appropriate macros.
runtime/mercury_minimal.c:
runtime/mercury_mm_own_stacks.c:
Don't define some global variables in high-level C grades that
are not necessary in those grades.
runtime/mercury_tabling.c:
Only define MR_table_assert_failed if MR_TABLE_DEBUG is defined
since it is otherwise unused.
Julien.
diff --git a/runtime/mercury_context.c b/runtime/mercury_context.c
index f32b1be..85fc51c 100644
--- a/runtime/mercury_context.c
+++ b/runtime/mercury_context.c
@@ -285,11 +285,13 @@ try_notify_engine(MR_EngineId engine_id, int action,
union MR_engine_wake_action_data *action_data, MR_Unsigned engine_state);
#endif
+#ifdef MR_PROFILE_PARALLEL_EXECUTION_SUPPORT
/*
** Write out the profiling data that we collect during execution.
*/
static void
MR_write_out_profiling_parallel_execution(void);
+#endif
#if defined(MR_LL_PARALLEL_CONJ)
static void
@@ -1251,7 +1253,8 @@ MR_find_ready_context(void)
#ifdef MR_DEBUG_THREADS
if (MR_debug_threads) {
fprintf(stderr,
- "%ld Eng: %d, c_depth: %d, Considering context %p\n",
+ "%ld Eng: %d, c_depth: %" MR_INTEGER_LENGTH_MODIFIER
+ "u, Considering context %p\n",
MR_SELF_THREAD_ID, engine_id, depth, cur);
}
#endif
@@ -1259,7 +1262,8 @@ MR_find_ready_context(void)
#ifdef MR_DEBUG_THREADS
if (MR_debug_threads) {
fprintf(stderr,
- "%ld Context requires engine %d and c_depth %d\n",
+ "%ld Context requires engine %d and c_depth %"
+ MR_INTEGER_LENGTH_MODIFIER "u\n",
MR_SELF_THREAD_ID, cur->MR_ctxt_resume_owner_engine,
cur->MR_ctxt_resume_c_depth);
}
@@ -1434,13 +1438,13 @@ MR_sched_yield(void)
#endif
}
+#ifndef MR_HIGHLEVEL_CODE
/*
** Check to see if any contexts that blocked on IO have become runnable.
** Return the number of contexts that are still blocked.
** The parameter specifies whether or not the call to select should block
** or not.
*/
-
static int
MR_check_pending_contexts(MR_bool block)
{
@@ -1534,8 +1538,9 @@ MR_check_pending_contexts(MR_bool block)
MR_fatal_error("select() unavailable!");
-#endif
+#endif /* !MR_CAN_DO_PENDING_IO */
}
+#endif /* not MR_HIGHLEVEL_CODE */
void
MR_schedule_context(MR_Context *ctxt)
@@ -1670,7 +1675,6 @@ MR_schedule_context(MR_Context *ctxt)
*/
MR_Unsigned state;
- MR_bool notified;
state = esync->d.es_state;
while (state & (ENGINE_STATE_SLEEPING | ENGINE_STATE_IDLE |
@@ -1794,7 +1798,8 @@ try_wake_engine(MR_EngineId engine_id, int action,
MR_atomic_dec_int(&MR_num_idle_engines);
#ifdef MR_DEBUG_THREADS
if (MR_debug_threads) {
- fprintf(stderr, "%ld Decrement MR_num_idle_engines %d\n",
+ fprintf(stderr, "%ld Decrement MR_num_idle_engines %"
+ MR_INTEGER_LENGTH_MODIFIER "d\n",
MR_SELF_THREAD_ID, MR_num_idle_engines);
}
#endif
@@ -1862,7 +1867,8 @@ try_notify_engine(MR_EngineId engine_id, int action,
MR_atomic_dec_int(&MR_num_idle_engines);
#ifdef MR_DEBUG_THREADS
if (MR_debug_threads) {
- fprintf(stderr, "%ld Decrement MR_num_idle_engines %d\n",
+ fprintf(stderr, "%ld Decrement MR_num_idle_engines %"
+ MR_INTEGER_LENGTH_MODIFIER "d\n",
MR_SELF_THREAD_ID, MR_num_idle_engines);
}
#endif
@@ -1957,6 +1963,7 @@ MR_shutdown_all_engines(void)
**
*/
+#ifdef MR_THREAD_SAFE
static void
action_shutdown_engine(void);
@@ -1968,6 +1975,7 @@ action_worksteal(MR_EngineId victim_engine_id);
*/
static MR_Code*
action_context(MR_Context *context);
+#endif /* MR_THREAD_SAFE */
/*
** The run queue used to include timing code. It has been removed and may be
@@ -2020,7 +2028,7 @@ advertise_engine_state_idle(void);
*/
static void
advertise_engine_state_working(void);
-#endif
+#endif /* MR_THREAD_SAFE */
MR_BEGIN_MODULE(scheduler_module_idle)
MR_init_entry_an(MR_do_idle);
diff --git a/runtime/mercury_debug.c b/runtime/mercury_debug.c
index e076f01..92672e8 100644
--- a/runtime/mercury_debug.c
+++ b/runtime/mercury_debug.c
@@ -40,10 +40,12 @@ static void MR_assign_csd(MR_CallSiteDynamic *csd1,
const MR_CallSiteDynamic *csd2);
#endif
+#ifdef MR_LOWLEVEL_DEBUG
static void MR_count_call(FILE *fp, const MR_Code *proc);
static void MR_print_ordinary_regs(FILE *fp);
static void MR_do_watches(FILE *fp);
static MR_bool MR_proc_matches_name(const MR_Code *proc, const char *name);
+#endif
#ifdef MR_LOWLEVEL_ADDR_DEBUG
#define MR_PRINT_RAW_ADDRS MR_TRUE
diff --git a/runtime/mercury_label.c b/runtime/mercury_label.c
index 4b9b4a7..50f4fef 100644
--- a/runtime/mercury_label.c
+++ b/runtime/mercury_label.c
@@ -57,8 +57,6 @@
/* the number of entries in the initial array */
#define INIT_ENTRY_SIZE (1 << 8)
-static int compare_entry_by_addr(const void *e1, const void *e2);
-
static MR_Entry *entry_array;
static int entry_array_size; /* # of entries allocated */
static int entry_array_next; /* # of entries used */
@@ -192,7 +190,6 @@ MR_prev_entry_by_addr(const MR_Code *addr)
int lo;
int hi;
int mid;
- int i;
MR_do_init_label_tables();
MR_do_init_modules();
diff --git a/runtime/mercury_make_type_info_body.h b/runtime/mercury_make_type_info_body.h
index 1ab4910..05ab43a 100644
--- a/runtime/mercury_make_type_info_body.h
+++ b/runtime/mercury_make_type_info_body.h
@@ -36,7 +36,6 @@ exist_func(const params_type params, const MR_PseudoTypeInfo pseudo_type_info,
MAYBE_DECLARE_ALLOC_ARG)
{
MR_TypeCtorInfo type_ctor_info;
- MR_TypeInfo expanded_type_info;
return_type expanded;
MR_Word *type_info_arena;
MR_Word type_info_arena_word;
diff --git a/runtime/mercury_memory.c b/runtime/mercury_memory.c
index 98daf90..146b64b 100644
--- a/runtime/mercury_memory.c
+++ b/runtime/mercury_memory.c
@@ -108,11 +108,6 @@
/*---------------------------------------------------------------------------*/
-#ifdef MR_HAVE_SIGINFO
- static MR_bool try_munprotect(void *address, void *context);
- static char *explain_context(void *context);
-#endif /* MR_HAVE_SIGINFO */
-
/*
** Define the memory zones used by the Mercury runtime.
** (The trail zone is declared in mercury_trail.c.)
diff --git a/runtime/mercury_memory_handlers.c b/runtime/mercury_memory_handlers.c
index 30b2384..6d455ce 100644
--- a/runtime/mercury_memory_handlers.c
+++ b/runtime/mercury_memory_handlers.c
@@ -106,9 +106,11 @@
static void MR_print_dump_stack(void);
static MR_bool MR_try_munprotect(void *address, void *context);
static char *MR_explain_context(void *context);
-static MR_Code *get_pc_from_context(void *the_context);
-static MR_Word *get_sp_from_context(void *the_context);
-static MR_Word *get_curfr_from_context(void *the_context);
+#if defined(MR_NATIVE_GC) && !defined(MR_HIGHLEVEL_CODE)
+ static MR_Code *get_pc_from_context(void *the_context);
+ static MR_Word *get_sp_from_context(void *the_context);
+ static MR_Word *get_curfr_from_context(void *the_context);
+#endif
static void leave_signal_handler(int sig);
#define STDERR 2
@@ -875,6 +877,7 @@ MR_filter_win32_exception(LPEXCEPTION_POINTERS exception_ptrs)
}
#endif /* MR_MSVC_STRUCTURED_EXCEPTIONS */
+#if defined(MR_NATIVE_GC) && !defined(MR_HIGHLEVEL_CODE)
/*
** get_pc_from_context:
** Given the signal context, return the program counter at the time
@@ -1013,6 +1016,7 @@ get_curfr_from_context(void *the_context)
return curfr_at_signal;
}
+#endif /* MR_NATIVE_GC && not MR_HIGHLEVEL_CODE */
static void
MR_print_dump_stack(void)
diff --git a/runtime/mercury_minimal_model.c b/runtime/mercury_minimal_model.c
index 4efc3dc..092779a 100644
--- a/runtime/mercury_minimal_model.c
+++ b/runtime/mercury_minimal_model.c
@@ -2510,7 +2510,9 @@ MR_END_MODULE
INIT mercury_sys_init_mmsc_modules
*/
+#ifndef MR_HIGHLEVEL_CODE
MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc mmsc_module;
+#endif
/* forward declarations to suppress gcc -Wmissing-decl warnings */
void mercury_sys_init_mmsc_modules_init(void);
diff --git a/runtime/mercury_mm_own_stacks.c b/runtime/mercury_mm_own_stacks.c
index 9c25962..335bfe9 100644
--- a/runtime/mercury_mm_own_stacks.c
+++ b/runtime/mercury_mm_own_stacks.c
@@ -889,7 +889,9 @@ MR_END_MODULE
INIT mercury_sys_init_mmos_modules
*/
+#ifndef MR_HIGHLEVEL_CODE
MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc mmos_module;
+#endif
/* forward declarations to suppress gcc -Wmissing-decl warnings */
void mercury_sys_init_mmos_modules_init(void);
diff --git a/runtime/mercury_tabling.c b/runtime/mercury_tabling.c
index 27ad87a..0c3fc25 100644
--- a/runtime/mercury_tabling.c
+++ b/runtime/mercury_tabling.c
@@ -22,9 +22,9 @@
#include <stdlib.h>
#include <string.h>
+#ifdef MR_TABLE_DEBUG
static void MR_table_assert_failed(const char *file, unsigned line);
-#ifdef MR_TABLE_DEBUG
#define MR_table_assert(cond) \
do { \
if (! (cond)) { \
@@ -1563,7 +1563,9 @@ MR_END_MODULE
INIT mercury_sys_init_table_modules
*/
+#ifndef MR_HIGHLEVEL_CODE
MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc table_memo_non_module;
+#endif
/* forward declarations to suppress gcc -Wmissing-decl warnings */
void mercury_sys_init_table_modules_init(void);
@@ -1595,6 +1597,7 @@ void mercury_sys_init_table_modules_write_out_proc_statics(FILE *fp)
/*---------------------------------------------------------------------------*/
+#ifdef MR_TABLE_DEBUG
static void
MR_table_assert_failed(const char *file, unsigned line)
{
@@ -1603,5 +1606,6 @@ MR_table_assert_failed(const char *file, unsigned line)
snprintf(buf, 256, "assertion failed: file %s, line %d", file, line);
MR_fatal_error(buf);
}
+#endif
/*---------------------------------------------------------------------------*/
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index d33ebcd..fe887e3 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -503,7 +503,7 @@ int MR_num_complexity_procs;
static void MR_process_args(int argc, char **argv);
static void MR_process_environment_options(void);
static void MR_process_options(int argc, char **argv);
-static void MR_usage(void);
+MR_NO_RETURN(static void MR_usage(void));
static MR_bool MR_matches_exec_name(const char *option);
#ifdef MR_TYPE_CTOR_STATS
More information about the reviews
mailing list