From owner-p4-projects@FreeBSD.ORG Tue Jun 21 19:17:56 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9EBD216A420; Tue, 21 Jun 2005 19:17:55 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 78C4D16A41C for ; Tue, 21 Jun 2005 19:17:55 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D47E43D4C for ; Tue, 21 Jun 2005 19:17:55 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j5LJHtsh062369 for ; Tue, 21 Jun 2005 19:17:55 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j5LJHs2I062366 for perforce@freebsd.org; Tue, 21 Jun 2005 19:17:54 GMT (envelope-from jhb@freebsd.org) Date: Tue, 21 Jun 2005 19:17:54 GMT Message-Id: <200506211917.j5LJHs2I062366@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 78772 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2005 19:17:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=78772 Change 78772 by jhb@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_ */