~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/gabriel-samfira/sys/windows/svc/go13.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}