aboutsummaryrefslogtreecommitdiff
path: root/macros.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-05-26 07:15:13 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-05-26 07:15:13 +0000
commite7fbded48f55d2606e1bdc51f3f31844d4e9c5bd (patch)
tree19dc7a6cd1919b14234c5d1db7f66113a4786959 /macros.h
parentpkgbuild: bump fcft requirement to 2.4.0 (diff)
parentmacros: add UNITTEST macro and use to replace test_keymap_lookup() (diff)
Merge branch 'fix-iso-left-tab'
Closes #547
Diffstat (limited to 'macros.h')
-rw-r--r--macros.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/macros.h b/macros.h
index 52c24e0e..7cfe777e 100644
--- a/macros.h
+++ b/macros.h
@@ -1,5 +1,7 @@
#pragma once
+#define PASTE(a, b) a##b
+#define XPASTE(a, b) PASTE(a, b)
#define DO_PRAGMA(x) _Pragma(#x)
#define VERCMP(x, y, cx, cy) ((cx > x) || ((cx == x) && (cy >= y)))
@@ -68,6 +70,7 @@
#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(constructor)
#define CONSTRUCTOR __attribute__((__constructor__))
+ #define HAVE_ATTR_CONSTRUCTOR 1
#else
#define CONSTRUCTOR
#endif
@@ -175,6 +178,19 @@
#define UNROLL_LOOP(n)
#endif
+#ifdef __COUNTER__
+ // Supported by GCC 4.3+ and Clang
+ #define COUNTER_ __COUNTER__
+#else
+ #define COUNTER_ __LINE__
+#endif
+
+#if defined(_DEBUG) && defined(HAVE_ATTR_CONSTRUCTOR)
+ #define UNITTEST static void CONSTRUCTOR XPASTE(unittest_, COUNTER_)(void)
+#else
+ #define UNITTEST static void UNUSED XPASTE(unittest_, COUNTER_)(void)
+#endif
+
#ifdef __clang__
#define IGNORE_WARNING(wflag) \
DO_PRAGMA(clang diagnostic push) \