1274958Sdim/* ===-------- ia32intrin.h ---------------------------------------------------===
2274958Sdim *
3274958Sdim * Permission is hereby granted, free of charge, to any person obtaining a copy
4274958Sdim * of this software and associated documentation files (the "Software"), to deal
5274958Sdim * in the Software without restriction, including without limitation the rights
6274958Sdim * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7274958Sdim * copies of the Software, and to permit persons to whom the Software is
8274958Sdim * furnished to do so, subject to the following conditions:
9274958Sdim *
10274958Sdim * The above copyright notice and this permission notice shall be included in
11274958Sdim * all copies or substantial portions of the Software.
12274958Sdim *
13274958Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14274958Sdim * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15274958Sdim * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16274958Sdim * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17274958Sdim * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18274958Sdim * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19274958Sdim * THE SOFTWARE.
20274958Sdim *
21274958Sdim *===-----------------------------------------------------------------------===
22274958Sdim */
23274958Sdim
24274958Sdim#ifndef __X86INTRIN_H
25274958Sdim#error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
26274958Sdim#endif
27274958Sdim
28274958Sdim#ifndef __IA32INTRIN_H
29274958Sdim#define __IA32INTRIN_H
30274958Sdim
31274958Sdim#ifdef __x86_64__
32274958Sdimstatic __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
33274958Sdim__readeflags(void)
34274958Sdim{
35296417Sdim  return __builtin_ia32_readeflags_u64();
36274958Sdim}
37274958Sdim
38274958Sdimstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
39274958Sdim__writeeflags(unsigned long long __f)
40274958Sdim{
41296417Sdim  __builtin_ia32_writeeflags_u64(__f);
42274958Sdim}
43274958Sdim
44274958Sdim#else /* !__x86_64__ */
45274958Sdimstatic __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
46274958Sdim__readeflags(void)
47274958Sdim{
48296417Sdim  return __builtin_ia32_readeflags_u32();
49274958Sdim}
50274958Sdim
51274958Sdimstatic __inline__ void __attribute__((__always_inline__, __nodebug__))
52274958Sdim__writeeflags(unsigned int __f)
53274958Sdim{
54296417Sdim  __builtin_ia32_writeeflags_u32(__f);
55274958Sdim}
56274958Sdim#endif /* !__x86_64__ */
57274958Sdim
58274958Sdimstatic __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
59274958Sdim__rdpmc(int __A) {
60274958Sdim  return __builtin_ia32_rdpmc(__A);
61274958Sdim}
62274958Sdim
63274958Sdim/* __rdtsc */
64274958Sdimstatic __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
65274958Sdim__rdtsc(void) {
66274958Sdim  return __builtin_ia32_rdtsc();
67274958Sdim}
68274958Sdim
69274958Sdim/* __rdtscp */
70274958Sdimstatic __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
71274958Sdim__rdtscp(unsigned int *__A) {
72274958Sdim  return __builtin_ia32_rdtscp(__A);
73274958Sdim}
74274958Sdim
75274958Sdim#define _rdtsc() __rdtsc()
76274958Sdim
77274958Sdim#endif /* __IA32INTRIN_H */
78