Skip to content

Commit b8bc7ae

Browse files
authored
Merge pull request #67 from jty2/github-jty2.synchronization-fixes
Fix register allocation problems in LSE cmpxchg and mysql/cas_event_mutex.h
2 parents 6abfb03 + d505ca8 commit b8bc7ae

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ext/linux/include/lk_cmpxchg.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,25 +223,28 @@ __CMPXCHG_CASE( , , mb_8, dmb ish, , l, "memory")
223223

224224
#define __LSE_CMPXCHG_CASE(w, sz, name, mb, cl...) \
225225
static inline unsigned long __cmpxchg_case_##name(volatile void *ptr, \
226-
unsigned long old, \
227-
unsigned long new) \
226+
unsigned long old, \
227+
unsigned long new) \
228228
{ \
229229
register unsigned long x0 asm ("x0") = (unsigned long)ptr; \
230230
register unsigned long x1 asm ("x1") = old; \
231231
register unsigned long x2 asm ("x2") = new; \
232+
unsigned long tmp; \
232233
\
233234
asm volatile( \
234235
/* LSE atomics */ \
235-
" mov " #w "30, %" #w "[old]\n" \
236-
" cas" #mb #sz "\t" #w "30, %" #w "[new], %[v]\n" \
237-
" mov %" #w "[ret], " #w "30" \
238-
: [ret] "+r" (x0), [v] "+Q" (*(unsigned long *)ptr) \
236+
" mov %" #w "[tmp], %" #w "[old]\n" \
237+
" cas" #mb #sz "\t%" #w "[tmp], %" #w "[new], %[v]\n" \
238+
" mov %" #w "[ret], %" #w "[tmp]" \
239+
: [ret] "+r" (x0), [v] "+Q" (*(unsigned long *)ptr), \
240+
[tmp] "=&r" (tmp) \
239241
: [old] "r" (x1), [new] "r" (x2) \
240242
: cl); \
241243
\
242244
return x0; \
243245
}
244246

247+
// w sz name mb cl
245248
__LSE_CMPXCHG_CASE(w, b, 1, )
246249
__LSE_CMPXCHG_CASE(w, h, 2, )
247250
__LSE_CMPXCHG_CASE(w, , 4, )

ext/mysql/cas_event_mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void lock_signal(void)
8484
uint32_t exResult;
8585

8686
__asm__ __volatile__ ("stxr %w[exResult], %[lockValue],[%[lockAddr]]"
87-
: [exResult] "=r" (exResult)
87+
: [exResult] "=&r" (exResult)
8888
: [lockAddr] "r" (lock), [lockValue] "r" (MUTEX_STATE_LOCKED)
8989
:"memory");
9090

0 commit comments

Comments
 (0)