From 3aa34d7e9a3b4e079cbbf108cee875b6bba15c42 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Fri, 2 Jul 2021 13:10:32 -0400 Subject: [PATCH] Fix tests on ARM --- unix/linux/types.go | 2 ++ unix/sysvshm_linux.go | 20 ++++++++++++++++++++ unix/sysvshm_unix.go | 6 +----- unix/sysvshm_unix_other.go | 12 ++++++++++++ unix/ztypes_linux.go | 2 ++ 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 unix/sysvshm_linux.go create mode 100644 unix/sysvshm_unix_other.go diff --git a/unix/linux/types.go b/unix/linux/types.go index ef8b3bbd..faea3d22 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -3848,6 +3848,8 @@ const ( IPC_EXCL = C.IPC_EXCL IPC_NOWAIT = C.IPC_NOWAIT IPC_PRIVATE = C.IPC_PRIVATE + + ipc_64 = C.IPC_64 ) const ( diff --git a/unix/sysvshm_linux.go b/unix/sysvshm_linux.go new file mode 100644 index 00000000..b9476c64 --- /dev/null +++ b/unix/sysvshm_linux.go @@ -0,0 +1,20 @@ +// Copyright 2021 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. + +//go:build linux +// +build linux + +package unix + +import "runtime" + +// SysvShmCtl performs control operations on the shared memory segment +// specified by id. +func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { + if runtime.GOARCH == "arm" { + cmd |= ipc_64 + } + + return shmctl(id, cmd, desc) +} diff --git a/unix/sysvshm_unix.go b/unix/sysvshm_unix.go index b968bf23..2ddcf894 100644 --- a/unix/sysvshm_unix.go +++ b/unix/sysvshm_unix.go @@ -42,11 +42,7 @@ func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { return b, nil } -// SysvShmCtl performs control operations on the shared memory segment -// specified by id. -func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { - return shmctl(id, cmd, desc) -} + // SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach. // diff --git a/unix/sysvshm_unix_other.go b/unix/sysvshm_unix_other.go new file mode 100644 index 00000000..5a1d03e7 --- /dev/null +++ b/unix/sysvshm_unix_other.go @@ -0,0 +1,12 @@ +// Copyright 2021 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. + +//go:build (darwin && amd64) +// +build darwin,amd64 + +// SysvShmCtl performs control operations on the shared memory segment +// specified by id. +func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { + return shmctl(id, cmd, desc) +} diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 0b13e079..249ecfcd 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -3942,6 +3942,8 @@ const ( IPC_EXCL = 0x400 IPC_NOWAIT = 0x800 IPC_PRIVATE = 0x0 + + ipc_64 = 0x100 ) const (