qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 6/8] htm: add header to abstract Hardware Transactio


From: Emilio G. Cota
Subject: [Qemu-devel] [PATCH 6/8] htm: add header to abstract Hardware Transactional Memory intrinsics
Date: Wed, 24 Aug 2016 18:18:01 -0400

Signed-off-by: Emilio G. Cota <address@hidden>
---
 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 <immintrin.h>
+
+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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]