-#if defined(__i386__)
-
-#define LMTX_ARG0 B_ARG0
-#define LMTX_ARG1 B_ARG1
-#define LMTX_REG %edx
-#define LMTX_A_REG %eax
-#define LMTX_A_REG32 %eax
-#define LMTX_C_REG %ecx
-#define LMTX_C_REG32 %ecx
-#define LMTX_D_REG %edx
-#define LMTX_RET_REG %eax
-#define LMTX_LGROUP_REG %esi
-#define LMTX_SSTATE_REG %edi
-#define LOAD_LMTX_REG(arg) mov arg, LMTX_REG
-#define LOAD_REG_ARG0(reg) push reg
-#define LOAD_REG_ARG1(reg) push reg
-#define LMTX_CHK_EXTENDED cmp LMTX_REG, LMTX_ARG0
-#define LMTX_ASSERT_OWNED cmpl $(MUTEX_ASSERT_OWNED), LMTX_ARG1
-
-#define LMTX_ENTER_EXTENDED \
- mov M_PTR(LMTX_REG), LMTX_REG ; \
- push LMTX_LGROUP_REG ; \
- push LMTX_SSTATE_REG ; \
- xor LMTX_SSTATE_REG, LMTX_SSTATE_REG ; \
- mov MUTEX_GRP(LMTX_REG), LMTX_LGROUP_REG ; \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- addl $1, GRP_MTX_STAT_UTIL(LMTX_LGROUP_REG) ; \
- jnc 11f ; \
- incl GRP_MTX_STAT_UTIL+4(LMTX_LGROUP_REG) ; \
-11:
-
-#define LMTX_EXIT_EXTENDED \
- pop LMTX_SSTATE_REG ; \
- pop LMTX_LGROUP_REG
-
-
-#define LMTX_CHK_EXTENDED_EXIT \
- cmp LMTX_REG, LMTX_ARG0 ; \
- je 12f ; \
- pop LMTX_SSTATE_REG ; \
- pop LMTX_LGROUP_REG ; \
-12:
-
-
-#if LOG_FIRST_MISS_ALONE
-#define LMTX_UPDATE_MISS \
- test $1, LMTX_SSTATE_REG ; \
- jnz 11f ; \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- incl GRP_MTX_STAT_MISS(LMTX_LGROUP_REG) ; \
- or $1, LMTX_SSTATE_REG ; \
-11:
-#else
-#define LMTX_UPDATE_MISS \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- incl GRP_MTX_STAT_MISS(LMTX_LGROUP_REG)
-#endif
-
-
-#if LOG_FIRST_MISS_ALONE
-#define LMTX_UPDATE_WAIT \
- test $2, LMTX_SSTATE_REG ; \
- jnz 11f ; \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- incl GRP_MTX_STAT_WAIT(LMTX_LGROUP_REG) ; \
- or $2, LMTX_SSTATE_REG ; \
-11:
-#else
-#define LMTX_UPDATE_WAIT \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- incl GRP_MTX_STAT_WAIT(LMTX_LGROUP_REG)
-#endif
-
-
-/*
- * Record the "direct wait" statistic, which indicates if a
- * miss proceeded to block directly without spinning--occurs
- * if the owner of the mutex isn't running on another processor
- * at the time of the check.
- */
-#define LMTX_UPDATE_DIRECT_WAIT \
- LOCK_IF_ATOMIC_STAT_UPDATES ; \
- incl GRP_MTX_STAT_DIRECT_WAIT(LMTX_LGROUP_REG)
-
-
-#define LMTX_CALLEXT1(func_name) \
- push LMTX_REG ; \
- push LMTX_REG ; \
- call EXT(func_name) ; \
- add $4, %esp ; \
- pop LMTX_REG
-
-#define LMTX_CALLEXT2(func_name, reg) \
- push LMTX_REG ; \
- push reg ; \
- push LMTX_REG ; \
- call EXT(func_name) ; \
- add $8, %esp ; \
- pop LMTX_REG
-
-#elif defined(__x86_64__)
-
-#define LMTX_ARG0 %rdi
-#define LMTX_ARG1 %rsi
-#define LMTX_REG_ORIG %rdi
-#define LMTX_REG %rdx
-#define LMTX_A_REG %rax
-#define LMTX_A_REG32 %eax
-#define LMTX_C_REG %rcx
-#define LMTX_C_REG32 %ecx
-#define LMTX_D_REG %rdx
-#define LMTX_RET_REG %rax
-#define LMTX_LGROUP_REG %r10
-#define LMTX_SSTATE_REG %r11
-#define LOAD_LMTX_REG(arg) mov %rdi, %rdx
-#define LOAD_REG_ARG0(reg) mov reg, %rdi
-#define LOAD_REG_ARG1(reg) mov reg, %rsi
-#define LMTX_CHK_EXTENDED cmp LMTX_REG, LMTX_REG_ORIG
-#define LMTX_ASSERT_OWNED cmp $(MUTEX_ASSERT_OWNED), LMTX_ARG1