Skip to content

Commit

Permalink
Merge pull request #321 from shintaro-iwasaki/pr/fix_misc
Browse files Browse the repository at this point in the history
fix miscellaneous issues
  • Loading branch information
shintaro-iwasaki committed Mar 25, 2021
2 parents bb94949 + d3c63b7 commit 6a144a7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/arch/abtd_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/include/abtu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 3 additions & 5 deletions test/util/abttest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6a144a7

Please sign in to comment.