os_essence.odin 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package os
  2. import "core:sys/es"
  3. Handle :: distinct int;
  4. Errno :: distinct int;
  5. ERROR_NONE :: (Errno) (es.SUCCESS);
  6. O_RDONLY :: 0x1;
  7. O_WRONLY :: 0x2;
  8. O_CREATE :: 0x4;
  9. O_TRUNC :: 0x8;
  10. stderr : Handle = 0;
  11. current_thread_id :: proc "contextless" () -> int {
  12. return (int) (es.ThreadGetID(es.CURRENT_THREAD));
  13. }
  14. heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
  15. return es.HeapAllocate(size, zero_memory);
  16. }
  17. heap_free :: proc(ptr: rawptr) {
  18. es.HeapFree(ptr);
  19. }
  20. heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
  21. return es.HeapReallocate(ptr, new_size, false);
  22. }
  23. open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) {
  24. return (Handle) (0), (Errno) (1);
  25. }
  26. close :: proc(fd: Handle) -> Errno {
  27. return (Errno) (1);
  28. }
  29. file_size :: proc(fd: Handle) -> (i64, Errno) {
  30. return (i64) (0), (Errno) (1);
  31. }
  32. read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
  33. return (int) (0), (Errno) (1);
  34. }
  35. write :: proc(fd: Handle, data: []u8) -> (int, Errno) {
  36. return (int) (0), (Errno) (1);
  37. }
  38. seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
  39. return (i64) (0), (Errno) (1);
  40. }