1*38fd1498Szrj /* Copyright (C) 2015-2018 Free Software Foundation, Inc.
2*38fd1498Szrj
3*38fd1498Szrj This file is part of GCC.
4*38fd1498Szrj
5*38fd1498Szrj GCC is free software; you can redistribute it and/or modify
6*38fd1498Szrj it under the terms of the GNU General Public License as published by
7*38fd1498Szrj the Free Software Foundation; either version 3, or (at your option)
8*38fd1498Szrj any later version.
9*38fd1498Szrj
10*38fd1498Szrj GCC is distributed in the hope that it will be useful,
11*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
12*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*38fd1498Szrj GNU General Public License for more details.
14*38fd1498Szrj
15*38fd1498Szrj Under Section 7 of GPL version 3, you are granted additional
16*38fd1498Szrj permissions described in the GCC Runtime Library Exception, version
17*38fd1498Szrj 3.1, as published by the Free Software Foundation.
18*38fd1498Szrj
19*38fd1498Szrj You should have received a copy of the GNU General Public License and
20*38fd1498Szrj a copy of the GCC Runtime Library Exception along with this program;
21*38fd1498Szrj see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22*38fd1498Szrj <http://www.gnu.org/licenses/>. */
23*38fd1498Szrj
24*38fd1498Szrj #if !defined _IMMINTRIN_H_INCLUDED
25*38fd1498Szrj # error "Never use <cetintrin.h> directly; include <x86intrin.h> instead."
26*38fd1498Szrj #endif
27*38fd1498Szrj
28*38fd1498Szrj #ifndef _CETINTRIN_H_INCLUDED
29*38fd1498Szrj #define _CETINTRIN_H_INCLUDED
30*38fd1498Szrj
31*38fd1498Szrj #ifndef __SHSTK__
32*38fd1498Szrj #pragma GCC push_options
33*38fd1498Szrj #pragma GCC target ("shstk")
34*38fd1498Szrj #define __DISABLE_SHSTK__
35*38fd1498Szrj #endif /* __SHSTK__ */
36*38fd1498Szrj
37*38fd1498Szrj #ifdef __x86_64__
38*38fd1498Szrj extern __inline unsigned long long
39*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_get_ssp(void)40*38fd1498Szrj _get_ssp (void)
41*38fd1498Szrj {
42*38fd1498Szrj return __builtin_ia32_rdsspq ();
43*38fd1498Szrj }
44*38fd1498Szrj #else
45*38fd1498Szrj extern __inline unsigned int
46*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_get_ssp(void)47*38fd1498Szrj _get_ssp (void)
48*38fd1498Szrj {
49*38fd1498Szrj return __builtin_ia32_rdsspd ();
50*38fd1498Szrj }
51*38fd1498Szrj #endif
52*38fd1498Szrj
53*38fd1498Szrj extern __inline void
54*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_inc_ssp(unsigned int __B)55*38fd1498Szrj _inc_ssp (unsigned int __B)
56*38fd1498Szrj {
57*38fd1498Szrj #ifdef __x86_64__
58*38fd1498Szrj __builtin_ia32_incsspq ((unsigned long long) __B);
59*38fd1498Szrj #else
60*38fd1498Szrj __builtin_ia32_incsspd (__B);
61*38fd1498Szrj #endif
62*38fd1498Szrj }
63*38fd1498Szrj
64*38fd1498Szrj extern __inline void
65*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_saveprevssp(void)66*38fd1498Szrj _saveprevssp (void)
67*38fd1498Szrj {
68*38fd1498Szrj __builtin_ia32_saveprevssp ();
69*38fd1498Szrj }
70*38fd1498Szrj
71*38fd1498Szrj extern __inline void
72*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rstorssp(void * __B)73*38fd1498Szrj _rstorssp (void *__B)
74*38fd1498Szrj {
75*38fd1498Szrj __builtin_ia32_rstorssp (__B);
76*38fd1498Szrj }
77*38fd1498Szrj
78*38fd1498Szrj extern __inline void
79*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wrssd(unsigned int __B,void * __C)80*38fd1498Szrj _wrssd (unsigned int __B, void *__C)
81*38fd1498Szrj {
82*38fd1498Szrj __builtin_ia32_wrssd (__B, __C);
83*38fd1498Szrj }
84*38fd1498Szrj
85*38fd1498Szrj #ifdef __x86_64__
86*38fd1498Szrj extern __inline void
87*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wrssq(unsigned long long __B,void * __C)88*38fd1498Szrj _wrssq (unsigned long long __B, void *__C)
89*38fd1498Szrj {
90*38fd1498Szrj __builtin_ia32_wrssq (__B, __C);
91*38fd1498Szrj }
92*38fd1498Szrj #endif
93*38fd1498Szrj
94*38fd1498Szrj extern __inline void
95*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wrussd(unsigned int __B,void * __C)96*38fd1498Szrj _wrussd (unsigned int __B, void *__C)
97*38fd1498Szrj {
98*38fd1498Szrj __builtin_ia32_wrussd (__B, __C);
99*38fd1498Szrj }
100*38fd1498Szrj
101*38fd1498Szrj #ifdef __x86_64__
102*38fd1498Szrj extern __inline void
103*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wrussq(unsigned long long __B,void * __C)104*38fd1498Szrj _wrussq (unsigned long long __B, void *__C)
105*38fd1498Szrj {
106*38fd1498Szrj __builtin_ia32_wrussq (__B, __C);
107*38fd1498Szrj }
108*38fd1498Szrj #endif
109*38fd1498Szrj
110*38fd1498Szrj extern __inline void
111*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_setssbsy(void)112*38fd1498Szrj _setssbsy (void)
113*38fd1498Szrj {
114*38fd1498Szrj __builtin_ia32_setssbsy ();
115*38fd1498Szrj }
116*38fd1498Szrj
117*38fd1498Szrj extern __inline void
118*38fd1498Szrj __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_clrssbsy(void * __B)119*38fd1498Szrj _clrssbsy (void *__B)
120*38fd1498Szrj {
121*38fd1498Szrj __builtin_ia32_clrssbsy (__B);
122*38fd1498Szrj }
123*38fd1498Szrj
124*38fd1498Szrj #ifdef __DISABLE_SHSTK__
125*38fd1498Szrj #undef __DISABLE_SHSTK__
126*38fd1498Szrj #pragma GCC pop_options
127*38fd1498Szrj #endif /* __DISABLE_SHSTK__ */
128*38fd1498Szrj
129*38fd1498Szrj #endif /* _CETINTRIN_H_INCLUDED. */
130