diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index edc6de0..0000000 --- a/.cirrus.yml +++ /dev/null @@ -1,69 +0,0 @@ -linux_task: - container: - image: golang:latest - env: - GO111MODULE: on - GOPATH: /tmp/go - CIRRUS_WORKING_DIR: /tmp/go/src/github.com/${CIRRUS_REPO_FULL_NAME} - build_script: - - go version - - go get ./... - - go build -race -v ./... - test_script: - - go test -race -v ./... - -osx_task: - macos_instance: - image: ghcr.io/cirruslabs/macos-ventura-base:latest - env: - GO111MODULE: on - GOPATH: /tmp/go - PATH: ${GOPATH}/bin:${PATH} - CIRRUS_WORKING_DIR: /tmp/go/src/github.com/${CIRRUS_REPO_FULL_NAME} - install_script: - - brew install go - build_script: - - go version - - go get ./... - - go build -race -v ./... - test_script: - - go test -race -v ./... - -windows_task: - windows_container: - image: cirrusci/windowsservercore:2019 - env: - GO111MODULE: on - GOPATH: C:\golang - PATH: ${GOPATH}\bin;C:\Program Files\Go\bin;C:\Users\ContainerAdministrator\go\bin;${PATH} - CIRRUS_WORKING_DIR: C:\golang\src\github.com\${CIRRUS_REPO_FULL_NAME} - install_script: - - choco install -y golang - - choco install -y mingw # This installs MinGW which includes gcc - - refreshenv - - gcc --version - build_script: - - go version - - go get ./... - - env CGO_ENABLED=1 go build -race -v ./... - test_script: - - refreshenv - - echo $PATH - - env CGO_ENABLED=1 go test -race -v ./... - -freebsd_task: - freebsd_instance: - image: freebsd-14-0-release-amd64-ufs - env: - GO111MODULE: on - GOPATH: /tmp/go - PATH: ${GOPATH}/bin:${PATH} - CIRRUS_WORKING_DIR: /tmp/go/src/github.com/${CIRRUS_REPO_FULL_NAME} - install_script: - - pkg install -y go git - build_script: - - go version - - go get ./... - - go build -race -v ./... - test_script: - - go test -race -v ./... diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eccb48f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: Build + run: | + go version + go get ./... + go build -race -v ./... + - name: Test + run: go test -race -v ./... + - name: Bench + run: go test -run=XXX -bench=. ./... + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: Build + run: | + go version + go get ./... + go build -race -v ./... + - name: Test + run: go test -race -v ./... + - name: Bench + run: go test -run=XXX -bench=. ./... + + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: Install MinGW (for gcc) + run: choco install -y mingw + - name: Build + run: | + go version + go get ./... + $env:CGO_ENABLED=1; go build -race -v ./... + - name: Test + run: | + $env:CGO_ENABLED=1; go test -race -v ./... + - name: Bench + run: go test -run=XXX -bench=. ./... diff --git a/go.mod b/go.mod index 11ba6e7..b433883 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/awnumar/memcall -go 1.18 +go 1.23.0 -require golang.org/x/sys v0.20.0 +require golang.org/x/sys v0.35.0 diff --git a/go.sum b/go.sum index 5d1e088..5ace7b9 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= diff --git a/memcall.go b/memcall.go index 5027493..4ca80f2 100644 --- a/memcall.go +++ b/memcall.go @@ -1,7 +1,6 @@ package memcall import ( - "reflect" "runtime" "unsafe" ) @@ -56,8 +55,3 @@ func _getStartPtr(b []byte) unsafe.Pointer { func _getPtr(b []byte) uintptr { return uintptr(_getStartPtr(b)) } - -func _getBytes(ptr uintptr, len int, cap int) []byte { - var sl = reflect.SliceHeader{Data: ptr, Len: len, Cap: cap} - return *(*[]byte)(unsafe.Pointer(&sl)) -} diff --git a/memcall_solaris.go b/memcall_solaris.go index 14c7035..9b1e885 100644 --- a/memcall_solaris.go +++ b/memcall_solaris.go @@ -1,4 +1,5 @@ //go:build solaris + package memcall import ( diff --git a/memcall_windows.go b/memcall_windows.go index 86eb6ab..2023d3b 100644 --- a/memcall_windows.go +++ b/memcall_windows.go @@ -5,6 +5,7 @@ package memcall import ( "errors" "fmt" + "unsafe" "golang.org/x/sys/windows" ) @@ -36,7 +37,7 @@ func Alloc(n int) ([]byte, error) { } // Convert this pointer to a slice. - b := _getBytes(ptr, n, n) + b := unsafe.Slice((*byte)(unsafe.Pointer(ptr)), n) // Wipe it just in case there is some remnant data. wipe(b)