wrappers_c.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===-- wrappers_c.cpp ------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "platform.h"
  9. // Skip this compilation unit if compiled as part of Bionic.
  10. #if !SCUDO_ANDROID || !_BIONIC
  11. #include "allocator_config.h"
  12. #include "internal_defs.h"
  13. #include "platform.h"
  14. #include "scudo/interface.h"
  15. #include "wrappers_c.h"
  16. #include "wrappers_c_checks.h"
  17. #include <stdint.h>
  18. #include <stdio.h>
  19. #define SCUDO_PREFIX(name) name
  20. #define SCUDO_ALLOCATOR Allocator
  21. // Export the static allocator so that the C++ wrappers can access it.
  22. // Technically we could have a completely separated heap for C & C++ but in
  23. // reality the amount of cross pollination between the two is staggering.
  24. SCUDO_REQUIRE_CONSTANT_INITIALIZATION
  25. scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)> SCUDO_ALLOCATOR;
  26. #include "wrappers_c.inc"
  27. #undef SCUDO_ALLOCATOR
  28. #undef SCUDO_PREFIX
  29. extern "C" INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
  30. #endif // !SCUDO_ANDROID || !_BIONIC