summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2023-06-13 10:07:16 +0200
committerJoel Klinghed <the_jk@spawned.biz>2023-06-13 10:07:16 +0200
commitfc4547b412e28164af1bf8981234c6af959ccc0b (patch)
tree061253e7a4f6abaca282223b36d10f0bed8cad23 /base
WIP
Diffstat (limited to 'base')
-rw-r--r--base/inc/macros.hh16
-rw-r--r--base/meson.build19
2 files changed, 35 insertions, 0 deletions
diff --git a/base/inc/macros.hh b/base/inc/macros.hh
new file mode 100644
index 0000000..6d88669
--- /dev/null
+++ b/base/inc/macros.hh
@@ -0,0 +1,16 @@
+#ifndef BASE_MACROS_HH
+#define BASE_MACROS_HH
+
+#if defined(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN)
+# define HIDDEN __attribute__((visibility ("hidden")))
+#else
+# define HIDDEN
+#endif
+
+#if defined(HAVE_ATTRIBUTE_UNLIKELY)
+# define UNLIKELY [[unlikely]]
+#else
+# define UNLIKELY
+#endif
+
+#endif // BASE_MACROS_HH
diff --git a/base/meson.build b/base/meson.build
new file mode 100644
index 0000000..71faace
--- /dev/null
+++ b/base/meson.build
@@ -0,0 +1,19 @@
+cpp = meson.get_compiler('cpp')
+cpp_flags = []
+if cpp.has_function_attribute('visibility:hidden')
+ cpp_flags += '-DHAVE_ATTRIBUTE_VISIBILITY_HIDDEN'
+endif
+if cpp.compiles('''int foo() {
+ [[unlikely]]
+ return 0;
+}''', name: 'C++20 unlikely attribute')
+ cpp_flags += '-DHAVE_ATTRIBUTE_UNLIKELY'
+ cpp_flags += '-Wno-c++20-attribute-extensions'
+endif
+
+inc = include_directories('inc')
+
+base_dep = declare_dependency(
+ compile_args: cpp_flags,
+ include_directories: inc,
+)