futex.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _ASM_GENERIC_FUTEX_H
  2. #define _ASM_GENERIC_FUTEX_H
  3. #include <linux/futex.h>
  4. #include <linux/uaccess.h>
  5. #include <asm/errno.h>
  6. static inline int
  7. futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
  8. {
  9. int op = (encoded_op >> 28) & 7;
  10. int cmp = (encoded_op >> 24) & 15;
  11. int oparg = (encoded_op << 8) >> 20;
  12. int cmparg = (encoded_op << 20) >> 20;
  13. int oldval = 0, ret;
  14. if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
  15. oparg = 1 << oparg;
  16. if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32)))
  17. return -EFAULT;
  18. pagefault_disable();
  19. switch (op) {
  20. case FUTEX_OP_SET:
  21. case FUTEX_OP_ADD:
  22. case FUTEX_OP_OR:
  23. case FUTEX_OP_ANDN:
  24. case FUTEX_OP_XOR:
  25. default:
  26. ret = -ENOSYS;
  27. }
  28. pagefault_enable();
  29. if (!ret) {
  30. switch (cmp) {
  31. case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
  32. case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
  33. case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
  34. case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
  35. case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
  36. case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
  37. default: ret = -ENOSYS;
  38. }
  39. }
  40. return ret;
  41. }
  42. static inline int
  43. futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
  44. u32 oldval, u32 newval)
  45. {
  46. return -ENOSYS;
  47. }
  48. #endif