Debian Codegraph @

src/LomiriMetrics/lomirimetricsglobal_p.h

raw symbols SCIP
1 // Copyright © 2016 Canonical Ltd.
2 // Author: Loïc Molinari <[email protected]>
3 //
4 // This file is part of Lomiri UI Toolkit.
5 //
6 // Lomiri UI Toolkit is free software: you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published by the
8 // Free Software Foundation; version 3.
9 //
10 // Lomiri UI Toolkit is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 // for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with Lomiri UI Toolkit. If not, see <http://www.gnu.org/licenses/>.
17
18 #ifndef LOMIRIMETRICSGLOBAL_P_H
19 #define LOMIRIMETRICSGLOBAL_P_H
20
21 #include <QtGlobal>
22
23 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
24 #include <LomiriMetrics-Qt6/lomirimetricsglobal.h>
25 #else
26 #include <LomiriMetrics/lomirimetricsglobal.h>
27 #endif
28
29 // Logging macros, debug macros are compiled out for release builds.
30 #define LOG(...) qDebug(__VA_ARGS__)
31 #define WARN(...) qWarning(__VA_ARGS__)
32 #define ASSERT(cond) do { if (Q_UNLIKELY(!(cond))) \
33 qFatal("Assertion `"#cond"' failed in file %s, line %d", __FILE__, __LINE__); } while (0)
34 #define ASSERT_X(cond,message) do { if (Q_UNLIKELY(!(cond))) \
35 qFatal("Assertion "#message" failed in file %s, line %d", __FILE__, __LINE__); } while (0)
36 #define NOT_REACHED() \
37 qFatal("Assertion `not reached' failed in file %s, line %d", __FILE__, __LINE__);
38
39 #if !defined(QT_NO_DEBUG)
40 #define DLOG(...) LOG(__VA_ARGS__)
41 #define DWARN(...) WARN(__VA_ARGS__)
42 #define DNOT_REACHED(...) NOT_REACHED()
43 #define DASSERT(cond) ASSERT(cond)
44 #define DASSERT_X(cond,message) ASSERT(cond, message)
45 #else
46 #define DLOG(...) qt_noop()
47 #define DWARN(...) qt_noop()
48 #define DNOT_REACHED(...) qt_noop()
49 #define DASSERT(cond) qt_noop()
50 #define DASSERT_X(cond,message) qt_noop()
51 #endif
52
53 // Compile-time constant representing the number of elements in an array.
54 template<typename T, size_t N> constexpr size_t ARRAY_SIZE(T (&)[N]) { return N; }
55
56 #define IS_POWER_OF_TWO(n) !((n) & ((n) - 1))
57
58 #define LOMIRI_METRICS_PRIVATE_EXPORT LOMIRI_METRICS_EXPORT
59
60 // Allocates size bytes and returns an pointer to the aligned memory. alignment
61 // must be a power-of-two and size a multiple of alignment.
62 void* alignedAlloc(size_t alignment, size_t size);
63
64 #endif // LOMIRIMETRICSGLOBAL_P_H