Update sync2 to just use atomic intrinsics rather than the parapoly wrappers

This commit is contained in:
gingerBill
2021-04-12 15:22:40 +01:00
parent e3ee005404
commit 4fb4ada2c7
7 changed files with 163 additions and 230 deletions

View File

@@ -2,7 +2,6 @@
package os
import "core:time"
import "core:path"
/*
For reference
@@ -71,6 +70,36 @@ _fill_file_info_from_stat :: proc(fi: ^File_Info, s: OS_Stat) {
fi.access_time = _make_time_from_unix_file_time(s.last_access);
}
@private
path_base :: proc(path: string) -> string {
is_separator :: proc(c: byte) -> bool {
return c == '/';
}
if path == "" {
return ".";
}
path := path;
for len(path) > 0 && is_separator(path[len(path)-1]) {
path = path[:len(path)-1];
}
i := len(path)-1;
for i >= 0 && !is_separator(path[i]) {
i -= 1;
}
if i >= 0 {
path = path[i+1:];
}
if path == "" {
return "/";
}
return path;
}
lstat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, err: Errno) {
context.allocator = allocator;
@@ -85,7 +114,7 @@ lstat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, e
if err != ERROR_NONE {
return;
}
fi.name = path.base(fi.fullpath);
fi.name = path_base(fi.fullpath);
return fi, ERROR_NONE;
}
@@ -103,7 +132,7 @@ stat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, er
if err != ERROR_NONE {
return;
}
fi.name = path.base(fi.fullpath);
fi.name = path_base(fi.fullpath);
return fi, ERROR_NONE;
}
@@ -121,6 +150,6 @@ fstat :: proc(fd: Handle, allocator := context.allocator) -> (fi: File_Info, err
if err != ERROR_NONE {
return;
}
fi.name = path.base(fi.fullpath);
fi.name = path_base(fi.fullpath);
return fi, ERROR_NONE;
}