unix: add Sysv shared memory support

Implements proposed API from https://golang.org/issue/46084. I chose
`SysvShmDesc` since it's a clearer name than `SysvShm`. Initially supports Darwin and Linux.

Solaris support has a blocker (https://golang.org/issue/46084#issuecomment-836980018)

For golang/go#46084

Change-Id: Ied0f768a74c448254adc3315348417825a7ec63e
GitHub-Last-Rev: befbd7af6b2f838753ac163ef387cebdb7957467
GitHub-Pull-Request: golang/sys#110
Reviewed-on: https://go-review.googlesource.com/c/sys/+/327830
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Dustin Spicuzza
2021-09-30 14:19:18 +00:00
committed by Tobias Klauser
parent 39ccf1dd6f
commit 969570ce7c
29 changed files with 841 additions and 8 deletions
+27
View File
@@ -106,6 +106,7 @@ struct termios2 {
#include <linux/if_packet.h>
#include <linux/if_pppox.h>
#include <linux/if_xdp.h>
#include <linux/ipc.h>
#include <linux/keyctl.h>
#include <linux/landlock.h>
#include <linux/loop.h>
@@ -128,6 +129,7 @@ struct termios2 {
#include <linux/random.h>
#include <linux/rtc.h>
#include <linux/rtnetlink.h>
#include <linux/shm.h>
#include <linux/socket.h>
#include <linux/stat.h>
#include <linux/taskstats.h>
@@ -3835,3 +3837,28 @@ const (
const (
PIDFD_NONBLOCK = C.O_NONBLOCK
)
// shm
type SysvIpcPerm C.struct_ipc64_perm
type SysvShmDesc C.struct_shmid64_ds
const (
IPC_CREAT = C.IPC_CREAT
IPC_EXCL = C.IPC_EXCL
IPC_NOWAIT = C.IPC_NOWAIT
IPC_PRIVATE = C.IPC_PRIVATE
ipc_64 = C.IPC_64
)
const (
IPC_RMID = C.IPC_RMID
IPC_SET = C.IPC_SET
IPC_STAT = C.IPC_STAT
)
const (
SHM_RDONLY = C.SHM_RDONLY
SHM_RND = C.SHM_RND
)