nisse@lysator.liu.se (Niels Möller) writes:
I haven't done the memory barrier thing yet, it appears to be more complicated than I had hoped. The manual I have say that the dmb instruction (data memory barrier) is available only with armv7 and later. And that armv6 uses writes to CP15 registers (I haven't yet tried to figure what that means out, or if this method works also on later versions).
I think I've found a simple solution. I deleted the initialized flag in fat_init, instead I let each caller read the particular function pointer it is interested in, and check if it is already properly initialized or not. I.e., check if the current value equals its static initializer, and if so, call fat_init.
This way, store order consistency between threads no longer matters, and we won't need any memory barriers.
I'd like to merge this code on the master branch soon. It would be nice if anyone else could give it a little testing, in particular on various ARM devices. I've tested it on a few different x86_64 pc:s and an ARMv7 pandaboard, all running gnu/linux.
Regards, /Niels