fix: use pragma for ptr checks
This commit is contained in:
10
Makefile
10
Makefile
@@ -1,11 +1,3 @@
|
|||||||
GO_VERSION=$(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2)
|
|
||||||
|
|
||||||
RACE_TEST_GCFLAGS=
|
|
||||||
ifneq ($(GO_VERSION), 1.13)
|
|
||||||
# support for unsafe means we cannot do unsafe pointer arithmetic checks
|
|
||||||
RACE_TEST_GCFLAGS=-gcflags=all=-d=checkptr=0
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Static linting of source files. See .golangci.toml for options
|
# Static linting of source files. See .golangci.toml for options
|
||||||
check:
|
check:
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
@@ -26,6 +18,6 @@ generate: gen_all_syscall
|
|||||||
|
|
||||||
tests:
|
tests:
|
||||||
GO111MODULE=off go test -v ./...
|
GO111MODULE=off go test -v ./...
|
||||||
GO111MODULE=off go test -race $(RACE_TEST_GCFLAGS) -short ./interp
|
GO111MODULE=off go test -race ./interp
|
||||||
|
|
||||||
.PHONY: check gen_all_syscall gen_tests
|
.PHONY: check gen_all_syscall gen_tests
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ func init() {
|
|||||||
func convert(from, to reflect.Type) func(src, dest reflect.Value) {
|
func convert(from, to reflect.Type) func(src, dest reflect.Value) {
|
||||||
switch {
|
switch {
|
||||||
case to.Kind() == reflect.UnsafePointer && from.Kind() == reflect.Uintptr:
|
case to.Kind() == reflect.UnsafePointer && from.Kind() == reflect.Uintptr:
|
||||||
return func(src, dest reflect.Value) {
|
return uintptrToUnsafePtr
|
||||||
dest.SetPointer(unsafe.Pointer(src.Interface().(uintptr))) //nolint:govet
|
|
||||||
}
|
|
||||||
case to.Kind() == reflect.UnsafePointer:
|
case to.Kind() == reflect.UnsafePointer:
|
||||||
return func(src, dest reflect.Value) {
|
return func(src, dest reflect.Value) {
|
||||||
dest.SetPointer(unsafe.Pointer(src.Pointer()))
|
dest.SetPointer(unsafe.Pointer(src.Pointer()))
|
||||||
@@ -58,4 +56,9 @@ func alignof(i interface{}) uintptr {
|
|||||||
return uintptr(reflect.ValueOf(i).Type().Align())
|
return uintptr(reflect.ValueOf(i).Type().Align())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:nocheckptr
|
||||||
|
func uintptrToUnsafePtr(src, dest reflect.Value) {
|
||||||
|
dest.SetPointer(unsafe.Pointer(src.Interface().(uintptr))) //nolint:govet
|
||||||
|
}
|
||||||
|
|
||||||
//go:generate ../../cmd/goexports/goexports unsafe
|
//go:generate ../../cmd/goexports/goexports unsafe
|
||||||
|
|||||||
Reference in New Issue
Block a user