Compiler-portability shims and small utility macros used throughout rlib.
More...
|
| file | rmacros.h |
| | Compiler-portability macros and small utility macros.
|
| |
|
|
#define | R_GNUC_PREREQ(x, y) 0 |
| | TRUE if compiling with GCC x.y or newer (0 elsewhere).
|
| |
|
|
#define | R_API_EXPORT |
| |
|
#define | R_API_IMPORT |
| |
|
#define | R_API_HIDDEN |
| |
|
#define | R_API R_API_IMPORT |
| | Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
|
| |
|
|
#define | NULL ((void*) 0) |
| | Null pointer constant (defined only if absent).
|
| |
|
#define | FALSE (0) |
| | Boolean false (0).
|
| |
|
#define | TRUE (!FALSE) |
| | Boolean true (!FALSE).
|
| |
|
Argument-evaluating macros (no type checking) — beware passing expressions with side effects.
|
|
#define | MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| | Larger of a and b.
|
| |
|
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| | Smaller of a and b.
|
| |
|
#define | ABS(a) (((a) < 0) ? -(a) : (a)) |
| | Absolute value of a.
|
| |
|
#define | CLAMP(x, l, h) (((x) > (h)) ? (h) : (((x) < (l)) ? (l) : (x))) |
| | Clamp x to the inclusive range [l, h].
|
| |
|
#define | R_N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0])) |
| | Number of elements in a fixed-size array a.
|
| |
|
|
#define | R_STRINGIFY_ARG(str) #str |
| | Stringify str without macro expansion.
|
| |
|
#define | R_STRINGIFY(str) R_STRINGIFY_ARG (str) |
| | Stringify str after macro expansion.
|
| |
|
#define | R_PASTE_ARGS(a1, a2) a1 ## a2 |
| | Token-paste a1 and a2 without macro expansion.
|
| |
|
#define | R_PASTE(a1, a2) R_PASTE_ARGS (a1, a2) |
| | Token-paste a1 and a2 after macro expansion.
|
| |
|
#define | R_STRLOC __FILE__ ":" R_STRINGIFY (__LINE__) |
| | Source location string "file:line".
|
| |
|
#define | R_STRFUNC ((const char*) ("???")) |
| | Current function name as a string (compiler-specific spelling).
|
| |
|
|
#define | R_BEGIN_DECLS |
| | Open an extern "C" block under C++ (no-op in C).
|
| |
|
#define | R_END_DECLS |
| |
|
#define | R_STMT_START do |
| | Start a brace-free multi-statement macro body; pair with R_STMT_END.
|
| |
|
#define | R_STMT_END while (0) |
| | End an R_STMT_START body (suppresses MSVC C4127 on the while(0)).
|
| |
|
|
#define | R_LIKELY(expr) (expr) |
| | Hint that expr is likely true (branch-prediction).
|
| |
|
#define | R_UNLIKELY(expr) (expr) |
| |
|
Each resolves to the GCC/Clang attribute, the MSVC equivalent, or nothing on toolchains that lack it.
|
|
#define | R_ATTR_WARN_UNUSED_RESULT |
| | Warn if a function's return value is ignored.
|
| |
|
#define | R_ATTR_NORETURN |
| | Mark a function as never returning.
|
| |
|
#define | R_ATTR_WEAK |
| |
|
#define | R_ATTR_ALIGN(a) |
| |
|
#define | R_ATTR_FALLTHROUGH ((void)0) |
| | Mark an intentional switch fall-through.
|
| |
|
#define | R_ATTR_NULL_TERMINATED |
| | Mark a variadic function as requiring a NULL sentinel.
|
| |
|
#define | R_ATTR_UNUSED |
| |
|
#define | R_ATTR_CONST |
| |
|
#define | R_ATTR_PURE |
| |
|
#define | R_ATTR_MALLOC |
| |
|
#define | R_ATTR_FORMAT_ARG(arg_idx) |
| |
|
#define | R_ATTR_PRINTF(fmt_idx, arg_idx) |
| |
|
#define | R_ATTR_SCANF(fmt_idx, arg_idx) |
| |
|
#define | R_ATTR_RESTRICT |
| | Pointer-aliasing hint (restrict) in the compiler's spelling.
|
| |
|
Define the Clang feature-test builtins as 0 on compilers that lack them.
|
|
#define | __has_feature(x) 0 |
| |
|
#define | __has_builtin(x) 0 |
| |
|
#define | __has_extension __has_feature |
| |
|
#define | R_ATTR_ALLOC_SIZE_ARG(x) |
| |
|
#define | R_ATTR_ALLOC_SIZE_ARGS(x, y) |
| |
Compiler-portability shims and small utility macros used throughout rlib.
Everything here resolves to a compiler-specific spelling (GCC / Clang attributes, MSVC __declspec, or an empty fallback) so the rest of the codebase can use one name regardless of toolchain: symbol-visibility decoration (R_API), function / variable attributes (the R_ATTR_* family), branch hints, constructors, and the usual MIN / MAX / stringify helpers.