PageRenderTime 32ms CodeModel.GetById 22ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/sh/include/asm/fpu.h

http://github.com/mirrors/linux
C Header | 74 lines | 59 code | 14 blank | 1 comment | 8 complexity | 38a28ae6b1ab6b53ef93e8fca98b06e7 MD5 | raw file
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __ASM_SH_FPU_H
 3#define __ASM_SH_FPU_H
 4
 5#ifndef __ASSEMBLY__
 6
 7#include <asm/ptrace.h>
 8
 9struct task_struct;
10
11#ifdef CONFIG_SH_FPU
12static inline void release_fpu(struct pt_regs *regs)
13{
14	regs->sr |= SR_FD;
15}
16
17static inline void grab_fpu(struct pt_regs *regs)
18{
19	regs->sr &= ~SR_FD;
20}
21
22extern void save_fpu(struct task_struct *__tsk);
23extern void restore_fpu(struct task_struct *__tsk);
24extern void fpu_state_restore(struct pt_regs *regs);
25extern void __fpu_state_restore(void);
26#else
27#define save_fpu(tsk)			do { } while (0)
28#define restore_fpu(tsk)		do { } while (0)
29#define release_fpu(regs)		do { } while (0)
30#define grab_fpu(regs)			do { } while (0)
31#define fpu_state_restore(regs)		do { } while (0)
32#define __fpu_state_restore(regs)	do { } while (0)
33#endif
34
35struct user_regset;
36
37extern int do_fpu_inst(unsigned short, struct pt_regs *);
38extern int init_fpu(struct task_struct *);
39
40extern int fpregs_get(struct task_struct *target,
41		      const struct user_regset *regset,
42		      unsigned int pos, unsigned int count,
43		      void *kbuf, void __user *ubuf);
44
45static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
46{
47	if (task_thread_info(tsk)->status & TS_USEDFPU) {
48		task_thread_info(tsk)->status &= ~TS_USEDFPU;
49		save_fpu(tsk);
50		release_fpu(regs);
51	} else
52		tsk->thread.fpu_counter = 0;
53}
54
55static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
56{
57	preempt_disable();
58	__unlazy_fpu(tsk, regs);
59	preempt_enable();
60}
61
62static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
63{
64	preempt_disable();
65	if (task_thread_info(tsk)->status & TS_USEDFPU) {
66		task_thread_info(tsk)->status &= ~TS_USEDFPU;
67		release_fpu(regs);
68	}
69	preempt_enable();
70}
71
72#endif /* __ASSEMBLY__ */
73
74#endif /* __ASM_SH_FPU_H */