OMAP: Add new function to check wether there is irq pending
[linux-ginger.git] / arch / sh / include / asm / fpu.h
blob1d3aee04b5ccc4c3c0181ead9ca3401733a6ece2
1 #ifndef __ASM_SH_FPU_H
2 #define __ASM_SH_FPU_H
4 #ifndef __ASSEMBLY__
5 #include <linux/preempt.h>
6 #include <asm/ptrace.h>
8 #ifdef CONFIG_SH_FPU
9 static inline void release_fpu(struct pt_regs *regs)
11 regs->sr |= SR_FD;
14 static inline void grab_fpu(struct pt_regs *regs)
16 regs->sr &= ~SR_FD;
19 struct task_struct;
21 extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
22 #else
24 #define release_fpu(regs) do { } while (0)
25 #define grab_fpu(regs) do { } while (0)
27 static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
29 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
31 #endif
33 struct user_regset;
35 extern int do_fpu_inst(unsigned short, struct pt_regs *);
37 extern int fpregs_get(struct task_struct *target,
38 const struct user_regset *regset,
39 unsigned int pos, unsigned int count,
40 void *kbuf, void __user *ubuf);
42 static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
44 preempt_disable();
45 if (test_tsk_thread_flag(tsk, TIF_USEDFPU))
46 save_fpu(tsk, regs);
47 preempt_enable();
50 static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
52 preempt_disable();
53 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) {
54 clear_tsk_thread_flag(tsk, TIF_USEDFPU);
55 release_fpu(regs);
57 preempt_enable();
60 static inline int init_fpu(struct task_struct *tsk)
62 if (tsk_used_math(tsk)) {
63 if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
64 unlazy_fpu(tsk, task_pt_regs(tsk));
65 return 0;
68 set_stopped_child_used_math(tsk);
69 return 0;
72 #endif /* __ASSEMBLY__ */
74 #endif /* __ASM_SH_FPU_H */