mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-15 18:08:45 -07:00
Add solaris support back in
This commit is contained in:
parent
2c6c84ac61
commit
1a35c440e8
4
cmd/strelaypoolsrv/Godeps/Godeps.json
generated
4
cmd/strelaypoolsrv/Godeps/Godeps.json
generated
@ -36,8 +36,8 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/oschwald/maxminddb-golang",
|
||||
"Comment": "v0.2.0-41-gcf814d2",
|
||||
"Rev": "cf814d2e9ee3d6ef5b756c0696548eb2f5508e03"
|
||||
"Comment": "v0.2.0-41-gbfd1341",
|
||||
"Rev": "bfd134128faa57c37ef41fff5fb1a9ca94450a9b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/syncthing/syncthing/lib/dialer",
|
||||
|
@ -4,12 +4,14 @@ package maxminddb
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func mmap(fd int, length int) (data []byte, err error) {
|
||||
return syscall.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
|
||||
return unix.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
|
||||
}
|
||||
|
||||
func munmap(b []byte) (err error) {
|
||||
return syscall.Munmap(b)
|
||||
return unix.Munmap(b)
|
||||
}
|
||||
|
@ -11,24 +11,25 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
"sync"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
type memoryMap []byte
|
||||
|
||||
// Windows
|
||||
var handleLock sync.Mutex
|
||||
var handleMap = map[uintptr]syscall.Handle{}
|
||||
var handleMap = map[uintptr]windows.Handle{}
|
||||
|
||||
func mmap(fd int, length int) (data []byte, err error) {
|
||||
h, errno := syscall.CreateFileMapping(syscall.Handle(fd), nil,
|
||||
uint32(syscall.PAGE_READONLY), 0, uint32(length), nil)
|
||||
h, errno := windows.CreateFileMapping(windows.Handle(fd), nil,
|
||||
uint32(windows.PAGE_READONLY), 0, uint32(length), nil)
|
||||
if h == 0 {
|
||||
return nil, os.NewSyscallError("CreateFileMapping", errno)
|
||||
}
|
||||
|
||||
addr, errno := syscall.MapViewOfFile(h, uint32(syscall.FILE_MAP_READ), 0,
|
||||
addr, errno := windows.MapViewOfFile(h, uint32(windows.FILE_MAP_READ), 0,
|
||||
0, uintptr(length))
|
||||
if addr == 0 {
|
||||
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
||||
@ -51,7 +52,7 @@ func (m *memoryMap) header() *reflect.SliceHeader {
|
||||
}
|
||||
|
||||
func flush(addr, len uintptr) error {
|
||||
errno := syscall.FlushViewOfFile(addr, len)
|
||||
errno := windows.FlushViewOfFile(addr, len)
|
||||
return os.NewSyscallError("FlushViewOfFile", errno)
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ func munmap(b []byte) (err error) {
|
||||
length := uintptr(dh.Len)
|
||||
|
||||
flush(addr, length)
|
||||
err = syscall.UnmapViewOfFile(addr)
|
||||
err = windows.UnmapViewOfFile(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -77,6 +78,6 @@ func munmap(b []byte) (err error) {
|
||||
}
|
||||
delete(handleMap, addr)
|
||||
|
||||
e := syscall.CloseHandle(syscall.Handle(handle))
|
||||
e := windows.CloseHandle(windows.Handle(handle))
|
||||
return os.NewSyscallError("CloseHandle", e)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user