Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions opal/include/opal/sys/amd64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserverd.
* Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -158,8 +160,8 @@ static inline int32_t opal_atomic_swap_32( volatile int32_t *addr,
int32_t oldval;

__asm__ __volatile__("xchg %1, %0" :
"=r" (oldval), "=m" (*addr) :
"0" (newval), "m" (*addr) :
"=r" (oldval), "+m" (*addr) :
"0" (newval) :
"memory");
return oldval;
}
Expand All @@ -174,8 +176,8 @@ static inline int64_t opal_atomic_swap_64( volatile int64_t *addr,
int64_t oldval;

__asm__ __volatile__("xchgq %1, %0" :
"=r" (oldval) :
"m" (*addr), "0" (newval) :
"=r" (oldval), "+m" (*addr) :
"0" (newval) :
"memory");
return oldval;
}
Expand Down Expand Up @@ -203,8 +205,8 @@ static inline int32_t opal_atomic_add_32(volatile int32_t* v, int i)
int ret = i;
__asm__ __volatile__(
SMPLOCK "xaddl %1,%0"
:"=m" (*v), "+r" (ret)
:"m" (*v)
:"+m" (*v), "+r" (ret)
:
:"memory", "cc"
);
return (ret+i);
Expand All @@ -224,8 +226,8 @@ static inline int64_t opal_atomic_add_64(volatile int64_t* v, int64_t i)
int64_t ret = i;
__asm__ __volatile__(
SMPLOCK "xaddq %1,%0"
:"=m" (*v), "+r" (ret)
:"m" (*v)
:"+m" (*v), "+r" (ret)
:
:"memory", "cc"
);
return (ret+i);
Expand All @@ -245,8 +247,8 @@ static inline int32_t opal_atomic_sub_32(volatile int32_t* v, int i)
int ret = -i;
__asm__ __volatile__(
SMPLOCK "xaddl %1,%0"
:"=m" (*v), "+r" (ret)
:"m" (*v)
:"+m" (*v), "+r" (ret)
:
:"memory", "cc"
);
return (ret-i);
Expand All @@ -266,8 +268,8 @@ static inline int64_t opal_atomic_sub_64(volatile int64_t* v, int64_t i)
int64_t ret = -i;
__asm__ __volatile__(
SMPLOCK "xaddq %1,%0"
:"=m" (*v), "+r" (ret)
:"m" (*v)
:"+m" (*v), "+r" (ret)
:
:"memory", "cc"
);
return (ret-i);
Expand Down