/***********************************************************************************************************************************
|
Build Header
|
|
This header file must be included in all source files. It contains defines that are required in all modules. The build.auto.c header
|
generated by meson is also included here.
|
***********************************************************************************************************************************/
|
#ifndef BUILD_H
|
#define BUILD_H
|
|
/***********************************************************************************************************************************
|
Ban unsafe functions
|
|
Poison unsafe functions so any use is a compile error. System headers containing poisoned identifiers must be processed first
|
because build.h is the first include in every file and poisoned identifiers are not exempt inside system headers. #undef prevents a
|
"poisoning existing macro" warning where fortify has defined the function as a macro.
|
***********************************************************************************************************************************/
|
#include <stdio.h>
|
#include <string.h>
|
|
#undef sprintf
|
#undef strcat
|
#undef strcpy
|
#undef strncpy
|
|
#pragma GCC poison sprintf strcat strcpy strncpy
|
|
/***********************************************************************************************************************************
|
Include build.auto.h and other (hopefully small) header files that are commonly used.
|
***********************************************************************************************************************************/
|
#include <build.auto.h>
|
#include <stdnoreturn.h>
|
|
/***********************************************************************************************************************************
|
Function attributes
|
***********************************************************************************************************************************/
|
// Indicate that a function should always be inlined
|
#define FN_INLINE_ALWAYS __attribute__((__always_inline__)) static inline
|
|
// Indicate that a function is formatted like printf (and provide format and args position)
|
#define FN_PRINTF(fmt, args) __attribute__((format(printf, fmt, args)))
|
|
// Indicate that a function is formatted like strftime (and provide format position)
|
#define FN_STRFTIME(fmt) __attribute__((format(strftime, fmt, 0)))
|
|
#endif
|