Go Windows to pass Flag to memory map syscall

huangapple go评论84阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2015年12月24日 03:30:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/34442474.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定