Re: cvs commit: src/sys/sys user.h

From: Bruce Evans <brde_at_optusnet.com.au>
Date: Thu, 1 May 2008 13:00:34 +1000 (EST)
On Wed, 30 Apr 2008, David O'Brien wrote:

> On Tue, Apr 29, 2008 at 05:41:18PM +0400, Yar Tikhiy wrote:
>> On Tue, Apr 29, 2008 at 3:17 PM, Oleksandr Tymoshenko <gonzo_at_freebsd.org> wrote:
>>> gonzo       2008-04-29 11:17:45 UTC
>>>   Modified files:
>>>     sys/sys              user.h
>>>   Log:
>>>     Define KINFO_PROC_SIZE for mips.
> ..
>> Perhaps it's time to introduce MD .h files for that instead of adding
>> MD #ifdefs to the MI .h file, isn't it? I.e., <sys/user.h> can include
>> <machine/_user.h>, which can define KINFO_PROC_SIZE and its possible
>> friends.
>
> I would like to see us go in that direction also.

KINFO_PROC_SIZE is special.  It can only be determined by looking at the
MI struct declared in <sys.user.h>, and the looking must not be automated
since the reason for existence of this macro is to prevent automated
changes to the size of the struct.

I would have used a definition like

     KI_NVOIDSTAR * sizeof(void *) + KI_NINTMAX_T * sizeof(intmax_t) + ...

where KI_N* are MI.  This requires the struct to not have any padding
or for the padding to be countable by and actually counted by an
expression like the above.  Unfortunately, the struct is not laid out
very carefully, (it has nested structs which it cannot control the
layout of) so it might have MD padding which would make some of the
KI_N*'s MD.  All padding is MD in theory, but in practice padding can
be made almost MI by a careful layout.

Bruce
Received on Thu May 01 2008 - 03:01:57 UTC