CNDP 22.08.0
Loading...
Searching...
No Matches
cne_rtm.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2012,2013,2021 Intel Corporation
3 */
4
5#ifndef _CNE_RTM_H_
6#define _CNE_RTM_H_ 1
7
8/* Official RTM intrinsics interface matching gcc/icc, but works
9 on older gcc compatible compilers and binutils. */
10
11#include <cne_common.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#define CNE_XBEGIN_STARTED (~0u)
18#define CNE_XABORT_EXPLICIT (1 << 0)
19#define CNE_XABORT_RETRY (1 << 1)
20#define CNE_XABORT_CONFLICT (1 << 2)
21#define CNE_XABORT_CAPACITY (1 << 3)
22#define CNE_XABORT_DEBUG (1 << 4)
23#define CNE_XABORT_NESTED (1 << 5)
24#define CNE_XABORT_CODE(x) (((x) >> 24) & 0xff)
25
26static __cne_always_inline unsigned int
27cne_xbegin(void)
28{
29 unsigned int ret = CNE_XBEGIN_STARTED;
30
31 asm volatile(".byte 0xc7,0xf8 ; .long 0" : "+a"(ret)::"memory");
32 return ret;
33}
34
35static __cne_always_inline void
36cne_xend(void)
37{
38 asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory");
39}
40
41/* not an inline function to workaround a clang bug with -O0 */
42#define cne_xabort(status) \
43 do { \
44 asm volatile(".byte 0xc6,0xf8,%P0" ::"i"(status) : "memory"); \
45 } while (0)
46
47static __cne_always_inline int
48cne_xtest(void)
49{
50 unsigned char out;
51
52 asm volatile(".byte 0x0f,0x01,0xd6 ; setnz %0" : "=r"(out)::"memory");
53 return out;
54}
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif /* _CNE_RTM_H_ */
#define __cne_always_inline
Definition cne_common.h:218