1
0
mirror of https://github.com/hslam/ipc.git synced 2025-04-29 13:49:27 +08:00
hslam_ipc/shm.go

39 lines
933 B
Go
Raw Normal View History

2020-11-29 04:42:18 +08:00
// Copyright (c) 2020 Meng Huang (mhboy@outlook.com)
// This package is licensed under a MIT license that can be found in the LICENSE file.
package ipc
import (
"github.com/hslam/shm"
)
2020-11-30 19:47:22 +08:00
// Shmget calls the shmget system call.
func Shmget(key int, size int, shmFlg int) (int, error) {
return shm.Get(key, size, shmFlg)
}
// Shmattach calls the shmat system call.
func Shmattach(shmid int, shmFlg int) (uintptr, error) {
return shm.Attach(shmid, shmFlg)
}
// Shmdetach calls the shmdt system call.
func Shmdetach(addr uintptr) error {
return shm.Detach(addr)
}
2020-11-29 04:42:18 +08:00
// Shmgetat calls the shmget and shmat system call.
2020-11-30 18:20:17 +08:00
func Shmgetat(key int, size int, shmFlg int) (int, []byte, error) {
2020-11-29 04:42:18 +08:00
return shm.GetAt(key, size, shmFlg)
}
2020-11-30 19:47:22 +08:00
// Shmdt calls the shmdt system call with []byte b.
2020-11-29 04:42:18 +08:00
func Shmdt(b []byte) error {
return shm.Dt(b)
}
// Shmrm removes the shm with the given id.
2020-11-30 18:20:17 +08:00
func Shmrm(shmid int) error {
2020-11-29 04:42:18 +08:00
return shm.Remove(shmid)
}