core, x86: Add user return notifiers
[safe/jmp/linux-2.6] / include / linux / user-return-notifier.h
1 #ifndef _LINUX_USER_RETURN_NOTIFIER_H
2 #define _LINUX_USER_RETURN_NOTIFIER_H
3
4 #ifdef CONFIG_USER_RETURN_NOTIFIER
5
6 #include <linux/list.h>
7 #include <linux/sched.h>
8
9 struct user_return_notifier {
10         void (*on_user_return)(struct user_return_notifier *urn);
11         struct hlist_node link;
12 };
13
14
15 void user_return_notifier_register(struct user_return_notifier *urn);
16 void user_return_notifier_unregister(struct user_return_notifier *urn);
17
18 static inline void propagate_user_return_notify(struct task_struct *prev,
19                                                 struct task_struct *next)
20 {
21         if (test_tsk_thread_flag(prev, TIF_USER_RETURN_NOTIFY)) {
22                 clear_tsk_thread_flag(prev, TIF_USER_RETURN_NOTIFY);
23                 set_tsk_thread_flag(next, TIF_USER_RETURN_NOTIFY);
24         }
25 }
26
27 void fire_user_return_notifiers(void);
28
29 #else
30
31 struct user_return_notifier {};
32
33 static inline void propagate_user_return_notify(struct task_struct *prev,
34                                                 struct task_struct *next)
35 {
36 }
37
38 static inline void fire_user_return_notifiers(void) {}
39
40 #endif
41
42 #endif