github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/runtime/atomic_386.c (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "runtime.h" 6 #include "../../cmd/ld/textflag.h" 7 8 #pragma textflag NOSPLIT 9 uint32 10 runtime·atomicload(uint32 volatile* addr) 11 { 12 return *addr; 13 } 14 15 #pragma textflag NOSPLIT 16 void* 17 runtime·atomicloadp(void* volatile* addr) 18 { 19 return *addr; 20 } 21 22 #pragma textflag NOSPLIT 23 uint64 24 runtime·xadd64(uint64 volatile* addr, int64 v) 25 { 26 uint64 old; 27 28 do 29 old = *addr; 30 while(!runtime·cas64(addr, old, old+v)); 31 32 return old+v; 33 } 34 35 #pragma textflag NOSPLIT 36 uint64 37 runtime·xchg64(uint64 volatile* addr, uint64 v) 38 { 39 uint64 old; 40 41 do 42 old = *addr; 43 while(!runtime·cas64(addr, old, v)); 44 45 return old; 46 }