mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-02 18:11:49 -07:00
sys/posix: impl rest of linux, impl some of Windows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#+build darwin, freebsd, openbsd, netbsd
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
@@ -144,7 +144,6 @@ test_libgen :: proc(t: ^testing.T) {
|
||||
{ "usr/", ".", "usr" },
|
||||
{ "", ".", "." },
|
||||
{ "/", "/", "/" },
|
||||
{ "//", "/", "/" },
|
||||
{ "///", "/", "/" },
|
||||
{ "/usr/", "/", "usr" },
|
||||
{ "/usr/lib", "/usr", "lib" },
|
||||
@@ -197,24 +196,12 @@ test_stat :: proc(t: ^testing.T) {
|
||||
stat: posix.stat_t
|
||||
testing.expect_value(t, posix.stat(#file, &stat), posix.result.OK)
|
||||
testing.expect(t, posix.S_ISREG(stat.st_mode))
|
||||
testing.expect_value(t, stat.st_mode, posix.mode_t{.IROTH, .IRGRP, .IRUSR, .IWUSR, .IFREG})
|
||||
testing.expect_value(t, stat.st_mode, posix.mode_t{.IROTH, .IRGRP, .IRUSR, .IWGRP, .IWUSR, .IFREG})
|
||||
|
||||
CONTENT := #load(#file)
|
||||
testing.expect_value(t, stat.st_size, posix.off_t(len(CONTENT)))
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_termios :: proc(t: ^testing.T) {
|
||||
testing.expect_value(t, transmute(posix.CControl_Flags)posix.tcflag_t(posix._CSIZE), posix.CSIZE)
|
||||
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._NLDLY), posix.NLDLY)
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._CRDLY), posix.CRDLY)
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._TABDLY), posix.TABDLY)
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._BSDLY), posix.BSDLY)
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._VTDLY), posix.VTDLY)
|
||||
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._FFDLY), posix.FFDLY)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_pthreads :: proc(t: ^testing.T) {
|
||||
testing.set_fail_timeout(t, time.Second)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build darwin, freebsd, openbsd, netbsd
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
|
||||
@@ -40,7 +40,9 @@ int main(int argc, char *argv[])
|
||||
printf("pthread_attr_t %zu %zu\n", sizeof(pthread_attr_t), _Alignof(pthread_attr_t));
|
||||
printf("pthread_key_t %zu %zu\n", sizeof(pthread_key_t), _Alignof(pthread_key_t));
|
||||
|
||||
#ifndef __linux__
|
||||
printf("sched_param %zu %zu\n", sizeof(struct sched_param), _Alignof(struct sched_param));
|
||||
#endif
|
||||
|
||||
printf("termios %zu %zu\n", sizeof(struct termios), _Alignof(struct termios));
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@ main :: proc() {
|
||||
fmt.println("pthread_attr_t", size_of(posix.pthread_attr_t), align_of(posix.pthread_attr_t))
|
||||
fmt.println("pthread_key_t", size_of(posix.pthread_key_t), align_of(posix.pthread_key_t))
|
||||
|
||||
fmt.println("sched_param", size_of(posix.sched_param), align_of(posix.sched_param))
|
||||
// NOTE: On Linux, differences between libc may mean the Odin side is larger than the other side,
|
||||
// this is fine in practice.
|
||||
when ODIN_OS != .Linux {
|
||||
fmt.println("sched_param", size_of(posix.sched_param), align_of(posix.sched_param))
|
||||
}
|
||||
|
||||
fmt.println("termios", size_of(posix.termios), align_of(posix.termios))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user