[x264-devel] gcc: Enable __sync_fetch_and_add() on x86-64

Henrik Gramner git at videolan.org
Tue Sep 20 20:57:51 CEST 2016


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Thu Jul 28 19:33:44 2016 +0200| [17378b2028146fa54a1b2b90da62554935d9dcc2] | committer: Anton Mitrofanov

gcc: Enable __sync_fetch_and_add() on x86-64

It was previously only enabled on 32-bit x86 for no reason, so 64-bit
systems had to use a mutex instead of a simple `lock xadd` instruction.

Note that this code is only used in some very specific configurations
involving sliced threads.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=17378b2028146fa54a1b2b90da62554935d9dcc2
---

 common/osdep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/osdep.h b/common/osdep.h
index 64e3431..e3152d0 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -249,7 +249,7 @@ int x264_threading_init( void );
 static ALWAYS_INLINE int x264_pthread_fetch_and_add( int *val, int add, x264_pthread_mutex_t *mutex )
 {
 #if HAVE_THREAD
-#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 0) && ARCH_X86
+#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 0) && (ARCH_X86 || ARCH_X86_64)
     return __sync_fetch_and_add( val, add );
 #else
     x264_pthread_mutex_lock( mutex );



More information about the x264-devel mailing list