Macros for atomic 'OR' and 'AND' operations introduced.

Compiler built-ins used, where possible. Necessary configure checks added.
New macros:
    nxt_atomic_or_fetch(ptr, val)
    nxt_atomic_and_fetch(ptr, val)

Syntax and behaviour is similar to __sync_or_and_fetch and __sync_and_and_fetch
GCC build-ins.
This commit is contained in:
Max Romanov
2017-04-21 16:55:13 +03:00
parent 6e7f98d6ae
commit cfed068c1d
2 changed files with 25 additions and 0 deletions

View File

@@ -21,6 +21,10 @@ nxt_feature_test="int main() {
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;
@@ -51,6 +55,10 @@ if [ $nxt_found = no ]; then
return 1;
if (n != 5)
return 1;
if (atomic_or_ulong_nv(&n, 2) != 7)
return 1;
if (atomic_and_ulong_nv(&n, 5) != 5)
return 1;
return 0;
}"
. auto/feature