tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CTLTYPE_UINT?



On Sat, Oct 4, 2014 at 9:24 AM, Alan Barrett <apb%cequrux.com@localhost> wrote:
> On Fri, 03 Oct 2014, Justin Cormack wrote:
>>
>> Back in the sysctl discussion a while back, core group said:
>>
>> http://mail-index.netbsd.org/tech-kern/2014/03/26/msg016779.html
>>
>> a) What types are needed?  Currently, CTLTYPE_INT is a signed
>>   32-bit type, and CTLTYPE_QUAD is an unsigned 64-bit type.
>>   Perhaps all four possible combinations of signed/unsigned and
>>   32 bits/64 bits should be supported.
>
>
> If you add new sysctl types, please use names that describe the size and
> signedness.  For example, rename CTLTYPE_INT to CTLTPE_INT32, keep
> CTLTYPE_INT as a backward compatible alias for CTLTYPE_INT32, and add
> CTLTYPE_UINT32.  Similarly, rename CTLTYPE_QUAD to CTLTYPE_UINT64, keep
> CTLTYPE_QUAD as an alias, and add CTLTYPE_INT64.  Please don't add a
> CTLTYPE_UINT with no indication of its size.
>
> A survey of what other OSes do would also be useful.

Freebsd (and Dragonfly):
     CTLTYPE_NODE    This is a node intended to be a parent for other nodes.
     CTLTYPE_INT     This is a signed integer.
     CTLTYPE_STRING  This is a nul-terminated string
     CTLTYPE_S64     This is a 64-bit signed integer.
     CTLTYPE_OPAQUE  This is an opaque data structure.
     CTLTYPE_STRUCT  Alias for CTLTYPE_OPAQUE.
     CTLTYPE_UINT    This is an unsigned integer.
     CTLTYPE_LONG    This is a signed long.
     CTLTYPE_ULONG   This is an unsigned long.
     CTLTYPE_U64     This is a 64-bit unsigned integer.

OpenBSD has the same types as NetBSD, ie CTLTYPE_INT and CTLTYPE_QUAD
as the int32 and uint64 types.

I agree about being explicit with the 32 bitness, but using S64 and
U64 as the 64 bit names to be consistent with FreeBSD might make
sense. long types seems best avoided if possible, you can see the
temptation to use them for memory amounts, but you could be running on
32 bit userspace on a 64 bit kernel.

Justin


Home | Main Index | Thread Index | Old Index