@@ -46,6 +46,8 @@ extern "C" {
4646
4747#include " pool_disjoint_temp.h"
4848
49+ extern __TLS umf_result_t TLS_last_allocation_error_dp;
50+
4951#ifdef __cplusplus
5052}
5153#endif
@@ -221,7 +223,7 @@ static void *memoryProviderAlloc(umf_memory_provider_handle_t hProvider,
221223 void *ptr;
222224 auto ret = umfMemoryProviderAlloc (hProvider, size, alignment, &ptr);
223225 if (ret != UMF_RESULT_SUCCESS) {
224- umf::getPoolLastStatusRef<DisjointPool>() = ret;
226+ TLS_last_allocation_error_dp = ret;
225227 return NULL ;
226228 }
227229 annotate_memory_inaccessible (ptr, size);
@@ -243,7 +245,7 @@ static umf_result_t memoryProviderFree(umf_memory_provider_handle_t hProvider,
243245 auto ret = umfMemoryProviderFree (hProvider, ptr, size);
244246 if (ret != UMF_RESULT_SUCCESS) {
245247
246- umf::getPoolLastStatusRef<DisjointPool>() = ret;
248+ TLS_last_allocation_error_dp = ret;
247249 // throw MemoryProviderError{ret};
248250 return ret;
249251 }
@@ -295,8 +297,7 @@ void *AllocImpl_allocate(AllocImpl *ai, size_t Size, bool *FromPool) {
295297
296298 if (Ptr == NULL ) {
297299 // TODO get code from func
298- umf::getPoolLastStatusRef<DisjointPool>() =
299- UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
300+ TLS_last_allocation_error_dp = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
300301 return nullptr ;
301302 }
302303
@@ -314,8 +315,7 @@ void *AllocImpl_allocate(AllocImpl *ai, size_t Size, bool *FromPool) {
314315
315316 if (Ptr == NULL ) {
316317 // TODO get code from func
317- umf::getPoolLastStatusRef<DisjointPool>() =
318- UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
318+ TLS_last_allocation_error_dp = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
319319 return nullptr ;
320320 }
321321
@@ -493,13 +493,13 @@ void *DisjointPool::malloc(size_t size) { // For full-slab allocations indicates
493493
494494void *DisjointPool::calloc (size_t , size_t ) {
495495 // Not supported
496- umf::getPoolLastStatusRef<DisjointPool>() = UMF_RESULT_ERROR_NOT_SUPPORTED;
496+ TLS_last_allocation_error_dp = UMF_RESULT_ERROR_NOT_SUPPORTED;
497497 return NULL ;
498498}
499499
500500void *DisjointPool::realloc (void *, size_t ) {
501501 // Not supported
502- umf::getPoolLastStatusRef<DisjointPool>() = UMF_RESULT_ERROR_NOT_SUPPORTED;
502+ TLS_last_allocation_error_dp = UMF_RESULT_ERROR_NOT_SUPPORTED;
503503 return NULL ;
504504}
505505
@@ -542,7 +542,7 @@ umf_result_t DisjointPool::free(void *ptr) {
542542}
543543
544544umf_result_t DisjointPool::get_last_allocation_error () {
545- return umf::getPoolLastStatusRef<DisjointPool>() ;
545+ return TLS_last_allocation_error_dp ;
546546}
547547
548548DisjointPool::DisjointPool () {}
0 commit comments