PERFORCE change 78772 for review
John Baldwin
jhb at FreeBSD.org
Tue Jun 21 19:17:56 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=78772
Change 78772 by jhb at jhb_slimer on 2005/06/21 19:17:37
Move the readandclear functions up closer to the other real
functions and add some more comments.
Affected files ...
.. //depot/projects/smpng/sys/amd64/include/atomic.h#17 edit
.. //depot/projects/smpng/sys/i386/include/atomic.h#35 edit
Differences ...
==== //depot/projects/smpng/sys/amd64/include/atomic.h#17 (text+ko) ====
@@ -231,6 +231,48 @@
#undef ATOMIC_ASM
#undef ATOMIC_STORE_LOAD
+#if !defined(WANT_FUNCTIONS)
+
+/* Read the current value and store a zero in the destination. */
+#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
+
+static __inline u_int
+atomic_readandclear_int(volatile u_int *addr)
+{
+ u_int result;
+
+ __asm __volatile (
+ " xorl %0,%0 ; "
+ " xchgl %1,%0 ; "
+ "# atomic_readandclear_int"
+ : "=&r" (result) /* 0 (result) */
+ : "m" (*addr)); /* 1 (addr) */
+
+ return (result);
+}
+
+static __inline u_long
+atomic_readandclear_long(volatile u_long *addr)
+{
+ u_long result;
+
+ __asm __volatile (
+ " xorq %0,%0 ; "
+ " xchgq %1,%0 ; "
+ "# atomic_readandclear_int"
+ : "=&r" (result) /* 0 (result) */
+ : "m" (*addr)); /* 1 (addr) */
+
+ return (result);
+}
+
+#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
+
+extern u_long atomic_readandclear_long(volatile u_long *);
+extern u_int atomic_readandclear_int(volatile u_int *);
+
+#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
+
/* Acquire and release variants are identical to the normal ones. */
#define atomic_set_acq_char atomic_set_char
#define atomic_set_rel_char atomic_set_char
@@ -325,7 +367,7 @@
#define atomic_cmpset_rel_32 atomic_cmpset_rel_int
#define atomic_readandclear_32 atomic_readandclear_int
-#if !defined(WANT_FUNCTIONS)
+/* Operations on pointers. */
static __inline int
atomic_cmpset_ptr(volatile void *dst, void *exp, void *src)
{
@@ -376,44 +418,5 @@
#undef ATOMIC_PTR
-#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
-
-static __inline u_int
-atomic_readandclear_int(volatile u_int *addr)
-{
- u_int result;
-
- __asm __volatile (
- " xorl %0,%0 ; "
- " xchgl %1,%0 ; "
- "# atomic_readandclear_int"
- : "=&r" (result) /* 0 (result) */
- : "m" (*addr)); /* 1 (addr) */
-
- return (result);
-}
-
-static __inline u_long
-atomic_readandclear_long(volatile u_long *addr)
-{
- u_long result;
-
- __asm __volatile (
- " xorq %0,%0 ; "
- " xchgq %1,%0 ; "
- "# atomic_readandclear_int"
- : "=&r" (result) /* 0 (result) */
- : "m" (*addr)); /* 1 (addr) */
-
- return (result);
-}
-
-#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
-
-extern u_long atomic_readandclear_long(volatile u_long *);
-extern u_int atomic_readandclear_int(volatile u_int *);
-
-#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
-
#endif /* !defined(WANT_FUNCTIONS) */
#endif /* ! _MACHINE_ATOMIC_H_ */
==== //depot/projects/smpng/sys/i386/include/atomic.h#35 (text+ko) ====
@@ -260,6 +260,32 @@
#undef ATOMIC_ASM
#undef ATOMIC_STORE_LOAD
+#if !defined(WANT_FUNCTIONS)
+
+/* Read the current value and store a zero in the destination. */
+#ifdef __GNUCLIKE_ASM
+
+static __inline u_int
+atomic_readandclear_int(volatile u_int *addr)
+{
+ u_int result;
+
+ __asm __volatile (
+ " xorl %0,%0 ; "
+ " xchgl %1,%0 ; "
+ "# atomic_readandclear_int"
+ : "=&r" (result) /* 0 (result) */
+ : "m" (*addr)); /* 1 (addr) */
+
+ return (result);
+}
+
+#else /* !__GNUCLIKE_ASM */
+
+extern u_int atomic_readandclear_int(volatile u_int *);
+
+#endif /* __GNUCLIKE_ASM */
+
/* Acquire and release variants are identical to the normal ones. */
#define atomic_set_acq_char atomic_set_char
#define atomic_set_rel_char atomic_set_char
@@ -366,7 +392,7 @@
#define atomic_store_rel_long(p, v) atomic_store_rel_int((volatile u_int *)(p), (v))
#define atomic_readandclear_long(p) atomic_readandclear_int((volatile u_int *)(p))
-#if !defined(WANT_FUNCTIONS)
+/* Operations on pointers. */
static __inline int
atomic_cmpset_ptr(volatile void *dst, void *exp, void *src)
{
@@ -417,28 +443,5 @@
#undef ATOMIC_PTR
-#ifdef __GNUCLIKE_ASM
-
-static __inline u_int
-atomic_readandclear_int(volatile u_int *addr)
-{
- u_int result;
-
- __asm __volatile (
- " xorl %0,%0 ; "
- " xchgl %1,%0 ; "
- "# atomic_readandclear_int"
- : "=&r" (result) /* 0 (result) */
- : "m" (*addr)); /* 1 (addr) */
-
- return (result);
-}
-
-#else /* !__GNUCLIKE_ASM */
-
-extern u_int atomic_readandclear_int(volatile u_int *);
-
-#endif /* __GNUCLIKE_ASM */
-
#endif /* !defined(WANT_FUNCTIONS) */
#endif /* ! _MACHINE_ATOMIC_H_ */
More information about the p4-projects
mailing list