xref: /openbsd-src/gnu/llvm/compiler-rt/lib/gwp_asan/optional/printf.h (revision d89ec533011f513df1010f142a111086a0785f09)
1*d89ec533Spatrick //===-- printf.h ------------------------------------------------*- C++ -*-===//
2*d89ec533Spatrick //
3*d89ec533Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*d89ec533Spatrick // See https://llvm.org/LICENSE.txt for license information.
5*d89ec533Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*d89ec533Spatrick //
7*d89ec533Spatrick //===----------------------------------------------------------------------===//
8*d89ec533Spatrick 
9*d89ec533Spatrick #ifndef GWP_ASAN_OPTIONAL_PRINTF_H_
10*d89ec533Spatrick #define GWP_ASAN_OPTIONAL_PRINTF_H_
11*d89ec533Spatrick 
12*d89ec533Spatrick namespace gwp_asan {
13*d89ec533Spatrick 
14*d89ec533Spatrick // ================================ Requirements ===============================
15*d89ec533Spatrick // This function is required to be provided by the supporting allocator iff the
16*d89ec533Spatrick // allocator wants to use any of the optional components.
17*d89ec533Spatrick // ================================ Description ================================
18*d89ec533Spatrick // This function shall produce output according to a strict subset of the C
19*d89ec533Spatrick // standard library's printf() family. This function must support printing the
20*d89ec533Spatrick // following formats:
21*d89ec533Spatrick //   1. integers: "%([0-9]*)?(z|ll)?{d,u,x,X}"
22*d89ec533Spatrick //   2. pointers: "%p"
23*d89ec533Spatrick //   3. strings:  "%[-]([0-9]*)?(\\.\\*)?s"
24*d89ec533Spatrick //   4. chars:    "%c"
25*d89ec533Spatrick // This function must be implemented in a signal-safe manner, and thus must not
26*d89ec533Spatrick // malloc().
27*d89ec533Spatrick // =================================== Notes ===================================
28*d89ec533Spatrick // This function has a slightly different signature than the C standard
29*d89ec533Spatrick // library's printf(). Notably, it returns 'void' rather than 'int'.
30*d89ec533Spatrick typedef void (*Printf_t)(const char *Format, ...);
31*d89ec533Spatrick 
32*d89ec533Spatrick } // namespace gwp_asan
33*d89ec533Spatrick #endif // GWP_ASAN_OPTIONAL_PRINTF_H_
34