summaryrefslogtreecommitdiff
path: root/atomic
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2019-10-16 10:10:59 +0000
committerIvan Zhakov <ivan@apache.org>2019-10-16 10:10:59 +0000
commit6e4f7ae03f61ef72066e573c6449d649dc32c4fd (patch)
treea4dfb1adf5d08684a0b7058835dae8895f0fd690 /atomic
parent90eb72a36774f501c0f7349d41bb8ca41d546e7e (diff)
downloadapr-6e4f7ae03f61ef72066e573c6449d649dc32c4fd.tar.gz
* atomic/win32/apr_atomic64.c
(apr_atomic_read64): Use direct memory read when compiled for x86_x64, since 64-bit reads are atomic in 64-bit Windows [1]. Suggested by: Yann Ylavic [1] https://docs.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1868502 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic')
-rw-r--r--atomic/win32/apr_atomic64.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/atomic/win32/apr_atomic64.c b/atomic/win32/apr_atomic64.c
index ca1f5e0ec..372003aaa 100644
--- a/atomic/win32/apr_atomic64.c
+++ b/atomic/win32/apr_atomic64.c
@@ -51,9 +51,16 @@ APR_DECLARE(void) apr_atomic_set64(volatile apr_uint64_t *mem, apr_uint64_t val)
APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem)
{
+#if defined(_M_X64)
+ /* https://docs.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access
+ * "Simple reads and writes to properly aligned 64-bit variables are atomic
+ * on 64-bit Windows."*/
+ return *mem;
+#else
/* 64-bit read is not atomic on 32-bit platform: use InterlockedCompareExchange
to perform atomic read. */
return InterlockedCompareExchange64((volatile LONG64 *)mem, 0, 0);
+#endif
}
APR_DECLARE(apr_uint64_t) apr_atomic_cas64(volatile apr_uint64_t *mem, apr_uint64_t with,