mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-18 17:54:13 +08:00
fc1d4c9c37
SH is able to support a complete futex implementation on UP by way of gUSA. However, IRQ toggling must be done for the old CPUs that don't have movli.l/movco.l (LL/SC) instructions. Provide a default implementation that does this, so it's possible to optimize for newer CPUs. Follows the same scheme as the current asm-sh/atomic-*.h headers. Signed-off-by: Kaz Kojima <kkojima@rr.iij4u.or.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
112 lines
1.8 KiB
C
112 lines
1.8 KiB
C
#ifndef __ASM_SH_FUTEX_IRQ_H
|
|
#define __ASM_SH_FUTEX_IRQ_H
|
|
|
|
#include <asm/system.h>
|
|
|
|
static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr,
|
|
int *oldval)
|
|
{
|
|
unsigned long flags;
|
|
int ret;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(*oldval, uaddr);
|
|
if (!ret)
|
|
ret = put_user(oparg, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr,
|
|
int *oldval)
|
|
{
|
|
unsigned long flags;
|
|
int ret;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(*oldval, uaddr);
|
|
if (!ret)
|
|
ret = put_user(*oldval + oparg, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr,
|
|
int *oldval)
|
|
{
|
|
unsigned long flags;
|
|
int ret;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(*oldval, uaddr);
|
|
if (!ret)
|
|
ret = put_user(*oldval | oparg, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr,
|
|
int *oldval)
|
|
{
|
|
unsigned long flags;
|
|
int ret;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(*oldval, uaddr);
|
|
if (!ret)
|
|
ret = put_user(*oldval & oparg, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr,
|
|
int *oldval)
|
|
{
|
|
unsigned long flags;
|
|
int ret;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(*oldval, uaddr);
|
|
if (!ret)
|
|
ret = put_user(*oldval ^ oparg, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int atomic_futex_op_cmpxchg_inatomic(int __user *uaddr,
|
|
int oldval, int newval)
|
|
{
|
|
unsigned long flags;
|
|
int ret, prev = 0;
|
|
|
|
local_irq_save(flags);
|
|
|
|
ret = get_user(prev, uaddr);
|
|
if (!ret && oldval == prev)
|
|
ret = put_user(newval, uaddr);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
if (ret)
|
|
return ret;
|
|
|
|
return prev;
|
|
}
|
|
|
|
#endif /* __ASM_SH_FUTEX_IRQ_H */
|