ARGOBOTS
dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
|
Go to the documentation of this file.
6 #ifndef ABTU_H_INCLUDED
7 #define ABTU_H_INCLUDED
77 if ((multiple & (multiple - 1)) == 0) {
79 return (val + multiple - 1) & (~(multiple - 1));
81 return ((val + multiple - 1) / multiple) * multiple;
87 if ((multiple & (multiple - 1)) == 0) {
89 return (val + multiple - 1) & (~(multiple - 1));
91 return ((val + multiple - 1) / multiple) * multiple;
97 if ((multiple & (multiple - 1)) == 0) {
99 return (val + multiple - 1) & (~(multiple - 1));
101 return ((val + multiple - 1) / multiple) * multiple;
107 if ((multiple & (multiple - 1)) == 0) {
109 return (
void *)((((uintptr_t)ptr) + multiple - 1) & (~(multiple - 1)));
111 return (
void *)(((((uintptr_t)ptr) + multiple - 1) / multiple) *
118 #ifdef HAVE___BUILTIN_EXPECT
119 #define ABTU_likely(cond) __builtin_expect(!!(cond), 1)
120 #define ABTU_unlikely(cond) __builtin_expect(!!(cond), 0)
122 #define ABTU_likely(cond) (cond)
123 #define ABTU_unlikely(cond) (cond)
126 #ifdef HAVE_FUNC_ATTRIBUTE_NORETURN
127 #define ABTU_noreturn __attribute__((noreturn))
129 #define ABTU_noreturn
132 #ifdef HAVE___BUILTIN_UNREACHABLE
133 #define ABTU_unreachable() __builtin_unreachable()
144 #ifdef ABT_CONFIG_HAVE_ALIGNOF_GCC
145 #define ABTU_alignof(type) (__alignof__(type))
146 #elif defined(ABT_CONFIG_HAVE_ALIGNOF_C11)
147 #define ABTU_alignof(type) (alignof(type))
149 #define ABTU_alignof(type) 16
151 #define ABTU_MAX_ALIGNMENT \
152 ABTU_max_size(ABTU_alignof(long double), ABTU_alignof(long long))
154 #ifdef HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT
155 #define ABTU_ret_err __attribute__((warn_unused_result))
170 #define ABTU_align_member_var(size) __attribute__((aligned(size)))
173 #define ABTU_align_member_var(size)
179 #if defined(__GNUC__) && defined(__SANITIZE_ADDRESS__)
188 #define ABTU_no_sanitize_address __attribute__((no_sanitize_address))
191 #if defined(__has_feature)
192 #if __has_feature(address_sanitizer)
193 #if __clang_major__ >= 4 || (__clang_major__ >= 3 && __clang_minor__ >= 7)
195 #define ABTU_no_sanitize_address __attribute__((no_sanitize("address")))
196 #elif (__clang_major__ >= 3 && __clang_minor__ >= 3)
198 #define ABTU_no_sanitize_address __attribute__((no_sanitize_address))
199 #elif (__clang_major__ >= 3 && __clang_minor__ >= 1)
201 #define ABTU_no_sanitize_address __attribute__((no_address_safety_analysis))
203 #define ABTU_no_sanitize_address
209 #ifndef ABTU_no_sanitize_address
211 #define ABTU_no_sanitize_address
220 int ret = posix_memalign(&ptr, alignment, size);
221 if (ABTI_IS_ERROR_CHECK_ENABLED && ret != 0) {
233 #ifdef ABT_CONFIG_USE_ALIGNED_ALLOC
249 if (ABTI_IS_ERROR_CHECK_ENABLED && ret !=
ABT_SUCCESS) {
252 memset(ptr, 0, num * size);
260 void *new_ptr, *old_ptr = *p_ptr;
262 if (ABTI_IS_ERROR_CHECK_ENABLED && ret !=
ABT_SUCCESS) {
275 void *ptr = malloc(size);
276 if (ABTI_IS_ERROR_CHECK_ENABLED && ptr == NULL) {
286 void *ptr = calloc(num, size);
287 if (ABTI_IS_ERROR_CHECK_ENABLED && ptr == NULL) {
298 void *ptr = realloc(*p_ptr, new_size);
299 if (ABTI_IS_ERROR_CHECK_ENABLED && ptr == NULL) {
358 const void *data,
int *overwritten);
static size_t ABTU_max_size(size_t a, size_t b)
static int ABTU_min_int(int a, int b)
ABTU_ret_err int ABTU_hashtable_create(size_t num_entries, size_t data_size, ABTU_hashtable **pp_hashtable)
int ABT_bool
Boolean type.
static int64_t ABTU_max_int64(int64_t a, int64_t b)
static uint64_t ABTU_max_uint64(uint64_t a, uint64_t b)
static ABTU_ret_err int ABTU_realloc(size_t old_size, size_t new_size, void **p_ptr)
static int ABTU_max_int(int a, int b)
int ABTU_is_supported_largepage_type(size_t size, size_t alignment_hint, ABTU_MEM_LARGEPAGE_TYPE requested)
static void * ABTU_roundup_ptr(void *ptr, size_t multiple)
static size_t ABTU_roundup_size(size_t val, size_t multiple)
static size_t ABTU_min_size(size_t a, size_t b)
static ABTU_ret_err int ABTU_memalign(size_t alignment, size_t size, void **p_ptr)
ABTU_ret_err int ABTU_alloc_largepage(size_t size, size_t alignment_hint, const ABTU_MEM_LARGEPAGE_TYPE *requested_types, int num_requested_types, ABTU_MEM_LARGEPAGE_TYPE *p_actual, void **p_ptr)
void ABTU_free_largepage(void *ptr, size_t size, ABTU_MEM_LARGEPAGE_TYPE type)
@ ABTU_MEM_LARGEPAGE_MMAP
void ABTU_hashtable_get(const ABTU_hashtable *p_hashtable, int key, void *data, int *found)
static int32_t ABTU_max_int32(int32_t a, int32_t b)
ABTU_ret_err int ABTU_mprotect(void *addr, size_t size, ABT_bool protect)
static uint64_t ABTU_min_uint64(uint64_t a, uint64_t b)
struct ABTU_hashtable_element ABTU_hashtable_element
static uint32_t ABTU_max_uint32(uint32_t a, uint32_t b)
#define ABTU_unreachable()
ABTU_ret_err int ABTU_atoui64(const char *str, uint64_t *p_val, ABT_bool *p_overflow)
@ ABTU_MEM_LARGEPAGE_MMAP_HUGEPAGE
void ABTU_hashtable_delete(ABTU_hashtable *p_hashtable, int key, int *deleted)
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
static uint64_t ABTU_roundup_uint64(uint64_t val, uint64_t multiple)
#define ABT_ERR_MEM
Error code: Memory allocation failure.
struct ABTU_hashtable ABTU_hashtable
static ABTU_ret_err int ABTU_calloc(size_t num, size_t size, void **p_ptr)
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
#define ABT_SUCCESS
Error code: the routine returns successfully.
ABTU_ret_err int ABTU_atoui32(const char *str, uint32_t *p_val, ABT_bool *p_overflow)
@ ABTU_MEM_LARGEPAGE_MALLOC
static int32_t ABTU_min_int32(int32_t a, int32_t b)
ABTU_ret_err int ABTU_atoi(const char *str, int *p_val, ABT_bool *p_overflow)
static void ABTU_free(void *ptr)
void ABTU_hashtable_free(ABTU_hashtable *p_hashtable)
ABTU_ret_err int ABTU_hashtable_set(ABTU_hashtable *p_hashtable, int key, const void *data, int *overwritten)
struct ABTU_hashtable_element * p_next
@ ABTU_MEM_LARGEPAGE_MEMALIGN
ABTU_ret_err int ABTU_atosz(const char *str, size_t *p_val, ABT_bool *p_overflow)
static int64_t ABTU_min_int64(int64_t a, int64_t b)
static uint32_t ABTU_min_uint32(uint32_t a, uint32_t b)
static uint32_t ABTU_roundup_uint32(uint32_t val, uint32_t multiple)