Re: getdirentries_args and other kernel syscall structures

From: rookie (asmrookie_at_gmail.com)
Date: 11/23/05

  • Next message: Pav Lucistnik: "even more stats for your pleasure"
    Date: Wed, 23 Nov 2005 12:23:07 +0100
    To: Daniel Rudy <dr2867@pacbell.net>
    
    

    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
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: Pav Lucistnik: "even more stats for your pleasure"

    Relevant Pages

    • Re: socket communication: send & receive doesnt work right
      ... So I don't want to send a string as bytes. ... litttle endian then unpredictable results may be obtained. ... public void send_doubles(double vals, int len) throws ... char *result; ...
      (microsoft.public.win32.programmer.networks)
    • Re: How to determine the way data is stored in memory?
      ... > the memory address increases in the left to right direction, ... using casts, get the char at the address of an int set to one, if it's ... low char is one the it's little endian ...
      (comp.lang.c)
    • Endianess: why does this code not change value on BE machine?
      ... I've searched this group for Big/Little endian issues, don't kill me, ... static short getShortBE (char *data) ... - this code swaps the bytes on a Little Endian Machine ... int main ...
      (comp.lang.c)
    • Re: Bi,Big and Little Endians
      ... > long int D; ... > arbitrary combination of big,little or bi Endian. ... char can differ, and having different sizes for ints or long ints ... Convert everything to ASCII and send that over the line. ...
      (comp.os.linux.development.apps)
    • Re: Variation of bit-counting
      ... > These numbers appear as IP subnet masks. ... void initHighBitCount { ... int i, j; ... Of course, this all assumes you are little endian, and chars are 8 ...
      (comp.programming)