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