mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
os2: initial implementation for Darwin&BSDs, process API is only thing incomplete
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//+private
|
||||
//+build darwin, netbsd, freebsd, openbsd
|
||||
package os2
|
||||
|
||||
import "core:sys/posix"
|
||||
import "core:strings"
|
||||
|
||||
_pipe :: proc() -> (r, w: ^File, err: Error) {
|
||||
fds: [2]posix.FD
|
||||
if posix.pipe(&fds) != .OK {
|
||||
err = _get_platform_error()
|
||||
return
|
||||
}
|
||||
|
||||
r = __new_file(fds[0])
|
||||
ri := (^File_Impl)(r.impl)
|
||||
|
||||
rname := strings.builder_make(file_allocator())
|
||||
// TODO(laytan): is this on all the posix targets?
|
||||
strings.write_string(&rname, "/dev/fd/")
|
||||
strings.write_int(&rname, int(fds[0]))
|
||||
ri.name = strings.to_string(rname)
|
||||
ri.cname = strings.to_cstring(&rname)
|
||||
|
||||
w = __new_file(fds[1])
|
||||
wi := (^File_Impl)(w.impl)
|
||||
|
||||
wname := strings.builder_make(file_allocator())
|
||||
// TODO(laytan): is this on all the posix targets?
|
||||
strings.write_string(&wname, "/dev/fd/")
|
||||
strings.write_int(&wname, int(fds[1]))
|
||||
wi.name = strings.to_string(wname)
|
||||
wi.cname = strings.to_cstring(&wname)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user