[igt-dev] [PATCH i-g-t v2 1/4] meson: add libatomic dependency

Guillaume Tucker guillaume.tucker at collabora.com
Thu Jun 13 13:53:19 UTC 2019


Add conditional dependency on libatomic in order to be able to use the
__atomic_* functions instead of the older __sync_* ones.  The
libatomic library is only needed when there aren't any native support
on the current architecture, so a linker test is used for this
purpose.  This enables atomic operations to be on a wider number of
architectures including MIPS.

Signed-off-by: Guillaume Tucker <guillaume.tucker at collabora.com>
---
 meson.build | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/meson.build b/meson.build
index 6268c58d3634..da25a28f3268 100644
--- a/meson.build
+++ b/meson.build
@@ -179,6 +179,19 @@ math = cc.find_library('m')
 realtime = cc.find_library('rt')
 dlsym = cc.find_library('dl')
 zlib = cc.find_library('z')
+if cc.links('''
+#include <stdint.h>
+int main(void) {
+  uint32_t x32 = 0;
+  uint64_t x64 = 0;
+  __atomic_load_n(&x32, __ATOMIC_SEQ_CST);
+  __atomic_load_n(&x64, __ATOMIC_SEQ_CST);
+  return 0;
+}''', name : 'built-in atomics')
+	libatomic = []
+else
+	libatomic = cc.find_library('atomic')
+endif
 
 if cc.has_header('linux/kd.h')
 	config.set('HAVE_LINUX_KD_H', 1)
-- 
2.20.1



More information about the igt-dev mailing list