aboutsummaryrefslogtreecommitdiff
path: root/src/linux_c.zig
diff options
context:
space:
mode:
authorGravatar Jarred SUmner <jarred@jarredsumner.com> 2022-04-06 01:52:15 -0700
committerGravatar Jarred SUmner <jarred@jarredsumner.com> 2022-04-06 01:53:05 -0700
commit81eb47de0eb08081ed0677b71aa47e9a2b473cab (patch)
tree051df34c66832ab2f0986370d5c8fbb3e12058fc /src/linux_c.zig
parent57cf035a73187439fbcd8703d7f4358463ee8314 (diff)
downloadbun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.tar.gz
bun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.tar.zst
bun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.zip
[bun.js] Add stdout, stderr, stdin to Bun and support sendfile() + splice()
Diffstat (limited to '')
-rw-r--r--src/linux_c.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/linux_c.zig b/src/linux_c.zig
index 6247df61d..ae5e9a3cb 100644
--- a/src/linux_c.zig
+++ b/src/linux_c.zig
@@ -280,3 +280,20 @@ pub const SystemErrno = enum(u8) {
pub fn preallocate_file(fd: std.os.fd_t, offset: std.os.off_t, len: std.os.off_t) anyerror!void {
_ = std.os.linux.fallocate(fd, 0, @intCast(i64, offset), len);
}
+
+/// splice() moves data between two file descriptors without copying
+/// between kernel address space and user address space. It
+/// transfers up to len bytes of data from the file descriptor fd_in
+/// to the file descriptor fd_out, where one of the file descriptors
+/// must refer to a pipe.
+pub fn splice(fd_in: std.os.fd_t, off_in: ?*i64, fd_out: std.os.fd_t, off_out: ?*i64, len: usize, flags: u32) usize {
+ return std.os.linux.syscall6(
+ .splice,
+ @bitCast(usize, @as(isize, fd_in)),
+ @ptrToInt(off_in),
+ @bitCast(usize, @as(isize, fd_out)),
+ @ptrToInt(off_out),
+ len,
+ flags,
+ );
+}