Repository: llvm/llvm-project
File: llvm/include/llvm/Support/Signals.h (C/C++)

Code before:
/// and should not be relied on for other purposes.
template <unsigned long MaxDepth>
int getStackTrace(std::array<void *, MaxDepth> &StackTrace);

/// Takes a set of \p Addresses, symbolizes them and stores the result in the
/// provided \p SymbolizedAddresses map.
/// NB: This is only intended to be used for introspection of LLVM by
/// Debugify, will not be enabled in release builds, and should not be relied
/// on for other purposes.
void symbolizeAddresses(AddressSet &Addresses,
                        SymbolizedAddressMap &SymbolizedAddresses);
#endif

// Run all registered signal handlers.
LLVM_ABI void RunSignalHandlers();

using SignalHandlerCallback = void (*)(void *);

/// Add a function to be called when an abort/kill signal is delivered to the
/// process. The handler can have a cookie passed to it to identify what
/// instance of the handler it is. On Unix systems, the
/// NeedsPOSIXUtilitySignalHandling argument indicates whether POSIX signal
/// handling semantics are followed, so that the signal handler resignals
/// itself to terminate after handling the signal.
#ifdef _WIN32
LLVM_ABI void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie);
#else
LLVM_ABI void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie,
                               bool NeedsPOSIXUtilitySignalHandling = false);
#endif

/// This function registers a function to be called when the user "interrupts"
/// the program (typically by pressing ctrl-c).  When the user interrupts the
/// program, the specified interrupt function is called instead of the program
/// being killed, and the interrupt function automatically disabled.
///
/// Note that interrupt functions are not allowed to call any non-reentrant
/// functions.  An null interrupt function pointer disables the current
/// installed function.  Note also that the handler may be executed on a
/// different thread on some platforms.
LLVM_ABI void SetInterruptFunction(void (*IF)());

/// Registers a function to be called when an "info" signal is delivered to
/// the process.
///
/// On POSIX systems, this will be SIGUSR1; on systems that have it, SIGINFO
/// will also be used (typically ctrl-t).
///
/// Note that signal handlers are not allowed to call any non-reentrant
/// functions.  An null function pointer disables the current installed
/// function.  Note also that the handler may be executed on a different

Review comment (suggestion):
Since this function is external ABI facing, I'm inclined to say the interface should be the same on all platforms (even if the additional param is a no-op for non-UNIX targets) or the user code will have to handle the difference.

Code after:
/// and should not be relied on for other purposes.
template <unsigned long MaxDepth>
int getStackTrace(std::array<void *, MaxDepth> &StackTrace);

/// Takes a set of \p Addresses, symbolizes them and stores the result in the
/// provided \p SymbolizedAddresses map.
/// NB: This is only intended to be used for introspection of LLVM by
/// Debugify, will not be enabled in release builds, and should not be relied
/// on for other purposes.
void symbolizeAddresses(AddressSet &Addresses,
                        SymbolizedAddressMap &SymbolizedAddresses);
#endif

// Run all registered signal handlers.
LLVM_ABI void RunSignalHandlers();

using SignalHandlerCallback = void (*)(void *);

/// Add a function to be called when an abort/kill signal is delivered to the
/// process. The handler can have a cookie passed to it to identify what
/// instance of the handler it is. The NeedsPOSIXUtilitySignalHandling
/// argument indicates whether POSIX signal handling semantics are followed,
/// so that the signal handler resignals itself to terminate after handling
/// the signal.
LLVM_ABI void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie,
                               bool NeedsPOSIXUtilitySignalHandling = false);

/// This function registers a function to be called when the user "interrupts"
/// the program (typically by pressing ctrl-c).  When the user interrupts the
/// program, the specified interrupt function is called instead of the program
/// being killed, and the interrupt function automatically disabled.
///
/// Note that interrupt functions are not allowed to call any non-reentrant
/// functions.  An null interrupt function pointer disables the current
/// installed function.  Note also that the handler may be executed on a
/// different thread on some platforms.
LLVM_ABI void SetInterruptFunction(void (*IF)());

/// Registers a function to be called when an "info" signal is delivered to
/// the process.
///
/// On POSIX systems, this will be SIGUSR1; on systems that have it, SIGINFO
/// will also be used (typically ctrl-t).
///
/// Note that signal handlers are not allowed to call any non-reentrant
/// functions.  An null function pointer disables the current installed
/// function.  Note also that the handler may be executed on a different
/// thread on some platforms.
LLVM_ABI void SetInfoSignalFunction(void (*Handler)());

/// Registers a function to be called in a "one-shot" manner when a pipe