svn commit: r212182 - head/sys/kern

Bruce Evans brde at optusnet.com.au
Mon Sep 6 13:45:22 UTC 2010


On Fri, 3 Sep 2010, pluknet wrote:

> On 3 September 2010 21:23, Matthew D Fleming <mdf at 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.

>> 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


More information about the svn-src-head mailing list