printf.h 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. //===-- printf.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 GWP_ASAN_OPTIONAL_PRINTF_H_
  9. #define GWP_ASAN_OPTIONAL_PRINTF_H_
  10. namespace gwp_asan {
  11. // ================================ Requirements ===============================
  12. // This function is required to be provided by the supporting allocator iff the
  13. // allocator wants to use any of the optional components.
  14. // ================================ Description ================================
  15. // This function shall produce output according to a strict subset of the C
  16. // standard library's printf() family. This function must support printing the
  17. // following formats:
  18. // 1. integers: "%([0-9]*)?(z|ll)?{d,u,x,X}"
  19. // 2. pointers: "%p"
  20. // 3. strings: "%[-]([0-9]*)?(\\.\\*)?s"
  21. // 4. chars: "%c"
  22. // This function must be implemented in a signal-safe manner, and thus must not
  23. // malloc().
  24. // =================================== Notes ===================================
  25. // This function has a slightly different signature than the C standard
  26. // library's printf(). Notably, it returns 'void' rather than 'int'.
  27. typedef void (*Printf_t)(const char *Format, ...);
  28. } // namespace gwp_asan
  29. #endif // GWP_ASAN_OPTIONAL_PRINTF_H_