wrappers_c.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "wrappers_c.h"
  13. #include "wrappers_c_checks.h"
  14. #include <stdint.h>
  15. #include <stdio.h>
  16. #define SCUDO_PREFIX(name) name
  17. #define SCUDO_ALLOCATOR Allocator
  18. extern "C" void SCUDO_PREFIX(malloc_postinit)();
  19. // Export the static allocator so that the C++ wrappers can access it.
  20. // Technically we could have a completely separated heap for C & C++ but in
  21. // reality the amount of cross pollination between the two is staggering.
  22. SCUDO_REQUIRE_CONSTANT_INITIALIZATION
  23. scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)> SCUDO_ALLOCATOR;
  24. #include "wrappers_c.inc"
  25. #undef SCUDO_ALLOCATOR
  26. #undef SCUDO_PREFIX
  27. extern "C" INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
  28. #endif // !SCUDO_ANDROID || !_BIONIC