Debian Codegraph @

internal/sysfs/futimens_darwin.go

raw symbols SCIP
1 package sysfs
2
3 import (
4 "syscall"
5 "unsafe"
6
7 experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
8 )
9
10 const _UTIME_OMIT = -2
11
12 func utimens(path string, atim, mtim int64) experimentalsys.Errno {
13 times := timesToTimespecs(atim, mtim)
14 if times == nil {
15 return 0
16 }
17 return experimentalsys.UnwrapOSError(syscall.UtimesNano(path, times[:]))
18 }
19
20 func futimens(fd uintptr, atim, mtim int64) experimentalsys.Errno {
21 times := timesToTimespecs(atim, mtim)
22 if times == nil {
23 return 0
24 }
25 _p0 := unsafe.Pointer(&times[0])
26
27 // Warning: futimens only exists since High Sierra (10.13).
28 _, _, e1 := syscall_syscall6(libc_futimens_trampoline_addr, fd, uintptr(_p0), 0, 0, 0, 0)
29 return experimentalsys.UnwrapOSError(e1)
30 }
31
32 // libc_futimens_trampoline_addr is the address of the
33 // `libc_futimens_trampoline` symbol, defined in `futimens_darwin.s`.
34 //
35 // We use this to invoke the syscall through syscall_syscall6 imported below.
36 var libc_futimens_trampoline_addr uintptr
37
38 // Imports the futimens symbol from libc as `libc_futimens`.
39 //
40 // Note: CGO mechanisms are used in darwin regardless of the CGO_ENABLED value
41 // or the "cgo" build flag. See /RATIONALE.md for why.
42 //go:cgo_import_dynamic libc_futimens futimens "/usr/lib/libSystem.B.dylib"