1 2# Copyright (C) Igor Sysoev 3# Copyright (C) NGINX, Inc. 4 5 6# GCC 4.1+ builtin atomic operations. 7 8nxt_feature="GCC builtin atomic operations" 9nxt_feature_name=NXT_HAVE_GCC_ATOMIC 10nxt_feature_run=yes 11nxt_feature_incs= 12nxt_feature_libs= 13nxt_feature_test="int main() { 14 long n = 0; 15 16 if (!__sync_bool_compare_and_swap(&n, 0, 3)) 17 return 1; 18 if (__sync_fetch_and_add(&n, 1) != 3) 19 return 1; 20 if (__sync_lock_test_and_set(&n, 5) != 4) 21 return 1; 22 if (n != 5) 23 return 1; 24 if (__sync_or_and_fetch(&n, 2) != 7) 25 return 1; 26 if (__sync_and_and_fetch(&n, 5) != 5) 27 return 1; 28 __sync_lock_release(&n); 29 if (n != 0) 30 return 1; 31 return 0; 32 }" 33. auto/feature 34 35 36# Solaris 10 builtin atomic operations. 37 38if [ $nxt_found = no ]; then 39 40 nxt_feature="Solaris builtin atomic operations" 41 nxt_feature_name=NXT_HAVE_SOLARIS_ATOMIC 42 nxt_feature_run=yes 43 nxt_feature_incs= 44 nxt_feature_libs= 45 nxt_feature_test="#include <atomic.h> 46 47 int main() { 48 ulong_t n = 0; 49 50 if (atomic_cas_ulong(&n, 0, 3) != 0) 51 return 1; 52 if (atomic_add_long_nv(&n, 1) != 4) 53 return 1; 54 if (atomic_swap_ulong(&n, 5) != 4) 55 return 1; 56 if (n != 5) 57 return 1; 58 if (atomic_or_ulong_nv(&n, 2) != 7) 59 return 1; 60 if (atomic_and_ulong_nv(&n, 5) != 5) 61 return 1; 62 return 0; 63 }" 64 . auto/feature 65fi 66 67 68# AIX xlC builtin atomic operations. 69 70if [ $nxt_found = no ]; then 71 72 if [ $NXT_64BIT = 1 ]; then 73 nxt_feature_test="int main() { 74 long n = 0; 75 long o = 0; 76 77 if (!__compare_and_swaplp(&n, &o, 3)) 78 return 1; 79 if (__fetch_and_addlp(&n, 1) != 3) 80 return 1; 81 if (__fetch_and_swaplp(&n, 5) != 4) 82 return 1; 83 if (n != 5) 84 return 1; 85 __isync(); 86 __lwsync(); 87 return 0; 88 }" 89 else 90 nxt_feature_test="int main() { 91 int n = 0; 92 int o = 0; 93 94 if (!__compare_and_swap(&n, &o, 3)) 95 return 1; 96 if (__fetch_and_add(&n, 1) != 3) 97 return 1; 98 if (__fetch_and_swap(&n, 5) != 4) 99 return 1; 100 if (n != 5) 101 return 1; 102 __isync(); 103 __lwsync(); 104 return 0; 105 }" 106 fi 107 108 nxt_feature="xlC builtin atomic operations" 109 nxt_feature_name=NXT_HAVE_XLC_ATOMIC 110 nxt_feature_run=yes 111 nxt_feature_incs= 112 nxt_feature_libs= 113 . auto/feature 114fi 115 116 117if [ $nxt_found = no ]; then 118 $echo 119 $echo $0: error: no atomic operations found. 120 $echo 121 exit 1; 122fi 123