runtime_go1.5.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2016 Peter Mattis.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. // implied. See the License for the specific language governing
  13. // permissions and limitations under the License. See the AUTHORS file
  14. // for names of contributors.
  15. //go:build go1.5 && !go1.6
  16. // +build go1.5,!go1.6
  17. package goid
  18. // Just enough of the structs from runtime/runtime2.go to get the offset to goid.
  19. // See https://github.com/golang/go/blob/release-branch.go1.5/src/runtime/runtime2.go
  20. type stack struct {
  21. lo uintptr
  22. hi uintptr
  23. }
  24. type gobuf struct {
  25. sp uintptr
  26. pc uintptr
  27. g uintptr
  28. ctxt uintptr
  29. ret uintptr
  30. lr uintptr
  31. bp uintptr
  32. }
  33. type g struct {
  34. stack stack
  35. stackguard0 uintptr
  36. stackguard1 uintptr
  37. _panic uintptr
  38. _defer uintptr
  39. m uintptr
  40. stackAlloc uintptr
  41. sched gobuf
  42. syscallsp uintptr
  43. syscallpc uintptr
  44. stkbar []uintptr
  45. stkbarPos uintptr
  46. param uintptr
  47. atomicstatus uint32
  48. stackLock uint32
  49. goid int64 // Here it is!
  50. }