futex.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef _LINUX_FUTEX_H
  2. #define _LINUX_FUTEX_H
  3. #include <uapi/linux/futex.h>
  4. struct inode;
  5. struct mm_struct;
  6. struct task_struct;
  7. union ktime;
  8. long do_futex(u32 __user *uaddr, int op, u32 val, union ktime *timeout,
  9. u32 __user *uaddr2, u32 val2, u32 val3);
  10. extern int
  11. handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi);
  12. /*
  13. * Futexes are matched on equal values of this key.
  14. * The key type depends on whether it's a shared or private mapping.
  15. * Don't rearrange members without looking at hash_futex().
  16. *
  17. * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
  18. * We use the two low order bits of offset to tell what is the kind of key :
  19. * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE)
  20. * (no reference on an inode or mm)
  21. * 01 : Shared futex (PTHREAD_PROCESS_SHARED)
  22. * mapped on a file (reference on the underlying inode)
  23. * 10 : Shared futex (PTHREAD_PROCESS_SHARED)
  24. * (but private mapping on an mm, and reference taken on it)
  25. */
  26. #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
  27. #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
  28. union futex_key {
  29. struct {
  30. unsigned long pgoff;
  31. struct inode *inode;
  32. int offset;
  33. } shared;
  34. struct {
  35. unsigned long address;
  36. struct mm_struct *mm;
  37. int offset;
  38. } private;
  39. struct {
  40. unsigned long word;
  41. void *ptr;
  42. int offset;
  43. } both;
  44. };
  45. #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
  46. #ifdef CONFIG_FUTEX
  47. extern void exit_robust_list(struct task_struct *curr);
  48. extern void exit_pi_state_list(struct task_struct *curr);
  49. #ifdef CONFIG_HAVE_FUTEX_CMPXCHG
  50. #define futex_cmpxchg_enabled 1
  51. #else
  52. extern int futex_cmpxchg_enabled;
  53. #endif
  54. #else
  55. static inline void exit_robust_list(struct task_struct *curr)
  56. {
  57. }
  58. static inline void exit_pi_state_list(struct task_struct *curr)
  59. {
  60. }
  61. #endif
  62. #endif