2011-06-28 13:09:53 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2013-08-12 14:47:18 -06:00
|
|
|
#include "../../cmd/ld/textflag.h"
|
2011-06-28 13:09:53 -06:00
|
|
|
|
2013-08-12 14:47:18 -06:00
|
|
|
#pragma textflag NOSPLIT
|
2011-06-28 13:09:53 -06:00
|
|
|
uint32
|
|
|
|
runtime·atomicload(uint32 volatile* addr)
|
|
|
|
{
|
|
|
|
return *addr;
|
|
|
|
}
|
2011-07-13 12:22:41 -06:00
|
|
|
|
2013-08-12 14:47:18 -06:00
|
|
|
#pragma textflag NOSPLIT
|
2011-07-13 12:22:41 -06:00
|
|
|
void*
|
|
|
|
runtime·atomicloadp(void* volatile* addr)
|
|
|
|
{
|
|
|
|
return *addr;
|
|
|
|
}
|
2012-04-05 08:47:43 -06:00
|
|
|
|
2013-08-12 14:47:18 -06:00
|
|
|
#pragma textflag NOSPLIT
|
2012-04-05 08:47:43 -06:00
|
|
|
uint64
|
|
|
|
runtime·xadd64(uint64 volatile* addr, int64 v)
|
|
|
|
{
|
|
|
|
uint64 old;
|
|
|
|
|
2013-07-11 22:03:32 -06:00
|
|
|
do
|
|
|
|
old = *addr;
|
|
|
|
while(!runtime·cas64(addr, old, old+v));
|
|
|
|
|
2012-04-05 08:47:43 -06:00
|
|
|
return old+v;
|
|
|
|
}
|
2013-03-05 00:46:52 -07:00
|
|
|
|
2013-08-12 14:47:18 -06:00
|
|
|
#pragma textflag NOSPLIT
|
2013-03-05 00:46:52 -07:00
|
|
|
uint64
|
|
|
|
runtime·xchg64(uint64 volatile* addr, uint64 v)
|
|
|
|
{
|
|
|
|
uint64 old;
|
|
|
|
|
2013-07-11 22:03:32 -06:00
|
|
|
do
|
2013-07-11 22:42:46 -06:00
|
|
|
old = *addr;
|
2013-07-11 22:03:32 -06:00
|
|
|
while(!runtime·cas64(addr, old, v));
|
|
|
|
|
2013-03-05 00:46:52 -07:00
|
|
|
return old;
|
|
|
|
}
|