Commit 43c6e810 authored by Kirill Smelkov's avatar Kirill Smelkov

X runtime.GetCPU()

This way one can verify on which physical CPU the code is currently
running.
parent ab401077
......@@ -7,3 +7,13 @@
package runtime
func sbrk0() uintptr
func _getcpu() (cpu, node uint32, ret int32)
func GetCPU() (cpu, node uint32) {
cpu, node, ret := _getcpu()
//println("_getcpu ->", cpu, node, ret)
if ret != 0 {
throw("getcpu failed")
}
return cpu, node
}
......@@ -45,6 +45,7 @@
#define SYS_epoll_ctl 233
#define SYS_pselect6 270
#define SYS_epoll_create1 291
#define SYS_getcpu 309
TEXT runtime·exit(SB),NOSPLIT,$0-4
MOVL code+0(FP), DI
......@@ -659,3 +660,13 @@ TEXT runtime·sbrk0(SB),NOSPLIT,$0-8
SYSCALL
MOVQ AX, ret+0(FP)
RET
// func _getcpu() (cpu, node uint32, ret int32)
TEXT runtime·_getcpu(SB),NOSPLIT,$0
LEAQ cpu+0(FP), DI
LEAQ node+4(FP), SI
XORQ DX, DX // tcache
MOVL $SYS_getcpu, AX
SYSCALL
MOVL AX, ret+8(FP)
RET
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