1# mach: bpf 2# output: pass\nexit 0 (0x0)\n 3/* xadd.s 4 Tests for BPF atomic exchange-and-add instructions in simulator 5 6 The xadd instructions (XADDW, XADDDW) operate on a memory location 7 specified in $dst + offset16, atomically adding the value in $src. 8 9 In the simulator, there isn't anything else happening. The atomic 10 instructions are identical to a non-atomic load/add/store. */ 11 12 .include "testutils.inc" 13 14 .text 15 .global main 16 .type main, @function 17main: 18 mov %r1, 0x1000 19 mov %r2, 5 20 21 /* basic xadd w */ 22 stw [%r1+0], 10 23 xaddw [%r1+0], %r2 24 ldxw %r3, [%r1+0] 25 fail_ne %r3, 15 26 27 /* basic xadd dw */ 28 stdw [%r1+8], 42 29 xadddw [%r1+8], %r2 30 ldxdw %r3, [%r1+8] 31 fail_ne %r3, 47 32 33 /* xadd w negative value */ 34 mov %r4, -1 35 xaddw [%r1+0], %r4 36 ldxw %r3, [%r1+0] 37 fail_ne %r3, 14 38 39 /* xadd dw negative val */ 40 xadddw [%r1+8], %r4 41 ldxdw %r3, [%r1+8] 42 fail_ne %r3, 46 43 44 pass 45