github.com/tetratelabs/wazero@v1.2.1/internal/sysfs/futimens_darwin.go (about) 1 package sysfs 2 3 import ( 4 "syscall" 5 _ "unsafe" // for go:linkname 6 ) 7 8 const ( 9 _AT_FDCWD = -0x2 10 _AT_SYMLINK_NOFOLLOW = 0x0020 11 _UTIME_NOW = -1 12 _UTIME_OMIT = -2 13 SupportsSymlinkNoFollow = true 14 ) 15 16 //go:noescape 17 //go:linkname utimensat syscall.utimensat 18 func utimensat(dirfd int, path string, times *[2]syscall.Timespec, flags int) error 19 20 func utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) error { 21 var flags int 22 if !symlinkFollow { 23 flags = _AT_SYMLINK_NOFOLLOW 24 } 25 return utimensat(_AT_FDCWD, path, times, flags) 26 } 27 28 func futimens(fd uintptr, times *[2]syscall.Timespec) error { 29 _p0 := timesToPtr(times) 30 31 // Warning: futimens only exists since High Sierra (10.13). 32 _, _, e1 := syscall_syscall6(libc_futimens_trampoline_addr, fd, uintptr(_p0), 0, 0, 0, 0) 33 if e1 != 0 { 34 return e1 35 } 36 return nil 37 } 38 39 // libc_futimens_trampoline_addr is the address of the 40 // `libc_futimens_trampoline` symbol, defined in `futimens_darwin.s`. 41 // 42 // We use this to invoke the syscall through syscall_syscall6 imported below. 43 var libc_futimens_trampoline_addr uintptr 44 45 // Imports the futimens symbol from libc as `libc_futimens`. 46 // 47 // Note: CGO mechanisms are used in darwin regardless of the CGO_ENABLED value 48 // or the "cgo" build flag. See /RATIONALE.md for why. 49 //go:cgo_import_dynamic libc_futimens futimens "/usr/lib/libSystem.B.dylib"