Re: Problems with double-word alignment on hppa and sparc
* Uwe Steinmann <firstname.lastname@example.org> [071127 14:02]:
> I need some help with #444494 since I'm neither an ocaml nor a
> hppa, sparc specialist. The package orpie ships with its own
> gsl ocaml bindings and they cannot be compiled on hppa and sparc
> due to an alignment problem. I contacted upstream of orpie and
> got the following answer:
> <upstream says>
> I've looked into this a bit, and I'm not sure it can be fixed very
> easily. The OCaml bindings for libgsl avoid some expensive copy
> operations by making the assumption that the platform can accept double
> arrays aligned on word boundaries. Apparently hppa and sparc don't
> provide this capability.
> </upstream says>
Uh, what are meant by word binaries? If word is 32bit, then this is
false. If word means (not so absurd as it might sound as first, the
8086 had that as word size, so it sticks in some people's mind) is
16bit then this is indeed true. (And I am quite supprised that it only
fails on hppa and sparc, I'd have guessed it to fail on almost anything
but i386. (perhaps some other architectures only print warnings to
syslog instead of punishing it directly with a sigbus)).
What you can, even on sparc, is having 32 or even 64 bit quantities
aligned to 16 bit in packed structs (and perhaps arrays). But you
have to make sure you are not triggering undefined behaviour (which
means sigbus here) by giving away pointer to unaligned data, nor forget
that even an packages struct as a whole has an enforced alignment.
(so having an struct with something on an +2 offset and and pointer
to that struct which is not 0(mod 4) may mean the data is aliged but
the compiler think it is misaligned and you get a buserror).
Bernhard R. Link