// 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 && !ios) || linux// +build darwin,!ios linuxpackage uniximport// SysvShmAttach attaches the Sysv shared memory segment associated with the// shared memory identifier id.func ( int, uintptr, int) ([]byte, error) { , := shmat(, , )if != nil {returnnil, }// Retrieve the size of the shared memory to enable slice creationvarSysvShmDesc , := SysvShmCtl(, IPC_STAT, &)if != nil {// release the shared memory if we can't find the size// ignoring error from shmdt as there's nothing sensible to return hereshmdt()returnnil, }// Use unsafe to convert addr into a []byte. := unsafe.Slice((*byte)(unsafe.Pointer()), int(.Segsz))return , nil}// SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach.//// It is not safe to use the slice after calling this function.func ( []byte) error {iflen() == 0 {returnEINVAL }returnshmdt(uintptr(unsafe.Pointer(&[0])))}// SysvShmGet returns the Sysv shared memory identifier associated with key.// If the IPC_CREAT flag is specified a new segment is created.func (, , int) ( int, error) {returnshmget(, , )}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.