Jeremie Courreges-Anglas <j...@wxcvbn.org> writes:

> Gert Doering <g...@greenie.muc.de> writes:
>
>> Hi,
>>
>> On Sat, Jun 10, 2017 at 07:58:13PM +0200, Jeremie Courreges-Anglas wrote:
>>> OpenBSD:
>>> 
>>> struct ip {
>>> #if _BYTE_ORDER == _LITTLE_ENDIAN
>>>     u_int     ip_hl:4,              /* header length */
>>>               ip_v:4;               /* version */
>>> #endif
>>> #if _BYTE_ORDER == _BIG_ENDIAN
>>>     u_int     ip_v:4,               /* version */
>>>               ip_hl:4;              /* header length */
>>> #endif
>>> ...
>>> 
>>> u_char -> u_int.  Dunno if it matters to the compiler, I can take a look
>>> later.
>>
>> I'm fairly sure it does matter.  An int is likely to be at least 16 bit, 
>> maybe 32 bit, so the compiler can assume "word aligned" - and *boom*.
>
> It doesn't seem to matter that much.  Which aligns well with the
> "bit fields are nasty" experience people seem to have.  From a quick
> glance at the c99 standard, I couldn't find language about this.

Appendix J.1 mentions this: "The alignment of the addressable storage
unit allocated to hold a bit-field (6.7.2.1)." as unspecified behavior.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to