~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/include/asm/futex.h

Version: ~ [ linux-5.10-rc1 ] ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __ASM_SH_FUTEX_H
  2 #define __ASM_SH_FUTEX_H
  3 
  4 #ifdef __KERNEL__
  5 
  6 #include <linux/futex.h>
  7 #include <linux/uaccess.h>
  8 #include <asm/errno.h>
  9 
 10 /* XXX: UP variants, fix for SH-4A and SMP.. */
 11 #include <asm/futex-irq.h>
 12 
 13 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
 14 {
 15         int op = (encoded_op >> 28) & 7;
 16         int cmp = (encoded_op >> 24) & 15;
 17         int oparg = (encoded_op << 8) >> 20;
 18         int cmparg = (encoded_op << 20) >> 20;
 19         int oldval = 0, ret;
 20 
 21         if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
 22                 oparg = 1 << oparg;
 23 
 24         if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
 25                 return -EFAULT;
 26 
 27         pagefault_disable();
 28 
 29         switch (op) {
 30         case FUTEX_OP_SET:
 31                 ret = atomic_futex_op_xchg_set(oparg, uaddr, &oldval);
 32                 break;
 33         case FUTEX_OP_ADD:
 34                 ret = atomic_futex_op_xchg_add(oparg, uaddr, &oldval);
 35                 break;
 36         case FUTEX_OP_OR:
 37                 ret = atomic_futex_op_xchg_or(oparg, uaddr, &oldval);
 38                 break;
 39         case FUTEX_OP_ANDN:
 40                 ret = atomic_futex_op_xchg_and(~oparg, uaddr, &oldval);
 41                 break;
 42         case FUTEX_OP_XOR:
 43                 ret = atomic_futex_op_xchg_xor(oparg, uaddr, &oldval);
 44                 break;
 45         default:
 46                 ret = -ENOSYS;
 47                 break;
 48         }
 49 
 50         pagefault_enable();
 51 
 52         if (!ret) {
 53                 switch (cmp) {
 54                 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
 55                 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
 56                 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
 57                 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
 58                 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
 59                 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
 60                 default: ret = -ENOSYS;
 61                 }
 62         }
 63 
 64         return ret;
 65 }
 66 
 67 static inline int
 68 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 69                               u32 oldval, u32 newval)
 70 {
 71         if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
 72                 return -EFAULT;
 73 
 74         return atomic_futex_op_cmpxchg_inatomic(uval, uaddr, oldval, newval);
 75 }
 76 
 77 #endif /* __KERNEL__ */
 78 #endif /* __ASM_SH_FUTEX_H */
 79 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp