blob: ccb3d2dd2294b4850fb51bc645f4f9a397c5c15a [file] [log] [blame]
Michael Liaoffaae352013-03-29 05:17:55 +00001/*===---- rdseedintrin.h - RDSEED intrinsics -------------------------------===
2 *
Chandler Carruth4cf57432019-04-08 20:51:30 +00003 * 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
Michael Liaoffaae352013-03-29 05:17:55 +00006 *
7 *===-----------------------------------------------------------------------===
8 */
9
Craig Topper664af9b2018-05-23 18:32:58 +000010#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
Michael Liaoffaae352013-03-29 05:17:55 +000011#error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead."
12#endif
13
Richard Smith49e56442013-07-14 05:41:45 +000014#ifndef __RDSEEDINTRIN_H
15#define __RDSEEDINTRIN_H
16
Eric Christopher4d1851682015-06-17 07:09:20 +000017/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000018#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("rdseed")))
Eric Christopher4d1851682015-06-17 07:09:20 +000019
Michael Kupersteine45af542015-06-30 13:36:19 +000020static __inline__ int __DEFAULT_FN_ATTRS
Michael Liaoffaae352013-03-29 05:17:55 +000021_rdseed16_step(unsigned short *__p)
22{
23 return __builtin_ia32_rdseed16_step(__p);
24}
25
Michael Kupersteine45af542015-06-30 13:36:19 +000026static __inline__ int __DEFAULT_FN_ATTRS
Michael Liaoffaae352013-03-29 05:17:55 +000027_rdseed32_step(unsigned int *__p)
28{
29 return __builtin_ia32_rdseed32_step(__p);
30}
31
32#ifdef __x86_64__
Michael Kupersteine45af542015-06-30 13:36:19 +000033static __inline__ int __DEFAULT_FN_ATTRS
Michael Liaoffaae352013-03-29 05:17:55 +000034_rdseed64_step(unsigned long long *__p)
35{
36 return __builtin_ia32_rdseed64_step(__p);
37}
38#endif
Eric Christopher4d1851682015-06-17 07:09:20 +000039
Michael Kupersteine45af542015-06-30 13:36:19 +000040#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +000041
Richard Smith49e56442013-07-14 05:41:45 +000042#endif /* __RDSEEDINTRIN_H */