![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Include dependency graph for macros.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | STR_HELPER(x) #x |
Stringify x WITHOUT expanding it first. Implementation detail of STR(). | |
| #define | STR(x) STR_HELPER(x) |
Stringify x after macro-expanding it, e.g. STR(LINE) gives "42". | |
| #define | DT_STRINGIFY_HELPER(x) #x |
Stringify x WITHOUT expanding it first. Implementation detail of DT_STRINGIFY(). | |
| #define | DT_STRINGIFY(x) DT_STRINGIFY_HELPER(x) |
| Expand-then-stringify, identical in behaviour to STR(). | |
| #define | DT_RESTRICT restrict |
restrict in C, nothing in C++. | |
| #define | IS_NULL_PTR(p) |
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on what we compare. We force here a semantic NULL check for pointers types that will fail for anything else than pointers, and make the code more explicit about what is checked. Rejected at COMPILE time: integers, floats, structs, and arrays – an array's __typeof__ cannot initialise a local, which is what stops IS_NULL_PTR(some_array) from quietly testing a never-NULL decayed address. | |
| #define | DT_FALLTHROUGH ((void)0) |
Mark a branch as impossible, naming it D in the message. | |
| #define | dt_unreachable_codepath_with_desc(D) dt_unreachable_codepath_with_caller(D, __FILE__, __LINE__, __FUNCTION__) |
| #define | dt_unreachable_codepath() dt_unreachable_codepath_with_caller("unreachable", __FILE__, __LINE__, __FUNCTION__) |
| Mark a branch as impossible. | |
Functions | |
| static void | dt_unreachable_codepath_with_caller (const char *description, const char *file, const int line, const char *function) |
| Back-end of the dt_unreachable_codepath() macros; call those, so the call site is recorded automatically. | |
| #define DT_FALLTHROUGH ((void)0) |
Mark a branch as impossible, naming it D in the message.
Mark a deliberate switch fall-through so compilers and analysers stop warning.
Write it as a statement where the break would go: case 7: b |= ...; DT_FALLTHROUGH;
The conventional "fall through" COMMENT is understood by GCC's -Wimplicit-fallthrough and by clang-tidy, but not by every analyser – SonarCloud reports each one as c:S128 ("switch case should end with an unconditional break"), which is 7 findings on one intentionally-unrolled loop in common/hash.h. The attribute is a token the parser sees, so it settles the question everywhere at once.
Expands to nothing on a toolchain without the attribute, where the comment convention (or nothing at all) was the only option anyway.
| #define DT_RESTRICT restrict |
restrict in C, nothing in C++.
restrict is not a C++ keyword, so a header shared with a .cc file cannot spell it directly. Where it survives (C), it is a PROMISE that the pointed-to memory is not reached through any other pointer for that object's lifetime; breaking the promise is undefined behaviour the compiler will happily optimise around, and the symptom is wrong pixels rather than a crash. Note the promise silently disappears in C++ translation units, so a bug it hides can behave differently in .c and .cc code.
| #define DT_STRINGIFY | ( | x | ) | DT_STRINGIFY_HELPER(x) |
Expand-then-stringify, identical in behaviour to STR().
Stringify x WITHOUT expanding it first. Implementation detail of DT_STRINGIFY().
| #define dt_unreachable_codepath | ( | ) | dt_unreachable_codepath_with_caller("unreachable", __FILE__, __LINE__, __FUNCTION__) |
Mark a branch as impossible.
| #define dt_unreachable_codepath_with_desc | ( | D | ) | dt_unreachable_codepath_with_caller(D, __FILE__, __LINE__, __FUNCTION__) |
| #define IS_NULL_PTR | ( | p | ) |
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on what we compare. We force here a semantic NULL check for pointers types that will fail for anything else than pointers, and make the code more explicit about what is checked. Rejected at COMPILE time: integers, floats, structs, and arrays – an array's __typeof__ cannot initialise a local, which is what stops IS_NULL_PTR(some_array) from quietly testing a never-NULL decayed address.
ACCEPTED, contrary to what this comment claimed for a long time: function pointers. __builtin_classify_type() reports them as pointers, so IS_NULL_PTR(callback) compiles and does the obvious, useful thing. Verified rather than assumed.
| p | any pointer expression. Evaluated EXACTLY ONCE – it is bound to a local first – so IS_NULL_PTR(*iter++) is safe. |
p is NULL.| #define STR | ( | x | ) | STR_HELPER(x) |
Stringify x after macro-expanding it, e.g. STR(LINE) gives "42".
|
inlinestatic |
Back-end of the dt_unreachable_codepath() macros; call those, so the call site is recorded automatically.
| description | short label for the impossible branch. |
| file,line,function | the call site, supplied by the macros. |
Definition at line 154 of file macros.h.
References description().