From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A8164B6F83 for ; Fri, 8 Apr 2011 07:48:32 +1000 (EST) Subject: Re: halt/reset on assert? From: Benjamin Herrenschmidt To: kevin diggs In-Reply-To: References: <4D966C5C.9030409__15236.8285613649$1301704900$gmane$org@cyconix.com> <4D9C6413.8030103@cyconix.com> <1302162933.2458.33.camel@pasglop> Content-Type: text/plain; charset="UTF-8" Date: Fri, 08 Apr 2011 07:48:09 +1000 Message-ID: <1302212889.2458.40.camel@pasglop> Mime-Version: 1.0 Cc: Andreas Schwab , linuxppc-dev@lists.ozlabs.org, Evan Lavelle List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, 2011-04-07 at 12:04 -0500, kevin diggs wrote: > On Thu, Apr 7, 2011 at 2:55 AM, Benjamin Herrenschmidt > wrote: > > On Wed, 2011-04-06 at 14:01 +0100, Evan Lavelle wrote: > >> #define MY_ASSERT(expr) if(!(expr)) BUG() > > > > Make it > > > > #define MY_ASSERT(expr) do { if .... } while(0) > > > > To ensure it has proper single statement semantics in C. > > > So THAT'S why they do this!!!!!! Now I just have to figure out what > 'proper single statement semantics' means! Thing what happens without the do { ... } while(0) if you have code that looks like: if (enable_debug) MY_ASSERT(foo); else something_else; Ben.