Commit 9788e3d4 authored by Vladimir Stefanovic's avatar Vladimir Stefanovic Committed by Brad Fitzpatrick

sync/atomic: add support for GOARCH=mips{,le}

Change-Id: I10f36710dd95b9bd31b3b82a3c32edcadb90ffa9
Reviewed-on: https://go-review.googlesource.com/31510
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent b241a064
......@@ -7,6 +7,7 @@ package atomic_test
import (
"runtime"
"runtime/internal/atomic"
"runtime/internal/sys"
"testing"
"unsafe"
)
......@@ -51,13 +52,13 @@ func TestXadduintptr(t *testing.T) {
// Tests that xadduintptr correctly updates 64-bit values. The place where
// we actually do so is mstats.go, functions mSysStat{Inc,Dec}.
func TestXadduintptrOnUint64(t *testing.T) {
/* if runtime.BigEndian != 0 {
if sys.BigEndian != 0 {
// On big endian architectures, we never use xadduintptr to update
// 64-bit values and hence we skip the test. (Note that functions
// mSysStat{Inc,Dec} in mstats.go have explicit checks for
// big-endianness.)
return
}*/
t.Skip("skip xadduintptr on big endian architecture")
}
const inc = 100
val := uint64(0)
atomic.Xadduintptr((*uintptr)(unsafe.Pointer(&val)), inc)
......
// Copyright 2016 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.
// +build mips mipsle
#include "textflag.h"
TEXT ·SwapInt32(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Xchg(SB)
TEXT ·SwapUint32(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Xchg(SB)
TEXT ·SwapInt64(SB),NOSPLIT,$0-24
JMP runtimeinternalatomic·Xchg64(SB)
TEXT ·SwapUint64(SB),NOSPLIT,$0-24
JMP runtimeinternalatomic·Xchg64(SB)
TEXT ·SwapUintptr(SB),NOSPLIT,$0-20
JMP runtimeinternalatomic·Xchg(SB)
TEXT ·CompareAndSwapInt32(SB),NOSPLIT,$0-13
JMP runtimeinternalatomic·Cas(SB)
TEXT ·CompareAndSwapUint32(SB),NOSPLIT,$0-13
JMP runtimeinternalatomic·Cas(SB)
TEXT ·CompareAndSwapUintptr(SB),NOSPLIT,$0-13
JMP runtimeinternalatomic·Cas(SB)
TEXT ·CompareAndSwapInt64(SB),NOSPLIT,$0-21
JMP runtimeinternalatomic·Cas64(SB)
TEXT ·CompareAndSwapUint64(SB),NOSPLIT,$0-21
JMP runtimeinternalatomic·Cas64(SB)
TEXT ·AddInt32(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Xadd(SB)
TEXT ·AddUint32(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Xadd(SB)
TEXT ·AddUintptr(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Xadd(SB)
TEXT ·AddInt64(SB),NOSPLIT,$0-20
JMP runtimeinternalatomic·Xadd64(SB)
TEXT ·AddUint64(SB),NOSPLIT,$0-20
JMP runtimeinternalatomic·Xadd64(SB)
TEXT ·LoadInt32(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Load(SB)
TEXT ·LoadUint32(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Load(SB)
TEXT ·LoadInt64(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Load64(SB)
TEXT ·LoadUint64(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Load64(SB)
TEXT ·LoadUintptr(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Load(SB)
TEXT ·LoadPointer(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Load(SB)
TEXT ·StoreInt32(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Store(SB)
TEXT ·StoreUint32(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Store(SB)
TEXT ·StoreInt64(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Store64(SB)
TEXT ·StoreUint64(SB),NOSPLIT,$0-12
JMP runtimeinternalatomic·Store64(SB)
TEXT ·StoreUintptr(SB),NOSPLIT,$0-8
JMP runtimeinternalatomic·Store(SB)
......@@ -1389,12 +1389,15 @@ func TestUnaligned64(t *testing.T) {
// Unaligned 64-bit atomics on 32-bit systems are
// a continual source of pain. Test that on 32-bit systems they crash
// instead of failing silently.
switch runtime.GOARCH {
default:
if unsafe.Sizeof(int(0)) != 4 {
t.Skip("test only runs on 32-bit systems")
}
if runtime.GOARCH == "amd64p32" {
// amd64p32 can handle unaligned atomics.
t.Skip("test not needed on amd64p32")
case "amd64p32", "mips", "mipsle":
// amd64p32 and mips can handle unaligned atomics.
t.Skipf("test not needed on %v", runtime.GOARCH)
}
x := make([]uint32, 4)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment