Skip to content

Commit 3e23660

Browse files
go.mod: update /x/sys to latest version
It has some new bug fixes we can use. Also replace a use of the "syscall" package with the x/sys/unix package, which has a compatible API.
1 parent 56bf31b commit 3e23660

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/segmentio/asm
22

3-
go 1.17
3+
go 1.18
44

5-
require golang.org/x/sys v0.0.0-20211110154304-99a53858aa08
5+
require golang.org/x/sys v0.0.0-20220412211240-33da011f77ad

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 h1:WecRHqgE09JBkh/584XIE6PMz5KKE/vER4izNUi30AQ=
2-
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
2+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

internal/buffer/buffer_mmap.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
// +build !purego
33
// +build aix android darwin dragonfly freebsd illumos ios linux netbsd openbsd plan9 solaris
44

5+
// TODO: replace the above with go:build unix once Go 1.19 is the lowest
6+
// supported version
7+
58
package buffer
69

710
import (
8-
"syscall"
11+
"golang.org/x/sys/unix"
912
)
1013

1114
type Buffer struct {
@@ -15,18 +18,18 @@ type Buffer struct {
1518
}
1619

1720
func New(n int) (Buffer, error) {
18-
pg := syscall.Getpagesize()
21+
pg := unix.Getpagesize()
1922
full := ((n+(pg-1))/pg + 2) * pg
2023

21-
b, err := syscall.Mmap(-1, 0, full, syscall.PROT_NONE, syscall.MAP_ANON|syscall.MAP_PRIVATE)
24+
b, err := unix.Mmap(-1, 0, full, unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE)
2225
if err != nil {
2326
return Buffer{}, err
2427
}
2528

2629
if n > 0 {
27-
err = syscall.Mprotect(b[pg:full-pg], syscall.PROT_READ|syscall.PROT_WRITE)
30+
err = unix.Mprotect(b[pg:full-pg], unix.PROT_READ|unix.PROT_WRITE)
2831
if err != nil {
29-
syscall.Munmap(b)
32+
unix.Munmap(b)
3033
return Buffer{}, err
3134
}
3235
}
@@ -49,5 +52,5 @@ func (a *Buffer) ProtectTail() []byte {
4952
}
5053

5154
func (a *Buffer) Release() {
52-
syscall.Munmap(a.mmap)
55+
unix.Munmap(a.mmap)
5356
}

0 commit comments

Comments
 (0)