Skip to content

Commit

Permalink
remove ProcPin/ProcUnpin; see golang/go#27539
Browse files Browse the repository at this point in the history
  • Loading branch information
vizee committed Apr 7, 2019
1 parent 20dba8a commit a01840b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
5 changes: 4 additions & 1 deletion asm_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ func Scas64(addr *uint64, cnt int, v int) (ret int)
// lock

//go:noescape
func LockOr32(addr *uint32, val uint32)
func LockAnd32(addr *uint32, val uint32) (ret uint32)

//go:noescape
func LockOr32(addr *uint32, val uint32) (ret uint32)

//go:noescape
func LockCmpxchg8(addr *byte, cmp byte, val byte) (ok bool)
Expand Down
12 changes: 11 additions & 1 deletion asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ found:
MOVQ DX, ret+24(FP)
RET

// func LockAnd32(addr *uint32, val uint32) uint32
TEXT ·LockAnd32(SB), NOSPLIT, $0-20
MOVQ addr+0(FP), BP
MOVL val+8(FP), AX
LOCK
ANDL AX, (BP)
MOVL AX, ret+16(FP)
RET

// func LockOr32(addr *uint32, val uint32)
TEXT ·LockOr32(SB), NOSPLIT, $0-12
TEXT ·LockOr32(SB), NOSPLIT, $0-20
MOVQ addr+0(FP), BP
MOVL val+8(FP), AX
LOCK
ORL AX, (BP)
MOVL AX, ret+16(FP)
RET

// func LockCmpxchg8(addr *byte, cmp byte, val byte) (ok bool)
Expand Down
6 changes: 6 additions & 0 deletions asm_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func TestScas64(t *testing.T) {
t.Log(Scas64(&arr[0], len(arr), 4))
}

func TestLockAnd32(t *testing.T) {
v := uint32(1)
LockAnd32(&v, 2)
t.Log(v)
}

func TestLockOr32(t *testing.T) {
v := uint32(1)
LockOr32(&v, 2)
Expand Down
6 changes: 0 additions & 6 deletions hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ package hack

func TLS() uintptr

// runtime

func ProcPin() int

func ProcUnpin()

func Nanotime() int64
8 changes: 0 additions & 8 deletions hack/hack_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ TEXT ·TLS(SB), NOSPLIT, $8
MOVQ AX, ret+0(FP)
RET

// func ProcPin() int
TEXT ·ProcPin(SB), NOSPLIT, $0
JMP runtime·procPin(SB)

// func ProcUnpin()
TEXT ·ProcUnpin(SB), NOSPLIT, $0
JMP runtime·procUnpin(SB)

// func Nanotime()
TEXT ·Nanotime(SB), NOSPLIT, $0
JMP runtime·nanotime(SB)
20 changes: 0 additions & 20 deletions hack/hack_test.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
package hack

import (
"runtime"
"sync"
"testing"
)

func TestTLS(t *testing.T) {
t.Log(TLS())
}

func TestProcPin(t *testing.T) {
if runtime.NumCPU() == 1 {
runtime.GOMAXPROCS(2)
}

var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
n := ProcPin()
ProcUnpin()
t.Log(n)
wg.Done()
}()
}
wg.Wait()
}

func TestNanotime(t *testing.T) {
t.Log(Nanotime())
}

0 comments on commit a01840b

Please sign in to comment.