]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Meson: Atomics
authorFred Morcos <fred.morcos@open-xchange.com>
Mon, 3 Jul 2023 10:33:36 +0000 (12:33 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Wed, 20 Mar 2024 12:28:25 +0000 (13:28 +0100)
meson/atomics/meson.build [new file with mode: 0644]

diff --git a/meson/atomics/meson.build b/meson/atomics/meson.build
new file mode 100644 (file)
index 0000000..8902b6e
--- /dev/null
@@ -0,0 +1,31 @@
+# Atomics
+# Inputs: deps
+
+prog = '''
+#include <stdint.h>
+
+int main() {
+  uint64_t val = 0;
+  __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);
+  return 0;
+}
+'''
+
+need_latomic = false
+
+if not cxx.links(prog, name: '-latomic is not needed for using __atomic builtins')
+  atomic = cxx.find_library('atomic', disabler: true, required: false)
+  if atomic.found()
+    if cxx.links(prog, name: '-latomic is needed for using __atomic builtins', dependencies: atomic)
+      need_latomic = true
+      summary('Atomics Library', atomic, section: 'System')
+      deps += atomic
+    else
+      error('libatomic needed but could not be found')
+    endif
+  else
+    error('libatomic needed and was found, but linking with it failed')
+  endif
+endif
+
+summary('Need -latomic', need_latomic, section: 'System')