thread_info.h 1.9 KB

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