wrappers_c.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //===-- wrappers_c.h --------------------------------------------*- 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. #ifndef SCUDO_WRAPPERS_C_H_
  9. #define SCUDO_WRAPPERS_C_H_
  10. #include "platform.h"
  11. #include "stats.h"
  12. // Bionic's struct mallinfo consists of size_t (mallinfo(3) uses int).
  13. #if SCUDO_ANDROID
  14. typedef size_t __scudo_mallinfo_data_t;
  15. #else
  16. typedef int __scudo_mallinfo_data_t;
  17. #endif
  18. struct __scudo_mallinfo {
  19. __scudo_mallinfo_data_t arena;
  20. __scudo_mallinfo_data_t ordblks;
  21. __scudo_mallinfo_data_t smblks;
  22. __scudo_mallinfo_data_t hblks;
  23. __scudo_mallinfo_data_t hblkhd;
  24. __scudo_mallinfo_data_t usmblks;
  25. __scudo_mallinfo_data_t fsmblks;
  26. __scudo_mallinfo_data_t uordblks;
  27. __scudo_mallinfo_data_t fordblks;
  28. __scudo_mallinfo_data_t keepcost;
  29. };
  30. struct __scudo_mallinfo2 {
  31. size_t arena;
  32. size_t ordblks;
  33. size_t smblks;
  34. size_t hblks;
  35. size_t hblkhd;
  36. size_t usmblks;
  37. size_t fsmblks;
  38. size_t uordblks;
  39. size_t fordblks;
  40. size_t keepcost;
  41. };
  42. // Android sometimes includes malloc.h no matter what, which yields to
  43. // conflicting return types for mallinfo() if we use our own structure. So if
  44. // struct mallinfo is declared (#define courtesy of malloc.h), use it directly.
  45. #if STRUCT_MALLINFO_DECLARED
  46. #define SCUDO_MALLINFO mallinfo
  47. #else
  48. #define SCUDO_MALLINFO __scudo_mallinfo
  49. #endif
  50. #if !SCUDO_ANDROID || !_BIONIC
  51. extern "C" void malloc_postinit();
  52. extern HIDDEN scudo::Allocator<scudo::Config, malloc_postinit> Allocator;
  53. #endif
  54. #endif // SCUDO_WRAPPERS_C_H_