Re: svn commit: r212182 - head/sys/kern

2010-09-06 Thread mdf
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:
>>>  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  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 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"


Re: svn commit: r212182 - head/sys/kern

2010-09-06 Thread Bruce Evans

On Fri, 3 Sep 2010, pluknet wrote:


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

Re: svn commit: r212182 - head/sys/kern

2010-09-03 Thread pluknet
On 3 September 2010 21:23, Matthew D Fleming  wrote:
> Author: mdf
> Date: Fri Sep  3 17:23:26 2010
> New Revision: 212182
> URL: http://svn.freebsd.org/changeset/base/212182
>
> Log:
>  Fix user-space libsbuf build.  Why isn't CTASSERT available to
>  user-space?
>
> 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

-- 
wbr,
pluknet
___
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"


Re: svn commit: r212182 - head/sys/kern

2010-09-03 Thread mdf
On Fri, Sep 3, 2010 at 10:23 AM, Matthew D Fleming  wrote:
> Author: mdf
> Date: Fri Sep  3 17:23:26 2010
> New Revision: 212182
> URL: http://svn.freebsd.org/changeset/base/212182
>
> Log:
>  Fix user-space libsbuf build.  Why isn't CTASSERT available to
>  user-space?

Sorry for the churn.  I am having a un-careful morning, it appears.

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)
>
___
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"


svn commit: r212182 - head/sys/kern

2010-09-03 Thread Matthew D Fleming
Author: mdf
Date: Fri Sep  3 17:23:26 2010
New Revision: 212182
URL: http://svn.freebsd.org/changeset/base/212182

Log:
  Fix user-space libsbuf build.  Why isn't CTASSERT available to
  user-space?

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)
___
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"