[x265] [PATCH 01 of 13] threading: add ATOMIC_ADD

Steve Borho steve at borho.org
Wed Jan 28 21:32:16 CET 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1422467386 21600
#      Wed Jan 28 11:49:46 2015 -0600
# Node ID 7f0b87cbad6d83a51c9cd957daac8081d772e473
# Parent  c1371f175178edcc0d0402a745b7478aa240c3b4
threading: add ATOMIC_ADD

diff -r c1371f175178 -r 7f0b87cbad6d source/common/threading.h
--- a/source/common/threading.h	Mon Jan 26 15:31:42 2015 -0600
+++ b/source/common/threading.h	Wed Jan 28 11:49:46 2015 -0600
@@ -53,6 +53,7 @@
 #define ATOMIC_AND(ptr, mask)               __sync_fetch_and_and(ptr, mask)
 #define ATOMIC_INC(ptr)                     __sync_add_and_fetch((volatile int32_t*)ptr, 1)
 #define ATOMIC_DEC(ptr)                     __sync_add_and_fetch((volatile int32_t*)ptr, -1)
+#define ATOMIC_ADD(ptr, value)              __sync_add_and_fetch((volatile int32_t*)ptr, value)
 #define GIVE_UP_TIME()                      usleep(0)
 
 #elif defined(_MSC_VER)                 /* Windows atomic intrinsics */
@@ -63,6 +64,7 @@
 #define CTZ(id, x)                          _BitScanForward(&id, x)
 #define ATOMIC_INC(ptr)                     InterlockedIncrement((volatile LONG*)ptr)
 #define ATOMIC_DEC(ptr)                     InterlockedDecrement((volatile LONG*)ptr)
+#define ATOMIC_ADD(ptr, value)              InterlockedAdd((volatile LONG*)ptr, value)
 #define ATOMIC_OR(ptr, mask)                _InterlockedOr((volatile LONG*)ptr, (LONG)mask)
 #define ATOMIC_AND(ptr, mask)               _InterlockedAnd((volatile LONG*)ptr, (LONG)mask)
 #define GIVE_UP_TIME()                      Sleep(0)


More information about the x265-devel mailing list