-# Atomics
-# Inputs: deps
-
-prog = '''
-#include <stdint.h>
-
-int main() {
- uint64_t val = 0;
- __atomic_add_fetch(&val, 1, __ATOMIC_RELAXED);
- return 0;
-}
-'''
-
+dep_atomic = declare_dependency()
need_latomic = false
+prog = fs.read('atomic_add_fetch.cc')
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)
+ lib_atomic = cxx.find_library('atomic', disabler: true, required: false)
+ if lib_atomic.found()
+ if cxx.links(prog, name: '-latomic is needed for using __atomic builtins', dependencies: lib_atomic)
need_latomic = true
- summary('Atomics Library', atomic, section: 'System')
- deps += atomic
+ dep_atomic = declare_dependency(dependencies: lib_atomic)
+ summary('Atomics Library', lib_atomic, section: 'System')
else
- error('libatomic needed but could not be found')
+ error('libatomic is needed and was found, but linking with it failed')
endif
else
- error('libatomic needed and was found, but linking with it failed')
+ error('libatomic is needed but could not be found')
endif
endif