Consider the following snippet from code running in the Linux kernel:
char *d;
u32 mask, step, val;
...
/* d is initialized with valid pointer pointing at buffer,
and mask, step and val are initialized to some sane values as well. */
...
val = (*d & mask) >> step;
As you see only d
is of char *
type, the rest are unsigned integers. I know that C performs type conversions automatically when
values of differing types participate in expressions, in this case
bit-wise operation. So, I'm assuming it is guaranteed that *d
will be promoted to uint32_t
as well?
If this assumption is correct, my 2nd question would be about the byte-order of 4 bytes located at memory pointed by d
. I think it has to be whatever byte-order the host implements, or if it's networking, then strictly big-endian.