Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Steven Rostedt | ce6bd42 | 2007-12-05 15:46:09 +0100 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | /* |
Steven Rostedt | ce6bd42 | 2007-12-05 15:46:09 +0100 | [diff] [blame] | 13 | * System call restart block. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | */ |
| 15 | struct restart_block { |
| 16 | long (*fn)(struct restart_block *); |
Steven Rostedt | ce6bd42 | 2007-12-05 15:46:09 +0100 | [diff] [blame] | 17 | union { |
| 18 | struct { |
| 19 | unsigned long arg0, arg1, arg2, arg3; |
| 20 | }; |
| 21 | /* For futex_wait */ |
| 22 | struct { |
| 23 | u32 *uaddr; |
| 24 | u32 val; |
| 25 | u32 flags; |
Thomas Gleixner | cd68998 | 2008-02-01 17:45:14 +0100 | [diff] [blame^] | 26 | u32 bitset; |
Steven Rostedt | ce6bd42 | 2007-12-05 15:46:09 +0100 | [diff] [blame] | 27 | u64 time; |
| 28 | } futex; |
| 29 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | extern long do_no_restart_syscall(struct restart_block *parm); |
| 33 | |
| 34 | #include <linux/bitops.h> |
| 35 | #include <asm/thread_info.h> |
| 36 | |
| 37 | #ifdef __KERNEL__ |
| 38 | |
| 39 | /* |
| 40 | * flag set/clear/test wrappers |
| 41 | * - pass TIF_xxxx constants to these functions |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | static inline void set_ti_thread_flag(struct thread_info *ti, int flag) |
| 45 | { |
Jeremy Fitzhardinge | 5548fec | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 46 | set_bit(flag, (unsigned long *)&ti->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) |
| 50 | { |
Jeremy Fitzhardinge | 5548fec | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 51 | clear_bit(flag, (unsigned long *)&ti->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) |
| 55 | { |
Jeremy Fitzhardinge | 5548fec | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 56 | return test_and_set_bit(flag, (unsigned long *)&ti->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) |
| 60 | { |
Jeremy Fitzhardinge | 5548fec | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 61 | return test_and_clear_bit(flag, (unsigned long *)&ti->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static inline int test_ti_thread_flag(struct thread_info *ti, int flag) |
| 65 | { |
Jeremy Fitzhardinge | 5548fec | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 66 | return test_bit(flag, (unsigned long *)&ti->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Roman Zippel | 3b66a1e | 2005-11-13 16:06:59 -0800 | [diff] [blame] | 69 | #define set_thread_flag(flag) \ |
| 70 | set_ti_thread_flag(current_thread_info(), flag) |
| 71 | #define clear_thread_flag(flag) \ |
| 72 | clear_ti_thread_flag(current_thread_info(), flag) |
| 73 | #define test_and_set_thread_flag(flag) \ |
| 74 | test_and_set_ti_thread_flag(current_thread_info(), flag) |
| 75 | #define test_and_clear_thread_flag(flag) \ |
| 76 | test_and_clear_ti_thread_flag(current_thread_info(), flag) |
| 77 | #define test_thread_flag(flag) \ |
| 78 | test_ti_thread_flag(current_thread_info(), flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Roman Zippel | 3b66a1e | 2005-11-13 16:06:59 -0800 | [diff] [blame] | 80 | #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED) |
| 81 | #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | #endif |
| 84 | |
| 85 | #endif /* _LINUX_THREAD_INFO_H */ |