[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 31 10:58:48 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #4 from Jonathan Dunlap <jadit2 at gmail.com> ---
I'm having an issue adding an asm block for the fast increment by operation.
It's been awhile since I've used asm productively so I'm probably missing
something simple.

HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) pure
nothrow @nogc
        if( __traits( compiles, mixin( "*cast(T*)&val" ~ op ~ "mod" ) ) )
[....]
get = set = atomicLoad!(MemoryOrder.raw)( val );

auto setptr = &set;
static if(op == "+=") {
  // qword ptr
  asm pure nothrow @nogc
  {
    mov EAX, mod;    //:678
    mov EDX, setptr; //:679
    lock; 
    xadd [EDX], EAX;
  }
}

Error:
src/core/atomic.d(678): Error: bad type/size of operands 'mov'
src/core/atomic.d(679): Error: bad type/size of operands 'mov'

--


More information about the Digitalmars-d-bugs mailing list