Skip to content

Commit

Permalink
Replace __sync_add_and_fetch with __atomic_add_fetch to avoid build e…
Browse files Browse the repository at this point in the history
…rrors with clang
  • Loading branch information
DamonFool committed Oct 22, 2020
1 parent 211bb62 commit dcc8c25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/hotspot/os_cpu/bsd_zero/atomic_bsd_zero.hpp
Expand Up @@ -184,7 +184,9 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(D volatile* dest, I add_value,
#ifdef M68K
return add_using_helper<int>(m68k_add_and_fetch, dest, add_value);
#else
return __sync_add_and_fetch(dest, add_value);
D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
FULL_MEM_BARRIER;
return res;
#endif // M68K
#endif // ARM
}
Expand All @@ -196,7 +198,9 @@ inline D Atomic::PlatformAdd<8>::add_and_fetch(D volatile* dest, I add_value,
STATIC_ASSERT(8 == sizeof(I));
STATIC_ASSERT(8 == sizeof(D));

return __sync_add_and_fetch(dest, add_value);
D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
FULL_MEM_BARRIER;
return res;
}

template<>
Expand Down
9 changes: 7 additions & 2 deletions src/hotspot/os_cpu/linux_zero/atomic_linux_zero.hpp
Expand Up @@ -49,7 +49,9 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(D volatile* dest, I add_value,
STATIC_ASSERT(4 == sizeof(I));
STATIC_ASSERT(4 == sizeof(D));

return __sync_add_and_fetch(dest, add_value);
D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
FULL_MEM_BARRIER;
return res;
}

template<>
Expand All @@ -58,7 +60,10 @@ inline D Atomic::PlatformAdd<8>::add_and_fetch(D volatile* dest, I add_value,
atomic_memory_order order) const {
STATIC_ASSERT(8 == sizeof(I));
STATIC_ASSERT(8 == sizeof(D));
return __sync_add_and_fetch(dest, add_value);

D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
FULL_MEM_BARRIER;
return res;
}

template<>
Expand Down

0 comments on commit dcc8c25

Please sign in to comment.