thread_info.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifdef TIF_RESTORE_SIGMASK
  80. /**
  81. * set_restore_sigmask() - make sure saved_sigmask processing gets done
  82. *
  83. * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code
  84. * will run before returning to user mode, to process the flag.
  85. */
  86. static inline void set_restore_sigmask(void)
  87. {
  88. set_thread_flag(TIF_RESTORE_SIGMASK);
  89. }
  90. #endif /* TIF_RESTORE_SIGMASK */
  91. #endif /* __KERNEL__ */
  92. #endif /* _LINUX_THREAD_INFO_H */