Paul Pluzhnikov wrote:
: "Manoj Pattanaik" <manoj.pattanaik@gmail.com> writes:
: > I have a C++ program which was giving an SIGBUS error due to unaligned
: > memory access in my code. Now my executable is running fine.
: If you get SIGBUS in debugger, your executable does not "run fine".
If Manoj says it's "running fine" who are we to argue? ;-)
Of course he could say "runs slow".
: If the code that generates SIGBUS is executed frequently, your exe
: is running horribly inefficiently, and you are patching over the
: problem with a hack. Couldn't you just fix the unaligned access in
: the first place?
If the performance is a problem, here are some of the things you can do:
http://docs.hp.com/en/7133/pragmas.htm#pragma-pack
There is +u# that makes every access slower, whether aligned or not.
There is the pack pragma that would only change certain structures.
Unfortunately, if you pass the address of an unaligned member to another
lib, like libc, you can only use allow_unaligned_data_access.
Note on IPF, unaligned access is orders of magnitude faster because it is
either handled directly by the hardware by the kernel without a user
signal handler.