From owner-freebsd-hackers Mon Feb 9 03:52:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA14805 for hackers-outgoing; Mon, 9 Feb 1998 03:52:10 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from shrimp.dataplex.net (shrimp.dataplex.net [208.2.87.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA14799 for ; Mon, 9 Feb 1998 03:52:07 -0800 (PST) (envelope-from rkw@dataplex.net) Received: from [208.2.87.4] (user4.dataplex.net [208.2.87.4]) by shrimp.dataplex.net (8.8.8/8.8.5) with ESMTP id FAA04761; Mon, 9 Feb 1998 05:51:51 -0600 (CST) X-Sender: rkw@mail.dataplex.net Message-Id: In-Reply-To: <19980209091644.21614@follo.net> References: ; from Michael Hancock on Mon, Feb 09, 1998 at 04:27:14PM +0900 <19980209075127.63680@follo.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Mon, 9 Feb 1998 05:49:52 -0600 To: Eivind Eklund From: Richard Wackerbarth Subject: Re: DIAGNOSTICS and DEBUG LOGGING (was Re: cvs commit: src/sys/conf options) Cc: Michael Hancock , FreeBSD Hackers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 2:16 AM -0600 2/9/98, Eivind Eklund wrote: >> > _ASSERTS - Enable precondition and other cheap assertions >> > _INVARIANTS - Enable invariant/postcondition checking (expensive) >> > INVARIANT_CODE - Compile in invariant functions. >> >> So we have 3 levels of "sanity checking" with increasing levels of cost. >> I like it, it's a good fit to how people want to use assertions in >> practice. > >Just to make this perfectly clear (I'm not certain if you got my >meaning or not): > >Enabling INVARIANT_CODE will not add _any_ checks to the kernel. INVARIANT_SUPPORT >Instead, it will add the code that is necessary to enable any checks >at will. If INVARIANT_CODE is defined for the entire kernel, then >_ASSERTS or _INVARIANTS can be defined for any single file without any >compilation trouble, even if _ASSERTS/_INVARIANTS isn't enabled for >any other file. Let me suggest something that I found to work well in developing drivers on MacOS. Rather than fill the code with #ifdef _ASSERTS if ((unsigned long)cblockp & (CBLOCK-1)) panic("Unaligned cblock in cblock_free"); #endif how about ASSERT(((unsigned long)cblockp & (CBLOCK-1)), "Unaligned cblock in cblock_free"); Then you can hide the _ASSERTS stuff in a header which defines the ASSERT macro and get rid of the clutter in the code. #ifdef _ASSERTS #define ASSERT(X,Y) if (X) panic(Y) #else #define ASSERT(X,Y) #endif Richard Wackerbarth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe hackers" in the body of the message