diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
commit | 16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch) | |
tree | e6530480020f62a2bdbf249988ec3e2a751d3927 /auto/atomic | |
download | unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2 |
Initial version.
Diffstat (limited to 'auto/atomic')
-rw-r--r-- | auto/atomic | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/auto/atomic b/auto/atomic new file mode 100644 index 00000000..6535bf74 --- /dev/null +++ b/auto/atomic @@ -0,0 +1,114 @@ + +# Copyright (C) Igor Sysoev +# Copyright (C) NGINX, Inc. + + +# GCC 4.1+ builtin atomic operations. + +nxt_feature="GCC builtin atomic operations" +nxt_feature_name=NXT_HAVE_GCC_ATOMIC +nxt_feature_run=yes +nxt_feature_incs= +nxt_feature_libs= +nxt_feature_test="int main() { + long n = 0; + + if (!__sync_bool_compare_and_swap(&n, 0, 3)) + return 1; + if (__sync_fetch_and_add(&n, 1) != 3) + return 1; + if (__sync_lock_test_and_set(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __sync_lock_release(&n); + if (n != 0) + return 1; + return 0; + }" +. auto/feature + + +# Solaris 10 builtin atomic operations. + +if [ $nxt_found = no ]; then + + nxt_feature="Solaris builtin atomic operations" + nxt_feature_name=NXT_HAVE_SOLARIS_ATOMIC + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + nxt_feature_test="#include <atomic.h> + + int main() { + ulong_t n = 0; + + if (atomic_cas_ulong(&n, 0, 3) != 0) + return 1; + if (atomic_add_long_nv(&n, 1) != 4) + return 1; + if (atomic_swap_ulong(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + return 0; + }" + . auto/feature +fi + + +# AIX xlC builtin atomic operations. + +if [ $nxt_found = no ]; then + + if [ $NXT_64BIT = 1 ]; then + nxt_feature_test="int main() { + long n = 0; + long o = 0; + + if (!__compare_and_swaplp(&n, &o, 3)) + return 1; + if (__fetch_and_addlp(&n, 1) != 3) + return 1; + if (__fetch_and_swaplp(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __isync(); + __lwsync(); + return 0; + }" + else + nxt_feature_test="int main() { + int n = 0; + int o = 0; + + if (!__compare_and_swap(&n, &o, 3)) + return 1; + if (__fetch_and_add(&n, 1) != 3) + return 1; + if (__fetch_and_swap(&n, 5) != 4) + return 1; + if (n != 5) + return 1; + __isync(); + __lwsync(); + return 0; + }" + fi + + nxt_feature="xlC builtin atomic operations" + nxt_feature_name=NXT_HAVE_XLC_ATOMIC + nxt_feature_run=yes + nxt_feature_incs= + nxt_feature_libs= + . auto/feature +fi + + +if [ $nxt_found = no ]; then + $echo + $echo $0: error: no atomic operations found. + $echo + exit 1; +fi |