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
38
extern
"C"
{
39
#endif
40
42
#undef STR_HELPER
43
#define STR_HELPER(x) #x
44
48
#undef STR
49
#define STR(x) STR_HELPER(x)
50
53
#define DT_STRINGIFY_HELPER(x) #x
54
60
#define DT_STRINGIFY(x) DT_STRINGIFY_HELPER(x)
61
70
#ifdef __cplusplus
71
#define DT_RESTRICT
72
#else
73
#define DT_RESTRICT restrict
74
#endif
75
96
#define IS_NULL_PTR(p) \
97
({ \
98
__typeof__(p) _tmp = (p); \
99
(void)sizeof(char[ \
100
(__builtin_classify_type(_tmp) == 5) ? 1 : -1 \
101
]); \
102
_tmp == NULL; \
103
})
104
121
#if defined(__has_attribute)
122
#if __has_attribute(fallthrough)
123
#define DT_FALLTHROUGH __attribute__((fallthrough))
124
#endif
125
#endif
126
#ifndef DT_FALLTHROUGH
127
#define DT_FALLTHROUGH ((void)0)
128
#endif
129
130
#define dt_unreachable_codepath_with_desc(D) \
131
dt_unreachable_codepath_with_caller(D, __FILE__, __LINE__, __FUNCTION__)
132
141
#define dt_unreachable_codepath() dt_unreachable_codepath_with_caller("unreachable", __FILE__, __LINE__, __FUNCTION__)
142
154
static
inline
void
dt_unreachable_codepath_with_caller
(
const
char
*
description
,
const
char
*file,
155
const
int
line,
const
char
*function)
156
{
157
fprintf(stderr,
"[dt_unreachable_codepath] {%s} %s:%d (%s) - we should not be here. please report this to "
158
"the developers."
,
159
description
, file, line, function);
160
__builtin_unreachable();
161
}
162
163
#ifdef __cplusplus
164
}
165
#endif
166
167
#endif
// DT_SYSTEM_MACROS_H
168
169
// clang-format off
170
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
171
// vim: shiftwidth=2 expandtab tabstop=2 cindent
172
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
173
// clang-format on
description
const char ** description(struct dt_iop_module_t *self)
Definition
ashift.c:168
dt_unreachable_codepath_with_caller
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 automatica...
Definition
macros.h:154
win.h
src
system
macros.h
Generated by
1.9.8