From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgV6-0006eo-QY for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcgV4-0004Mw-Sf for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:23 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:37427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgV2-0004Jk-JJ for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:22 -0400 From: "Emilio G. Cota" Date: Wed, 24 Aug 2016 18:18:01 -0400 Message-Id: <1472077083-15022-6-git-send-email-cota@braap.org> In-Reply-To: <1472077083-15022-1-git-send-email-cota@braap.org> References: <20160824211240.GA26546@flamenco> <1472077083-15022-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [PATCH 6/8] htm: add header to abstract Hardware Transactional Memory intrinsics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: alex.bennee@linaro.org, mttcg@greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com, mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, serge.fdrv@gmail.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, dgilbert@redhat.com, crosthwaite.peter@gmail.com Signed-off-by: Emilio G. Cota --- include/qemu/htm.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 include/qemu/htm.h diff --git a/include/qemu/htm.h b/include/qemu/htm.h new file mode 100644 index 0000000..dc84bc1 --- /dev/null +++ b/include/qemu/htm.h @@ -0,0 +1,43 @@ +#ifndef HTM_H +#define HTM_H + +enum htm { + HTM_OK, + HTM_ABORT_RETRY, + HTM_ABORT_NORETRY, +}; + +#if defined(__x86_64__) +/* compile with -mrtm */ +#include + +static inline enum htm htm_begin(void) +{ + int status; + + status = _xbegin(); + if (unlikely(status != _XBEGIN_STARTED)) { + if (status & _XABORT_RETRY) { + return HTM_ABORT_RETRY; + } + return HTM_ABORT_NORETRY; + } + return HTM_OK; +} + +static inline void htm_end(void) +{ + _xend(); +} + +static inline bool htm_test(void) +{ + return _xtest(); +} + +static inline void htm_abort(void) +{ + _xabort(0); +} +#endif /* ISA */ +#endif /* HTM_H */ -- 2.5.0