Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/libatomic_ops.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-08-17 13:58:59 +0400
committerIvan Maidanski <ivmai@mail.ru>2013-08-17 14:03:20 +0400
commita81940c26cf3b66a5ea251b04a90db16161c5bbc (patch)
tree1c18a1e67be2cd42efcb6c9a9adfe2c565706ff6
parentdb2eef2f6e44c06e3a50b50a494dc242e4669d68 (diff)
Fix ARM char/short fetch_and_add and double-CAS operands width (GCC/Clang)
* src/atomic_ops/sysdeps/gcc/arm.h (AO_char_fetch_and_add, AO_short_fetch_and_add): Use 32-bit int type for "tmp" and "result" local variables instead of char/short type (resolve Clang3.3 warning "size being stored is truncated, use a modifier to specify the size" enabled by -Wasm-operand-widths compiler option); cast "incr" argument to int to prevent Clang3.2 warning about value truncation. * src/atomic_ops/sysdeps/gcc/arm.h (AO_double_compare_and_swap): Swap assembly code operands ("new_val.AO_whole" and "addr") to prevent Clang3.3 warning about operand truncation.
-rw-r--r--src/atomic_ops/sysdeps/gcc/arm.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/atomic_ops/sysdeps/gcc/arm.h b/src/atomic_ops/sysdeps/gcc/arm.h
index a2cca02..874ed07 100644
--- a/src/atomic_ops/sysdeps/gcc/arm.h
+++ b/src/atomic_ops/sysdeps/gcc/arm.h
@@ -389,7 +389,7 @@ AO_xor(volatile AO_t *p, AO_t value)
AO_INLINE unsigned char
AO_char_fetch_and_add(volatile unsigned char *p, unsigned char incr)
{
- unsigned char result, tmp;
+ unsigned result, tmp;
int flag;
__asm__ __volatile__("@AO_char_fetch_and_add\n"
@@ -401,16 +401,16 @@ AO_xor(volatile AO_t *p, AO_t value)
" bne 1b\n"
AO_THUMB_RESTORE_MODE
: "=&r" (result), "=&r" (flag), "=&r" (tmp), "+m" (*p)
- : "r" (incr), "r" (p)
+ : "r" ((unsigned)incr), "r" (p)
: AO_THUMB_SWITCH_CLOBBERS "cc");
- return result;
+ return (unsigned char)result;
}
# define AO_HAVE_char_fetch_and_add
AO_INLINE unsigned short
AO_short_fetch_and_add(volatile unsigned short *p, unsigned short incr)
{
- unsigned short result, tmp;
+ unsigned result, tmp;
int flag;
__asm__ __volatile__("@AO_short_fetch_and_add\n"
@@ -422,9 +422,9 @@ AO_xor(volatile AO_t *p, AO_t value)
" bne 1b\n"
AO_THUMB_RESTORE_MODE
: "=&r" (result), "=&r" (flag), "=&r" (tmp), "+m" (*p)
- : "r" (incr), "r" (p)
+ : "r" ((unsigned)incr), "r" (p)
: AO_THUMB_SWITCH_CLOBBERS "cc");
- return result;
+ return (unsigned short)result;
}
# define AO_HAVE_short_fetch_and_add
#endif /* AO_ARM_HAVE_LDREXBH */
@@ -542,9 +542,9 @@ AO_fetch_compare_and_swap(volatile AO_t *addr, AO_t old_val, AO_t new_val)
if (tmp != old_val.AO_whole)
break;
__asm__ __volatile__(
- " strexd %0, %2, %H2, [%3]\n" /* store new one if matched */
+ " strexd %0, %3, %H3, [%2]\n" /* store new one if matched */
: "=&r"(result), "+m"(*addr)
- : "r"(new_val.AO_whole), "r"(addr)
+ : "r" (addr), "r" (new_val.AO_whole)
: "cc");
} while (AO_EXPECT_FALSE(result));
return !result; /* if succeded, return 1 else 0 */