1 /*===---- cetintrin.h - CET intrinsic --------------------------------------=== 2 * 3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 * See https://llvm.org/LICENSE.txt for license information. 5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 * 7 *===-----------------------------------------------------------------------=== 8 */ 9 10 #ifndef __IMMINTRIN_H 11 #error "Never use <cetintrin.h> directly; include <immintrin.h> instead." 12 #endif 13 14 #ifndef __CETINTRIN_H 15 #define __CETINTRIN_H 16 17 /* Define the default attributes for the functions in this file. */ 18 #define __DEFAULT_FN_ATTRS \ 19 __attribute__((__always_inline__, __nodebug__, __target__("shstk"))) 20 21 static __inline__ void __DEFAULT_FN_ATTRS _incsspd(int __a) { 22 __builtin_ia32_incsspd(__a); 23 } 24 25 #ifdef __x86_64__ 26 static __inline__ void __DEFAULT_FN_ATTRS _incsspq(unsigned long long __a) { 27 __builtin_ia32_incsspq(__a); 28 } 29 #endif /* __x86_64__ */ 30 31 #ifdef __x86_64__ 32 static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { 33 __builtin_ia32_incsspq(__a); 34 } 35 #else /* __x86_64__ */ 36 static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { 37 __builtin_ia32_incsspd((int)__a); 38 } 39 #endif /* __x86_64__ */ 40 41 static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd(unsigned int __a) { 42 return __builtin_ia32_rdsspd(__a); 43 } 44 45 static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32() { 46 unsigned int t; 47 return __builtin_ia32_rdsspd(t); 48 } 49 50 #ifdef __x86_64__ 51 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long long __a) { 52 return __builtin_ia32_rdsspq(__a); 53 } 54 55 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64() { 56 unsigned long long t; 57 return __builtin_ia32_rdsspq(t); 58 } 59 #endif /* __x86_64__ */ 60 61 #ifdef __x86_64__ 62 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _get_ssp(void) { 63 return __builtin_ia32_rdsspq(0); 64 } 65 #else /* __x86_64__ */ 66 static __inline__ unsigned int __DEFAULT_FN_ATTRS _get_ssp(void) { 67 return __builtin_ia32_rdsspd(0); 68 } 69 #endif /* __x86_64__ */ 70 71 static __inline__ void __DEFAULT_FN_ATTRS _saveprevssp() { 72 __builtin_ia32_saveprevssp(); 73 } 74 75 static __inline__ void __DEFAULT_FN_ATTRS _rstorssp(void * __p) { 76 __builtin_ia32_rstorssp(__p); 77 } 78 79 static __inline__ void __DEFAULT_FN_ATTRS _wrssd(unsigned int __a, void * __p) { 80 __builtin_ia32_wrssd(__a, __p); 81 } 82 83 #ifdef __x86_64__ 84 static __inline__ void __DEFAULT_FN_ATTRS _wrssq(unsigned long long __a, void * __p) { 85 __builtin_ia32_wrssq(__a, __p); 86 } 87 #endif /* __x86_64__ */ 88 89 static __inline__ void __DEFAULT_FN_ATTRS _wrussd(unsigned int __a, void * __p) { 90 __builtin_ia32_wrussd(__a, __p); 91 } 92 93 #ifdef __x86_64__ 94 static __inline__ void __DEFAULT_FN_ATTRS _wrussq(unsigned long long __a, void * __p) { 95 __builtin_ia32_wrussq(__a, __p); 96 } 97 #endif /* __x86_64__ */ 98 99 static __inline__ void __DEFAULT_FN_ATTRS _setssbsy() { 100 __builtin_ia32_setssbsy(); 101 } 102 103 static __inline__ void __DEFAULT_FN_ATTRS _clrssbsy(void * __p) { 104 __builtin_ia32_clrssbsy(__p); 105 } 106 107 #undef __DEFAULT_FN_ATTRS 108 109 #endif /* __CETINTRIN_H */ 110