Signed-off-by: Emilio G. Cota <c...@braap.org> --- target-i386/helper.h | 4 ++++ target-i386/mem_helper.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/target-i386/helper.h b/target-i386/helper.h index 1320edc..af84836 100644 --- a/target-i386/helper.h +++ b/target-i386/helper.h @@ -74,8 +74,12 @@ DEF_HELPER_3(boundw, void, env, tl, int) DEF_HELPER_3(boundl, void, env, tl, int) DEF_HELPER_1(rsm, void, env) DEF_HELPER_2(into, void, env, int) +DEF_HELPER_4(cmpxchgb, tl, env, tl, tl, tl) +DEF_HELPER_4(cmpxchgw, tl, env, tl, tl, tl) +DEF_HELPER_4(cmpxchgl, tl, env, tl, tl, tl) DEF_HELPER_2(cmpxchg8b, void, env, tl) #ifdef TARGET_X86_64 +DEF_HELPER_4(cmpxchgq, tl, env, tl, tl, tl) DEF_HELPER_2(cmpxchg16b, void, env, tl) #endif DEF_HELPER_1(single_step, void, env) diff --git a/target-i386/mem_helper.c b/target-i386/mem_helper.c index c2f4769..3b17326 100644 --- a/target-i386/mem_helper.c +++ b/target-i386/mem_helper.c @@ -56,6 +56,21 @@ void helper_lock_init(void) } #endif +#define GEN_CMPXCHG_HELPER(NAME) \ +target_ulong glue(helper_, NAME)(CPUX86State *env, target_ulong addr, \ + target_ulong old, target_ulong new) \ +{ \ + return glue(glue(cpu_, NAME), _data_ra)(env, addr, old, new, GETPC()); \ +} + +GEN_CMPXCHG_HELPER(cmpxchgb) +GEN_CMPXCHG_HELPER(cmpxchgw) +GEN_CMPXCHG_HELPER(cmpxchgl) +#ifdef TARGET_X86_64 +GEN_CMPXCHG_HELPER(cmpxchgq) +#endif +#undef GEN_CMPXCHG_HELPER + void helper_cmpxchg8b(CPUX86State *env, target_ulong a0) { uint64_t d; -- 2.5.0