Inlining std.atomic.AtomicFence

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed Jan 14 09:08:12 PST 2015


In LDC, how do we make std.atomic.atomicFence inline?

    void atomicFence() nothrow
    {
        llvm_memory_fence();
    }

I was working on fixing a race condition in the unittest for this module and the assembly for the unitest has a nice ARM dmb instructions (arm memory fence).  But then I had similar testcode in another module and atomicFence did not inline, even with -Os -inline.

Changing atomicFence to a template function does make it inline into a dmb instruction but that changes the core.atomic API I suppose.  Is there a better solution?
--
Dan


More information about the digitalmars-d-ldc mailing list