github.com/gogf/gkafka@v1.0.1-0.20190702070843-033a14468069/third/golang.org/x/sys/windows/svc/go13.go (about) 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. 4 5 // +build windows 6 // +build go1.3 7 8 package svc 9 10 import "unsafe" 11 12 const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 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) 17 } 18 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)) 23 } 24 25 // from sys_386.s and sys_amd64.s 26 func servicectlhandler(ctl uint32) uintptr 27 func servicemain(argc uint32, argv **uint16) 28 29 func getServiceMain(r *uintptr) { 30 *r = funcPC(servicemain) 31 }