On 2020-02-21 23:08, Jim Wilson wrote: > On Fri, Feb 21, 2020 at 9:38 AM J.W. Jagersma <jwjagersma@xxxxxxxxx> wrote: >>> Besides the performance loss, i386 doesn't have cmpxchg which means >>> atomic support will be a problem. Otherwise, it will probably work. >> >> I did notice that using i386, my program doesn't link at -O0 due to >> undefined references to __atomic_* builtins. Somehow it works at -O1 >> and above. It seems the only atomic operations I use are compiled to >> 'lock add/sub' instructions. > > Atomics are probably inline expanded with optimization. There is a > libatomic library you can link with, -latomic, that should implement > all atomics that aren't inline expanded. But I'm not sure exactly how > this works with a i386 toolchain given that cmpxchg is missing. > > Jim It seems libatomic is not available on x86, configure says the target is unsupported. I suppose on a single 386 (do 386 SMP systems even exist?) you could emulate any atomic operation just by disabling interrupts. Except maybe for memory-mapped devices where you do need a single instruction. So far I haven't needed that yet, anyway.