Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Go to the documentation of this file.
31 #if __TBB_WEAK_SYMBOLS_PRESENT
33 #pragma weak scalable_malloc
34 #pragma weak scalable_free
35 #pragma weak scalable_aligned_malloc
36 #pragma weak scalable_aligned_free
91 #define DEBUG_SUFFIX "_debug"
98 #define MALLOCLIB_NAME "tbbmalloc" DEBUG_SUFFIX ".dll"
100 #define MALLOCLIB_NAME "libtbbmalloc" DEBUG_SUFFIX ".dylib"
101 #elif __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __sun || _AIX || __ANDROID__
102 #define MALLOCLIB_NAME "libtbbmalloc" DEBUG_SUFFIX ".so"
103 #elif __linux__ // Note that order of these #elif's is important!
104 #define MALLOCLIB_NAME "libtbbmalloc" DEBUG_SUFFIX __TBB_STRING(.so.TBB_COMPATIBLE_INTERFACE_VERSION)
126 #if !__TBB_RML_STATIC
147 (*FreeHandler)( ptr );
161 (*padded_free_handler)( ptr );
171 #if _MSC_VER && !defined(__INTEL_COMPILER)
173 #pragma warning( disable: 4146 4706 )
181 size_t bytes = n*element_size;
183 if (bytes<n || bytes+nfs_cache_line_size<bytes) {
188 if (bytes==0) bytes = 1;
190 void* result = (*padded_allocate_handler)( bytes, nfs_cache_line_size );
194 __TBB_ASSERT(
is_aligned(result, nfs_cache_line_size),
"The address returned isn't aligned to cache line size" );
199 (*padded_free_handler)(
p );
203 unsigned char* result = NULL;
204 unsigned char* base = (
unsigned char*)std::malloc(alignment+bytes);
207 result = (
unsigned char*)((uintptr_t)(base+alignment)&-alignment);
209 ((uintptr_t*)result)[-1] = uintptr_t(base);
216 __TBB_ASSERT( (uintptr_t)
p>=0x4096,
"attempt to free block not obtained from cache_aligned_allocator" );
218 unsigned char* base = ((
unsigned char**)
p)[-1];
225 void* result = (*MallocHandler) (n);
240 void* void_ptr = (*MallocHandler)(1);
241 (*FreeHandler)(void_ptr);
246 "Both shim pointers must refer to routines from the same package (either TBB or CRT)" );
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.
void __TBB_EXPORTED_FUNC scalable_free(void *ptr)
static const dynamic_link_descriptor MallocLinkTable[]
Table describing how to link the handlers.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
OPEN_INTERNAL_NAMESPACE bool dynamic_link(const char *, const dynamic_link_descriptor *, size_t, dynamic_link_handle *handle, int)
void initialize_cache_aligned_allocator()
Defined in cache_aligned_allocator.cpp.
Association between a handler name and location of pointer to it.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
bool is_power_of_two(integer_type arg)
A function to check if passed integer is a power of 2.
void initialize_handler_pointers()
Initialize the allocation/free handler pointers.
static void *(* padded_allocate_handler)(size_t bytes, size_t alignment)
Handler for padded memory allocation.
void *__TBB_EXPORTED_FUNC scalable_aligned_malloc(size_t size, size_t alignment)
#define DLD(s, h)
The helper to construct dynamic_link_descriptor structure.
static void DummyFree(void *ptr)
Dummy routine used for first indirect call via FreeHandler.
static void padded_free(void *p)
void *__TBB_EXPORTED_FUNC scalable_malloc(size_t size)
static void(* padded_free_handler)(void *p)
Handler for padded memory deallocation.
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
static void * DummyMalloc(size_t size)
Dummy routine used for first indirect call via MallocHandler.
static size_t NFS_LineSize
bool is_aligned(T *pointer, uintptr_t alignment)
A function to check if passed in pointer is aligned on a specific border.
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
#define __TBB_EXPORTED_FUNC
static void *(* MallocHandler)(size_t size)
Handler for memory allocation.
void atomic_do_once(const F &initializer, atomic< do_once_state > &state)
One-time initialization function.
size_t __TBB_EXPORTED_FUNC NFS_GetLineSize()
Cache/sector line size.
void __TBB_EXPORTED_FUNC scalable_aligned_free(void *ptr)
static void(* FreeHandler)(void *pointer)
Handler for memory deallocation.
void const char const char int ITT_FORMAT __itt_group_sync p
void __TBB_EXPORTED_FUNC NFS_Free(void *)
Free memory allocated by NFS_Allocate.
void PrintExtraVersionInfo(const char *category, const char *format,...)
Prints arbitrary extra TBB version information on stderr.
static void dummy_padded_free(void *ptr)
Dummy routine used for first indirect call via padded_free_handler.
void *__TBB_EXPORTED_FUNC NFS_Allocate(size_t n_element, size_t element_size, void *hint)
Allocate memory on cache/sector line boundary.
static void * padded_allocate(size_t bytes, size_t alignment)
static tbb::atomic< do_once_state > initialization_state
bool __TBB_EXPORTED_FUNC is_malloc_used_v3()
Returns true if standard malloc/free are used to work with memory.
static void * dummy_padded_allocate(size_t bytes, size_t alignment)
Dummy routine used for first indirect call via padded_allocate_handler.
Copyright © 2005-2020 Intel Corporation. All Rights Reserved.
Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
registered trademarks or trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.
* Other names and brands may be claimed as the property of others.