summaryrefslogtreecommitdiff
path: root/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-05-27 15:46:15 +0000
committerLibravatar GitHub <noreply@github.com>2024-05-27 17:46:15 +0200
commit1e7b32490dfdccddd04f46d4b0416b48d749d51b (patch)
tree62a11365933a5a11e0800af64cbdf9172e5e6e7a /vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go
parent[chore] Small styling + link issues (#2933) (diff)
downloadgotosocial-1e7b32490dfdccddd04f46d4b0416b48d749d51b.tar.xz
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
Diffstat (limited to 'vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go')
-rw-r--r--vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go
new file mode 100644
index 000000000..88e4008f0
--- /dev/null
+++ b/vendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go
@@ -0,0 +1,51 @@
+package sysfs
+
+import (
+ "syscall"
+ _ "unsafe"
+
+ experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
+)
+
+const (
+ _AT_FDCWD = -0x2
+ _AT_SYMLINK_NOFOLLOW = 0x0020
+ _UTIME_OMIT = -2
+)
+
+//go:noescape
+//go:linkname utimensat syscall.utimensat
+func utimensat(dirfd int, path string, times *[2]syscall.Timespec, flags int) error
+
+func utimens(path string, atim, mtim int64) experimentalsys.Errno {
+ times := timesToTimespecs(atim, mtim)
+ if times == nil {
+ return 0
+ }
+ var flags int
+ return experimentalsys.UnwrapOSError(utimensat(_AT_FDCWD, path, times, flags))
+}
+
+func futimens(fd uintptr, atim, mtim int64) experimentalsys.Errno {
+ times := timesToTimespecs(atim, mtim)
+ if times == nil {
+ return 0
+ }
+ _p0 := timesToPtr(times)
+
+ // Warning: futimens only exists since High Sierra (10.13).
+ _, _, e1 := syscall_syscall6(libc_futimens_trampoline_addr, fd, uintptr(_p0), 0, 0, 0, 0)
+ return experimentalsys.UnwrapOSError(e1)
+}
+
+// libc_futimens_trampoline_addr is the address of the
+// `libc_futimens_trampoline` symbol, defined in `futimens_darwin.s`.
+//
+// We use this to invoke the syscall through syscall_syscall6 imported below.
+var libc_futimens_trampoline_addr uintptr
+
+// Imports the futimens symbol from libc as `libc_futimens`.
+//
+// Note: CGO mechanisms are used in darwin regardless of the CGO_ENABLED value
+// or the "cgo" build flag. See /RATIONALE.md for why.
+//go:cgo_import_dynamic libc_futimens futimens "/usr/lib/libSystem.B.dylib"