xref: /linux/tools/testing/selftests/x86/helpers.h (revision cbac924200b838cfb8d8b1415113d788089dc50b)
1 // SPDX-License-Identifier: GPL-2.0-only
2 #ifndef __SELFTESTS_X86_HELPERS_H
3 #define __SELFTESTS_X86_HELPERS_H
4 
5 #include <asm/processor-flags.h>
6 
7 static inline unsigned long get_eflags(void)
8 {
9 #ifdef __x86_64__
10 	return __builtin_ia32_readeflags_u64();
11 #else
12 	return __builtin_ia32_readeflags_u32();
13 #endif
14 }
15 
16 static inline void set_eflags(unsigned long eflags)
17 {
18 #ifdef __x86_64__
19 	__builtin_ia32_writeeflags_u64(eflags);
20 #else
21 	__builtin_ia32_writeeflags_u32(eflags);
22 #endif
23 }
24 
25 #endif /* __SELFTESTS_X86_HELPERS_H */
26