Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef DT_SYSTEM_MACROS_H
19#define DT_SYSTEM_MACROS_H
20
21/* Base language-level macros with zero dependencies. This is the bottom of the
22 * include graph: anything may include it, it includes nothing of ours. */
23
24#include <stdio.h>
25#include <stddef.h>
26
27/* Windows legacy-macro shim. windows.h #defines `near`, `grp2`, `interface` and
28 * friends, and win/win.h #undefs them (and orders winsock2 before windows.h). Every
29 * TU used to inherit this through darktable.h; now that low-level code no
30 * longer includes the orchestrator, the shim has to live at the bottom of the stack
31 * -- this header -- or the collisions come back on MinGW only, far from their cause.
32 * Harmless on every other platform: the whole block disappears. */
33#if defined _WIN32
34#include "win/win.h"
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#undef STR_HELPER
42#define STR_HELPER(x) #x
43
44#undef STR
45#define STR(x) STR_HELPER(x)
46
47#define DT_STRINGIFY_HELPER(x) #x
48#define DT_STRINGIFY(x) DT_STRINGIFY_HELPER(x)
49
50// When included by a C++ file, restrict qualifiers are not allowed
51#ifdef __cplusplus
52#define DT_RESTRICT
53#else
54#define DT_RESTRICT restrict
55#endif
56
65#define IS_NULL_PTR(p) \
66 ({ \
67 __typeof__(p) _tmp = (p); \
68 (void)sizeof(char[ \
69 (__builtin_classify_type(_tmp) == 5) ? 1 : -1 \
70 ]); \
71 _tmp == NULL; \
72 })
73
74#define dt_unreachable_codepath_with_desc(D) \
75 dt_unreachable_codepath_with_caller(D, __FILE__, __LINE__, __FUNCTION__)
76#define dt_unreachable_codepath() dt_unreachable_codepath_with_caller("unreachable", __FILE__, __LINE__, __FUNCTION__)
77static inline void dt_unreachable_codepath_with_caller(const char *description, const char *file,
78 const int line, const char *function)
79{
80 fprintf(stderr, "[dt_unreachable_codepath] {%s} %s:%d (%s) - we should not be here. please report this to "
81 "the developers.",
82 description, file, line, function);
84}
85
86#ifdef __cplusplus
87}
88#endif
89
90#endif // DT_SYSTEM_MACROS_H
91
92// clang-format off
93// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
94// vim: shiftwidth=2 expandtab tabstop=2 cindent
95// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
96// clang-format on
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:166
static void dt_unreachable_codepath_with_caller(const char *description, const char *file, const int line, const char *function)
Definition macros.h:77