Fixed some style bugs (mainly assorted errors in comments, and inconsistent
spelling of `result').
This commit is contained in:
parent
08651e1f24
commit
f28e1c8f99
@ -33,8 +33,8 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Various simple arithmetic on memory which is atomic in the presence
|
||||
* of interrupts and multiple processors.
|
||||
* Various simple operations on memory, each of which is atomic in the
|
||||
* presence of interrupts and multiple processors.
|
||||
*
|
||||
* atomic_set_char(P, V) (*(u_char *)(P) |= (V))
|
||||
* atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V))
|
||||
@ -50,13 +50,13 @@
|
||||
* atomic_clear_int(P, V) (*(u_int *)(P) &= ~(V))
|
||||
* atomic_add_int(P, V) (*(u_int *)(P) += (V))
|
||||
* atomic_subtract_int(P, V) (*(u_int *)(P) -= (V))
|
||||
* atomic_readandclear_int(P) (return *(u_int *)P; *(u_int *)P = 0;)
|
||||
* atomic_readandclear_int(P) (return (*(u_int *)(P)); *(u_int *)(P) = 0;)
|
||||
*
|
||||
* atomic_set_long(P, V) (*(u_long *)(P) |= (V))
|
||||
* atomic_clear_long(P, V) (*(u_long *)(P) &= ~(V))
|
||||
* atomic_add_long(P, V) (*(u_long *)(P) += (V))
|
||||
* atomic_subtract_long(P, V) (*(u_long *)(P) -= (V))
|
||||
* atomic_readandclear_long(P) (return *(u_long *)P; *(u_long *)P = 0;)
|
||||
* atomic_readandclear_long(P) (return (*(u_long *)(P)); *(u_long *)(P) = 0;)
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -82,8 +82,8 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
|
||||
#else /* !KLD_MODULE && __GNUCLIKE_ASM */
|
||||
|
||||
/*
|
||||
* For userland, assume the SMP case and use lock prefixes so that
|
||||
* the binaries will run on both types of systems.
|
||||
* For userland, always use lock prefixes so that the binaries will run
|
||||
* on both SMP and !SMP systems.
|
||||
*/
|
||||
#if defined(SMP) || !defined(_KERNEL)
|
||||
#define MPLOCKED "lock ; "
|
||||
@ -197,7 +197,7 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
|
||||
} \
|
||||
struct __hack
|
||||
|
||||
#else /* defined(SMP) */
|
||||
#else /* !(_KERNEL && !SMP) */
|
||||
|
||||
#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \
|
||||
static __inline u_##TYPE \
|
||||
@ -206,7 +206,7 @@ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
|
||||
u_##TYPE res; \
|
||||
\
|
||||
__asm __volatile(MPLOCKED LOP \
|
||||
: "=a" (res), /* 0 (result) */\
|
||||
: "=a" (res), /* 0 */ \
|
||||
"=m" (*p) /* 1 */ \
|
||||
: "m" (*p) /* 2 */ \
|
||||
: "memory"); \
|
||||
@ -227,7 +227,7 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
|
||||
} \
|
||||
struct __hack
|
||||
|
||||
#endif /* SMP */
|
||||
#endif /* _KERNEL && !SMP */
|
||||
|
||||
#endif /* KLD_MODULE || !__GNUCLIKE_ASM */
|
||||
|
||||
@ -259,7 +259,7 @@ ATOMIC_STORE_LOAD(long, "cmpxchgq %0,%1", "xchgq %1,%0");
|
||||
#undef ATOMIC_ASM
|
||||
#undef ATOMIC_STORE_LOAD
|
||||
|
||||
#if !defined(WANT_FUNCTIONS)
|
||||
#ifndef WANT_FUNCTIONS
|
||||
|
||||
/* Read the current value and store a zero in the destination. */
|
||||
#ifdef __GNUCLIKE_ASM
|
||||
@ -267,39 +267,39 @@ ATOMIC_STORE_LOAD(long, "cmpxchgq %0,%1", "xchgq %1,%0");
|
||||
static __inline u_int
|
||||
atomic_readandclear_int(volatile u_int *addr)
|
||||
{
|
||||
u_int result;
|
||||
u_int res;
|
||||
|
||||
result = 0;
|
||||
res = 0;
|
||||
__asm __volatile(
|
||||
" xchgl %1,%0 ; "
|
||||
"# atomic_readandclear_int"
|
||||
: "+r" (result), /* 0 (result) */
|
||||
"=m" (*addr) /* 1 (addr) */
|
||||
: "+r" (res), /* 0 */
|
||||
"=m" (*addr) /* 1 */
|
||||
: "m" (*addr));
|
||||
|
||||
return (result);
|
||||
return (res);
|
||||
}
|
||||
|
||||
static __inline u_long
|
||||
atomic_readandclear_long(volatile u_long *addr)
|
||||
{
|
||||
u_long result;
|
||||
u_long res;
|
||||
|
||||
result = 0;
|
||||
res = 0;
|
||||
__asm __volatile(
|
||||
" xchgq %1,%0 ; "
|
||||
"# atomic_readandclear_long"
|
||||
: "+r" (result), /* 0 (result) */
|
||||
"=m" (*addr) /* 1 (addr) */
|
||||
: "+r" (res), /* 0 */
|
||||
"=m" (*addr) /* 1 */
|
||||
: "m" (*addr));
|
||||
|
||||
return (result);
|
||||
return (res);
|
||||
}
|
||||
|
||||
#else /* !__GNUCLIKE_ASM */
|
||||
|
||||
u_int atomic_readandclear_int(volatile u_int *);
|
||||
u_long atomic_readandclear_long(volatile u_long *);
|
||||
u_int atomic_readandclear_int(volatile u_int *addr);
|
||||
u_long atomic_readandclear_long(volatile u_long *addr);
|
||||
|
||||
#endif /* __GNUCLIKE_ASM */
|
||||
|
||||
@ -437,6 +437,6 @@ u_long atomic_readandclear_long(volatile u_long *);
|
||||
#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long
|
||||
#define atomic_readandclear_ptr atomic_readandclear_long
|
||||
|
||||
#endif /* !defined(WANT_FUNCTIONS) */
|
||||
#endif /* !WANT_FUNCTIONS */
|
||||
|
||||
#endif /* !_MACHINE_ATOMIC_H_ */
|
||||
|
@ -33,8 +33,8 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Various simple arithmetic on memory which is atomic in the presence
|
||||
* of interrupts and multiple processors.
|
||||
* Various simple operations on memory, each of which is atomic in the
|
||||
* presence of interrupts and multiple processors.
|
||||
*
|
||||
* atomic_set_char(P, V) (*(u_char *)(P) |= (V))
|
||||
* atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V))
|
||||
@ -50,13 +50,13 @@
|
||||
* atomic_clear_int(P, V) (*(u_int *)(P) &= ~(V))
|
||||
* atomic_add_int(P, V) (*(u_int *)(P) += (V))
|
||||
* atomic_subtract_int(P, V) (*(u_int *)(P) -= (V))
|
||||
* atomic_readandclear_int(P) (return *(u_int *)P; *(u_int *)P = 0;)
|
||||
* atomic_readandclear_int(P) (return (*(u_int *)(P)); *(u_int *)(P) = 0;)
|
||||
*
|
||||
* atomic_set_long(P, V) (*(u_long *)(P) |= (V))
|
||||
* atomic_clear_long(P, V) (*(u_long *)(P) &= ~(V))
|
||||
* atomic_add_long(P, V) (*(u_long *)(P) += (V))
|
||||
* atomic_subtract_long(P, V) (*(u_long *)(P) -= (V))
|
||||
* atomic_readandclear_long(P) (return *(u_long *)P; *(u_long *)P = 0;)
|
||||
* atomic_readandclear_long(P) (return (*(u_long *)(P)); *(u_long *)(P) = 0;)
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -81,8 +81,8 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
|
||||
#else /* !KLD_MODULE && __GNUCLIKE_ASM */
|
||||
|
||||
/*
|
||||
* For userland, assume the SMP case and use lock prefixes so that
|
||||
* the binaries will run on both types of systems.
|
||||
* For userland, always use lock prefixes so that the binaries will run
|
||||
* on both SMP and !SMP systems.
|
||||
*/
|
||||
#if defined(SMP) || !defined(_KERNEL)
|
||||
#define MPLOCKED "lock ; "
|
||||
@ -112,7 +112,7 @@ struct __hack
|
||||
* Returns 0 on failure, non-zero on success
|
||||
*/
|
||||
|
||||
#if defined(CPU_DISABLE_CMPXCHG)
|
||||
#ifdef CPU_DISABLE_CMPXCHG
|
||||
|
||||
static __inline int
|
||||
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
@ -139,7 +139,7 @@ atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
return (res);
|
||||
}
|
||||
|
||||
#else /* defined(CPU_DISABLE_CMPXCHG) */
|
||||
#else /* !CPU_DISABLE_CMPXCHG */
|
||||
|
||||
static __inline int
|
||||
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
@ -162,7 +162,7 @@ atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
return (res);
|
||||
}
|
||||
|
||||
#endif /* defined(CPU_DISABLE_CMPXCHG) */
|
||||
#endif /* CPU_DISABLE_CMPXCHG */
|
||||
|
||||
/*
|
||||
* Atomically add the value of v to the integer pointed to by p and return
|
||||
@ -206,7 +206,7 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
|
||||
} \
|
||||
struct __hack
|
||||
|
||||
#else /* defined(SMP) */
|
||||
#else /* !(_KERNEL && !SMP) */
|
||||
|
||||
#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \
|
||||
static __inline u_##TYPE \
|
||||
@ -215,7 +215,7 @@ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
|
||||
u_##TYPE res; \
|
||||
\
|
||||
__asm __volatile(MPLOCKED LOP \
|
||||
: "=a" (res), /* 0 (result) */\
|
||||
: "=a" (res), /* 0 */ \
|
||||
"=m" (*p) /* 1 */ \
|
||||
: "m" (*p) /* 2 */ \
|
||||
: "memory"); \
|
||||
@ -236,7 +236,7 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
|
||||
} \
|
||||
struct __hack
|
||||
|
||||
#endif /* !defined(SMP) */
|
||||
#endif /* _KERNEL && !SMP */
|
||||
|
||||
#endif /* KLD_MODULE || !__GNUCLIKE_ASM */
|
||||
|
||||
@ -268,7 +268,7 @@ ATOMIC_STORE_LOAD(long, "cmpxchgl %0,%1", "xchgl %1,%0");
|
||||
#undef ATOMIC_ASM
|
||||
#undef ATOMIC_STORE_LOAD
|
||||
|
||||
#if !defined(WANT_FUNCTIONS)
|
||||
#ifndef WANT_FUNCTIONS
|
||||
|
||||
static __inline int
|
||||
atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
|
||||
@ -284,39 +284,39 @@ atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
|
||||
static __inline u_int
|
||||
atomic_readandclear_int(volatile u_int *addr)
|
||||
{
|
||||
u_int result;
|
||||
u_int res;
|
||||
|
||||
result = 0;
|
||||
res = 0;
|
||||
__asm __volatile(
|
||||
" xchgl %1,%0 ; "
|
||||
"# atomic_readandclear_int"
|
||||
: "+r" (result), /* 0 (result) */
|
||||
"=m" (*addr) /* 1 (addr) */
|
||||
: "+r" (res), /* 0 */
|
||||
"=m" (*addr) /* 1 */
|
||||
: "m" (*addr));
|
||||
|
||||
return (result);
|
||||
return (res);
|
||||
}
|
||||
|
||||
static __inline u_long
|
||||
atomic_readandclear_long(volatile u_long *addr)
|
||||
{
|
||||
u_long result;
|
||||
u_long res;
|
||||
|
||||
result = 0;
|
||||
res = 0;
|
||||
__asm __volatile(
|
||||
" xchgl %1,%0 ; "
|
||||
"# atomic_readandclear_long"
|
||||
: "+r" (result), /* 0 (result) */
|
||||
"=m" (*addr) /* 1 (addr) */
|
||||
: "+r" (result), /* 0 */
|
||||
"=m" (*addr) /* 1 */
|
||||
: "m" (*addr));
|
||||
|
||||
return (result);
|
||||
return (res);
|
||||
}
|
||||
|
||||
#else /* !__GNUCLIKE_ASM */
|
||||
|
||||
u_int atomic_readandclear_int(volatile u_int *);
|
||||
u_long atomic_readandclear_long(volatile u_long *);
|
||||
u_int atomic_readandclear_int(volatile u_int *addr);
|
||||
u_long atomic_readandclear_long(volatile u_long *addr);
|
||||
|
||||
#endif /* __GNUCLIKE_ASM */
|
||||
|
||||
@ -454,6 +454,6 @@ u_long atomic_readandclear_long(volatile u_long *);
|
||||
#define atomic_readandclear_ptr(p) \
|
||||
atomic_readandclear_int((volatile u_int *)(p))
|
||||
|
||||
#endif /* !defined(WANT_FUNCTIONS) */
|
||||
#endif /* !WANT_FUNCTIONS */
|
||||
|
||||
#endif /* !_MACHINE_ATOMIC_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user