tech-kern archive

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

Re: CTLTYPE_UINT?



On Sat, 04 Oct 2014, Justin Cormack wrote:
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.

The S64 and U64 names are fine.  I'd also add S32 and U32.

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.

One of the reasons that I like user/kernel interfaces to use types with explicit bit width is to simplify running 32-bit userland on 64-bit kernels. If you use a type whose actual size changes between 32 bits and 64 bits, then the kernel has to have a compatibility layer to copy and adjust the data, and tools like kdump or ktruss should also translate (it's a bug that they don't do so today). If you use a type that's always 64 bits, then it's much easier to deal with. Occasionally, an argument for run-time efficiency in a 32-bit userland will outweigh this argument for ease of coding, and then a type whose size changes should be used.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index