tbbmalloc_proxy.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright (c) 2005-2020 Intel Corporation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. Replacing the standard memory allocation routines in Microsoft* C/C++ RTL
  15. (malloc/free, global new/delete, etc.) with the TBB memory allocator.
  16. Include the following header to a source of any binary which is loaded during
  17. application startup
  18. #include "tbb/tbbmalloc_proxy.h"
  19. or add following parameters to the linker options for the binary which is
  20. loaded during application startup. It can be either exe-file or dll.
  21. For win32
  22. tbbmalloc_proxy.lib /INCLUDE:"___TBB_malloc_proxy"
  23. win64
  24. tbbmalloc_proxy.lib /INCLUDE:"__TBB_malloc_proxy"
  25. */
  26. #ifndef __TBB_tbbmalloc_proxy_H
  27. #define __TBB_tbbmalloc_proxy_H
  28. #if _MSC_VER
  29. #ifdef _DEBUG
  30. #pragma comment(lib, "tbbmalloc_proxy_debug.lib")
  31. #else
  32. #pragma comment(lib, "tbbmalloc_proxy.lib")
  33. #endif
  34. #if defined(_WIN64)
  35. #pragma comment(linker, "/include:__TBB_malloc_proxy")
  36. #else
  37. #pragma comment(linker, "/include:___TBB_malloc_proxy")
  38. #endif
  39. #else
  40. /* Primarily to support MinGW */
  41. extern "C" void __TBB_malloc_proxy();
  42. struct __TBB_malloc_proxy_caller {
  43. __TBB_malloc_proxy_caller() { __TBB_malloc_proxy(); }
  44. } volatile __TBB_malloc_proxy_helper_object;
  45. #endif // _MSC_VER
  46. /* Public Windows API */
  47. extern "C" int TBB_malloc_replacement_log(char *** function_replacement_log_ptr);
  48. #endif //__TBB_tbbmalloc_proxy_H