Merge pull request #3063 from zhsj/fix-mipsx

Use unix.SignalNum in ParseSignal on unix platform
This commit is contained in:
Michael Crosby 2019-03-04 11:31:16 -06:00 committed by GitHub
commit 30b6f460b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 873 additions and 263 deletions

View File

@ -1,60 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package containerd
import (
"syscall"
"golang.org/x/sys/unix"
)
var signalMap = map[string]syscall.Signal{
"ABRT": unix.SIGABRT,
"ALRM": unix.SIGALRM,
"BUS": unix.SIGBUS,
"CHLD": unix.SIGCHLD,
"CLD": unix.SIGCLD,
"CONT": unix.SIGCONT,
"FPE": unix.SIGFPE,
"HUP": unix.SIGHUP,
"ILL": unix.SIGILL,
"INT": unix.SIGINT,
"IO": unix.SIGIO,
"IOT": unix.SIGIOT,
"KILL": unix.SIGKILL,
"PIPE": unix.SIGPIPE,
"POLL": unix.SIGPOLL,
"PROF": unix.SIGPROF,
"PWR": unix.SIGPWR,
"QUIT": unix.SIGQUIT,
"SEGV": unix.SIGSEGV,
"STKFLT": unix.SIGSTKFLT,
"STOP": unix.SIGSTOP,
"SYS": unix.SIGSYS,
"TERM": unix.SIGTERM,
"TRAP": unix.SIGTRAP,
"TSTP": unix.SIGTSTP,
"TTIN": unix.SIGTTIN,
"TTOU": unix.SIGTTOU,
"URG": unix.SIGURG,
"USR1": unix.SIGUSR1,
"USR2": unix.SIGUSR2,
"VTALRM": unix.SIGVTALRM,
"WINCH": unix.SIGWINCH,
"XCPU": unix.SIGXCPU,
"XFSZ": unix.SIGXFSZ,
}

View File

@ -1,58 +0,0 @@
// +build darwin freebsd solaris
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package containerd
import (
"syscall"
"golang.org/x/sys/unix"
)
var signalMap = map[string]syscall.Signal{
"ABRT": unix.SIGABRT,
"ALRM": unix.SIGALRM,
"BUS": unix.SIGBUS,
"CHLD": unix.SIGCHLD,
"CONT": unix.SIGCONT,
"FPE": unix.SIGFPE,
"HUP": unix.SIGHUP,
"ILL": unix.SIGILL,
"INT": unix.SIGINT,
"IO": unix.SIGIO,
"IOT": unix.SIGIOT,
"KILL": unix.SIGKILL,
"PIPE": unix.SIGPIPE,
"PROF": unix.SIGPROF,
"QUIT": unix.SIGQUIT,
"SEGV": unix.SIGSEGV,
"STOP": unix.SIGSTOP,
"SYS": unix.SIGSYS,
"TERM": unix.SIGTERM,
"TRAP": unix.SIGTRAP,
"TSTP": unix.SIGTSTP,
"TTIN": unix.SIGTTIN,
"TTOU": unix.SIGTTOU,
"URG": unix.SIGURG,
"USR1": unix.SIGUSR1,
"USR2": unix.SIGUSR2,
"VTALRM": unix.SIGVTALRM,
"WINCH": unix.SIGWINCH,
"XCPU": unix.SIGXCPU,
"XFSZ": unix.SIGXFSZ,
}

View File

@ -20,13 +20,11 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
"strings"
"syscall" "syscall"
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/opencontainers/image-spec/specs-go/v1" v1 "github.com/opencontainers/image-spec/specs-go/v1"
) )
// StopSignalLabel is a well-known containerd label for storing the stop // StopSignalLabel is a well-known containerd label for storing the stop
@ -83,23 +81,3 @@ func GetOCIStopSignal(ctx context.Context, image Image, defaultSignal string) (s
return config.StopSignal, nil return config.StopSignal, nil
} }
// ParseSignal parses a given string into a syscall.Signal
// it checks that the signal exists in the platform-appropriate signalMap
func ParseSignal(rawSignal string) (syscall.Signal, error) {
s, err := strconv.Atoi(rawSignal)
if err == nil {
sig := syscall.Signal(s)
for _, msig := range signalMap {
if sig == msig {
return sig, nil
}
}
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
signal, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
if !ok {
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
return signal, nil
}

47
signals_test.go Normal file
View File

@ -0,0 +1,47 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package containerd
import (
"fmt"
"syscall"
"testing"
)
func TestParseSignal(t *testing.T) {
testSignals := []struct {
raw string
want syscall.Signal
err bool
}{
{"1", syscall.Signal(1), false},
{"SIGKILL", syscall.SIGKILL, false},
{"NONEXIST", 0, true},
{"65536", 0, true},
}
for _, ts := range testSignals {
t.Run(fmt.Sprintf("%s/%d/%t", ts.raw, ts.want, ts.err), func(t *testing.T) {
got, err := ParseSignal(ts.raw)
if ts.err && err == nil {
t.Errorf("ParseSignal(%s) should return error", ts.raw)
}
if !ts.err && got != ts.want {
t.Errorf("ParseSignal(%s) return %d, want %d", ts.raw, got, ts.want)
}
})
}
}

47
signals_unix.go Normal file
View File

@ -0,0 +1,47 @@
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package containerd
import (
"fmt"
"strconv"
"strings"
"syscall"
"golang.org/x/sys/unix"
)
// ParseSignal parses a given string into a syscall.Signal
// the rawSignal can be a string with "SIG" prefix,
// or a signal number in string format.
func ParseSignal(rawSignal string) (syscall.Signal, error) {
s, err := strconv.Atoi(rawSignal)
if err == nil {
signal := syscall.Signal(s)
if unix.SignalName(signal) != "" {
return signal, nil
}
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
signal := unix.SignalNum(strings.ToUpper(rawSignal))
if signal == 0 {
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
return signal, nil
}

View File

@ -17,6 +17,9 @@
package containerd package containerd
import ( import (
"fmt"
"strconv"
"strings"
"syscall" "syscall"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
@ -37,3 +40,24 @@ var signalMap = map[string]syscall.Signal{
"ALRM": syscall.Signal(windows.SIGALRM), "ALRM": syscall.Signal(windows.SIGALRM),
"TERM": syscall.Signal(windows.SIGTERM), "TERM": syscall.Signal(windows.SIGTERM),
} }
// ParseSignal parses a given string into a syscall.Signal
// the rawSignal can be a string with "SIG" prefix,
// or a signal number in string format.
func ParseSignal(rawSignal string) (syscall.Signal, error) {
s, err := strconv.Atoi(rawSignal)
if err == nil {
sig := syscall.Signal(s)
for _, msig := range signalMap {
if sig == msig {
return sig, nil
}
}
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
signal, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
if !ok {
return -1, fmt.Errorf("unknown signal %q", rawSignal)
}
return signal, nil
}

View File

@ -28,7 +28,7 @@ golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac
google.golang.org/grpc v1.12.0 google.golang.org/grpc v1.12.0
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7 github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
golang.org/x/sys 41f3e6584952bb034a481797859f6ab34b6803bd https://github.com/golang/sys golang.org/x/sys d455e41777fca6e8a5a79e34a14b8368bc11d9ba https://github.com/golang/sys
github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/image-spec v1.0.1
golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895

30
vendor/golang.org/x/sys/cpu/byteorder.go generated vendored Normal file
View File

@ -0,0 +1,30 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
import (
"encoding/binary"
"runtime"
)
// hostByteOrder returns binary.LittleEndian on little-endian machines and
// binary.BigEndian on big-endian machines.
func hostByteOrder() binary.ByteOrder {
switch runtime.GOARCH {
case "386", "amd64", "amd64p32",
"arm", "arm64",
"mipsle", "mips64le", "mips64p32le",
"ppc64le",
"riscv", "riscv64":
return binary.LittleEndian
case "armbe", "arm64be",
"mips", "mips64", "mips64p32",
"ppc", "ppc64",
"s390", "s390x",
"sparc", "sparc64":
return binary.BigEndian
}
panic("unknown architecture")
}

37
vendor/golang.org/x/sys/cpu/cpu.go generated vendored
View File

@ -6,6 +6,13 @@
// various CPU architectures. // various CPU architectures.
package cpu package cpu
// Initialized reports whether the CPU features were initialized.
//
// For some GOOS/GOARCH combinations initialization of the CPU features depends
// on reading an operating specific file, e.g. /proc/self/auxv on linux/arm
// Initialized will report false if reading the file fails.
var Initialized bool
// CacheLinePad is used to pad structs to avoid false sharing. // CacheLinePad is used to pad structs to avoid false sharing.
type CacheLinePad struct{ _ [cacheLineSize]byte } type CacheLinePad struct{ _ [cacheLineSize]byte }
@ -87,3 +94,33 @@ var PPC64 struct {
IsPOWER9 bool // ISA v3.00 (POWER9) IsPOWER9 bool // ISA v3.00 (POWER9)
_ CacheLinePad _ CacheLinePad
} }
// S390X contains the supported CPU features of the current IBM Z
// (s390x) platform. If the current platform is not IBM Z then all
// feature flags are false.
//
// S390X is padded to avoid false sharing. Further HasVX is only set
// if the OS supports vector registers in addition to the STFLE
// feature bit being set.
var S390X struct {
_ CacheLinePad
HasZARCH bool // z/Architecture mode is active [mandatory]
HasSTFLE bool // store facility list extended
HasLDISP bool // long (20-bit) displacements
HasEIMM bool // 32-bit immediates
HasDFP bool // decimal floating point
HasETF3EH bool // ETF-3 enhanced
HasMSA bool // message security assist (CPACF)
HasAES bool // KM-AES{128,192,256} functions
HasAESCBC bool // KMC-AES{128,192,256} functions
HasAESCTR bool // KMCTR-AES{128,192,256} functions
HasAESGCM bool // KMA-GCM-AES{128,192,256} functions
HasGHASH bool // KIMD-GHASH function
HasSHA1 bool // K{I,L}MD-SHA-1 functions
HasSHA256 bool // K{I,L}MD-SHA-256 functions
HasSHA512 bool // K{I,L}MD-SHA-512 functions
HasSHA3 bool // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions
HasVX bool // vector facility
HasVXE bool // vector-enhancements facility 1
_ CacheLinePad
}

View File

@ -1,67 +0,0 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
const cacheLineSize = 64
// HWCAP/HWCAP2 bits. These are exposed by Linux.
const (
hwcap_FP = 1 << 0
hwcap_ASIMD = 1 << 1
hwcap_EVTSTRM = 1 << 2
hwcap_AES = 1 << 3
hwcap_PMULL = 1 << 4
hwcap_SHA1 = 1 << 5
hwcap_SHA2 = 1 << 6
hwcap_CRC32 = 1 << 7
hwcap_ATOMICS = 1 << 8
hwcap_FPHP = 1 << 9
hwcap_ASIMDHP = 1 << 10
hwcap_CPUID = 1 << 11
hwcap_ASIMDRDM = 1 << 12
hwcap_JSCVT = 1 << 13
hwcap_FCMA = 1 << 14
hwcap_LRCPC = 1 << 15
hwcap_DCPOP = 1 << 16
hwcap_SHA3 = 1 << 17
hwcap_SM3 = 1 << 18
hwcap_SM4 = 1 << 19
hwcap_ASIMDDP = 1 << 20
hwcap_SHA512 = 1 << 21
hwcap_SVE = 1 << 22
hwcap_ASIMDFHM = 1 << 23
)
func doinit() {
// HWCAP feature bits
ARM64.HasFP = isSet(HWCap, hwcap_FP)
ARM64.HasASIMD = isSet(HWCap, hwcap_ASIMD)
ARM64.HasEVTSTRM = isSet(HWCap, hwcap_EVTSTRM)
ARM64.HasAES = isSet(HWCap, hwcap_AES)
ARM64.HasPMULL = isSet(HWCap, hwcap_PMULL)
ARM64.HasSHA1 = isSet(HWCap, hwcap_SHA1)
ARM64.HasSHA2 = isSet(HWCap, hwcap_SHA2)
ARM64.HasCRC32 = isSet(HWCap, hwcap_CRC32)
ARM64.HasATOMICS = isSet(HWCap, hwcap_ATOMICS)
ARM64.HasFPHP = isSet(HWCap, hwcap_FPHP)
ARM64.HasASIMDHP = isSet(HWCap, hwcap_ASIMDHP)
ARM64.HasCPUID = isSet(HWCap, hwcap_CPUID)
ARM64.HasASIMDRDM = isSet(HWCap, hwcap_ASIMDRDM)
ARM64.HasJSCVT = isSet(HWCap, hwcap_JSCVT)
ARM64.HasFCMA = isSet(HWCap, hwcap_FCMA)
ARM64.HasLRCPC = isSet(HWCap, hwcap_LRCPC)
ARM64.HasDCPOP = isSet(HWCap, hwcap_DCPOP)
ARM64.HasSHA3 = isSet(HWCap, hwcap_SHA3)
ARM64.HasSM3 = isSet(HWCap, hwcap_SM3)
ARM64.HasSM4 = isSet(HWCap, hwcap_SM4)
ARM64.HasASIMDDP = isSet(HWCap, hwcap_ASIMDDP)
ARM64.HasSHA512 = isSet(HWCap, hwcap_SHA512)
ARM64.HasSVE = isSet(HWCap, hwcap_SVE)
ARM64.HasASIMDFHM = isSet(HWCap, hwcap_ASIMDFHM)
}
func isSet(hwc uint, value uint) bool {
return hwc&value != 0
}

21
vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go generated vendored Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !gccgo
package cpu
// haveAsmFunctions reports whether the other functions in this file can
// be safely called.
func haveAsmFunctions() bool { return true }
// The following feature detection functions are defined in cpu_s390x.s.
// They are likely to be expensive to call so the results should be cached.
func stfle() facilityList
func kmQuery() queryResult
func kmcQuery() queryResult
func kmctrQuery() queryResult
func kmaQuery() queryResult
func kimdQuery() queryResult
func klmdQuery() queryResult

22
vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go generated vendored Normal file
View File

@ -0,0 +1,22 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build gccgo
package cpu
// haveAsmFunctions reports whether the other functions in this file can
// be safely called.
func haveAsmFunctions() bool { return false }
// TODO(mundaym): the following feature detection functions are currently
// stubs. See https://golang.org/cl/162887 for how to fix this.
// They are likely to be expensive to call so the results should be cached.
func stfle() facilityList { panic("not implemented for gccgo") }
func kmQuery() queryResult { panic("not implemented for gccgo") }
func kmcQuery() queryResult { panic("not implemented for gccgo") }
func kmctrQuery() queryResult { panic("not implemented for gccgo") }
func kmaQuery() queryResult { panic("not implemented for gccgo") }
func kimdQuery() queryResult { panic("not implemented for gccgo") }
func klmdQuery() queryResult { panic("not implemented for gccgo") }

View File

@ -7,9 +7,7 @@
package cpu package cpu
import ( import (
"encoding/binary"
"io/ioutil" "io/ioutil"
"runtime"
) )
const ( const (
@ -18,44 +16,44 @@ const (
procAuxv = "/proc/self/auxv" procAuxv = "/proc/self/auxv"
uintSize uint = 32 << (^uint(0) >> 63) uintSize = int(32 << (^uint(0) >> 63))
) )
// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2 // For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
// These are initialized in cpu_$GOARCH.go // These are initialized in cpu_$GOARCH.go
// and should not be changed after they are initialized. // and should not be changed after they are initialized.
var HWCap uint var hwCap uint
var HWCap2 uint var hwCap2 uint
func init() { func init() {
buf, err := ioutil.ReadFile(procAuxv) buf, err := ioutil.ReadFile(procAuxv)
if err != nil { if err != nil {
panic("read proc auxv failed: " + err.Error()) // e.g. on android /proc/self/auxv is not accessible, so silently
// ignore the error and leave Initialized = false
return
} }
pb := int(uintSize / 8) bo := hostByteOrder()
for len(buf) >= 2*(uintSize/8) {
for i := 0; i < len(buf)-pb*2; i += pb * 2 {
var tag, val uint var tag, val uint
switch uintSize { switch uintSize {
case 32: case 32:
tag = uint(binary.LittleEndian.Uint32(buf[i:])) tag = uint(bo.Uint32(buf[0:]))
val = uint(binary.LittleEndian.Uint32(buf[i+pb:])) val = uint(bo.Uint32(buf[4:]))
buf = buf[8:]
case 64: case 64:
if runtime.GOARCH == "ppc64" { tag = uint(bo.Uint64(buf[0:]))
tag = uint(binary.BigEndian.Uint64(buf[i:])) val = uint(bo.Uint64(buf[8:]))
val = uint(binary.BigEndian.Uint64(buf[i+pb:])) buf = buf[16:]
} else {
tag = uint(binary.LittleEndian.Uint64(buf[i:]))
val = uint(binary.LittleEndian.Uint64(buf[i+pb:]))
}
} }
switch tag { switch tag {
case _AT_HWCAP: case _AT_HWCAP:
HWCap = val hwCap = val
case _AT_HWCAP2: case _AT_HWCAP2:
HWCap2 = val hwCap2 = val
} }
} }
doinit() doinit()
Initialized = true
} }

67
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go generated vendored Normal file
View File

@ -0,0 +1,67 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
const cacheLineSize = 64
// HWCAP/HWCAP2 bits. These are exposed by Linux.
const (
hwcap_FP = 1 << 0
hwcap_ASIMD = 1 << 1
hwcap_EVTSTRM = 1 << 2
hwcap_AES = 1 << 3
hwcap_PMULL = 1 << 4
hwcap_SHA1 = 1 << 5
hwcap_SHA2 = 1 << 6
hwcap_CRC32 = 1 << 7
hwcap_ATOMICS = 1 << 8
hwcap_FPHP = 1 << 9
hwcap_ASIMDHP = 1 << 10
hwcap_CPUID = 1 << 11
hwcap_ASIMDRDM = 1 << 12
hwcap_JSCVT = 1 << 13
hwcap_FCMA = 1 << 14
hwcap_LRCPC = 1 << 15
hwcap_DCPOP = 1 << 16
hwcap_SHA3 = 1 << 17
hwcap_SM3 = 1 << 18
hwcap_SM4 = 1 << 19
hwcap_ASIMDDP = 1 << 20
hwcap_SHA512 = 1 << 21
hwcap_SVE = 1 << 22
hwcap_ASIMDFHM = 1 << 23
)
func doinit() {
// HWCAP feature bits
ARM64.HasFP = isSet(hwCap, hwcap_FP)
ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
ARM64.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM)
ARM64.HasAES = isSet(hwCap, hwcap_AES)
ARM64.HasPMULL = isSet(hwCap, hwcap_PMULL)
ARM64.HasSHA1 = isSet(hwCap, hwcap_SHA1)
ARM64.HasSHA2 = isSet(hwCap, hwcap_SHA2)
ARM64.HasCRC32 = isSet(hwCap, hwcap_CRC32)
ARM64.HasATOMICS = isSet(hwCap, hwcap_ATOMICS)
ARM64.HasFPHP = isSet(hwCap, hwcap_FPHP)
ARM64.HasASIMDHP = isSet(hwCap, hwcap_ASIMDHP)
ARM64.HasCPUID = isSet(hwCap, hwcap_CPUID)
ARM64.HasASIMDRDM = isSet(hwCap, hwcap_ASIMDRDM)
ARM64.HasJSCVT = isSet(hwCap, hwcap_JSCVT)
ARM64.HasFCMA = isSet(hwCap, hwcap_FCMA)
ARM64.HasLRCPC = isSet(hwCap, hwcap_LRCPC)
ARM64.HasDCPOP = isSet(hwCap, hwcap_DCPOP)
ARM64.HasSHA3 = isSet(hwCap, hwcap_SHA3)
ARM64.HasSM3 = isSet(hwCap, hwcap_SM3)
ARM64.HasSM4 = isSet(hwCap, hwcap_SM4)
ARM64.HasASIMDDP = isSet(hwCap, hwcap_ASIMDDP)
ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512)
ARM64.HasSVE = isSet(hwCap, hwcap_SVE)
ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
}
func isSet(hwc uint, value uint) bool {
return hwc&value != 0
}

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build linux
// +build ppc64 ppc64le // +build ppc64 ppc64le
package cpu package cpu
@ -21,10 +22,10 @@ const (
func doinit() { func doinit() {
// HWCAP2 feature bits // HWCAP2 feature bits
PPC64.IsPOWER8 = isSet(HWCap2, _PPC_FEATURE2_ARCH_2_07) PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07)
PPC64.IsPOWER9 = isSet(HWCap2, _PPC_FEATURE2_ARCH_3_00) PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00)
PPC64.HasDARN = isSet(HWCap2, _PPC_FEATURE2_DARN) PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN)
PPC64.HasSCV = isSet(HWCap2, _PPC_FEATURE2_SCV) PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV)
} }
func isSet(hwc uint, value uint) bool { func isSet(hwc uint, value uint) bool {

161
vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go generated vendored Normal file
View File

@ -0,0 +1,161 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
const cacheLineSize = 256
const (
// bit mask values from /usr/include/bits/hwcap.h
hwcap_ZARCH = 2
hwcap_STFLE = 4
hwcap_MSA = 8
hwcap_LDISP = 16
hwcap_EIMM = 32
hwcap_DFP = 64
hwcap_ETF3EH = 256
hwcap_VX = 2048
hwcap_VXE = 8192
)
// bitIsSet reports whether the bit at index is set. The bit index
// is in big endian order, so bit index 0 is the leftmost bit.
func bitIsSet(bits []uint64, index uint) bool {
return bits[index/64]&((1<<63)>>(index%64)) != 0
}
// function is the code for the named cryptographic function.
type function uint8
const (
// KM{,A,C,CTR} function codes
aes128 function = 18 // AES-128
aes192 function = 19 // AES-192
aes256 function = 20 // AES-256
// K{I,L}MD function codes
sha1 function = 1 // SHA-1
sha256 function = 2 // SHA-256
sha512 function = 3 // SHA-512
sha3_224 function = 32 // SHA3-224
sha3_256 function = 33 // SHA3-256
sha3_384 function = 34 // SHA3-384
sha3_512 function = 35 // SHA3-512
shake128 function = 36 // SHAKE-128
shake256 function = 37 // SHAKE-256
// KLMD function codes
ghash function = 65 // GHASH
)
// queryResult contains the result of a Query function
// call. Bits are numbered in big endian order so the
// leftmost bit (the MSB) is at index 0.
type queryResult struct {
bits [2]uint64
}
// Has reports whether the given functions are present.
func (q *queryResult) Has(fns ...function) bool {
if len(fns) == 0 {
panic("no function codes provided")
}
for _, f := range fns {
if !bitIsSet(q.bits[:], uint(f)) {
return false
}
}
return true
}
// facility is a bit index for the named facility.
type facility uint8
const (
// cryptography facilities
msa4 facility = 77 // message-security-assist extension 4
msa8 facility = 146 // message-security-assist extension 8
)
// facilityList contains the result of an STFLE call.
// Bits are numbered in big endian order so the
// leftmost bit (the MSB) is at index 0.
type facilityList struct {
bits [4]uint64
}
// Has reports whether the given facilities are present.
func (s *facilityList) Has(fs ...facility) bool {
if len(fs) == 0 {
panic("no facility bits provided")
}
for _, f := range fs {
if !bitIsSet(s.bits[:], uint(f)) {
return false
}
}
return true
}
func doinit() {
// test HWCAP bit vector
has := func(featureMask uint) bool {
return hwCap&featureMask == featureMask
}
// mandatory
S390X.HasZARCH = has(hwcap_ZARCH)
// optional
S390X.HasSTFLE = has(hwcap_STFLE)
S390X.HasLDISP = has(hwcap_LDISP)
S390X.HasEIMM = has(hwcap_EIMM)
S390X.HasETF3EH = has(hwcap_ETF3EH)
S390X.HasDFP = has(hwcap_DFP)
S390X.HasMSA = has(hwcap_MSA)
S390X.HasVX = has(hwcap_VX)
if S390X.HasVX {
S390X.HasVXE = has(hwcap_VXE)
}
// We need implementations of stfle, km and so on
// to detect cryptographic features.
if !haveAsmFunctions() {
return
}
// optional cryptographic functions
if S390X.HasMSA {
aes := []function{aes128, aes192, aes256}
// cipher message
km, kmc := kmQuery(), kmcQuery()
S390X.HasAES = km.Has(aes...)
S390X.HasAESCBC = kmc.Has(aes...)
if S390X.HasSTFLE {
facilities := stfle()
if facilities.Has(msa4) {
kmctr := kmctrQuery()
S390X.HasAESCTR = kmctr.Has(aes...)
}
if facilities.Has(msa8) {
kma := kmaQuery()
S390X.HasAESGCM = kma.Has(aes...)
}
}
// compute message digest
kimd := kimdQuery() // intermediate (no padding)
klmd := klmdQuery() // last (padding)
S390X.HasSHA1 = kimd.Has(sha1) && klmd.Has(sha1)
S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256)
S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512)
S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist
sha3 := []function{
sha3_224, sha3_256, sha3_384, sha3_512,
shake128, shake256,
}
S390X.HasSHA3 = kimd.Has(sha3...) && klmd.Has(sha3...)
}
}

View File

@ -1,9 +1,11 @@
// Copyright 2018 The Go Authors. All rights reserved. // Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build !linux,arm64
package cpu package cpu
const cacheLineSize = 256 const cacheLineSize = 64
func doinit() {} func doinit() {}

12
vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !linux
// +build ppc64 ppc64le
package cpu
const cacheLineSize = 128
func doinit() {}

57
vendor/golang.org/x/sys/cpu/cpu_s390x.s generated vendored Normal file
View File

@ -0,0 +1,57 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !gccgo
#include "textflag.h"
// func stfle() facilityList
TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32
MOVD $ret+0(FP), R1
MOVD $3, R0 // last doubleword index to store
XC $32, (R1), (R1) // clear 4 doublewords (32 bytes)
WORD $0xb2b01000 // store facility list extended (STFLE)
RET
// func kmQuery() queryResult
TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KM-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xB92E0024 // cipher message (KM)
RET
// func kmcQuery() queryResult
TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KMC-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xB92F0024 // cipher message with chaining (KMC)
RET
// func kmctrQuery() queryResult
TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KMCTR-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xB92D4024 // cipher message with counter (KMCTR)
RET
// func kmaQuery() queryResult
TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KMA-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xb9296024 // cipher message with authentication (KMA)
RET
// func kimdQuery() queryResult
TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KIMD-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xB93E0024 // compute intermediate message digest (KIMD)
RET
// func klmdQuery() queryResult
TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16
MOVD $0, R0 // set function code to 0 (KLMD-Query)
MOVD $ret+0(FP), R1 // address of 16-byte return value
WORD $0xB93F0024 // compute last message digest (KLMD)
RET

View File

@ -9,6 +9,8 @@ package cpu
const cacheLineSize = 64 const cacheLineSize = 64
func init() { func init() {
Initialized = true
maxID, _, _, _ := cpuid(0, 0) maxID, _, _, _ := cpuid(0, 0)
if maxID < 1 { if maxID < 1 {

View File

@ -32,7 +32,7 @@ To build the files for your current OS and architecture, make sure GOOS and
GOARCH are set correctly and run `mkall.sh`. This will generate the files for GOARCH are set correctly and run `mkall.sh`. This will generate the files for
your specific system. Running `mkall.sh -n` shows the commands that will be run. your specific system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, perl, go Requirements: bash, go
### New Build System (currently for `GOOS == "linux"`) ### New Build System (currently for `GOOS == "linux"`)
@ -52,14 +52,14 @@ system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
then generate all of the files for all of the GOOS/GOARCH pairs in the new build then generate all of the files for all of the GOOS/GOARCH pairs in the new build
system. Running `mkall.sh -n` shows the commands that will be run. system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, perl, go, docker Requirements: bash, go, docker
## Component files ## Component files
This section describes the various files used in the code generation process. This section describes the various files used in the code generation process.
It also contains instructions on how to modify these files to add a new It also contains instructions on how to modify these files to add a new
architecture/OS or to add additional syscalls, types, or constants. Note that architecture/OS or to add additional syscalls, types, or constants. Note that
if you are using the new build system, the scripts cannot be called normally. if you are using the new build system, the scripts/programs cannot be called normally.
They must be called from within the docker container. They must be called from within the docker container.
### asm files ### asm files
@ -81,8 +81,8 @@ each GOOS/GOARCH pair.
### mksysnum ### mksysnum
Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl` Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
for the old system). This script takes in a list of header files containing the for the old system). This program takes in a list of header files containing the
syscall number declarations and parses them to produce the corresponding list of syscall number declarations and parses them to produce the corresponding list of
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
constants. constants.
@ -92,14 +92,14 @@ new installation of the target OS (or updating the source checkouts for the
new build system). However, depending on the OS, you make need to update the new build system). However, depending on the OS, you make need to update the
parsing in mksysnum. parsing in mksysnum.
### mksyscall.pl ### mksyscall.go
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
hand-written Go files which implement system calls (for unix, the specific OS, hand-written Go files which implement system calls (for unix, the specific OS,
or the specific OS/Architecture pair respectively) that need special handling or the specific OS/Architecture pair respectively) that need special handling
and list `//sys` comments giving prototypes for ones that can be generated. and list `//sys` comments giving prototypes for ones that can be generated.
The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
them into syscalls. This requires the name of the prototype in the comment to them into syscalls. This requires the name of the prototype in the comment to
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
prototype can be exported (capitalized) or not. prototype can be exported (capitalized) or not.
@ -160,7 +160,7 @@ signal numbers, and constants. Generated by `mkerrors.sh` (see above).
### `zsyscall_${GOOS}_${GOARCH}.go` ### `zsyscall_${GOOS}_${GOARCH}.go`
A file containing all the generated syscalls for a specific GOOS and GOARCH. A file containing all the generated syscalls for a specific GOOS and GOARCH.
Generated by `mksyscall.pl` (see above). Generated by `mksyscall.go` (see above).
### `zsysnum_${GOOS}_${GOARCH}.go` ### `zsysnum_${GOOS}_${GOARCH}.go`

View File

@ -25,8 +25,8 @@ func cmsgAlignOf(salen int) int {
if SizeofPtr == 8 { if SizeofPtr == 8 {
salign = 4 salign = 4
} }
case "openbsd": case "netbsd", "openbsd":
// OpenBSD armv7 requires 64-bit alignment. // NetBSD and OpenBSD armv7 require 64-bit alignment.
if runtime.GOARCH == "arm" { if runtime.GOARCH == "arm" {
salign = 8 salign = 8
} }

View File

@ -416,6 +416,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys Chmod(path string, mode uint32) (err error) //sys Chmod(path string, mode uint32) (err error)
//sys Chown(path string, uid int, gid int) (err error) //sys Chown(path string, uid int, gid int) (err error)
//sys Chroot(path string) (err error) //sys Chroot(path string) (err error)
//sys ClockGettime(clockid int32, time *Timespec) (err error)
//sys Close(fd int) (err error) //sys Close(fd int) (err error)
//sys Dup(fd int) (nfd int, err error) //sys Dup(fd int) (nfd int, err error)
//sys Dup2(from int, to int) (err error) //sys Dup2(from int, to int) (err error)

View File

@ -994,6 +994,20 @@ func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
} }
// SetsockoptSockFprog attaches a classic BPF or an extended BPF program to a
// socket to filter incoming packets. See 'man 7 socket' for usage information.
func SetsockoptSockFprog(fd, level, opt int, fprog *SockFprog) error {
return setsockopt(fd, level, opt, unsafe.Pointer(fprog), unsafe.Sizeof(*fprog))
}
func SetsockoptCanRawFilter(fd, level, opt int, filter []CanFilter) error {
var p unsafe.Pointer
if len(filter) > 0 {
p = unsafe.Pointer(&filter[0])
}
return setsockopt(fd, level, opt, p, uintptr(len(filter)*SizeofCanFilter))
}
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html) // Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
// KeyctlInt calls keyctl commands in which each argument is an int. // KeyctlInt calls keyctl commands in which each argument is an int.

View File

@ -28,6 +28,11 @@ var (
errENOENT error = syscall.ENOENT errENOENT error = syscall.ENOENT
) )
var (
signalNameMapOnce sync.Once
signalNameMap map[string]syscall.Signal
)
// errnoErr returns common boxed Errno values, to prevent // errnoErr returns common boxed Errno values, to prevent
// allocations at runtime. // allocations at runtime.
func errnoErr(e syscall.Errno) error { func errnoErr(e syscall.Errno) error {
@ -66,6 +71,19 @@ func SignalName(s syscall.Signal) string {
return "" return ""
} }
// SignalNum returns the syscall.Signal for signal named s,
// or 0 if a signal with such name is not found.
// The signal name should start with "SIG".
func SignalNum(s string) syscall.Signal {
signalNameMapOnce.Do(func() {
signalNameMap = make(map[string]syscall.Signal)
for _, signal := range signalList {
signalNameMap[signal.name] = signal.num
}
})
return signalNameMap[s]
}
// clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte. // clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte.
func clen(n []byte) int { func clen(n []byte) int {
i := bytes.IndexByte(n, 0) i := bytes.IndexByte(n, 0)

View File

@ -943,6 +943,21 @@ func libc_chroot_trampoline()
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockGettime(clockid int32, time *Timespec) (err error) {
_, _, e1 := syscall_syscall(funcPC(libc_clock_gettime_trampoline), uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
func libc_clock_gettime_trampoline()
//go:linkname libc_clock_gettime libc_clock_gettime
//go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) { func Close(fd int) (err error) {
_, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0) _, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
if e1 != 0 { if e1 != 0 {

View File

@ -108,6 +108,8 @@ TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
JMP libc_chown(SB) JMP libc_chown(SB)
TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0 TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
JMP libc_chroot(SB) JMP libc_chroot(SB)
TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
JMP libc_clock_gettime(SB)
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0 TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
JMP libc_close(SB) JMP libc_close(SB)
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0 TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0

View File

@ -1,4 +1,4 @@
// mksyscall_solaris.pl -tags solaris,amd64 syscall_solaris.go syscall_solaris_amd64.go // go run mksyscall_solaris.go -tags solaris,amd64 syscall_solaris.go syscall_solaris_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
// +build solaris,amd64 // +build solaris,amd64

View File

@ -1,4 +1,4 @@
// go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/syscall.h // go run mksysnum.go /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/syscall.h
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
// +build amd64,darwin // +build amd64,darwin
@ -431,6 +431,8 @@ const (
SYS_NTP_ADJTIME = 527 SYS_NTP_ADJTIME = 527
SYS_NTP_GETTIME = 528 SYS_NTP_GETTIME = 528
SYS_OS_FAULT_WITH_PAYLOAD = 529 SYS_OS_FAULT_WITH_PAYLOAD = 529
SYS_MAXSYSCALL = 530 SYS_KQUEUE_WORKLOOP_CTL = 530
SYS___MACH_BRIDGE_REMOTE_TIME = 531
SYS_MAXSYSCALL = 532
SYS_INVALID = 63 SYS_INVALID = 63
) )

View File

@ -405,6 +405,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -434,6 +439,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -569,6 +575,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -634,6 +641,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x8 SizeofSockFprog = 0x8

View File

@ -406,6 +406,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -435,6 +440,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -570,6 +576,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -635,6 +642,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -409,6 +409,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -438,6 +443,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -573,6 +579,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -638,6 +645,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x8 SizeofSockFprog = 0x8

View File

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -571,6 +577,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -636,6 +643,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -572,6 +578,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -637,6 +644,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x8 SizeofSockFprog = 0x8

View File

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -571,6 +577,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -636,6 +643,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -571,6 +577,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -636,6 +643,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -572,6 +578,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -637,6 +644,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x8 SizeofSockFprog = 0x8

View File

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -572,6 +578,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -637,6 +644,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -408,6 +408,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -437,6 +442,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -572,6 +578,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -637,6 +644,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -407,6 +407,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -436,6 +441,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -571,6 +577,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -636,6 +643,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -406,6 +406,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -435,6 +440,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -570,6 +576,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -635,6 +642,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -410,6 +410,11 @@ type TCPInfo struct {
Total_retrans uint32 Total_retrans uint32
} }
type CanFilter struct {
Id uint32
Mask uint32
}
const ( const (
SizeofSockaddrInet4 = 0x10 SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c SizeofSockaddrInet6 = 0x1c
@ -439,6 +444,7 @@ const (
SizeofICMPv6Filter = 0x20 SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc SizeofUcred = 0xc
SizeofTCPInfo = 0x68 SizeofTCPInfo = 0x68
SizeofCanFilter = 0x8
) )
const ( const (
@ -574,6 +580,7 @@ const (
SizeofIfAddrmsg = 0x8 SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8 SizeofRtNexthop = 0x8
SizeofNdUseroptmsg = 0x10
) )
type NlMsghdr struct { type NlMsghdr struct {
@ -639,6 +646,17 @@ type RtNexthop struct {
Ifindex int32 Ifindex int32
} }
type NdUseroptmsg struct {
Family uint8
Pad1 uint8
Opts_len uint16
Ifindex int32
Icmp_type uint8
Icmp_code uint8
Pad2 uint16
Pad3 uint32
}
const ( const (
SizeofSockFilter = 0x8 SizeofSockFilter = 0x8
SizeofSockFprog = 0x10 SizeofSockFprog = 0x10

View File

@ -149,7 +149,7 @@ const (
DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS = 0x22b DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS = 0x22b
DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS = 0x22c DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS = 0x22c
DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS = 0x22d DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS = 0x22d
DOMAIN_ALIAS_RID_MONITORING_USERS = 0X22e DOMAIN_ALIAS_RID_MONITORING_USERS = 0x22e
DOMAIN_ALIAS_RID_LOGGING_USERS = 0x22f DOMAIN_ALIAS_RID_LOGGING_USERS = 0x22f
DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS = 0x230 DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS = 0x230
DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS = 0x231 DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS = 0x231

View File

@ -80,6 +80,7 @@ type ChangeRequest struct {
EventType uint32 EventType uint32
EventData uintptr EventData uintptr
CurrentStatus Status CurrentStatus Status
Context uintptr
} }
// Handler is the interface that must be implemented to build Windows service. // Handler is the interface that must be implemented to build Windows service.
@ -121,12 +122,11 @@ func init() {
cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr() cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr()
} }
// The HandlerEx prototype also has a context pointer but since we don't use
// it at start-up time we don't have to pass it over either.
type ctlEvent struct { type ctlEvent struct {
cmd Cmd cmd Cmd
eventType uint32 eventType uint32
eventData uintptr eventData uintptr
context uintptr
errno uint32 errno uint32
} }
@ -238,13 +238,12 @@ func (s *service) run() {
exitFromHandler <- exitCode{ss, errno} exitFromHandler <- exitCode{ss, errno}
}() }()
status := Status{State: Stopped}
ec := exitCode{isSvcSpecific: true, errno: 0} ec := exitCode{isSvcSpecific: true, errno: 0}
outcr := ChangeRequest{
CurrentStatus: Status{State: Stopped},
}
var outch chan ChangeRequest var outch chan ChangeRequest
inch := s.c inch := s.c
var cmd Cmd
var evtype uint32
var evdata uintptr
loop: loop:
for { for {
select { select {
@ -255,10 +254,11 @@ loop:
} }
inch = nil inch = nil
outch = cmdsToHandler outch = cmdsToHandler
cmd = r.cmd outcr.Cmd = r.cmd
evtype = r.eventType outcr.EventType = r.eventType
evdata = r.eventData outcr.EventData = r.eventData
case outch <- ChangeRequest{cmd, evtype, evdata, status}: outcr.Context = r.context
case outch <- outcr:
inch = s.c inch = s.c
outch = nil outch = nil
case c := <-changesFromHandler: case c := <-changesFromHandler:
@ -271,7 +271,7 @@ loop:
} }
break loop break loop
} }
status = c outcr.CurrentStatus = c
case ec = <-exitFromHandler: case ec = <-exitFromHandler:
break loop break loop
} }
@ -315,8 +315,8 @@ func Run(name string, handler Handler) error {
return err return err
} }
ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr { ctlHandler := func(ctl, evtype, evdata, context uintptr) uintptr {
e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata} e := ctlEvent{cmd: Cmd(ctl), eventType: uint32(evtype), eventData: evdata, context: context}
// We assume that this callback function is running on // We assume that this callback function is running on
// the same thread as Run. Nowhere in MS documentation // the same thread as Run. Nowhere in MS documentation
// I could find statement to guarantee that. So putting // I could find statement to guarantee that. So putting

View File

@ -22,7 +22,8 @@ TEXT ·servicemain(SB),7,$0
MOVL AX, (SP) MOVL AX, (SP)
MOVL $·servicectlhandler(SB), AX MOVL $·servicectlhandler(SB), AX
MOVL AX, 4(SP) MOVL AX, 4(SP)
MOVL $0, 8(SP) // Set context to 123456 to test issue #25660.
MOVL $123456, 8(SP)
MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX
MOVL SP, BP MOVL SP, BP
CALL AX CALL AX

View File

@ -14,6 +14,8 @@ TEXT ·servicemain(SB),7,$0
MOVQ ·sName(SB), CX MOVQ ·sName(SB), CX
MOVQ $·servicectlhandler(SB), DX MOVQ $·servicectlhandler(SB), DX
// BUG(pastarmovj): Figure out a way to pass in context in R8. // BUG(pastarmovj): Figure out a way to pass in context in R8.
// Set context to 123456 to test issue #25660.
MOVQ $123456, R8
MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX
CALL AX CALL AX
CMPQ AX, $0 CMPQ AX, $0