• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* thread_info.h: common low-level thread information accessors
2  *
3  * Copyright (C) 2002  David Howells (dhowells@redhat.com)
4  * - Incorporating suggestions made by Linus Torvalds
5  */
6 
7 #ifndef _LINUX_THREAD_INFO_H
8 #define _LINUX_THREAD_INFO_H
9 
10 /*
11  * System call restart block.
12  */
13 struct restart_block {
14 	long (*fn)(struct restart_block *);
15 	unsigned long arg0, arg1, arg2, arg3;
16 };
17 
18 extern long do_no_restart_syscall(struct restart_block *parm);
19 
20 #include <linux/bitops.h>
21 #include <asm/thread_info.h>
22 
23 #ifdef __KERNEL__
24 
25 /*
26  * flag set/clear/test wrappers
27  * - pass TIF_xxxx constants to these functions
28  */
29 
set_ti_thread_flag(struct thread_info * ti,int flag)30 static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
31 {
32 	set_bit(flag,&ti->flags);
33 }
34 
clear_ti_thread_flag(struct thread_info * ti,int flag)35 static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
36 {
37 	clear_bit(flag,&ti->flags);
38 }
39 
test_and_set_ti_thread_flag(struct thread_info * ti,int flag)40 static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
41 {
42 	return test_and_set_bit(flag,&ti->flags);
43 }
44 
test_and_clear_ti_thread_flag(struct thread_info * ti,int flag)45 static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
46 {
47 	return test_and_clear_bit(flag,&ti->flags);
48 }
49 
test_ti_thread_flag(struct thread_info * ti,int flag)50 static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
51 {
52 	return test_bit(flag,&ti->flags);
53 }
54 
55 #define set_thread_flag(flag) \
56 	set_ti_thread_flag(current_thread_info(), flag)
57 #define clear_thread_flag(flag) \
58 	clear_ti_thread_flag(current_thread_info(), flag)
59 #define test_and_set_thread_flag(flag) \
60 	test_and_set_ti_thread_flag(current_thread_info(), flag)
61 #define test_and_clear_thread_flag(flag) \
62 	test_and_clear_ti_thread_flag(current_thread_info(), flag)
63 #define test_thread_flag(flag) \
64 	test_ti_thread_flag(current_thread_info(), flag)
65 
66 #define set_need_resched()	set_thread_flag(TIF_NEED_RESCHED)
67 #define clear_need_resched()	clear_thread_flag(TIF_NEED_RESCHED)
68 
69 #endif
70 
71 #endif /* _LINUX_THREAD_INFO_H */
72