xref: /oneTBB/include/oneapi/tbb/tbbmalloc_proxy.h (revision b15aabb3)
149e08aacStbbdev /*
2*b15aabb3Stbbdev     Copyright (c) 2005-2021 Intel Corporation
349e08aacStbbdev 
449e08aacStbbdev     Licensed under the Apache License, Version 2.0 (the "License");
549e08aacStbbdev     you may not use this file except in compliance with the License.
649e08aacStbbdev     You may obtain a copy of the License at
749e08aacStbbdev 
849e08aacStbbdev         http://www.apache.org/licenses/LICENSE-2.0
949e08aacStbbdev 
1049e08aacStbbdev     Unless required by applicable law or agreed to in writing, software
1149e08aacStbbdev     distributed under the License is distributed on an "AS IS" BASIS,
1249e08aacStbbdev     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349e08aacStbbdev     See the License for the specific language governing permissions and
1449e08aacStbbdev     limitations under the License.
1549e08aacStbbdev */
1649e08aacStbbdev 
1749e08aacStbbdev /*
1849e08aacStbbdev Replacing the standard memory allocation routines in Microsoft* C/C++ RTL
1949e08aacStbbdev (malloc/free, global new/delete, etc.) with the TBB memory allocator.
2049e08aacStbbdev 
2149e08aacStbbdev Include the following header to a source of any binary which is loaded during
2249e08aacStbbdev application startup
2349e08aacStbbdev 
2449e08aacStbbdev #include "oneapi/tbb/tbbmalloc_proxy.h"
2549e08aacStbbdev 
2649e08aacStbbdev or add following parameters to the linker options for the binary which is
2749e08aacStbbdev loaded during application startup. It can be either exe-file or dll.
2849e08aacStbbdev 
2949e08aacStbbdev For win32
3049e08aacStbbdev tbbmalloc_proxy.lib /INCLUDE:"___TBB_malloc_proxy"
3149e08aacStbbdev win64
3249e08aacStbbdev tbbmalloc_proxy.lib /INCLUDE:"__TBB_malloc_proxy"
3349e08aacStbbdev */
3449e08aacStbbdev 
3549e08aacStbbdev #ifndef __TBB_tbbmalloc_proxy_H
3649e08aacStbbdev #define __TBB_tbbmalloc_proxy_H
3749e08aacStbbdev 
3849e08aacStbbdev #if _MSC_VER
3949e08aacStbbdev 
4049e08aacStbbdev #ifdef _DEBUG
4149e08aacStbbdev     #pragma comment(lib, "tbbmalloc_proxy_debug.lib")
4249e08aacStbbdev #else
4349e08aacStbbdev     #pragma comment(lib, "tbbmalloc_proxy.lib")
4449e08aacStbbdev #endif
4549e08aacStbbdev 
4649e08aacStbbdev #if defined(_WIN64)
4749e08aacStbbdev     #pragma comment(linker, "/include:__TBB_malloc_proxy")
4849e08aacStbbdev #else
4949e08aacStbbdev     #pragma comment(linker, "/include:___TBB_malloc_proxy")
5049e08aacStbbdev #endif
5149e08aacStbbdev 
5249e08aacStbbdev #else
5349e08aacStbbdev /* Primarily to support MinGW */
5449e08aacStbbdev 
5549e08aacStbbdev extern "C" void __TBB_malloc_proxy();
5649e08aacStbbdev struct __TBB_malloc_proxy_caller {
__TBB_malloc_proxy_caller__TBB_malloc_proxy_caller5749e08aacStbbdev     __TBB_malloc_proxy_caller() { __TBB_malloc_proxy(); }
5849e08aacStbbdev } volatile __TBB_malloc_proxy_helper_object;
5949e08aacStbbdev 
6049e08aacStbbdev #endif // _MSC_VER
6149e08aacStbbdev 
6249e08aacStbbdev /* Public Windows API */
6349e08aacStbbdev extern "C" int TBB_malloc_replacement_log(char *** function_replacement_log_ptr);
6449e08aacStbbdev 
6549e08aacStbbdev #endif //__TBB_tbbmalloc_proxy_H
66