summaryrefslogtreecommitdiffhomepage
path: root/auto/atomic
blob: 08061e9afbd6f84d5310b1629a69e0feb034b61e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

# 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(void) {
                      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;
                      if (__sync_or_and_fetch(&n, 2) != 7)
                          return 1;
                      if (__sync_and_and_fetch(&n, 5) != 5)
                          return 1;
                      __sync_lock_release(&n);
                      if (n != 0)
                          return 1;
                      return 0;
                  }"
. auto/feature


if [ $nxt_found = no ]; then
    $echo
    $echo $0: error: no atomic operations found.
    $echo
    exit 1;
fi