}
static inline long
-__kernel_cmpxchg2 (void * oldval, void * newval, void *mem, int val_size)
+__kernel_cmpxchg2 (const void *oldval, const void *newval, void *mem,
+ int val_size)
{
register unsigned long lws_mem asm("r26") = (unsigned long) (mem);
register long lws_ret asm("r28");
if (__builtin_expect (lws_errno == -EFAULT || lws_errno == -ENOSYS, 0))
__builtin_trap ();
- /* If the kernel LWS call fails, retrun EBUSY */
+ /* If the kernel LWS call fails, return EBUSY */
if (!lws_errno && lws_ret)
lws_errno = -EBUSY;
int failure; \
\
do { \
- tmp = *ptr; \
+ tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
newval = PFX_OP (tmp INF_OP val); \
failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX); \
} while (failure != 0); \
return tmp; \
}
-FETCH_AND_OP_2 (add, , +, long long, 8, 3)
-FETCH_AND_OP_2 (sub, , -, long long, 8, 3)
-FETCH_AND_OP_2 (or, , |, long long, 8, 3)
-FETCH_AND_OP_2 (and, , &, long long, 8, 3)
-FETCH_AND_OP_2 (xor, , ^, long long, 8, 3)
-FETCH_AND_OP_2 (nand, ~, &, long long, 8, 3)
-
FETCH_AND_OP_2 (add, , +, short, 2, 1)
FETCH_AND_OP_2 (sub, , -, short, 2, 1)
FETCH_AND_OP_2 (or, , |, short, 2, 1)
int failure; \
\
do { \
- tmp = *ptr; \
+ tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
newval = PFX_OP (tmp INF_OP val); \
failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX); \
} while (failure != 0); \
return PFX_OP (tmp INF_OP val); \
}
-OP_AND_FETCH_2 (add, , +, long long, 8, 3)
-OP_AND_FETCH_2 (sub, , -, long long, 8, 3)
-OP_AND_FETCH_2 (or, , |, long long, 8, 3)
-OP_AND_FETCH_2 (and, , &, long long, 8, 3)
-OP_AND_FETCH_2 (xor, , ^, long long, 8, 3)
-OP_AND_FETCH_2 (nand, ~, &, long long, 8, 3)
-
OP_AND_FETCH_2 (add, , +, short, 2, 1)
OP_AND_FETCH_2 (sub, , -, short, 2, 1)
OP_AND_FETCH_2 (or, , |, short, 2, 1)
int failure, tmp; \
\
do { \
- tmp = *ptr; \
+ tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
failure = __kernel_cmpxchg (tmp, PFX_OP (tmp INF_OP val), ptr); \
} while (failure != 0); \
\
int tmp, failure; \
\
do { \
- tmp = *ptr; \
+ tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
failure = __kernel_cmpxchg (tmp, PFX_OP (tmp INF_OP val), ptr); \
} while (failure != 0); \
\
\
while (1) \
{ \
- actual_oldval = *ptr; \
+ actual_oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
\
if (__builtin_expect (oldval != actual_oldval, 0)) \
return actual_oldval; \
\
if (__builtin_expect (!fail, 1)) \
return actual_oldval; \
- } \
+ } \
} \
\
bool HIDDEN \
return (failure != 0); \
}
-COMPARE_AND_SWAP_2 (long long, 8, 3)
COMPARE_AND_SWAP_2 (short, 2, 1)
COMPARE_AND_SWAP_2 (char, 1, 0)
while (1)
{
- actual_oldval = *ptr;
+ actual_oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
if (__builtin_expect (oldval != actual_oldval, 0))
return actual_oldval;
int failure; \
\
do { \
- oldval = *ptr; \
+ oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
failure = __kernel_cmpxchg2 (&oldval, &val, ptr, INDEX); \
} while (failure != 0); \
\
return oldval; \
}
-SYNC_LOCK_TEST_AND_SET_2 (long long, 8, 3)
SYNC_LOCK_TEST_AND_SET_2 (short, 2, 1)
SYNC_LOCK_TEST_AND_SET_2 (signed char, 1, 0)
int failure, oldval;
do {
- oldval = *ptr;
+ oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);
failure = __kernel_cmpxchg (oldval, val, ptr);
} while (failure != 0);
TYPE failure, oldval, zero = 0; \
\
do { \
- oldval = *ptr; \
+ oldval = __atomic_load_n (ptr, __ATOMIC_SEQ_CST); \
failure = __kernel_cmpxchg2 (&oldval, &zero, ptr, INDEX); \
} while (failure != 0); \
}
-SYNC_LOCK_RELEASE_2 (long long, 8, 3)
SYNC_LOCK_RELEASE_2 (short, 2, 1)
SYNC_LOCK_RELEASE_2 (signed char, 1, 0)