cetintrin.h 3.3 KB

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