sys/posix: impl rest of linux, impl some of Windows

This commit is contained in:
Laytan Laats
2024-10-20 18:38:37 +02:00
committed by flysand7
parent 879771fe32
commit 49ddbd9b99
63 changed files with 1237 additions and 789 deletions
+30
View File
@@ -0,0 +1,30 @@
#+build linux, windows, darwin, netbsd, openbsd, freebsd
package posix
when ODIN_OS == .Windows {
foreign import lib "system:libucrt.lib"
} else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework"
} else {
foreign import lib "system:c"
}
// string.h - string operations
// NOTE: most of the symbols in this header are not useful in Odin and have been left out.
foreign lib {
/*
Map the error number to a locale-dependent error message string.
Returns: a string that may be invalidated by subsequent calls
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html ]]
*/
@(link_name="strerror")
_strerror :: proc(errnum: Errno) -> cstring ---
}
strerror :: #force_inline proc "contextless" (errnum: Maybe(Errno) = nil) -> cstring {
return _strerror(errnum.? or_else errno())
}