File: stack_tags_main.go

package info (click to toggle)
golang-github-jtolds-gls 4.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 92 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// +build !js

package gls

// This file is used for standard Go builds, which have the expected runtime
// support

import (
	"runtime"
)

var (
	findPtr = func() uintptr {
		var pc [1]uintptr
		n := runtime.Callers(4, pc[:])
		if n != 1 {
			panic("failed to find function pointer")
		}
		return pc[0]
	}

	getStack = func(offset, amount int) (stack []uintptr, next_offset int) {
		stack = make([]uintptr, amount)
		stack = stack[:runtime.Callers(offset, stack)]
		if len(stack) < amount {
			return stack, 0
		}
		return stack, offset + len(stack)
	}
)