0

when i explore the mutex lock function implemtion in go .

func (m *Mutex) Lock()

I find some function called in this method which without function body .

func runtime_canSpin(i int) bool   // in sync/runtime.go
func runtime_doSpin()

I want to find the code and login with these method . But i only can find something like this in https://golang.org/ref/spec#Function_declarations

A function declaration may omit the body. Such a declaration provides the signature for a function implemented outside Go, such as an assembly routine.

what can i do to find the code hidden?

郑卓彬
  • 11
  • 1
  • The code is not "hidden", these functions often are implemented in assembly (in which case look at the .s files) or are kinda renamed with the go:linkname directive (see runtime/proc.go for sync_runtime_doSpin()). – Volker Apr 04 '18 at 06:51
  • The function is [defined here](https://github.com/golang/go/blob/00fab20582abc614dcf31ca444b4275240de9ae6/src/runtime/proc.go#L4919-L4922) using go:linkname. – Charlie Tumahai Apr 04 '18 at 07:01
  • thanks , i know go likename now . – 郑卓彬 Apr 04 '18 at 07:10

0 Answers0