xant/libhl

ATOMIC_CAS cann't work on ARM

Closed this issue · 4 comments

luokj commented

Use hash function on ARM platform, but it crash when callinig ht_create

xant commented

ATOMIC_CAS makes use of __sync_bool_compare_and_swap which I believe it's provided by the compiler also on ARM. Could you provide the exception and the stacktrace (and maybe a coredump) for your crash?

xant commented

@luokj I think I understand what is your problem.
If it is crashing at runtime with an "Unhandled fault: Alignment Exception",
adding "-mno-unaligned-access" to CFLAGS should fix.
I'll check myself when I'll have access again to a linux ARM system.
Note that maybe on linux you can configure the linux kernel at runtime (/proc/cpu/alignment) to ignore the exception and don't kill the process.

luokj commented
xant commented

Ok, packing some structures was overriding the natural alignment and obviously making it not work on ARM unless the "-maligned-access" option was passed to the compiler (but then with obvious performance loss because of unaligned memory access)
I just made packing of those structure optional and controlled by the USE_PACKED_STRUCTURES preprocessor symbol.

Fixed in 172f5a