diff mbox

[FFmpeg-devel] compat/atomics: fix atomic_fetch_xor()

Message ID 20170329185745.3384-1-jamrial@gmail.com
State Accepted
Commit 7942907878dd4c263ba7431067c33ce6b5d53ceb
Headers show

Commit Message

James Almer March 29, 2017, 6:57 p.m. UTC
---
 compat/atomics/dummy/stdatomic.h   | 2 +-
 compat/atomics/gcc/stdatomic.h     | 4 ++--
 compat/atomics/pthread/stdatomic.h | 2 +-
 compat/atomics/suncc/stdatomic.h   | 2 +-
 compat/atomics/win32/stdatomic.h   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

Comments

wm4 March 29, 2017, 7:02 p.m. UTC | #1
On Wed, 29 Mar 2017 15:57:45 -0300
James Almer <jamrial@gmail.com> wrote:

> ---
>  compat/atomics/dummy/stdatomic.h   | 2 +-
>  compat/atomics/gcc/stdatomic.h     | 4 ++--
>  compat/atomics/pthread/stdatomic.h | 2 +-
>  compat/atomics/suncc/stdatomic.h   | 2 +-
>  compat/atomics/win32/stdatomic.h   | 2 +-
>  5 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/compat/atomics/dummy/stdatomic.h b/compat/atomics/dummy/stdatomic.h
> index c26f629aa2..59d85f915d 100644
> --- a/compat/atomics/dummy/stdatomic.h
> +++ b/compat/atomics/dummy/stdatomic.h
> @@ -156,7 +156,7 @@ FETCH_MODIFY(and, &)
>      atomic_fetch_or(object, operand)
>  
>  #define atomic_fetch_xor_explicit(object, operand, order) \
> -    atomic_fetch_sub(object, operand)
> +    atomic_fetch_xor(object, operand)
>  
>  #define atomic_fetch_and_explicit(object, operand, order) \
>      atomic_fetch_and(object, operand)
> diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h
> index 2b64687437..e13ed0e068 100644
> --- a/compat/atomics/gcc/stdatomic.h
> +++ b/compat/atomics/gcc/stdatomic.h
> @@ -147,10 +147,10 @@ do {                                    \
>      atomic_fetch_or(object, operand)
>  
>  #define atomic_fetch_xor(object, operand) \
> -    __sync_fetch_and_sub(object, operand)
> +    __sync_fetch_and_xor(object, operand)
>  
>  #define atomic_fetch_xor_explicit(object, operand, order) \
> -    atomic_fetch_sub(object, operand)
> +    atomic_fetch_xor(object, operand)
>  
>  #define atomic_fetch_and(object, operand) \
>      __sync_fetch_and_and(object, operand)
> diff --git a/compat/atomics/pthread/stdatomic.h b/compat/atomics/pthread/stdatomic.h
> index 1b7278e4fd..81a60f102b 100644
> --- a/compat/atomics/pthread/stdatomic.h
> +++ b/compat/atomics/pthread/stdatomic.h
> @@ -177,7 +177,7 @@ FETCH_MODIFY(and, &)
>      atomic_fetch_or(object, operand)
>  
>  #define atomic_fetch_xor_explicit(object, operand, order) \
> -    atomic_fetch_sub(object, operand)
> +    atomic_fetch_xor(object, operand)
>  
>  #define atomic_fetch_and_explicit(object, operand, order) \
>      atomic_fetch_and(object, operand)
> diff --git a/compat/atomics/suncc/stdatomic.h b/compat/atomics/suncc/stdatomic.h
> index 119c2ba3c9..4a864a4ae9 100644
> --- a/compat/atomics/suncc/stdatomic.h
> +++ b/compat/atomics/suncc/stdatomic.h
> @@ -166,7 +166,7 @@ static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand)
>      atomic_fetch_or(object, operand)
>  
>  #define atomic_fetch_xor_explicit(object, operand, order) \
> -    atomic_fetch_sub(object, operand)
> +    atomic_fetch_xor(object, operand)
>  
>  #define atomic_fetch_and_explicit(object, operand, order) \
>      atomic_fetch_and(object, operand)
> diff --git a/compat/atomics/win32/stdatomic.h b/compat/atomics/win32/stdatomic.h
> index 4cbba9c78d..fa7ef51ea5 100644
> --- a/compat/atomics/win32/stdatomic.h
> +++ b/compat/atomics/win32/stdatomic.h
> @@ -159,7 +159,7 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp
>      atomic_fetch_or(object, operand)
>  
>  #define atomic_fetch_xor_explicit(object, operand, order) \
> -    atomic_fetch_sub(object, operand)
> +    atomic_fetch_xor(object, operand)
>  
>  #define atomic_fetch_and_explicit(object, operand, order) \
>      atomic_fetch_and(object, operand)

Pretty nice copy&paste bug.

(Why are the _explicit aliases duplicated in the first place? I doubt
any emulation can actually make use of the order argument...)
James Almer April 2, 2017, 5:06 a.m. UTC | #2
On 3/29/2017 4:02 PM, wm4 wrote:
> On Wed, 29 Mar 2017 15:57:45 -0300
> James Almer <jamrial@gmail.com> wrote:
> 
>> ---
>>  compat/atomics/dummy/stdatomic.h   | 2 +-
>>  compat/atomics/gcc/stdatomic.h     | 4 ++--
>>  compat/atomics/pthread/stdatomic.h | 2 +-
>>  compat/atomics/suncc/stdatomic.h   | 2 +-
>>  compat/atomics/win32/stdatomic.h   | 2 +-
>>  5 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/compat/atomics/dummy/stdatomic.h b/compat/atomics/dummy/stdatomic.h
>> index c26f629aa2..59d85f915d 100644
>> --- a/compat/atomics/dummy/stdatomic.h
>> +++ b/compat/atomics/dummy/stdatomic.h
>> @@ -156,7 +156,7 @@ FETCH_MODIFY(and, &)
>>      atomic_fetch_or(object, operand)
>>  
>>  #define atomic_fetch_xor_explicit(object, operand, order) \
>> -    atomic_fetch_sub(object, operand)
>> +    atomic_fetch_xor(object, operand)
>>  
>>  #define atomic_fetch_and_explicit(object, operand, order) \
>>      atomic_fetch_and(object, operand)
>> diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h
>> index 2b64687437..e13ed0e068 100644
>> --- a/compat/atomics/gcc/stdatomic.h
>> +++ b/compat/atomics/gcc/stdatomic.h
>> @@ -147,10 +147,10 @@ do {                                    \
>>      atomic_fetch_or(object, operand)
>>  
>>  #define atomic_fetch_xor(object, operand) \
>> -    __sync_fetch_and_sub(object, operand)
>> +    __sync_fetch_and_xor(object, operand)
>>  
>>  #define atomic_fetch_xor_explicit(object, operand, order) \
>> -    atomic_fetch_sub(object, operand)
>> +    atomic_fetch_xor(object, operand)
>>  
>>  #define atomic_fetch_and(object, operand) \
>>      __sync_fetch_and_and(object, operand)
>> diff --git a/compat/atomics/pthread/stdatomic.h b/compat/atomics/pthread/stdatomic.h
>> index 1b7278e4fd..81a60f102b 100644
>> --- a/compat/atomics/pthread/stdatomic.h
>> +++ b/compat/atomics/pthread/stdatomic.h
>> @@ -177,7 +177,7 @@ FETCH_MODIFY(and, &)
>>      atomic_fetch_or(object, operand)
>>  
>>  #define atomic_fetch_xor_explicit(object, operand, order) \
>> -    atomic_fetch_sub(object, operand)
>> +    atomic_fetch_xor(object, operand)
>>  
>>  #define atomic_fetch_and_explicit(object, operand, order) \
>>      atomic_fetch_and(object, operand)
>> diff --git a/compat/atomics/suncc/stdatomic.h b/compat/atomics/suncc/stdatomic.h
>> index 119c2ba3c9..4a864a4ae9 100644
>> --- a/compat/atomics/suncc/stdatomic.h
>> +++ b/compat/atomics/suncc/stdatomic.h
>> @@ -166,7 +166,7 @@ static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand)
>>      atomic_fetch_or(object, operand)
>>  
>>  #define atomic_fetch_xor_explicit(object, operand, order) \
>> -    atomic_fetch_sub(object, operand)
>> +    atomic_fetch_xor(object, operand)
>>  
>>  #define atomic_fetch_and_explicit(object, operand, order) \
>>      atomic_fetch_and(object, operand)
>> diff --git a/compat/atomics/win32/stdatomic.h b/compat/atomics/win32/stdatomic.h
>> index 4cbba9c78d..fa7ef51ea5 100644
>> --- a/compat/atomics/win32/stdatomic.h
>> +++ b/compat/atomics/win32/stdatomic.h
>> @@ -159,7 +159,7 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp
>>      atomic_fetch_or(object, operand)
>>  
>>  #define atomic_fetch_xor_explicit(object, operand, order) \
>> -    atomic_fetch_sub(object, operand)
>> +    atomic_fetch_xor(object, operand)
>>  
>>  #define atomic_fetch_and_explicit(object, operand, order) \
>>      atomic_fetch_and(object, operand)
> 
> Pretty nice copy&paste bug.

Neither VLC, libav or us used the xor functions anywhere, so nobody
really noticed.

Pushed.
diff mbox

Patch

diff --git a/compat/atomics/dummy/stdatomic.h b/compat/atomics/dummy/stdatomic.h
index c26f629aa2..59d85f915d 100644
--- a/compat/atomics/dummy/stdatomic.h
+++ b/compat/atomics/dummy/stdatomic.h
@@ -156,7 +156,7 @@  FETCH_MODIFY(and, &)
     atomic_fetch_or(object, operand)
 
 #define atomic_fetch_xor_explicit(object, operand, order) \
-    atomic_fetch_sub(object, operand)
+    atomic_fetch_xor(object, operand)
 
 #define atomic_fetch_and_explicit(object, operand, order) \
     atomic_fetch_and(object, operand)
diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h
index 2b64687437..e13ed0e068 100644
--- a/compat/atomics/gcc/stdatomic.h
+++ b/compat/atomics/gcc/stdatomic.h
@@ -147,10 +147,10 @@  do {                                    \
     atomic_fetch_or(object, operand)
 
 #define atomic_fetch_xor(object, operand) \
-    __sync_fetch_and_sub(object, operand)
+    __sync_fetch_and_xor(object, operand)
 
 #define atomic_fetch_xor_explicit(object, operand, order) \
-    atomic_fetch_sub(object, operand)
+    atomic_fetch_xor(object, operand)
 
 #define atomic_fetch_and(object, operand) \
     __sync_fetch_and_and(object, operand)
diff --git a/compat/atomics/pthread/stdatomic.h b/compat/atomics/pthread/stdatomic.h
index 1b7278e4fd..81a60f102b 100644
--- a/compat/atomics/pthread/stdatomic.h
+++ b/compat/atomics/pthread/stdatomic.h
@@ -177,7 +177,7 @@  FETCH_MODIFY(and, &)
     atomic_fetch_or(object, operand)
 
 #define atomic_fetch_xor_explicit(object, operand, order) \
-    atomic_fetch_sub(object, operand)
+    atomic_fetch_xor(object, operand)
 
 #define atomic_fetch_and_explicit(object, operand, order) \
     atomic_fetch_and(object, operand)
diff --git a/compat/atomics/suncc/stdatomic.h b/compat/atomics/suncc/stdatomic.h
index 119c2ba3c9..4a864a4ae9 100644
--- a/compat/atomics/suncc/stdatomic.h
+++ b/compat/atomics/suncc/stdatomic.h
@@ -166,7 +166,7 @@  static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand)
     atomic_fetch_or(object, operand)
 
 #define atomic_fetch_xor_explicit(object, operand, order) \
-    atomic_fetch_sub(object, operand)
+    atomic_fetch_xor(object, operand)
 
 #define atomic_fetch_and_explicit(object, operand, order) \
     atomic_fetch_and(object, operand)
diff --git a/compat/atomics/win32/stdatomic.h b/compat/atomics/win32/stdatomic.h
index 4cbba9c78d..fa7ef51ea5 100644
--- a/compat/atomics/win32/stdatomic.h
+++ b/compat/atomics/win32/stdatomic.h
@@ -159,7 +159,7 @@  static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp
     atomic_fetch_or(object, operand)
 
 #define atomic_fetch_xor_explicit(object, operand, order) \
-    atomic_fetch_sub(object, operand)
+    atomic_fetch_xor(object, operand)
 
 #define atomic_fetch_and_explicit(object, operand, order) \
     atomic_fetch_and(object, operand)