#include <vdso/futex.h>
#define __stringify_1(x...) #x
#define __stringify(x...) __stringify_1(x)
#define LABEL(prefix, which) __stringify(prefix##_try_unlock_cs_##which:)
#define JNZ_END(prefix) "jnz " __stringify(prefix) "_try_unlock_cs_end\n"
#define CLEAR_POPQ "movq %[zero], %a[pop]\n"
#define CLEAR_POPL "movl %k[zero], %a[pop]\n"
#define futex_robust_try_unlock(prefix, clear_pop, __lock, __tid, __pop)\
({ \
asm volatile ( \
" \n" \
" lock cmpxchgl %k[zero], %a[lock] \n" \
" \n" \
LABEL(prefix, start) \
" \n" \
JNZ_END(prefix) \
" \n" \
LABEL(prefix, success) \
" \n" \
clear_pop \
" \n" \
LABEL(prefix, end) \
: [tid] "+&a" (__tid) \
: [lock] "D" (__lock), \
[pop] "d" (__pop), \
[zero] "r" (0UL) \
: "memory" \
); \
__tid; \
})
#ifdef __x86_64__
__u32 __vdso_futex_robust_list64_try_unlock(__u32 *lock, __u32 tid, __u64 *pop)
{
return futex_robust_try_unlock(__futex_list64, CLEAR_POPQ, lock, tid, pop);
}
#endif
#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
__u32 __vdso_futex_robust_list32_try_unlock(__u32 *lock, __u32 tid, __u32 *pop)
{
return futex_robust_try_unlock(__futex_list32, CLEAR_POPL, lock, tid, pop);
}
#endif