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