tech-net archive

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

Re: Adding ifam_pid to ifa_msghdr



    Date:        Thu, 01 Sep 2016 00:40:14 +0100
    From:        Roy Marples <roy%marples.name@localhost>
    Message-ID:  <4026094.yb7LW5zMxf%uberpc.marples.name@localhost>

  | Hopefully this satisfies your alignment 
  | requirement, otherwise please explain more fully.

In structs that are part of the ABI, to avoid potential messes from
any of different compilers being used, or compiler version changes
altering things, or even parts of the code being compiled with different
compiler options, there should be no (rational) potential for anonymous
padding fields (which the compiler might, or might not, decide to include).

As I understand the diff, your new struct starts with (ignoring irrelevant
unsigneds) a short, 2 chars, a short, and an int.   Typically there will be
2 bytes of padding after the initial 6 bytes before the int, so the int is
4 byte aligned.   But just typically - the language doesn't require those
padding bytes.   To avoid problems, insert another short (or 2 chars) so
that there are no anonymous fields left and every byte of space used is
accounted for by something the compiler cannot simply decide to omit.

(In the previous version, the new pid_t field (ie: int) followed a short
which followed other int fields - again, there would typically be 2 bytes
of padding inserted.)

I'm sure there are other ABI structs in the system where this issue has
been ignored, and we're just trusting compiler consistency to retain the
ABI, but we should fix those when encountered, and certainly should not
be creating new ones.

kre



Home | Main Index | Thread Index | Old Index