Re: [PATCH 7/8] i2c: add 'transferred' field to struct i2c_msg

Al Viro
2012-10-27T17:02:41Z

On Sat, Oct 27, 2012 at 05:40:13PM +0100, Al Viro wrote:

> You are wrong. Assumption that pointers are aligned to 32bit boundary
> is simply not true. In particular, on m68k alignment is 16bit, i.e. there
> struct foo {
> char x;
> void *p;
> }; will have 1 byte occupied by x, followed by 1-byte gap, followed by 4 bytes
> occupied by p.
>
> Note, BTW, that m68k includes things like coldfire, etc. and I wouldn't be
> surprised by e.g. coldfire-based SoC with i2c on it.

BTW, that's easily verified - take a cross-compiler and do this:
; cat >a.c <<'EOF'
struct { char x; void *y; } v;
int z = (char *)&v.y - (char *)&v;
EOF
; m68k-linux-gnu-gcc -S a.c
; grep -A1 'z:' a.s
z:
.long 2
;
and watch what it puts into z. gcc is very liberal about what it considers
a constant expression, so it allows that sort of expressions as initializers
for global variables. Not a portable C, but convenient for experiments like
that; just grab a cross-toolchain and feed it testcases of that kind...