On Tuesday, August 29, 2017 12:18:18 PM Maxim Sobolev wrote: > John, OK, maybe you are right and the current status quo was just an > accident. I am curious what do you and other people think about expressing > expected structure size and padding more explicitly instead of trying to > accommodate for sometimes intricate play between alignment and type size > with something like char[N]? I.e. along the following lines: > > #if __WORDSIZE < 64
Use #ifdef __LP64__ > #define MD_IOCTL_LEN 436 > #else > #define MD_IOCTL_LEN 448 > #endif > > struct md_ioctl { > union { > struct _md_ioctl_payload { > unsigned version; /* Structure layout version */ > unsigned unit; /* unit number */ > enum md_types type ; /* type of disk */ > char *file; /* pathname of file to mount */ > off_t mediasize; /* size of disk in bytes */ > unsigned sectorsize; /* sectorsize */ > unsigned options; /* options */ > u_int64_t base; /* base address */ > int fwheads; /* firmware heads */ > int fwsectors; /* firmware sectors */ > char *label; /* label of the device */ > } md; > char raw[MD_IOCTL_LEN]; /* payload + padding for future ideas */ > }; > }; > CTASSERT(sizeof(struct md_ioctl) == MD_IOCTL_LEN); This is not the style we use in other structures in FreeBSD. Simply making the existing MDNPAD depend on the #ifdef would be more consistent. For a really good example of how to handle padding, see kinfo_proc which has separate "spare" arrays for int, long, void *, and char. -- John Baldwin _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"