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 #ifdef HAVE___BUILTIN_EXPECT
108 #define ABTU_likely(cond) __builtin_expect(!!(cond), 1)
109 #define ABTU_unlikely(cond) __builtin_expect(!!(cond), 0)
111 #define ABTU_likely(cond) (cond)
112 #define ABTU_unlikely(cond) (cond)
115 #ifdef HAVE_FUNC_ATTRIBUTE_NORETURN
116 #define ABTU_noreturn __attribute__((noreturn))
118 #define ABTU_noreturn
121 #ifdef HAVE___BUILTIN_UNREACHABLE
122 #define ABTU_unreachable() __builtin_unreachable()
133 #ifdef ABT_CONFIG_HAVE_ALIGNOF_GCC
134 #define ABTU_alignof(type) (__alignof__(type))
135 #elif defined(ABT_CONFIG_HAVE_ALIGNOF_C11)
136 #define ABTU_alignof(type) (alignof(type))
138 #define ABTU_alignof(type) 16
140 #define ABTU_MAX_ALIGNMENT \
141 ABTU_max_size(ABTU_alignof(long double), ABTU_alignof(long long))
143 #ifdef HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT
144 #define ABTU_ret_err __attribute__((warn_unused_result))
159 #define ABTU_align_member_var(size) __attribute__((aligned(size)))
162 #define ABTU_align_member_var(size)
168 #if defined(__GNUC__) && defined(__SANITIZE_ADDRESS__)
177 #define ABTU_no_sanitize_address __attribute__((no_sanitize_address))
180 #if defined(__has_feature)
181 #if __has_feature(address_sanitizer)
182 #if __clang_major__ >= 4 || (__clang_major__ >= 3 && __clang_minor__ >= 7)
184 #define ABTU_no_sanitize_address __attribute__((no_sanitize("address")))
185 #elif (__clang_major__ >= 3 && __clang_minor__ >= 3)
187 #define ABTU_no_sanitize_address __attribute__((no_sanitize_address))
188 #elif (__clang_major__ >= 3 && __clang_minor__ >= 1)
190 #define ABTU_no_sanitize_address __attribute__((no_address_safety_analysis))
192 #define ABTU_no_sanitize_address
198 #ifndef ABTU_no_sanitize_address
200 #define ABTU_no_sanitize_address
209 int ret = posix_memalign(&ptr, alignment, size);
222 #ifdef ABT_CONFIG_USE_ALIGNED_ALLOC
241 memset(ptr, 0, num * size);
249 void *new_ptr, *old_ptr = *p_ptr;
264 void *ptr = malloc(size);
275 void *ptr = calloc(num, size);
287 void *ptr = realloc(*p_ptr, new_size);
static size_t ABTU_max_size(size_t a, size_t b)
static int ABTU_min_int(int a, int b)
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 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
static int32_t ABTU_max_int32(int32_t a, int32_t b)
static uint64_t ABTU_min_uint64(uint64_t a, uint64_t b)
#define ABTI_IS_ERROR_CHECK_ENABLED
static uint32_t ABTU_max_uint32(uint32_t a, uint32_t b)
ABTU_ret_err int ABTU_atoui64(const char *str, uint64_t *p_val, ABT_bool *p_overflow)
@ ABTU_MEM_LARGEPAGE_MMAP_HUGEPAGE
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.
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)
@ 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 ABTU_noreturn void ABTU_unreachable(void)
static uint32_t ABTU_min_uint32(uint32_t a, uint32_t b)
static uint32_t ABTU_roundup_uint32(uint32_t val, uint32_t multiple)