Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Nov 2005 09:32:09 -0800
From:      Daniel Rudy <dr2867@pacbell.net>
To:        rookie@gufi.org
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: getdirentries_args and other kernel syscall structures
Message-ID:  <4384A799.30809@pacbell.net>
In-Reply-To: <3bbf2fe10511230323xafaea9cr@mail.gmail.com>
References:  <4383F0CA.2030609@pacbell.net> <3bbf2fe10511230323xafaea9cr@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
At about the time of 11/23/2005 3:23 AM, rookie stated the following:
> 2005/11/23, Daniel Rudy <dr2867@pacbell.net>:
> 
>>Ok, I'va got a little question here.  In the structure
>>getdirentries_args, there seems to be duplicated fields that I'm not
>>entirely sure what they do.  Here's the definition of a structure
>>verbatim from sys/sysproto.h:
>>
>>struct getdirentries_args {
>>        char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
>>        char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
>>        char count_l_[PADL_(u_int)]; u_int count; char
>>count_r_[PADR_(u_int)];
>>        char basep_l_[PADL_(long *)]; long * basep; char
>>basep_r_[PADR_(long *)];
>>};
>>
>>Now my question is what does the l and r variables do?  It seems that
>>they do something with padding the data based on the endian of the
>>machine?  I look through this header file, and I see all the structures
>>have similar constructs.  Is it something that can be safely ignored
> 
> 
> It just pads in the right way (according with endianism) the structure
> to the right word. For example, x86 gots sizeof(long *) == 4. If you
> want to have a syscall structure like that:
> 
> struct example_sys
> {
>    char f;
>    short p;
>    int g;
> };
> 
> it is misaligned. In order to get a proper padded structure (all 32
> bits entries) to speed-up accesses to the members, this little trick
> is used.
> 
> Attilio
> 
> --
> Peace can only be achieved by understanding - A. Einstein
> 

Ah, a performance trick.  I get it now.  Thanks.

-- 
Daniel Rudy



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4384A799.30809>