summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/internal/util
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-11-10 07:29:48 +0100
committerLibravatar tobi <tobi.smethurst@protonmail.com>2025-11-17 14:14:33 +0100
commit6a3b09a507aca0498845d9118a21a82bb5054301 (patch)
tree5297960ecfe66f723179eb5a1a6f8d59504c3433 /vendor/github.com/ncruces/go-sqlite3/internal/util
parent[performance] add optional S3 object info caching (#4546) (diff)
downloadgotosocial-6a3b09a507aca0498845d9118a21a82bb5054301.tar.xz
[chore] update dependencies (#4547)
- codeberg.org/gruf/go-ffmpreg: v0.6.12 -> v0.6.14 - github.com/ncruces/go-sqlite3: v0.30.0 -> v0.30.1 - github.com/wazero/wazero: v1.9.0 -> v1.10.0 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4547 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/internal/util')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go b/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go
index 913a5f733..f1fee0b50 100644
--- a/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go
+++ b/vendor/github.com/ncruces/go-sqlite3/internal/util/mmap_windows.go
@@ -1,12 +1,10 @@
package util
import (
- "context"
"os"
"reflect"
"unsafe"
- "github.com/tetratelabs/wazero/api"
"golang.org/x/sys/windows"
)
@@ -16,14 +14,21 @@ type MappedRegion struct {
addr uintptr
}
-func MapRegion(ctx context.Context, mod api.Module, f *os.File, offset int64, size int32) (*MappedRegion, error) {
- h, err := windows.CreateFileMapping(windows.Handle(f.Fd()), nil, windows.PAGE_READWRITE, 0, 0, nil)
+func MapRegion(f *os.File, offset int64, size int32) (*MappedRegion, error) {
+ maxSize := offset + int64(size)
+ h, err := windows.CreateFileMapping(
+ windows.Handle(f.Fd()), nil, windows.PAGE_READWRITE,
+ uint32(maxSize>>32), uint32(maxSize), nil)
if h == 0 {
return nil, err
}
+ const allocationGranularity = 64 * 1024
+ align := offset % allocationGranularity
+ offset -= align
+
a, err := windows.MapViewOfFile(h, windows.FILE_MAP_WRITE,
- uint32(offset>>32), uint32(offset), uintptr(size))
+ uint32(offset>>32), uint32(offset), uintptr(size)+uintptr(align))
if a == 0 {
windows.CloseHandle(h)
return nil, err
@@ -32,9 +37,9 @@ func MapRegion(ctx context.Context, mod api.Module, f *os.File, offset int64, si
ret := &MappedRegion{Handle: h, addr: a}
// SliceHeader, although deprecated, avoids a go vet warning.
sh := (*reflect.SliceHeader)(unsafe.Pointer(&ret.Data))
+ sh.Data = a + uintptr(align)
sh.Len = int(size)
sh.Cap = int(size)
- sh.Data = a
return ret, nil
}