When disassembling my program I noticed that;
while (!block->meta.lock);
would be compiled into;
0x0040167f <+111>: jmp 0x40167f <gc_malloc+111>
Clearly this is a useless infinite loop. I'm using C99 so I can't make it volatile.
My current solution:
while (!block->meta.lock) {
__sync_synchronize();
}
This generates a lot of extra assembly. What I'm really trying to generate is the equivalent of a rep nop
lock;
See What does "rep; nop;" mean in x86 assembly?
How can I hint this to gcc?