From owner-svn-src-all@FreeBSD.ORG Mon Sep 6 22:31:54 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5F9910656B9; Mon, 6 Sep 2010 22:31:54 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 558E08FC1B; Mon, 6 Sep 2010 22:31:54 +0000 (UTC) Received: by ywt2 with SMTP id 2so2043356ywt.13 for ; Mon, 06 Sep 2010 15:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=redaSvLhhIiTmqD7RPshdf487A0lyuS/WlajIyi/wCs=; b=FmHYP81lbITQ7EpiSNsbLLi+1drVvhAq4ZTFJYvY0A7xvw6ZitOxrpYTgo+Om7F0HD TvCprNpeVMwxswIVstyVUh7gqIT+oICLz8tU8n9p082l0/yD6BHmbla8wz+iZ4p8gJFw C2W20K1qRW/n2dGWpY/I3GZEJa9Dm8SLGu788= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Z+z3sA6n40IWY6WtlT2E7XALp8rDI48buDM/FyeXzKGoJsbKH8i59s4CHNUv43inAF SaIYxcwoHeDcTFtOKIQVFvngFr+BgRQ8QVH7I+KgnmbqeF3+3ZoNsXD2lo0DHdXcMmSn Bdo0YYuEcX0EMG9WDboyzkPSjpi3ToZoJDUFk= MIME-Version: 1.0 Received: by 10.100.53.30 with SMTP id b30mr302551ana.43.1283812313579; Mon, 06 Sep 2010 15:31:53 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.100.126.20 with HTTP; Mon, 6 Sep 2010 15:31:53 -0700 (PDT) In-Reply-To: <20100906234057.O954@delplex.bde.org> References: <201009031723.o83HNR7k056625@svn.freebsd.org> <20100906234057.O954@delplex.bde.org> Date: Mon, 6 Sep 2010 15:31:53 -0700 X-Google-Sender-Auth: XPwcSz0-XCXb8zdqmNQU09hyKLs Message-ID: From: mdf@FreeBSD.org To: Bruce Evans Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, pluknet , src-committers@freebsd.org Subject: Re: svn commit: r212182 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2010 22:31:55 -0000 On Mon, Sep 6, 2010 at 6:45 AM, Bruce Evans wrote: > On Fri, 3 Sep 2010, pluknet wrote: > >> On 3 September 2010 21:23, Matthew D Fleming wrote: >>> >>> Log: >>> =A0Fix user-space libsbuf build. =A0Why isn't CTASSERT available to >>> =A0user-space? > > Well, user headers shouldn't be enlisted to check for kernel bugs that > can be checked well enough in the kernel. I agree, but in this case one could define different constants for user space and kernel space, and the code could be wrong only for user-space, where there isn't a compile-time assert. I do always appreciate style and standards advice from Mr Bruce. It's the only way to learn (usually, hopefully, from other people's mistakes ;-) Thanks, matthew >>> Modified: >>> =A0head/sys/kern/subr_sbuf.c >>> >>> Modified: head/sys/kern/subr_sbuf.c >>> >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >>> --- head/sys/kern/subr_sbuf.c =A0 Fri Sep =A03 16:12:39 2010 =A0 =A0 = =A0 =A0(r212181) >>> +++ head/sys/kern/subr_sbuf.c =A0 Fri Sep =A03 17:23:26 2010 =A0 =A0 = =A0 =A0(r212182) >>> @@ -116,8 +116,10 @@ _assert_sbuf_state(const char *fun, stru >>> >>> =A0#endif /* _KERNEL && INVARIANTS */ >>> >>> +#ifdef _KERNEL >>> =A0CTASSERT(powerof2(SBUF_MAXEXTENDSIZE)); >>> =A0CTASSERT(powerof2(SBUF_MAXEXTENDINCR)); >>> +#endif >>> >>> =A0static int >>> =A0sbuf_extendsize(int size) >> >> Hi, >> >> as I can see, the next (and maybe preferred) model is used in system >> headers: >> >> #ifdef CTASSERT >> CTASSERT(...); >> #endif > > Needed, even in the kernel, since CTASSERT() is only defined if the > kernel-only header has been included. > > If this macro were defined in a user header, then it would have to be > more global (probably defined in ) but not in the applicatio= n > namespace (probably spelled __CTASSERT()), so it would be uglier. > > Bruce