github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/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  
     7  #pragma textflag 7
     8  uint32
     9  runtime·atomicload(uint32 volatile* addr)
    10  {
    11  	return *addr;
    12  }
    13  
    14  #pragma textflag 7
    15  void*
    16  runtime·atomicloadp(void* volatile* addr)
    17  {
    18  	return *addr;
    19  }
    20  
    21  #pragma textflag 7
    22  uint64
    23  runtime·xadd64(uint64 volatile* addr, int64 v)
    24  {
    25  	uint64 old;
    26  
    27  	old = *addr;
    28  	while(!runtime·cas64(addr, &old, old+v)) {
    29  		// nothing
    30  	}
    31  	return old+v;
    32  }
    33  
    34  #pragma textflag 7
    35  uint64
    36  runtime·xchg64(uint64 volatile* addr, uint64 v)
    37  {
    38  	uint64 old;
    39  
    40  	old = *addr;
    41  	while(!runtime·cas64(addr, &old, v)) {
    42  		// nothing
    43  	}
    44  	return old;
    45  }