英文:
Go Windows to pass Flag to memory map syscall
问题
在Unix中,Go可以这样做:
// func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
syscall.Mmap(., ., ., ., syscall.MAP_SHARED|syscall.XXX)
在Windows中,你可以使用以下代码:
// func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error)
syscall.CreateFileMapping(., ., syscall.PAGE_READONLY, ., ., nil)
但是我没有看到CreateFileMapping
函数的任何标志参数。
有人知道如何像syscall.Mmap(., ., ., ., syscall.MAP_SHARED|syscall.XXX)
这样传递标志给CreateFileMapping
函数吗?
英文:
In Unix, Go can do this:
// func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
syscall.Mmap(., ., ., ., syscall.MAP_SHARED|syscall.XXX)
In Windows, you can use this:
https://github.com/golang/go/blob/master/src/syscall/zsyscall_windows.go#L970-L981
// func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error)
syscall.CreateFileMapping(., ., syscall.PAGE_READONLY, ., ., nil)
But I don't see any flag arguments to CreateFileMapping
for Windows.
Does anybody know how to pass flags to CreateFileMapping
function like syscall.MAP_SHARED|syscall.XXX
?
答案1
得分: 0
看起来你可以从Windows对该系统调用的参考文档中获取保护标志的整数值。与类Unix的标志不是一一对应的,例如,与其为共享映射设置一个标志,似乎当你向调用传递一个文件名时,默认情况下会得到一个共享映射。
英文:
It looks like you can get the integer values for the protection flags from the Windows reference for that syscall. There doesn't seem to be a one-to-one mapping with the Unix-y flags, e.g. rather than having a flag for shared maps, it appears you get a shared map by default when you pass the call a filename.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论