thread_info.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef _LINUX_THREAD_INFO_H
  7. #define _LINUX_THREAD_INFO_H
  8. #include <linux/types.h>
  9. struct timespec;
  10. struct compat_timespec;
  11. /*
  12. * System call restart block.
  13. */
  14. struct restart_block {
  15. long (*fn)(struct restart_block *);
  16. union {
  17. struct {
  18. unsigned long arg0, arg1, arg2, arg3;
  19. };
  20. /* For futex_wait */
  21. struct {
  22. u32 *uaddr;
  23. u32 val;
  24. u32 flags;
  25. u32 bitset;
  26. u64 time;
  27. } futex;
  28. /* For nanosleep */
  29. struct {
  30. clockid_t index;
  31. struct timespec __user *rmtp;
  32. #ifdef CONFIG_COMPAT
  33. struct compat_timespec __user *compat_rmtp;
  34. #endif
  35. u64 expires;
  36. } nanosleep;
  37. };
  38. };
  39. extern long do_no_restart_syscall(struct restart_block *parm);
  40. #include <linux/bitops.h>
  41. #include <asm/thread_info.h>
  42. #ifdef __KERNEL__
  43. /*
  44. * flag set/clear/test wrappers
  45. * - pass TIF_xxxx constants to these functions
  46. */
  47. static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
  48. {
  49. set_bit(flag, (unsigned long *)&ti->flags);
  50. }
  51. static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
  52. {
  53. clear_bit(flag, (unsigned long *)&ti->flags);
  54. }
  55. static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
  56. {
  57. return test_and_set_bit(flag, (unsigned long *)&ti->flags);
  58. }
  59. static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
  60. {
  61. return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
  62. }
  63. static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
  64. {
  65. return test_bit(flag, (unsigned long *)&ti->flags);
  66. }
  67. #define set_thread_flag(flag) \
  68. set_ti_thread_flag(current_thread_info(), flag)
  69. #define clear_thread_flag(flag) \
  70. clear_ti_thread_flag(current_thread_info(), flag)
  71. #define test_and_set_thread_flag(flag) \
  72. test_and_set_ti_thread_flag(current_thread_info(), flag)
  73. #define test_and_clear_thread_flag(flag) \
  74. test_and_clear_ti_thread_flag(current_thread_info(), flag)
  75. #define test_thread_flag(flag) \
  76. test_ti_thread_flag(current_thread_info(), flag)
  77. #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
  78. #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
  79. #endif
  80. #endif /* _LINUX_THREAD_INFO_H */