blob: 1c4eb41dbd89df9182c3fcdbf9f418c5958cc5c6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 */
13struct restart_block {
14 long (*fn)(struct restart_block *);
15 unsigned long arg0, arg1, arg2, arg3;
16};
17
18extern 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070030static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
31{
32 set_bit(flag,&ti->flags);
33}
34
35static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
36{
37 clear_bit(flag,&ti->flags);
38}
39
40static 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
45static 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
50static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
51{
52 return test_bit(flag,&ti->flags);
53}
54
Roman Zippel3b66a1e2005-11-13 16:06:59 -080055#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Roman Zippel3b66a1e2005-11-13 16:06:59 -080066#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
67#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#endif
70
71#endif /* _LINUX_THREAD_INFO_H */