xref: /kernel/linux/linux-6.6/tools/testing/selftests/x86/helpers.h
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/tools/testing/selftests/x86/
162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci#ifndef __SELFTESTS_X86_HELPERS_H
362306a36Sopenharmony_ci#define __SELFTESTS_X86_HELPERS_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/processor-flags.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistatic inline unsigned long get_eflags(void)
862306a36Sopenharmony_ci{
962306a36Sopenharmony_ci#ifdef __x86_64__
1062306a36Sopenharmony_ci	return __builtin_ia32_readeflags_u64();
1162306a36Sopenharmony_ci#else
1262306a36Sopenharmony_ci	return __builtin_ia32_readeflags_u32();
1362306a36Sopenharmony_ci#endif
1462306a36Sopenharmony_ci}
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistatic inline void set_eflags(unsigned long eflags)
1762306a36Sopenharmony_ci{
1862306a36Sopenharmony_ci#ifdef __x86_64__
1962306a36Sopenharmony_ci	__builtin_ia32_writeeflags_u64(eflags);
2062306a36Sopenharmony_ci#else
2162306a36Sopenharmony_ci	__builtin_ia32_writeeflags_u32(eflags);
2262306a36Sopenharmony_ci#endif
2362306a36Sopenharmony_ci}
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#endif /* __SELFTESTS_X86_HELPERS_H */
26

Indexes created Thu Nov 07 10:32:03 CST 2024