On Mon, Sep 6, 2010 at 6:45 AM, Bruce Evans <b...@optusnet.com.au> wrote: > On Fri, 3 Sep 2010, pluknet wrote: > >> On 3 September 2010 21:23, Matthew D Fleming <m...@freebsd.org> wrote: >>> >>> Log: >>> Fix user-space libsbuf build. Why isn't CTASSERT available to >>> user-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: >>> head/sys/kern/subr_sbuf.c >>> >>> Modified: head/sys/kern/subr_sbuf.c >>> >>> ============================================================================== >>> --- head/sys/kern/subr_sbuf.c Fri Sep 3 16:12:39 2010 (r212181) >>> +++ head/sys/kern/subr_sbuf.c Fri Sep 3 17:23:26 2010 (r212182) >>> @@ -116,8 +116,10 @@ _assert_sbuf_state(const char *fun, stru >>> >>> #endif /* _KERNEL && INVARIANTS */ >>> >>> +#ifdef _KERNEL >>> CTASSERT(powerof2(SBUF_MAXEXTENDSIZE)); >>> CTASSERT(powerof2(SBUF_MAXEXTENDINCR)); >>> +#endif >>> >>> static int >>> sbuf_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 <sys/systm.h> has been included. > > If this macro were defined in a user header, then it would have to be > more global (probably defined in <sys/cdefs.h>) but not in the application > namespace (probably spelled __CTASSERT()), so it would be uglier. > > Bruce _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"