Skip to content

Commit

Permalink
add comment for goid.s
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Apr 22, 2024
1 parent 8590a45 commit d1969fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions goid.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#include "textflag.h"

// After go1.9, goid in "goroutine struct" has a stable offset.
// See https://github.com/golang/go/blob/master/src/runtime/runtime2.go#L436
//
// This file exposes "goid()" function by
// 1. get current "g" pointer,
// 2. extract goid with a hardcoded offset.
// *) for GOARCH amd64/arm64, offset=152, size=8.
// *) for GOARCH arm/386, offset=80, size=4.
//

#ifdef GOARCH_amd64
TEXT ·goid(SB),NOSPLIT,$0-8
MOVQ (TLS), R14
Expand Down

0 comments on commit d1969fb

Please sign in to comment.