From owner-freebsd-bugs Wed Feb 12 3:30:18 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8E4B437B401 for ; Wed, 12 Feb 2003 03:30:09 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 779E543FAF for ; Wed, 12 Feb 2003 03:30:08 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h1CBU8NS018579 for ; Wed, 12 Feb 2003 03:30:08 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h1CBU8Ef018577; Wed, 12 Feb 2003 03:30:08 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C536537B401 for ; Wed, 12 Feb 2003 03:25:19 -0800 (PST) Received: from HAL9000.homeunix.com (12-233-57-224.client.attbi.com [12.233.57.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id C97C843FAF for ; Wed, 12 Feb 2003 03:25:18 -0800 (PST) (envelope-from das@HAL9000.homeunix.com) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id h1CBPHDm007870 for ; Wed, 12 Feb 2003 03:25:17 -0800 (PST) (envelope-from das@HAL9000.homeunix.com) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id h1CBPHZ7007869; Wed, 12 Feb 2003 03:25:17 -0800 (PST) (envelope-from das) Message-Id: <200302121125.h1CBPHZ7007869@HAL9000.homeunix.com> Date: Wed, 12 Feb 2003 03:25:17 -0800 (PST) From: David Schultz To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/48205: [PATCH] sys/$arch/include/critical.h: fix gccisms Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 48205 >Category: kern >Synopsis: [PATCH] sys/$arch/include/critical.h: fix gccisms >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 12 03:30:08 PST 2003 >Closed-Date: >Last-Modified: >Originator: David Schultz >Release: 5.0-CURRENT >Organization: >Environment: >Description: All of the sys/$arch/include/critical.h files have a !__GNUC__ case that is not syntactically or logically valid. This patch eliminates the need for a !__GNUC__ case by macroifying some simple inline functions. This patch has been compile tested on i386. It should introduce no functional changes. >How-To-Repeat: >Fix: Index: alpha/include/critical.h =================================================================== RCS file: /home/ncvs/src/sys/alpha/include/critical.h,v retrieving revision 1.1 diff -u -r1.1 critical.h --- alpha/include/critical.h 1 Apr 2002 23:51:22 -0000 1.1 +++ alpha/include/critical.h 10 Feb 2003 16:25:55 -0000 @@ -26,22 +26,15 @@ void cpu_critical_fork_exit(void); void cpu_thread_link(struct thread *td); -#ifdef __GNUC__ - /* * cpu_critical_enter: * * This routine is called from critical_enter() on the 0->1 transition * of td_critnest, prior to it being incremented to 1. */ -static __inline void -cpu_critical_enter(void) -{ - struct thread *td; - - td = curthread; - td->td_md.md_savecrit = intr_disable(); -} +#define cpu_critical_enter() do { \ + curthread->td_md.md_savecrit = intr_disable(); \ +} while (0) /* * cpu_critical_exit: @@ -50,21 +43,7 @@ * of td_critnest, after it has been decremented to 0. We are * exiting the last critical section. */ -static __inline void -cpu_critical_exit(void) -{ - struct thread *td; - - td = curthread; - intr_restore(td->td_md.md_savecrit); -} - -#else /* !__GNUC__ */ - -void cpu_critical_enter(void) -void cpu_critical_exit(void) - -#endif /* __GNUC__ */ +#define cpu_critical_exit() (void)intr_restore(curthread->td_md.md_savecrit) __END_DECLS Index: i386/include/critical.h =================================================================== RCS file: /home/ncvs/src/sys/i386/include/critical.h,v retrieving revision 1.2 diff -u -r1.2 critical.h --- i386/include/critical.h 10 Jul 2002 20:15:58 -0000 1.2 +++ i386/include/critical.h 10 Feb 2003 16:26:01 -0000 @@ -27,8 +27,6 @@ void cpu_critical_fork_exit(void); void cpu_thread_link(struct thread *td); -#ifdef __GNUC__ - /* * cpu_critical_enter: * @@ -51,31 +49,19 @@ * Note that the td->critnest (1->0) transition interrupt race against * our int_pending/unpend() check below is handled by the interrupt * code for us, so we do not have to do anything fancy. + * + * We may have to schedule pending interrupts. Create conditions + * similar to an interrupt context and call unpend(). + * + * note: we do this even if we are in an interrupt nesting level. + * Deep nesting is protected by critical_*() and if we + * conditionalized it then we would have to check int_pending + * again whenever we decrement td_intr_nesting_level to 0. */ -static __inline void -cpu_critical_exit(void) -{ - /* - * We may have to schedule pending interrupts. Create - * conditions similar to an interrupt context and call - * unpend(). - * - * note: we do this even if we are in an interrupt - * nesting level. Deep nesting is protected by - * critical_*() and if we conditionalized it then we - * would have to check int_pending again whenever - * we decrement td_intr_nesting_level to 0. - */ - if (PCPU_GET(int_pending)) - cpu_unpend(); -} - -#else /* !__GNUC__ */ - -void cpu_critical_enter(void) -void cpu_critical_exit(void) - -#endif /* __GNUC__ */ +#define cpu_critical_exit() do { \ + if (PCPU_GET(int_pending)) \ + cpu_unpend(); \ +} while (0) __END_DECLS Index: ia64/include/critical.h =================================================================== RCS file: /home/ncvs/src/sys/ia64/include/critical.h,v retrieving revision 1.1 diff -u -r1.1 critical.h --- ia64/include/critical.h 1 Apr 2002 23:51:22 -0000 1.1 +++ ia64/include/critical.h 10 Feb 2003 16:26:02 -0000 @@ -26,22 +26,15 @@ void cpu_critical_fork_exit(void); void cpu_thread_link(struct thread *td); -#ifdef __GNUC__ - /* * cpu_critical_enter: * * This routine is called from critical_enter() on the 0->1 transition * of td_critnest, prior to it being incremented to 1. */ -static __inline void -cpu_critical_enter(void) -{ - struct thread *td; - - td = curthread; - td->td_md.md_savecrit = intr_disable(); -} +#define cpu_critical_enter() do { \ + curthread->td_md.md_savecrit = intr_disable(); \ +} while (0) /* * cpu_critical_exit: @@ -50,22 +43,7 @@ * of td_critnest, after it has been decremented to 0. We are * exiting the last critical section. */ -static __inline void -cpu_critical_exit(void) -{ - struct thread *td; - - td = curthread; - intr_restore(td->td_md.md_savecrit); -} - - -#else /* !__GNUC__ */ - -void cpu_critical_enter(void) -void cpu_critical_exit(void) - -#endif /* __GNUC__ */ +#define cpu_critical_exit() (void)intr_restore(curthread->td_md.md_savecrit) __END_DECLS Index: powerpc/include/critical.h =================================================================== RCS file: /home/ncvs/src/sys/powerpc/include/critical.h,v retrieving revision 1.2 diff -u -r1.2 critical.h --- powerpc/include/critical.h 29 Jun 2002 09:55:57 -0000 1.2 +++ powerpc/include/critical.h 10 Feb 2003 16:26:10 -0000 @@ -26,8 +26,6 @@ void cpu_critical_fork_exit(void); void cpu_thread_link(struct thread *td); -#ifdef __GNUC__ - /* * cpu_critical_enter: * @@ -35,17 +33,12 @@ * of td_critnest, prior to it being incremented to 1. */ -static __inline void -cpu_critical_enter(void) -{ - u_int msr; - struct thread *td = curthread; - - msr = mfmsr(); - td->td_md.md_savecrit = msr; - msr &= ~PSL_EE; - mtmsr(msr); -} +#define cpu_critical_enter() do { \ + u_int _msr = mfmsr(); \ + curthread->td_md.md_savecrit = _msr; \ + _msr &= ~PSL_EE; \ + _mtmsr(_msr); \ +} while (0) /* * cpu_critical_exit: @@ -54,21 +47,7 @@ * of td_critnest, after it has been decremented to 0. We are * exiting the last critical section. */ -static __inline void -cpu_critical_exit(void) -{ - struct thread *td = curthread; - - mtmsr(td->td_md.md_savecrit); -} - - -#else /* !__GNUC__ */ - -void cpu_critical_enter(void) -void cpu_critical_exit(void) - -#endif /* __GNUC__ */ +#define cpu_critical_exit() (void)mtmsr(curthread->td_md.md_savecrit) __END_DECLS Index: sparc64/include/critical.h =================================================================== RCS file: /home/ncvs/src/sys/sparc64/include/critical.h,v retrieving revision 1.1 diff -u -r1.1 critical.h --- sparc64/include/critical.h 1 Apr 2002 23:51:23 -0000 1.1 +++ sparc64/include/critical.h 10 Feb 2003 16:26:10 -0000 @@ -26,25 +26,18 @@ void cpu_critical_fork_exit(void); void cpu_thread_link(struct thread *td); -#ifdef __GNUC__ - /* * cpu_critical_enter: * * This routine is called from critical_enter() on the 0->1 transition * of td_critnest, prior to it being incremented to 1. */ -static __inline void -cpu_critical_enter(void) -{ - struct thread *td; - critical_t pil; - - td = curthread; - pil = rdpr(pil); - wrpr(pil, 0, 14); - td->td_md.md_savecrit = pil; -} +#define cpu_critical_enter() do { \ + struct thread *_td = curthread; \ + critical_t _pil = rdpr(pil); \ + wrpr(pil, 0, 14); \ + _td->td_md.md_savecrit = _pil; \ +} while (0) /* @@ -54,21 +47,7 @@ * of td_critnest, after it has been decremented to 0. We are * exiting the last critical section. */ -static __inline void -cpu_critical_exit(void) -{ - struct thread *td; - - td = curthread; - wrpr(pil, td->td_md.md_savecrit, 0); -} - -#else /* !__GNUC__ */ - -void cpu_critical_enter(void) -void cpu_critical_exit(void) - -#endif /* __GNUC__ */ +#define cpu_critical_exit() (void)wrpr(pil, curthread->td_md.md_savecrit, 0) __END_DECLS >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message