diff --git a/src/arch/abtd_env.c b/src/arch/abtd_env.c index 9b564d44..42e33a19 100644 --- a/src/arch/abtd_env.c +++ b/src/arch/abtd_env.c @@ -23,9 +23,9 @@ /* To avoid potential overflow, we intentionally use a smaller value than the * real limit. */ #define ABTD_ENV_INT_MAX ((int)(INT_MAX / 2)) -#define ABTD_ENV_UINT32_MAX ((int)(UINT32_MAX / 2)) -#define ABTD_ENV_UINT64_MAX ((int)(UINT64_MAX / 2)) -#define ABTD_ENV_SIZE_MAX ((int)(SIZE_MAX / 2)) +#define ABTD_ENV_UINT32_MAX ((uint32_t)(UINT32_MAX / 2)) +#define ABTD_ENV_UINT64_MAX ((uint64_t)(UINT64_MAX / 2)) +#define ABTD_ENV_SIZE_MAX ((size_t)(SIZE_MAX / 2)) static uint32_t roundup_pow2_uint32(uint32_t val); #ifdef ABT_CONFIG_USE_MEM_POOL diff --git a/src/include/abtu.h b/src/include/abtu.h index afb07c5d..f297edaa 100644 --- a/src/include/abtu.h +++ b/src/include/abtu.h @@ -112,18 +112,24 @@ static inline size_t ABTU_roundup_size(size_t val, size_t multiple) #define ABTU_unlikely(cond) (cond) #endif -#ifdef HAVE___BUILTIN_UNREACHABLE -#define ABTU_unreachable() __builtin_unreachable() -#else -#define ABTU_unreachable() -#endif - #ifdef HAVE_FUNC_ATTRIBUTE_NORETURN #define ABTU_noreturn __attribute__((noreturn)) #else #define ABTU_noreturn #endif +#ifdef HAVE___BUILTIN_UNREACHABLE +#define ABTU_unreachable() __builtin_unreachable() +#else +/* abort is better than entering an unknown area. First assert(0), which shows + * something if assert() is enabled. If assert() is disabled, let's abort(). */ +static inline ABTU_noreturn void ABTU_unreachable(void) +{ + assert(0); + abort(); +} +#endif + #ifdef ABT_CONFIG_HAVE_ALIGNOF_GCC #define ABTU_alignof(type) (__alignof__(type)) #elif defined(ABT_CONFIG_HAVE_ALIGNOF_C11) diff --git a/src/info.c b/src/info.c index 8e019559..b3864228 100644 --- a/src/info.c +++ b/src/info.c @@ -372,7 +372,6 @@ int ABT_info_query_config(ABT_info_query_kind query_kind, void *val) break; default: ABTI_HANDLE_ERROR(ABT_ERR_INV_QUERY_KIND); - break; } return ABT_SUCCESS; } diff --git a/src/thread.c b/src/thread.c index 59974765..aac05d15 100644 --- a/src/thread.c +++ b/src/thread.c @@ -484,6 +484,9 @@ int ABT_thread_free_many(int num_threads, ABT_thread *thread_list) for (i = 0; i < num_threads; i++) { ABTI_thread *p_thread = ABTI_thread_get_ptr(thread_list[i]); + thread_list[i] = ABT_THREAD_NULL; + if (!p_thread) + continue; /* TODO: check input */ thread_join(&p_local, p_thread); ABTI_thread_free(p_global, p_local, p_thread); @@ -582,8 +585,11 @@ int ABT_thread_join_many(int num_threads, ABT_thread *thread_list) ABTI_local *p_local = ABTI_local_get_local(); int i; for (i = 0; i < num_threads; i++) { + ABTI_thread *p_thread = ABTI_thread_get_ptr(thread_list[i]); + if (!p_thread) + continue; /* TODO: check input */ - thread_join(&p_local, ABTI_thread_get_ptr(thread_list[i])); + thread_join(&p_local, p_thread); } return ABT_SUCCESS; } diff --git a/test/util/abttest.c b/test/util/abttest.c index ca535f8e..efd6f810 100644 --- a/test/util/abttest.c +++ b/test/util/abttest.c @@ -221,9 +221,6 @@ void ATS_read_args(int argc, char **argv) int ATS_get_arg_val(ATS_arg arg) { - if (arg < ATS_ARG_N_ES || (int)arg >= NUM_ARG_KINDS) { - return 0; - } return g_arg_val[arg]; } @@ -344,14 +341,15 @@ static inline size_t ABT_tool_unit_entry_table_index(const void *unit) uint32_t val2 = val ^ (val >> 16); return (val2 ^ (val2 >> 8)) & (ATS_TOOL_UNIT_ENTRY_TABLE_NUM_ENTIRES - 1); - } else if (sizeof(void *) == 8) { + } else { + /* We support only 32-bit or 64-bit pointer sizes. */ + assert(sizeof(void *) == 8); uint64_t val = (uint64_t)(uintptr_t)unit; uint64_t val2 = val ^ (val >> 32); uint64_t val3 = val2 ^ (val2 >> 16); return (val3 ^ (val3 >> 8)) & (ATS_TOOL_UNIT_ENTRY_TABLE_NUM_ENTIRES - 1); } - return 0; } static ATS_tool_unit_entry *ATS_tool_get_unit_entry(const void *unit)