Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 53 lines 1.1 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2#ifndef __SELFTESTS_X86_HELPERS_H 3#define __SELFTESTS_X86_HELPERS_H 4 5#include <signal.h> 6#include <string.h> 7 8#include <asm/processor-flags.h> 9 10#include "kselftest.h" 11 12static inline unsigned long get_eflags(void) 13{ 14#ifdef __x86_64__ 15 return __builtin_ia32_readeflags_u64(); 16#else 17 return __builtin_ia32_readeflags_u32(); 18#endif 19} 20 21static inline void set_eflags(unsigned long eflags) 22{ 23#ifdef __x86_64__ 24 __builtin_ia32_writeeflags_u64(eflags); 25#else 26 __builtin_ia32_writeeflags_u32(eflags); 27#endif 28} 29 30static inline void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), int flags) 31{ 32 struct sigaction sa; 33 34 memset(&sa, 0, sizeof(sa)); 35 sa.sa_sigaction = handler; 36 sa.sa_flags = SA_SIGINFO | flags; 37 sigemptyset(&sa.sa_mask); 38 if (sigaction(sig, &sa, 0)) 39 ksft_exit_fail_msg("sigaction failed"); 40} 41 42static inline void clearhandler(int sig) 43{ 44 struct sigaction sa; 45 46 memset(&sa, 0, sizeof(sa)); 47 sa.sa_handler = SIG_DFL; 48 sigemptyset(&sa.sa_mask); 49 if (sigaction(sig, &sa, 0)) 50 ksft_exit_fail_msg("sigaction failed"); 51} 52 53#endif /* __SELFTESTS_X86_HELPERS_H */