Rename use iterate define

Signed-off-by: Timur Valeev <valeev.timur@huawei.com>
This commit is contained in:
Timur Valeev
2022-07-29 10:04:25 +03:00
parent c5f5968099
commit b01de45aea
3 changed files with 11 additions and 8 deletions
+2
View File
@@ -44,6 +44,7 @@ ohos_shared_library("libmimalloc_shared") {
"MI_SHARED_LIB",
"MI_SHARED_LIB_EXPORT",
"MI_TLS_PTHREAD",
"MI_USE_SYNCHRONIZED_ITERATE",
"__OHOS__",
"mimalloc_EXPORTS"
]
@@ -65,6 +66,7 @@ ohos_static_library("libmimalloc_static") {
defines = [
"MI_MALLOC_OVERRIDE",
"MI_TLS_PTHREAD",
"MI_USE_SYNCHRONIZED_ITERATE",
"__OHOS__",
"mimalloc_EXPORTS"
]
+7 -6
View File
@@ -15,7 +15,7 @@ terms of the MIT license. A copy of the license can be found in the file
#pragma warning(disable:4204) // non-constant aggregate initializer
#endif
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
mi_decl_cache_align _Atomic(bool) heap_init_disabled; // = 0
#endif
@@ -632,7 +632,7 @@ int mi_malloc_iterate(void* base, size_t size, void (*callback)(void* base, size
return 0;
}
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
static inline void mi_common_lock(_Atomic(bool) *flag) {
while (mi_atomic_exchange_acq_rel(flag, true)) {
mi_atomic_yield();
@@ -646,17 +646,18 @@ static inline void mi_common_unlock(_Atomic(bool) *flag) {
bool _mi_heap_lock_malloc(void) {
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
mi_heap_t *heap = mi_get_default_heap();
if (mi_unlikely(heap == NULL || heap->tld == NULL))
return false;
mi_common_lock(&heap->tld->malloc_disabled);
return true;
#endif
return false;
}
void _mi_heap_unlock_malloc(void) {
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
mi_heap_t *heap = mi_get_default_heap();
if (mi_likely(heap != NULL && heap->tld != NULL))
mi_common_unlock(&heap->tld->malloc_disabled);
@@ -664,7 +665,7 @@ void _mi_heap_unlock_malloc(void) {
}
void _mi_heap_lock_iterate(void) {
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
mi_common_lock(&heap_init_disabled);
mi_heap_t* heap = _mi_heap_main_get();
while (heap != NULL) {
@@ -676,7 +677,7 @@ void _mi_heap_lock_iterate(void) {
}
void _mi_heap_unlock_iterate(void) {
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
mi_heap_t* heap = _mi_heap_main_get();
while (heap != NULL) {
if (heap->tld != NULL)
+2 -2
View File
@@ -15,7 +15,7 @@ terms of the MIT license. A copy of the license can be found in the file
static mi_decl_cache_align _Atomic(bool) lock_heap_queue; // = 0
static mi_heap_t* heap_queue_last; // = NULL
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
extern mi_decl_cache_align _Atomic(bool) heap_init_disabled; // = 0
#endif
@@ -343,7 +343,7 @@ static bool _mi_heap_init(void) {
tld->segments.os = &tld->os;
tld->os.stats = &tld->stats;
_mi_heap_set_default_direct(heap);
#if defined(USE_SYNCHRONIZED_ITERATE)
#if defined(MI_USE_SYNCHRONIZED_ITERATE)
while (mi_atomic_load_acquire(&heap_init_disabled)) {}
#endif
mi_heap_queue_push(heap);