-
Notifications
You must be signed in to change notification settings - Fork 6
/
shm_windows.go
51 lines (41 loc) · 1.11 KB
/
shm_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2020 Meng Huang ([email protected])
// This package is licensed under a MIT license that can be found in the LICENSE file.
// +build windows
package shm
import (
"errors"
"os"
"syscall"
)
// Open returns the fd.
func Open(name string, oflag int, perm int) (int, error) {
file, err := os.OpenFile(name, oflag, os.FileMode(perm))
if err != nil {
return 0, err
}
return int(file.Fd()), nil
}
// Unlink unlinks the name.
func Unlink(name string) error {
return os.Remove(name)
}
// GetAt calls the shmget and shmat system call.
func GetAt(key int, size int, shmFlg int) (int, []byte, error) {
return 0, nil, errors.New("not supported")
}
// Dt calls the shmdt system call.
func Dt(b []byte) error {
return errors.New("not supported")
}
// Remove removes the shm with the given id.
func Remove(shmid int) error {
return errors.New("not supported")
}
// Ftruncate changes the file size of the fd.
func Ftruncate(fd int, length int64) (err error) {
return syscall.Ftruncate(syscall.Handle(fd), length)
}
// Close closes the fd.
func Close(fd int) (err error) {
return syscall.Close(syscall.Handle(fd))
}