[PATCH i-g-t v4 1/4] meson: add libatomic dependency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add conditional dependency on GCC's 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 makes atomic operations available on a wider number of
architectures including MIPS.

Signed-off-by: Guillaume Tucker <guillaume.tucker@xxxxxxxxxxxxx>
Reviewed-by: Simon Ser <simon.ser@xxxxxxxxx>
---

Notes:
    v2: add linker test for libatomic
    v3: use null_dep
    v4: fix sentence in commit message

 meson.build | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/meson.build b/meson.build
index b1028ee6aaaf..f0cb2543ca64 100644
--- a/meson.build
+++ b/meson.build
@@ -180,6 +180,20 @@ 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 = null_dep
+else
+	libatomic = cc.find_library('atomic')
+endif
+
 if cc.has_header('linux/kd.h')
 	config.set('HAVE_LINUX_KD_H', 1)
 endif
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux