thread_info.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /*
  10. * System call restart block.
  11. */
  12. struct restart_block {
  13. long (*fn)(struct restart_block *);
  14. union {
  15. struct {
  16. unsigned long arg0, arg1, arg2, arg3;
  17. };
  18. /* For futex_wait */
  19. struct {
  20. u32 *uaddr;
  21. u32 val;
  22. u32 flags;
  23. u64 time;
  24. } futex;
  25. };
  26. };
  27. extern long do_no_restart_syscall(struct restart_block *parm);
  28. #include <linux/bitops.h>
  29. #include <asm/thread_info.h>
  30. #ifdef __KERNEL__
  31. /*
  32. * flag set/clear/test wrappers
  33. * - pass TIF_xxxx constants to these functions
  34. */
  35. static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
  36. {
  37. set_bit(flag,&ti->flags);
  38. }
  39. static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
  40. {
  41. clear_bit(flag,&ti->flags);
  42. }
  43. static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
  44. {
  45. return test_and_set_bit(flag,&ti->flags);
  46. }
  47. static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
  48. {
  49. return test_and_clear_bit(flag,&ti->flags);
  50. }
  51. static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
  52. {
  53. return test_bit(flag,&ti->flags);
  54. }
  55. #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)
  65. #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
  66. #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
  67. #endif
  68. #endif /* _LINUX_THREAD_INFO_H */