mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-24 15:38:27 +00: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",
|
"ImportPath": "github.com/oschwald/maxminddb-golang",
|
||||||
"Comment": "v0.2.0-41-gcf814d2",
|
"Comment": "v0.2.0-41-gbfd1341",
|
||||||
"Rev": "cf814d2e9ee3d6ef5b756c0696548eb2f5508e03"
|
"Rev": "bfd134128faa57c37ef41fff5fb1a9ca94450a9b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/syncthing/syncthing/lib/dialer",
|
"ImportPath": "github.com/syncthing/syncthing/lib/dialer",
|
||||||
|
@ -4,12 +4,14 @@ package maxminddb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func mmap(fd int, length int) (data []byte, err error) {
|
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) {
|
func munmap(b []byte) (err error) {
|
||||||
return syscall.Munmap(b)
|
return unix.Munmap(b)
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,25 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
type memoryMap []byte
|
type memoryMap []byte
|
||||||
|
|
||||||
// Windows
|
// Windows
|
||||||
var handleLock sync.Mutex
|
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) {
|
func mmap(fd int, length int) (data []byte, err error) {
|
||||||
h, errno := syscall.CreateFileMapping(syscall.Handle(fd), nil,
|
h, errno := windows.CreateFileMapping(windows.Handle(fd), nil,
|
||||||
uint32(syscall.PAGE_READONLY), 0, uint32(length), nil)
|
uint32(windows.PAGE_READONLY), 0, uint32(length), nil)
|
||||||
if h == 0 {
|
if h == 0 {
|
||||||
return nil, os.NewSyscallError("CreateFileMapping", errno)
|
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))
|
0, uintptr(length))
|
||||||
if addr == 0 {
|
if addr == 0 {
|
||||||
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
return nil, os.NewSyscallError("MapViewOfFile", errno)
|
||||||
@ -51,7 +52,7 @@ func (m *memoryMap) header() *reflect.SliceHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flush(addr, len uintptr) error {
|
func flush(addr, len uintptr) error {
|
||||||
errno := syscall.FlushViewOfFile(addr, len)
|
errno := windows.FlushViewOfFile(addr, len)
|
||||||
return os.NewSyscallError("FlushViewOfFile", errno)
|
return os.NewSyscallError("FlushViewOfFile", errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ func munmap(b []byte) (err error) {
|
|||||||
length := uintptr(dh.Len)
|
length := uintptr(dh.Len)
|
||||||
|
|
||||||
flush(addr, length)
|
flush(addr, length)
|
||||||
err = syscall.UnmapViewOfFile(addr)
|
err = windows.UnmapViewOfFile(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -77,6 +78,6 @@ func munmap(b []byte) (err error) {
|
|||||||
}
|
}
|
||||||
delete(handleMap, addr)
|
delete(handleMap, addr)
|
||||||
|
|
||||||
e := syscall.CloseHandle(syscall.Handle(handle))
|
e := windows.CloseHandle(windows.Handle(handle))
|
||||||
return os.NewSyscallError("CloseHandle", e)
|
return os.NewSyscallError("CloseHandle", e)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user