Re: Unaligned memory accesses

2007-09-05 Thread Kevin Ryde
[EMAIL PROTECTED] (Ludovic Courtès) writes: > > No it can't. AFAICS, there's nothing in the C standard forcing fields > of unions to be stored at offset zero when said fields have different > sizes. Union elements start at the start of the combined space. In particular if the elements are struct

Re: Unaligned memory accesses

2007-09-04 Thread Ludovic Courtès
Hi, Kevin Ryde <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] (Ludovic Courtès) writes: >> + if (((struct sockaddr *) &addr)->sa_family ... > > That can use the union member instead of a cast, can it? No it can't. AFAICS, there's nothing in the C standard forcing fields of unions to be store

Re: Unaligned memory accesses

2007-09-03 Thread Kevin Ryde
[EMAIL PROTECTED] (Ludovic Courtès) writes: > > `accept' would randomly yield a "bus error" on SPARC). Looks ok. > + if (((struct sockaddr *) &addr)->sa_family ... That can use the union member instead of a cast, can it? ___ Guile-devel mailing list

Unaligned memory accesses

2007-09-02 Thread Ludovic Courtès
Hi, I just committed the attached patch, which fixes unaligned accesses in `socket.c' (notably, `accept' would randomly yield a "bus error" on SPARC). The trick is to use unions to allow the compiler to suitably align variables. Trying to compile with `-Wcast-align' (on SPARC) is instructive. T