Blame view

include/linux/thread_info.h 3.39 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
  /* thread_info.h: common low-level thread information accessors
   *
   * Copyright (C) 2002  David Howells (dhowells@redhat.com)
   * - Incorporating suggestions made by Linus Torvalds
   */
  
  #ifndef _LINUX_THREAD_INFO_H
  #define _LINUX_THREAD_INFO_H
ce6bd420f   Steven Rostedt   futex: fix for fu...
9
  #include <linux/types.h>
a332d86d3   Thomas Gleixner   hrtimer: add nano...
10
11
  struct timespec;
  struct compat_timespec;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
  /*
ce6bd420f   Steven Rostedt   futex: fix for fu...
13
   * System call restart block.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
   */
  struct restart_block {
  	long (*fn)(struct restart_block *);
ce6bd420f   Steven Rostedt   futex: fix for fu...
17
  	union {
52400ba94   Darren Hart   futex: add requeu...
18
  		/* For futex_wait and futex_wait_requeue_pi */
ce6bd420f   Steven Rostedt   futex: fix for fu...
19
  		struct {
a3c74c525   Namhyung Kim   futex: Mark resta...
20
  			u32 __user *uaddr;
ce6bd420f   Steven Rostedt   futex: fix for fu...
21
22
  			u32 val;
  			u32 flags;
cd689985c   Thomas Gleixner   futex: Add bitset...
23
  			u32 bitset;
ce6bd420f   Steven Rostedt   futex: fix for fu...
24
  			u64 time;
a3c74c525   Namhyung Kim   futex: Mark resta...
25
  			u32 __user *uaddr2;
ce6bd420f   Steven Rostedt   futex: fix for fu...
26
  		} futex;
a332d86d3   Thomas Gleixner   hrtimer: add nano...
27
28
  		/* For nanosleep */
  		struct {
ab8177bc5   Thomas Gleixner   hrtimers: Avoid t...
29
  			clockid_t clockid;
a332d86d3   Thomas Gleixner   hrtimer: add nano...
30
31
32
33
34
35
  			struct timespec __user *rmtp;
  #ifdef CONFIG_COMPAT
  			struct compat_timespec __user *compat_rmtp;
  #endif
  			u64 expires;
  		} nanosleep;
be5dad20a   Thomas Gleixner   select: add a pol...
36
37
38
39
40
41
42
43
  		/* For poll */
  		struct {
  			struct pollfd __user *ufds;
  			int nfds;
  			int has_timeout;
  			unsigned long tv_sec;
  			unsigned long tv_nsec;
  		} poll;
ce6bd420f   Steven Rostedt   futex: fix for fu...
44
  	};
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
47
48
49
50
51
52
53
54
55
56
57
  };
  
  extern long do_no_restart_syscall(struct restart_block *parm);
  
  #include <linux/bitops.h>
  #include <asm/thread_info.h>
  
  #ifdef __KERNEL__
  
  /*
   * flag set/clear/test wrappers
   * - pass TIF_xxxx constants to these functions
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
  static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
  {
5548fecdf   Jeremy Fitzhardinge   x86: clean up bit...
60
  	set_bit(flag, (unsigned long *)&ti->flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
62
63
64
  }
  
  static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
  {
5548fecdf   Jeremy Fitzhardinge   x86: clean up bit...
65
  	clear_bit(flag, (unsigned long *)&ti->flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
67
68
69
  }
  
  static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
  {
5548fecdf   Jeremy Fitzhardinge   x86: clean up bit...
70
  	return test_and_set_bit(flag, (unsigned long *)&ti->flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
74
  }
  
  static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
  {
5548fecdf   Jeremy Fitzhardinge   x86: clean up bit...
75
  	return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
78
79
  }
  
  static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
  {
5548fecdf   Jeremy Fitzhardinge   x86: clean up bit...
80
  	return test_bit(flag, (unsigned long *)&ti->flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
  }
3b66a1edb   Roman Zippel   [PATCH] m68k: con...
82
83
84
85
86
87
88
89
90
91
92
93
94
  #define set_thread_flag(flag) \
  	set_ti_thread_flag(current_thread_info(), flag)
  #define clear_thread_flag(flag) \
  	clear_ti_thread_flag(current_thread_info(), flag)
  #define test_and_set_thread_flag(flag) \
  	test_and_set_ti_thread_flag(current_thread_info(), flag)
  #define test_and_clear_thread_flag(flag) \
  	test_and_clear_ti_thread_flag(current_thread_info(), flag)
  #define test_thread_flag(flag) \
  	test_ti_thread_flag(current_thread_info(), flag)
  
  #define set_need_resched()	set_thread_flag(TIF_NEED_RESCHED)
  #define clear_need_resched()	clear_thread_flag(TIF_NEED_RESCHED)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95

f3de272b8   Roland McGrath   signals: use HAVE...
96
97
98
99
100
101
  #if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
  /*
   * An arch can define its own version of set_restore_sigmask() to get the
   * job done however works, with or without TIF_RESTORE_SIGMASK.
   */
  #define HAVE_SET_RESTORE_SIGMASK	1
4e4c22c71   Roland McGrath   signals: add set_...
102
103
104
105
  /**
   * set_restore_sigmask() - make sure saved_sigmask processing gets done
   *
   * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code
7648d961f   Roland McGrath   signals: set_rest...
106
107
108
109
110
111
   * will run before returning to user mode, to process the flag.  For
   * all callers, TIF_SIGPENDING is already set or it's no harm to set
   * it.  TIF_RESTORE_SIGMASK need not be in the set of bits that the
   * arch code will notice on return to user mode, in case those bits
   * are scarce.  We set TIF_SIGPENDING here to ensure that the arch
   * signal code always gets run when TIF_RESTORE_SIGMASK is set.
4e4c22c71   Roland McGrath   signals: add set_...
112
113
114
115
   */
  static inline void set_restore_sigmask(void)
  {
  	set_thread_flag(TIF_RESTORE_SIGMASK);
7648d961f   Roland McGrath   signals: set_rest...
116
  	set_thread_flag(TIF_SIGPENDING);
4e4c22c71   Roland McGrath   signals: add set_...
117
  }
f3de272b8   Roland McGrath   signals: use HAVE...
118
  #endif	/* TIF_RESTORE_SIGMASK && !HAVE_SET_RESTORE_SIGMASK */
4e4c22c71   Roland McGrath   signals: add set_...
119
120
  
  #endif	/* __KERNEL__ */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
122
  
  #endif /* _LINUX_THREAD_INFO_H */