From owner-cvs-src@FreeBSD.ORG Wed Feb 18 11:12:46 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BAF0116A4D1 for ; Wed, 18 Feb 2004 11:12:46 -0800 (PST) Received: from mail5.speakeasy.net (mail5.speakeasy.net [216.254.0.205]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9562443D1F for ; Wed, 18 Feb 2004 11:12:46 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 28301 invoked from network); 18 Feb 2004 19:12:46 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 18 Feb 2004 19:12:46 -0000 Received: from 10.50.40.205 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.10/8.12.10) with ESMTP id i1IJCg2J097268; Wed, 18 Feb 2004 14:12:43 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: Marcel Moolenaar Date: Wed, 18 Feb 2004 14:14:00 -0500 User-Agent: KMail/1.6 References: <200401192127.i0JLRBL3041817@repoman.freebsd.org> <200402180839.09285.jhb@FreeBSD.org> <20040218174059.GC7878@ns1.xcllnt.net> In-Reply-To: <20040218174059.GC7878@ns1.xcllnt.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200402181414.01381.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: src-committers@FreeBSD.org cc: Bruce Evans cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: Poul-Henning Kamp cc: Jun Kuriyama Subject: Re: cvs commit: src/sys/alpha/alpha support.s src/sys/i386/i386 swtch.s src/sys/kern kern_shutdown.c src/sys/sys systm.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2004 19:12:46 -0000 On Wednesday 18 February 2004 12:40 pm, Marcel Moolenaar wrote: > On Wed, Feb 18, 2004 at 08:39:09AM -0500, John Baldwin wrote: > > Use MPASS() (macros that came in with SMPng from BSD/OS). MPASS(foo) > > will work much like assert() in userland including file/line number info. > > I use it a lot for simple != NULL tests and the like. > > I like the behaviour of MPASS(), just not its name and the fact it's > defined in lock.h. If we can call it ASSERT and move its definition > to systm.h, then I'm hooked. I have wanted to have a better name for it and it's associated friends (MPASS2, MPASS3, MPASS4). KASSERT() really is a good name, and perhaps what we should do is replace MPASS/KASSERT() with something like this: KASSERT(condition) (just asserts a condition like MPASS does now) KASSERTV(condition, printf args) (verbose assertion, has its own message) These could perhaps output the current file and line, but then you have the problem of things like the mutex code that pass around file and line info to give more relevant file and line numbers (and hence the MPASS3() and MPASS4() macros that BSD/OS provides). If you want to preserve that, perhaps one could add: KASSERTL(condition, file, line) KASSERTLV(condition, file, line, printf args) Thus, you have: #define KASSERT(condition) KASSERTL(condition, __FILE__, __LINE__) #define KASSERTV(condition, ...) KASSERTLV(condition, __FILE__, __LINE__, \ __VA_ARGS__) #define KASSERTL(condition, file, line) KASSERTLV(condition, file, line, \ "%s", __STRING(condition)) #define KASSERTLV(condition, file, line, ...) do { \ if (!(condition)) { \ printf("Assertion \""); \ printf(__VA_ARGS__); \ printf("\" failed at %s:%d\n", file, line); \ } \ } while(0) Even nicer might be to make fixup_filename() from subr_witness.c a global #ifdef INVARIANTS_SUPPORT and have KASSERTLV() use that (it trims any (../)* from the front of a filename to improve readability of messages by just returning a char * pointer farther along in the string). If ASSERT() is preferred to KASSERT() that would certain ease the transition to the different macros. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org