------------------------------------------------------------ revno: 13778 revision-id: squid3@treenet.co.nz-20150321073814-ozv1ql6olc2wzn9r parent: squid3@treenet.co.nz-20150321063234-rta170rzn4h85n3n committer: Amos Jeffries branch nick: 3.5 timestamp: Sat 2015-03-21 00:38:14 -0700 message: Portability: check 64-bit GNU atomic operators are useable Sometimes (namely 32-bit OpenBSD libstdc++) do not fully implement the GNU atomic operators for both 32-bit and 64-bit. But Squid makes use of both types if the compiler deems them required. We need to check them all before declaring the atomics usable, or not. Thanks to Stuart Henderson for identifying the issue. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20150321073814-ozv1ql6olc2wzn9r # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 95aeb0bc49632a8880a8f6281d5ff0e9cfe5bab1 # timestamp: 2015-03-21 07:45:34 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20150321063234-\ # rta170rzn4h85n3n # # Begin patch === modified file 'configure.ac' --- configure.ac 2015-02-18 12:16:21 +0000 +++ configure.ac 2015-03-21 07:38:14 +0000 @@ -427,17 +427,30 @@ dnl AC_MSG_CHECKING([for GNU atomic operations support]) AC_RUN_IFELSE([AC_LANG_PROGRAM([[ - int n = 0; + int32_t n_32 = 0; + uint64_t n_64 = 0; ]],[[ - __sync_add_and_fetch(&n, 10); // n becomes 10 - __sync_fetch_and_add(&n, 20); // n becomes 30 - __sync_sub_and_fetch(&n, 15); // n becomes 15 - __sync_bool_compare_and_swap(&n, 15, 201); // n becomes 201 - __sync_fetch_and_and(&n, 200); // n becomes 200 - return (n == 200) ? 0 : -1; + // 32-bit + __sync_add_and_fetch(&n_32, 10); // n becomes 10 + __sync_fetch_and_add(&n_32, 20); // n becomes 30 + __sync_sub_and_fetch(&n_32, 15); // n becomes 15 + __sync_bool_compare_and_swap(&n_32, 15, 201); // n becomes 201 + __sync_fetch_and_and(&n_32, 200); // n becomes 200 + if (n != 200) return -1; + + // 64-bit + __sync_add_and_fetch(&n_64, 10); // n becomes 10 + __sync_fetch_and_add(&n_64, 20); // n becomes 30 + __sync_sub_and_fetch(&n_64, 15); // n becomes 15 + __sync_bool_compare_and_swap(&n_64, 15, 201); // n becomes 201 + __sync_fetch_and_and(&n_64, 200); // n becomes 200 + if (n_64 != 200) return -1; + + // seems to be okay. + return 0; ]])], [ - AC_DEFINE(HAVE_ATOMIC_OPS,1,[Define to 1 if you have __sync_add_and_fetch() and such]) + AC_DEFINE(HAVE_ATOMIC_OPS,1,[Define to 1 if you have GCC __sync_add_and_fetch() and such]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no)