Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Giorgos Keramidas <keramida@xxxxxxxxxxxxxxx>
- Date: Mon, 13 Feb 2006 10:48:02 +0200
On 2006-02-13 00:34, Colin Percival <cperciva@xxxxxxxxxxx> wrote:
Giorgos Keramidas wrote:
On 2006-02-13 00:23, "M. Warner Losh" <imp@xxxxxxxxxx> wrote:
struct foo foo;
uint32_t value[sizeof(foo) / sizeof(uint32_t)];
memcpy(value, &foo);
// write out value one 32-bit word at a time
Is that right? Or at least 'proper' here means defined.
AFAIK, yes.
I agree that the behaviour of the above code is defined, but
I'd be much happier if value[] was defined to be an array of
length ((sizeof(foo) - 1) / sizeof(uint32_t) + 1), just in
case sizeof(foo) happens to not be a multiple of 4. :-)
Good thinking. It's probably a good idea to avoid copying random
garbage, and using something like:
struct foo foo;
uint32_t value[sizeof(uint32_t) * (sizeof(foo) / sizeof(uint32_t) + 1)];
and then copying only sizeof(foo) bytes. This is probably defined too
and won't allow overflowing of value[], but I don't really want to know
what it does on machines of varying endianess :-)
- Giorgos
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Peter Jeremy
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- References:
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Stefan Farfeleder
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Dag-Erling Smørgrav
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Erik Trulsson
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: M. Warner Losh
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Giorgos Keramidas
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- From: Colin Percival
- Re: [releng_6 tinderbox] failure on sparc64/sparc64
- Prev by Date: Re: [releng_6 tinderbox] failure on sparc64/sparc64
- Next by Date: Re: NTFS write support
- Previous by thread: Re: [releng_6 tinderbox] failure on sparc64/sparc64
- Next by thread: Re: [releng_6 tinderbox] failure on sparc64/sparc64
- Index(es):