rtmintrin.h revision 7cb4fae8da8f541f43d39896c989b06c69fd7821
1463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao/*===---- rtmintrin.h - RTM intrinsics -------------------------------------===
2463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao *
3463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * Permission is hereby granted, free of charge, to any person obtaining a copy
4463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * of this software and associated documentation files (the "Software"), to deal
5463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * in the Software without restriction, including without limitation the rights
6463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * copies of the Software, and to permit persons to whom the Software is
8463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * furnished to do so, subject to the following conditions:
9463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao *
10463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * The above copyright notice and this permission notice shall be included in
11463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * all copies or substantial portions of the Software.
12463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao *
13463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao * THE SOFTWARE.
20463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao *
21463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao *===-----------------------------------------------------------------------===
22463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao */
23463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao
24463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#ifndef __IMMINTRIN_H
25463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#error "Never use <rtmintrin.h> directly; include <immintrin.h> instead."
26463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#endif
27463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao
287cb4fae8da8f541f43d39896c989b06c69fd7821Richard Smith#ifndef __RTMINTRIN_H
297cb4fae8da8f541f43d39896c989b06c69fd7821Richard Smith#define __RTMINTRIN_H
307cb4fae8da8f541f43d39896c989b06c69fd7821Richard Smith
31463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XBEGIN_STARTED   (~0u)
32463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_EXPLICIT  (1 << 0)
33463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_RETRY     (1 << 1)
34463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_CONFLICT  (1 << 2)
35463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_CAPACITY  (1 << 3)
36463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_DEBUG     (1 << 4)
37463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_NESTED    (1 << 5)
38463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _XABORT_CODE(x)   (((x) >> 24) & 0xFF)
39463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao
40463eb89d5e36b05d74c14b937384076d745b3b84Michael Liaostatic __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
41463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao_xbegin(void)
42463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao{
43463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao  return __builtin_ia32_xbegin();
44463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao}
45463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao
46463eb89d5e36b05d74c14b937384076d745b3b84Michael Liaostatic __inline__ void __attribute__((__always_inline__, __nodebug__))
47463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao_xend(void)
48463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao{
49463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao  __builtin_ia32_xend();
50463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao}
51463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao
52463eb89d5e36b05d74c14b937384076d745b3b84Michael Liao#define _xabort(imm) __builtin_ia32_xabort((imm))
537cb4fae8da8f541f43d39896c989b06c69fd7821Richard Smith
547cb4fae8da8f541f43d39896c989b06c69fd7821Richard Smith#endif /* __RTMINTRIN_H */
55