mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Using fcntl() based fallocate on darwin doesnt work with file descriptors returned by shm_open
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package shm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func Fallocate_simple(fd int, size int64) (err error) {
|
||||
store := &syscall.Fstore_t{
|
||||
Flags: syscall.F_ALLOCATEALL,
|
||||
Posmode: syscall.F_PEOFPOSMODE,
|
||||
Offset: 0,
|
||||
Length: size,
|
||||
}
|
||||
|
||||
for {
|
||||
if _, _, err = syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_PREALLOCATE, uintptr(unsafe.Pointer(store))); !errors.Is(err, unix.EINTR) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
//go:build !darwin && !linux
|
||||
//go:build !linux
|
||||
|
||||
package shm
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
var _ = fmt.Print
|
||||
|
||||
func TestSHM(t *testing.T) {
|
||||
force_use_of_fallocate = runtime.GOOS == "darwin" || runtime.GOOS == "linux"
|
||||
force_use_of_fallocate = runtime.GOOS == "linux"
|
||||
defer func() { force_use_of_fallocate = false }()
|
||||
data := make([]byte, 13347)
|
||||
_, _ = rand.Read(data)
|
||||
|
||||
Reference in New Issue
Block a user