1
// Copyright 2014 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
14
// Should be a built-in for unsafe.Pointer?
15
func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
16
return unsafe.Pointer(uintptr(p) + x)
19
// funcPC returns the entry PC of the function f.
20
// It assumes that f is a func value. Otherwise the behavior is undefined.
21
func funcPC(f interface{}) uintptr {
22
return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize))
25
// from sys_386.s and sys_amd64.s
26
func servicectlhandler(ctl uint32) uintptr
27
func servicemain(argc uint32, argv **uint16)
29
func getServiceMain(r *uintptr) {
30
*r = funcPC(servicemain)