mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-15 14:54:55 +00:00
hv: remove atomic_add/subtract API
add atomic_inc(64)/dec(64) API. Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
fadaf14a94
commit
336a8883db
@ -225,7 +225,7 @@ int destroy_vcpu(struct vcpu *vcpu)
|
|||||||
(unsigned long *)&vcpu->vm->hw.vcpu_array[vcpu->vcpu_id],
|
(unsigned long *)&vcpu->vm->hw.vcpu_array[vcpu->vcpu_id],
|
||||||
(unsigned long)NULL);
|
(unsigned long)NULL);
|
||||||
|
|
||||||
atomic_subtract_int(&vcpu->vm->hw.created_vcpus, 1);
|
atomic_dec(&vcpu->vm->hw.created_vcpus);
|
||||||
|
|
||||||
vlapic_free(vcpu);
|
vlapic_free(vcpu);
|
||||||
free(vcpu->arch_vcpu.vmcs);
|
free(vcpu->arch_vcpu.vmcs);
|
||||||
|
@ -54,27 +54,26 @@ static inline void atomic_clear_int(unsigned int *p, unsigned int v)
|
|||||||
: "cc", "memory");
|
: "cc", "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#define build_atomic_inc(name, size, type, ptr) \
|
||||||
* #define atomic_add_int(P, V) (*(unsigned int *)(P) += (V))
|
static inline void name(type *ptr) \
|
||||||
*/
|
{ \
|
||||||
static inline void atomic_add_int(unsigned int *p, unsigned int v)
|
asm volatile(BUS_LOCK "inc" size " %0" \
|
||||||
{
|
: "=m" (*ptr) \
|
||||||
__asm __volatile(BUS_LOCK "addl %1,%0"
|
: "m" (*ptr)); \
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
}
|
||||||
|
build_atomic_inc(atomic_inc, "l", int, p)
|
||||||
|
build_atomic_inc(atomic_inc64, "q", long, p)
|
||||||
|
|
||||||
/*
|
#define build_atomic_dec(name, size, type, ptr) \
|
||||||
* #define atomic_subtract_int(P, V) (*(unsigned int *)(P) -= (V))
|
static inline void name(type *ptr) \
|
||||||
*/
|
{ \
|
||||||
static inline void atomic_subtract_int(unsigned int *p, unsigned int v)
|
asm volatile(BUS_LOCK "dec" size " %0" \
|
||||||
{
|
: "=m" (*ptr) \
|
||||||
__asm __volatile(BUS_LOCK "subl %1,%0"
|
: "m" (*ptr)); \
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
}
|
||||||
|
build_atomic_dec(atomic_dec, "l", int, p)
|
||||||
|
build_atomic_dec(atomic_dec64, "q", long, p)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #define atomic_swap_int(P, V) \
|
* #define atomic_swap_int(P, V) \
|
||||||
@ -117,28 +116,6 @@ static inline void atomic_clear_long(unsigned long *p, unsigned long v)
|
|||||||
: "cc", "memory");
|
: "cc", "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* #define atomic_add_long(P, V) (*(unsigned long *)(P) += (V))
|
|
||||||
*/
|
|
||||||
static inline void atomic_add_long(unsigned long *p, unsigned long v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "addq %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #define atomic_subtract_long(P, V) (*(unsigned long *)(P) -= (V))
|
|
||||||
*/
|
|
||||||
static inline void atomic_subtract_long(unsigned long *p, unsigned long v)
|
|
||||||
{
|
|
||||||
__asm __volatile(BUS_LOCK "subq %1,%0"
|
|
||||||
: "+m" (*p)
|
|
||||||
: "r" (v)
|
|
||||||
: "cc", "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #define atomic_swap_long(P, V) \
|
* #define atomic_swap_long(P, V) \
|
||||||
* (return (*(unsigned long *)(P)); *(unsigned long *)(P) = (V);)
|
* (return (*(unsigned long *)(P)); *(unsigned long *)(P) = (V);)
|
||||||
|
Loading…
Reference in New Issue
Block a user