Begin converting os.Errno to be a nil-able type as a transition period

This commit is contained in:
gingerBill
2024-08-04 10:51:08 +01:00
parent 71932628cc
commit e60951a902
22 changed files with 1165 additions and 666 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ HAS_RAND_BYTES :: true
_rand_bytes :: proc(dst: []byte) { _rand_bytes :: proc(dst: []byte) {
ret := (os.Errno)(win32.BCryptGenRandom(nil, raw_data(dst), u32(len(dst)), win32.BCRYPT_USE_SYSTEM_PREFERRED_RNG)) ret := (os.Errno)(win32.BCryptGenRandom(nil, raw_data(dst), u32(len(dst)), win32.BCRYPT_USE_SYSTEM_PREFERRED_RNG))
if ret != os.ERROR_NONE { if ret != os.ERROR_NONE {
switch ret { #partial switch ret {
case os.ERROR_INVALID_HANDLE: case os.ERROR_INVALID_HANDLE:
// The handle to the first parameter is invalid. // The handle to the first parameter is invalid.
// This should not happen here, since we explicitly pass nil to it // This should not happen here, since we explicitly pass nil to it
+6
View File
@@ -13,6 +13,12 @@ SEEK_SET :: 0
SEEK_CUR :: 1 SEEK_CUR :: 1
SEEK_END :: 2 SEEK_END :: 2
Platform_Error :: _Platform_Error
Error :: Platform_Error
Errno :: Error // alias
ERROR_NONE :: Errno(0)
write_string :: proc(fd: Handle, str: string) -> (int, Errno) { write_string :: proc(fd: Handle, str: string) -> (int, Errno) {
return write(fd, transmute([]byte)str) return write(fd, transmute([]byte)str)
} }
+4 -4
View File
@@ -3,7 +3,7 @@ package os2
import "core:io" import "core:io"
import "base:runtime" import "base:runtime"
General_Error :: enum u32 { General_Platform_Error :: enum u32 {
None, None,
Permission_Denied, Permission_Denied,
@@ -29,7 +29,7 @@ General_Error :: enum u32 {
Unsupported, Unsupported,
} }
Platform_Error :: enum i32 {None=0} Platform_Platform_Error :: enum i32 {None=0}
Error :: union #shared_nil { Error :: union #shared_nil {
General_Error, General_Error,
@@ -43,7 +43,7 @@ ERROR_NONE :: Error{}
is_platform_error :: proc(ferr: Error) -> (err: i32, ok: bool) { is_platform_Platform_Error :: proc(ferr: Error) -> (err: i32, ok: bool) {
v := ferr.(Platform_Error) or_else {} v := ferr.(Platform_Error) or_else {}
return i32(v), i32(v) != 0 return i32(v), i32(v) != 0
} }
@@ -104,7 +104,7 @@ error_string :: proc(ferr: Error) -> string {
return "unknown error" return "unknown error"
} }
print_error :: proc(f: ^File, ferr: Error, msg: string) { print_Platform_Error :: proc(f: ^File, ferr: Error, msg: string) {
TEMP_ALLOCATOR_GUARD() TEMP_ALLOCATOR_GUARD()
err_str := error_string(ferr) err_str := error_string(ferr)
+1 -1
View File
@@ -142,7 +142,7 @@ _errno_strings : [linux.Errno]string = {
} }
_get_platform_error :: proc(errno: linux.Errno) -> Error { _get_platform_Platform_Error :: proc(errno: linux.Errno) -> Error {
#partial switch errno { #partial switch errno {
case .NONE: case .NONE:
return nil return nil
+1 -1
View File
@@ -20,7 +20,7 @@ _error_string :: proc(errno: i32) -> string {
return "<unknown platform error>" return "<unknown platform error>"
} }
_get_platform_error :: proc() -> Error { _get_platform_Platform_Error :: proc() -> Error {
err := win32.GetLastError() err := win32.GetLastError()
if err == 0 { if err == 0 {
return nil return nil
+1 -1
View File
@@ -15,7 +15,7 @@ to_reader :: to_stream
@(private) @(private)
error_to_io_error :: proc(ferr: Error) -> io.Error { error_to_io_Platform_Error :: proc(ferr: Error) -> io.Error {
if ferr == nil { if ferr == nil {
return .None return .None
} }
+1 -1
View File
@@ -370,7 +370,7 @@ Process_State :: struct {
timeout (if specified) has reached zero. If the timeout is `TIMEOUT_INFINITE`, timeout (if specified) has reached zero. If the timeout is `TIMEOUT_INFINITE`,
no timeout restriction is imposed and the procedure can block indefinately. no timeout restriction is imposed and the procedure can block indefinately.
If the timeout has expired, the `General_Error.Timeout` is returned as If the timeout has expired, the `GeneralPlatform_Error.Timeout` is returned as
the error. the error.
If an error is returned for any other reason, other than timeout, the If an error is returned for any other reason, other than timeout, the
+7 -7
View File
@@ -101,7 +101,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
if selection >= {.PPid, .Priority} { if selection >= {.PPid, .Priority} {
entry, entry_err := _process_entry_by_pid(info.pid) entry, entry_err := _process_entry_by_pid(info.pid)
if entry_err != nil { if entry_err != nil {
err = General_Error.Not_Exist err = GeneralPlatform_Error.Not_Exist
return return
} }
if .PPid in selection { if .PPid in selection {
@@ -147,7 +147,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
} }
if process_info.PebBaseAddress == nil { if process_info.PebBaseAddress == nil {
// Not sure what the error is // Not sure what the error is
err = General_Error.Unsupported err = GeneralPlatform_Error.Unsupported
return return
} }
process_peb: win32.PEB process_peb: win32.PEB
@@ -210,7 +210,7 @@ _process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields
if selection >= {.PPid, .Priority} { // snap process if selection >= {.PPid, .Priority} { // snap process
entry, entry_err := _process_entry_by_pid(info.pid) entry, entry_err := _process_entry_by_pid(info.pid)
if entry_err != nil { if entry_err != nil {
err = General_Error.Not_Exist err = GeneralPlatform_Error.Not_Exist
return return
} }
if .PPid in selection { if .PPid in selection {
@@ -239,7 +239,7 @@ _process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields
} }
if process_info.PebBaseAddress == nil { if process_info.PebBaseAddress == nil {
// Not sure what the error is // Not sure what the error is
err = General_Error.Unsupported err = GeneralPlatform_Error.Unsupported
return return
} }
@@ -301,7 +301,7 @@ _current_process_info :: proc(selection: Process_Info_Fields, allocator: runtime
if selection >= {.PPid, .Priority} { // snap process if selection >= {.PPid, .Priority} { // snap process
entry, entry_err := _process_entry_by_pid(info.pid) entry, entry_err := _process_entry_by_pid(info.pid)
if entry_err != nil { if entry_err != nil {
err = General_Error.Not_Exist err = GeneralPlatform_Error.Not_Exist
return return
} }
if .PPid in selection { if .PPid in selection {
@@ -459,7 +459,7 @@ _process_wait :: proc(process: Process, timeout: time.Duration) -> (process_stat
} }
return return
case win32.WAIT_TIMEOUT: case win32.WAIT_TIMEOUT:
err = General_Error.Timeout err = GeneralPlatform_Error.Timeout
return return
case: case:
err = _get_platform_error() err = _get_platform_error()
@@ -508,7 +508,7 @@ _process_entry_by_pid :: proc(pid: int) -> (entry: win32.PROCESSENTRY32W, err: E
} }
status = win32.Process32NextW(snap, &entry) status = win32.Process32NextW(snap, &entry)
} }
err = General_Error.Not_Exist err = GeneralPlatform_Error.Not_Exist
return return
} }
+234 -123
View File
@@ -10,146 +10,257 @@ import "core:c"
Handle :: distinct i32 Handle :: distinct i32
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct int
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno : 0 _Platform_Error :: enum i32 {
EPERM: Errno : 1 /* Operation not permitted */ NONE = 0,
ENOENT: Errno : 2 /* No such file or directory */ EPERM = 1, /* Operation not permitted */
ESRCH: Errno : 3 /* No such process */ ENOENT = 2, /* No such file or directory */
EINTR: Errno : 4 /* Interrupted system call */ ESRCH = 3, /* No such process */
EIO: Errno : 5 /* Input/output error */ EINTR = 4, /* Interrupted system call */
ENXIO: Errno : 6 /* Device not configured */ EIO = 5, /* Input/output error */
E2BIG: Errno : 7 /* Argument list too long */ ENXIO = 6, /* Device not configured */
ENOEXEC: Errno : 8 /* Exec format error */ E2BIG = 7, /* Argument list too long */
EBADF: Errno : 9 /* Bad file descriptor */ ENOEXEC = 8, /* Exec format error */
ECHILD: Errno : 10 /* No child processes */ EBADF = 9, /* Bad file descriptor */
EDEADLK: Errno : 11 /* Resource deadlock avoided */ ECHILD = 10, /* No child processes */
ENOMEM: Errno : 12 /* Cannot allocate memory */ EDEADLK = 11, /* Resource deadlock avoided */
EACCES: Errno : 13 /* Permission denied */ ENOMEM = 12, /* Cannot allocate memory */
EFAULT: Errno : 14 /* Bad address */ EACCES = 13, /* Permission denied */
ENOTBLK: Errno : 15 /* Block device required */ EFAULT = 14, /* Bad address */
EBUSY: Errno : 16 /* Device / Resource busy */ ENOTBLK = 15, /* Block device required */
EEXIST: Errno : 17 /* File exists */ EBUSY = 16, /* Device / Resource busy */
EXDEV: Errno : 18 /* Cross-device link */ EEXIST = 17, /* File exists */
ENODEV: Errno : 19 /* Operation not supported by device */ EXDEV = 18, /* Cross-device link */
ENOTDIR: Errno : 20 /* Not a directory */ ENODEV = 19, /* Operation not supported by device */
EISDIR: Errno : 21 /* Is a directory */ ENOTDIR = 20, /* Not a directory */
EINVAL: Errno : 22 /* Invalid argument */ EISDIR = 21, /* Is a directory */
ENFILE: Errno : 23 /* Too many open files in system */ EINVAL = 22, /* Invalid argument */
EMFILE: Errno : 24 /* Too many open files */ ENFILE = 23, /* Too many open files in system */
ENOTTY: Errno : 25 /* Inappropriate ioctl for device */ EMFILE = 24, /* Too many open files */
ETXTBSY: Errno : 26 /* Text file busy */ ENOTTY = 25, /* Inappropriate ioctl for device */
EFBIG: Errno : 27 /* File too large */ ETXTBSY = 26, /* Text file busy */
ENOSPC: Errno : 28 /* No space left on device */ EFBIG = 27, /* File too large */
ESPIPE: Errno : 29 /* Illegal seek */ ENOSPC = 28, /* No space left on device */
EROFS: Errno : 30 /* Read-only file system */ ESPIPE = 29, /* Illegal seek */
EMLINK: Errno : 31 /* Too many links */ EROFS = 30, /* Read-only file system */
EPIPE: Errno : 32 /* Broken pipe */ EMLINK = 31, /* Too many links */
EPIPE = 32, /* Broken pipe */
/* math software */ /* math software */
EDOM: Errno : 33 /* Numerical argument out of domain */ EDOM = 33, /* Numerical argument out of domain */
ERANGE: Errno : 34 /* Result too large */ ERANGE = 34, /* Result too large */
/* non-blocking and interrupt i/o */ /* non-blocking and interrupt i/o */
EAGAIN: Errno : 35 /* Resource temporarily unavailable */ EAGAIN = 35, /* Resource temporarily unavailable */
EWOULDBLOCK: Errno : EAGAIN /* Operation would block */ EWOULDBLOCK = EAGAIN, /* Operation would block */
EINPROGRESS: Errno : 36 /* Operation now in progress */ EINPROGRESS = 36, /* Operation now in progress */
EALREADY: Errno : 37 /* Operation already in progress */ EALREADY = 37, /* Operation already in progress */
/* ipc/network software -- argument errors */ /* ipc/network software -- argument errors */
ENOTSOCK: Errno : 38 /* Socket operation on non-socket */ ENOTSOCK = 38, /* Socket operation on non-socket */
EDESTADDRREQ: Errno : 39 /* Destination address required */ EDESTADDRREQ = 39, /* Destination address required */
EMSGSIZE: Errno : 40 /* Message too long */ EMSGSIZE = 40, /* Message too long */
EPROTOTYPE: Errno : 41 /* Protocol wrong type for socket */ EPROTOTYPE = 41, /* Protocol wrong type for socket */
ENOPROTOOPT: Errno : 42 /* Protocol not available */ ENOPROTOOPT = 42, /* Protocol not available */
EPROTONOSUPPORT: Errno : 43 /* Protocol not supported */ EPROTONOSUPPOR = 43, /* Protocol not supported */
ESOCKTNOSUPPORT: Errno : 44 /* Socket type not supported */ ESOCKTNOSUPPOR = 44, /* Socket type not supported */
ENOTSUP: Errno : 45 /* Operation not supported */ ENOTSUP = 45, /* Operation not supported */
EOPNOTSUPP:: ENOTSUP EOPNOTSUPP = ENOTSUP,
EPFNOSUPPORT: Errno : 46 /* Protocol family not supported */ EPFNOSUPPORT = 46, /* Protocol family not supported */
EAFNOSUPPORT: Errno : 47 /* Address family not supported by protocol family */ EAFNOSUPPORT = 47, /* Address family not supported by protocol family */
EADDRINUSE: Errno : 48 /* Address already in use */ EADDRINUSE = 48, /* Address already in use */
EADDRNOTAVAIL: Errno : 49 /* Can't assign requested address */ EADDRNOTAVAIL = 49, /* Can't assign requested address */
/* ipc/network software -- operational errors */ /* ipc/network software -- operational errors */
ENETDOWN: Errno : 50 /* Network is down */ ENETDOWN = 50, /* Network is down */
ENETUNREACH: Errno : 51 /* Network is unreachable */ ENETUNREAC = 51, /* Network is unreachable */
ENETRESET: Errno : 52 /* Network dropped connection on reset */ ENETRESET = 52, /* Network dropped connection on reset */
ECONNABORTED: Errno : 53 /* Software caused connection abort */ ECONNABORTE = 53, /* Software caused connection abort */
ECONNRESET: Errno : 54 /* Connection reset by peer */ ECONNRESET = 54, /* Connection reset by peer */
ENOBUFS: Errno : 55 /* No buffer space available */ ENOBUFS = 55, /* No buffer space available */
EISCONN: Errno : 56 /* Socket is already connected */ EISCONN = 56, /* Socket is already connected */
ENOTCONN: Errno : 57 /* Socket is not connected */ ENOTCONN = 57, /* Socket is not connected */
ESHUTDOWN: Errno : 58 /* Can't send after socket shutdown */ ESHUTDOWN = 58, /* Can't send after socket shutdown */
ETOOMANYREFS: Errno : 59 /* Too many references: can't splice */ ETOOMANYREF = 59, /* Too many references: can't splice */
ETIMEDOUT: Errno : 60 /* Operation timed out */ ETIMEDOUT = 60, /* Operation timed out */
ECONNREFUSED: Errno : 61 /* Connection refused */ ECONNREFUSE = 61, /* Connection refused */
ELOOP: Errno : 62 /* Too many levels of symbolic links */ ELOOP = 62, /* Too many levels of symbolic links */
ENAMETOOLONG: Errno : 63 /* File name too long */ ENAMETOOLON = 63, /* File name too long */
/* should be rearranged */ /* should be rearranged */
EHOSTDOWN: Errno : 64 /* Host is down */ EHOSTDOWN = 64, /* Host is down */
EHOSTUNREACH: Errno : 65 /* No route to host */ EHOSTUNREAC = 65, /* No route to host */
ENOTEMPTY: Errno : 66 /* Directory not empty */ ENOTEMPTY = 66, /* Directory not empty */
/* quotas & mush */ /* quotas & mush */
EPROCLIM: Errno : 67 /* Too many processes */ EPROCLIM = 67, /* Too many processes */
EUSERS: Errno : 68 /* Too many users */ EUSERS = 68, /* Too many users */
EDQUOT: Errno : 69 /* Disc quota exceeded */ EDQUOT = 69, /* Disc quota exceeded */
/* Network File System */ /* Network File System */
ESTALE: Errno : 70 /* Stale NFS file handle */ ESTALE = 70, /* Stale NFS file handle */
EREMOTE: Errno : 71 /* Too many levels of remote in path */ EREMOTE = 71, /* Too many levels of remote in path */
EBADRPC: Errno : 72 /* RPC struct is bad */ EBADRPC = 72, /* RPC struct is bad */
ERPCMISMATCH: Errno : 73 /* RPC version wrong */ ERPCMISMATC = 73, /* RPC version wrong */
EPROGUNAVAIL: Errno : 74 /* RPC prog. not avail */ EPROGUNAVAI = 74, /* RPC prog. not avail */
EPROGMISMATCH: Errno : 75 /* Program version wrong */ EPROGMISMATC = 75, /* Program version wrong */
EPROCUNAVAIL: Errno : 76 /* Bad procedure for program */ EPROCUNAVAI = 76, /* Bad procedure for program */
ENOLCK: Errno : 77 /* No locks available */ ENOLC = 77, /* No locks available */
ENOSYS: Errno : 78 /* Function not implemented */ ENOSY = 78, /* Function not implemented */
EFTYPE: Errno : 79 /* Inappropriate file type or format */ EFTYP = 79, /* Inappropriate file type or format */
EAUTH: Errno : 80 /* Authentication error */ EAUT = 80, /* Authentication error */
ENEEDAUTH: Errno : 81 /* Need authenticator */ ENEEDAUT = 81, /* Need authenticator */
/* Intelligent device errors */ /* Intelligent device errors */
EPWROFF: Errno : 82 /* Device power is off */ EPWROF = 82, /* Device power is off */
EDEVERR: Errno : 83 /* Device error, e.g. paper out */ EDEVER = 83, /* Device error, e.g. paper out */
EOVERFLOW: Errno : 84 /* Value too large to be stored in data type */ EOVERFLO = 84, /* Value too large to be stored in data type */
/* Program loading errors */ /* Program loading errors */
EBADEXEC: Errno : 85 /* Bad executable */ EBADEXE = 85, /* Bad executable */
EBADARCH: Errno : 86 /* Bad CPU type in executable */ EBADARC = 86, /* Bad CPU type in executable */
ESHLIBVERS: Errno : 87 /* Shared library version mismatch */ ESHLIBVER = 87, /* Shared library version mismatch */
EBADMACHO: Errno : 88 /* Malformed Macho file */ EBADMACH = 88, /* Malformed Macho file */
ECANCELED: Errno : 89 /* Operation canceled */ ECANCELE = 89, /* Operation canceled */
EIDRM: Errno : 90 /* Identifier removed */ EIDRM = 90, /* Identifier removed */
ENOMSG: Errno : 91 /* No message of desired type */ ENOMSG = 91, /* No message of desired type */
EILSEQ: Errno : 92 /* Illegal byte sequence */ EILSEQ = 92, /* Illegal byte sequence */
ENOATTR: Errno : 93 /* Attribute not found */ ENOATT = 93, /* Attribute not found */
EBADMSG: Errno : 94 /* Bad message */ EBADMS = 94, /* Bad message */
EMULTIHOP: Errno : 95 /* Reserved */ EMULTIHO = 95, /* Reserved */
ENODATA: Errno : 96 /* No message available on STREAM */ ENODAT = 96, /* No message available on STREAM */
ENOLINK: Errno : 97 /* Reserved */ ENOLIN = 97, /* Reserved */
ENOSR: Errno : 98 /* No STREAM resources */ ENOSR = 98, /* No STREAM resources */
ENOSTR: Errno : 99 /* Not a STREAM */ ENOSTR = 99, /* Not a STREAM */
EPROTO: Errno : 100 /* Protocol error */ EPROTO = 100, /* Protocol error */
ETIME: Errno : 101 /* STREAM ioctl timeout */ ETIME = 101, /* STREAM ioctl timeout */
ENOPOLICY: Errno : 103 /* No such policy registered */ ENOPOLIC = 103, /* No such policy registered */
ENOTRECOVERABLE: Errno : 104 /* State not recoverable */ ENOTRECOVERABL = 104, /* State not recoverable */
EOWNERDEAD: Errno : 105 /* Previous owner died */ EOWNERDEAD = 105, /* Previous owner died */
EQFULL: Errno : 106 /* Interface output queue is full */ EQFUL = 106, /* Interface output queue is full */
ELAST: Errno : 106 /* Must be equal largest errno */ ELAS = 106, /* Must be equal largest errno */
}
EPERM :: Platform_Error.EPERM
ENOENT :: Platform_Error.ENOENT
ESRCH :: Platform_Error.ESRCH
EINTR :: Platform_Error.EINTR
EIO :: Platform_Error.EIO
ENXIO :: Platform_Error.ENXIO
E2BIG :: Platform_Error.E2BIG
ENOEXEC :: Platform_Error.ENOEXEC
EBADF :: Platform_Error.EBADF
ECHILD :: Platform_Error.ECHILD
EDEADLK :: Platform_Error.EDEADLK
ENOMEM :: Platform_Error.ENOMEM
EACCES :: Platform_Error.EACCES
EFAULT :: Platform_Error.EFAULT
ENOTBLK :: Platform_Error.ENOTBLK
EBUSY :: Platform_Error.EBUSY
EEXIST :: Platform_Error.EEXIST
EXDEV :: Platform_Error.EXDEV
ENODEV :: Platform_Error.ENODEV
ENOTDIR :: Platform_Error.ENOTDIR
EISDIR :: Platform_Error.EISDIR
EINVAL :: Platform_Error.EINVAL
ENFILE :: Platform_Error.ENFILE
EMFILE :: Platform_Error.EMFILE
ENOTTY :: Platform_Error.ENOTTY
ETXTBSY :: Platform_Error.ETXTBSY
EFBIG :: Platform_Error.EFBIG
ENOSPC :: Platform_Error.ENOSPC
ESPIPE :: Platform_Error.ESPIPE
EROFS :: Platform_Error.EROFS
EMLINK :: Platform_Error.EMLINK
EPIPE :: Platform_Error.EPIPE
EDOM :: Platform_Error.EDOM
ERANGE :: Platform_Error.ERANGE
EAGAIN :: Platform_Error.EAGAIN
EWOULDBLOCK :: Platform_Error.EWOULDBLOCK
EINPROGRESS :: Platform_Error.EINPROGRESS
EALREADY :: Platform_Error.EALREADY
ENOTSOCK :: Platform_Error.ENOTSOCK
EDESTADDRREQ :: Platform_Error.EDESTADDRREQ
EMSGSIZE :: Platform_Error.EMSGSIZE
EPROTOTYPE :: Platform_Error.EPROTOTYPE
ENOPROTOOPT :: Platform_Error.ENOPROTOOPT
EPROTONOSUPPOR :: Platform_Error.EPROTONOSUPPOR
ESOCKTNOSUPPOR :: Platform_Error.ESOCKTNOSUPPOR
ENOTSUP :: Platform_Error.ENOTSUP
EOPNOTSUPP :: Platform_Error.EOPNOTSUPP
EPFNOSUPPORT :: Platform_Error.EPFNOSUPPORT
EAFNOSUPPORT :: Platform_Error.EAFNOSUPPORT
EADDRINUSE :: Platform_Error.EADDRINUSE
EADDRNOTAVAIL :: Platform_Error.EADDRNOTAVAIL
ENETDOWN :: Platform_Error.ENETDOWN
ENETUNREAC :: Platform_Error.ENETUNREAC
ENETRESET :: Platform_Error.ENETRESET
ECONNABORTE :: Platform_Error.ECONNABORTE
ECONNRESET :: Platform_Error.ECONNRESET
ENOBUFS :: Platform_Error.ENOBUFS
EISCONN :: Platform_Error.EISCONN
ENOTCONN :: Platform_Error.ENOTCONN
ESHUTDOWN :: Platform_Error.ESHUTDOWN
ETOOMANYREF :: Platform_Error.ETOOMANYREF
ETIMEDOUT :: Platform_Error.ETIMEDOUT
ECONNREFUSE :: Platform_Error.ECONNREFUSE
ELOOP :: Platform_Error.ELOOP
ENAMETOOLON :: Platform_Error.ENAMETOOLON
EHOSTDOWN :: Platform_Error.EHOSTDOWN
EHOSTUNREAC :: Platform_Error.EHOSTUNREAC
ENOTEMPTY :: Platform_Error.ENOTEMPTY
EPROCLIM :: Platform_Error.EPROCLIM
EUSERS :: Platform_Error.EUSERS
EDQUOT :: Platform_Error.EDQUOT
ESTALE :: Platform_Error.ESTALE
EREMOTE :: Platform_Error.EREMOTE
EBADRPC :: Platform_Error.EBADRPC
ERPCMISMATC :: Platform_Error.ERPCMISMATC
EPROGUNAVAI :: Platform_Error.EPROGUNAVAI
EPROGMISMATC :: Platform_Error.EPROGMISMATC
EPROCUNAVAI :: Platform_Error.EPROCUNAVAI
ENOLC :: Platform_Error.ENOLC
ENOSY :: Platform_Error.ENOSY
EFTYP :: Platform_Error.EFTYP
EAUT :: Platform_Error.EAUT
ENEEDAUT :: Platform_Error.ENEEDAUT
EPWROF :: Platform_Error.EPWROF
EDEVER :: Platform_Error.EDEVER
EOVERFLO :: Platform_Error.EOVERFLO
EBADEXE :: Platform_Error.EBADEXE
EBADARC :: Platform_Error.EBADARC
ESHLIBVER :: Platform_Error.ESHLIBVER
EBADMACH :: Platform_Error.EBADMACH
ECANCELE :: Platform_Error.ECANCELE
EIDRM :: Platform_Error.EIDRM
ENOMSG :: Platform_Error.ENOMSG
EILSEQ :: Platform_Error.EILSEQ
ENOATT :: Platform_Error.ENOATT
EBADMS :: Platform_Error.EBADMS
EMULTIHO :: Platform_Error.EMULTIHO
ENODAT :: Platform_Error.ENODAT
ENOLIN :: Platform_Error.ENOLIN
ENOSR :: Platform_Error.ENOSR
ENOSTR :: Platform_Error.ENOSTR
EPROTO :: Platform_Error.EPROTO
ETIME :: Platform_Error.ETIME
ENOPOLIC :: Platform_Error.ENOPOLIC
ENOTRECOVERABL :: Platform_Error.ENOTRECOVERABL
EOWNERDEAD :: Platform_Error.EOWNERDEAD
EQFUL :: Platform_Error.EQFUL
ELAS :: Platform_Error.ELAS
O_RDONLY :: 0x0000 O_RDONLY :: 0x0000
O_WRONLY :: 0x0001 O_WRONLY :: 0x0001
@@ -524,12 +635,12 @@ foreign dl {
@(link_name="dlerror") _unix_dlerror :: proc() -> cstring --- @(link_name="dlerror") _unix_dlerror :: proc() -> cstring ---
} }
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__error()^) return Error(__error()^)
} }
get_last_error_string :: proc() -> string { get_last_error_string :: proc() -> string {
return cast(string)_darwin_string_error(cast(c.int)get_last_error()) return string(_darwin_string_error(__error()^))
} }
@@ -548,7 +659,7 @@ open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (Handle, Errno
cstr := strings.clone_to_cstring(path, context.temp_allocator) cstr := strings.clone_to_cstring(path, context.temp_allocator)
handle := _unix_open(cstr, i32(flags), u16(mode)) handle := _unix_open(cstr, i32(flags), u16(mode))
if handle == -1 { if handle == -1 {
return INVALID_HANDLE, cast(Errno)get_last_error() return INVALID_HANDLE, get_last_error()
} }
/* /*
+18 -18
View File
@@ -2,54 +2,54 @@ package os
import "core:sys/es" import "core:sys/es"
Handle :: distinct int; Handle :: distinct int
Errno :: distinct int; _Platform_Error :: enum i32 {NONE}
ERROR_NONE :: (Errno) (es.SUCCESS); ERROR_NONE :: Errno(es.SUCCESS)
O_RDONLY :: 0x1; O_RDONLY :: 0x1
O_WRONLY :: 0x2; O_WRONLY :: 0x2
O_CREATE :: 0x4; O_CREATE :: 0x4
O_TRUNC :: 0x8; O_TRUNC :: 0x8
stderr : Handle = 0; stderr : Handle = 0
current_thread_id :: proc "contextless" () -> int { current_thread_id :: proc "contextless" () -> int {
return (int) (es.ThreadGetID(es.CURRENT_THREAD)); return (int) (es.ThreadGetID(es.CURRENT_THREAD))
} }
heap_alloc :: proc(size: int, zero_memory := true) -> rawptr { heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
return es.HeapAllocate(size, zero_memory); return es.HeapAllocate(size, zero_memory)
} }
heap_free :: proc(ptr: rawptr) { heap_free :: proc(ptr: rawptr) {
es.HeapFree(ptr); es.HeapFree(ptr)
} }
heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr { heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
return es.HeapReallocate(ptr, new_size, false); return es.HeapReallocate(ptr, new_size, false)
} }
open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) {
return (Handle) (0), (Errno) (1); return (Handle) (0), (Errno) (1)
} }
close :: proc(fd: Handle) -> Errno { close :: proc(fd: Handle) -> Errno {
return (Errno) (1); return (Errno) (1)
} }
file_size :: proc(fd: Handle) -> (i64, Errno) { file_size :: proc(fd: Handle) -> (i64, Errno) {
return (i64) (0), (Errno) (1); return (i64) (0), (Errno) (1)
} }
read :: proc(fd: Handle, data: []byte) -> (int, Errno) { read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
return (int) (0), (Errno) (1); return (int) (0), (Errno) (1)
} }
write :: proc(fd: Handle, data: []u8) -> (int, Errno) { write :: proc(fd: Handle, data: []u8) -> (int, Errno) {
return (int) (0), (Errno) (1); return (int) (0), (Errno) (1)
} }
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
return (i64) (0), (Errno) (1); return (i64) (0), (Errno) (1)
} }
+193 -98
View File
@@ -9,105 +9,200 @@ import "core:c"
Handle :: distinct i32 Handle :: distinct i32
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct i32
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno : 0 _Platform_Error :: enum i32 {
EPERM: Errno : 1 NONE = 0,
ENOENT: Errno : 2 EPERM = 1,
ESRCH: Errno : 3 ENOENT = 2,
EINTR: Errno : 4 ESRCH = 3,
EIO: Errno : 5 EINTR = 4,
ENXIO: Errno : 6 EIO = 5,
E2BIG: Errno : 7 ENXIO = 6,
ENOEXEC: Errno : 8 E2BIG = 7,
EBADF: Errno : 9 ENOEXEC = 8,
ECHILD: Errno : 10 EBADF = 9,
EBEADLK: Errno : 11 ECHILD = 10,
ENOMEM: Errno : 12 EBEADLK = 11,
EACCESS: Errno : 13 ENOMEM = 12,
EFAULT: Errno : 14 EACCESS = 13,
ENOTBLK: Errno : 15 EFAULT = 14,
EBUSY: Errno : 16 ENOTBLK = 15,
EEXIST: Errno : 17 EBUSY = 16,
EXDEV: Errno : 18 EEXIST = 17,
ENODEV: Errno : 19 EXDEV = 18,
ENOTDIR: Errno : 20 ENODEV = 19,
EISDIR: Errno : 21 ENOTDIR = 20,
EINVAL: Errno : 22 EISDIR = 21,
ENFILE: Errno : 23 EINVAL = 22,
EMFILE: Errno : 24 ENFILE = 23,
ENOTTY: Errno : 25 EMFILE = 24,
ETXTBSY: Errno : 26 ENOTTY = 25,
EFBIG: Errno : 27 ETXTBSY = 26,
ENOSPC: Errno : 28 EFBIG = 27,
ESPIPE: Errno : 29 ENOSPC = 28,
EROFS: Errno : 30 ESPIPE = 29,
EMLINK: Errno : 31 EROFS = 30,
EPIPE: Errno : 32 EMLINK = 31,
EDOM: Errno : 33 EPIPE = 32,
ERANGE: Errno : 34 /* Result too large */ EDOM = 33,
EAGAIN: Errno : 35 ERANGE = 34, /* Result too large */
EINPROGRESS: Errno : 36 EAGAIN = 35,
EALREADY: Errno : 37 EINPROGRESS = 36,
ENOTSOCK: Errno : 38 EALREADY = 37,
EDESTADDRREQ: Errno : 39 ENOTSOCK = 38,
EMSGSIZE: Errno : 40 EDESTADDRREQ = 39,
EPROTOTYPE: Errno : 41 EMSGSIZE = 40,
ENOPROTOOPT: Errno : 42 EPROTOTYPE = 41,
EPROTONOSUPPORT: Errno : 43 ENOPROTOOPT = 42,
ESOCKTNOSUPPORT: Errno : 44 EPROTONOSUPPORT = 43,
EOPNOTSUPP: Errno : 45 ESOCKTNOSUPPORT = 44,
EPFNOSUPPORT: Errno : 46 EOPNOTSUPP = 45,
EAFNOSUPPORT: Errno : 47 EPFNOSUPPORT = 46,
EADDRINUSE: Errno : 48 EAFNOSUPPORT = 47,
EADDRNOTAVAIL: Errno : 49 EADDRINUSE = 48,
ENETDOWN: Errno : 50 EADDRNOTAVAIL = 49,
ENETUNREACH: Errno : 51 ENETDOWN = 50,
ENETRESET: Errno : 52 ENETUNREACH = 51,
ECONNABORTED: Errno : 53 ENETRESET = 52,
ECONNRESET: Errno : 54 ECONNABORTED = 53,
ENOBUFS: Errno : 55 ECONNRESET = 54,
EISCONN: Errno : 56 ENOBUFS = 55,
ENOTCONN: Errno : 57 EISCONN = 56,
ESHUTDOWN: Errno : 58 ENOTCONN = 57,
ETIMEDOUT: Errno : 60 ESHUTDOWN = 58,
ECONNREFUSED: Errno : 61 ETIMEDOUT = 60,
ELOOP: Errno : 62 ECONNREFUSED = 61,
ENAMETOOLING: Errno : 63 ELOOP = 62,
EHOSTDOWN: Errno : 64 ENAMETOOLING = 63,
EHOSTUNREACH: Errno : 65 EHOSTDOWN = 64,
ENOTEMPTY: Errno : 66 EHOSTUNREACH = 65,
EPROCLIM: Errno : 67 ENOTEMPTY = 66,
EUSERS: Errno : 68 EPROCLIM = 67,
EDQUOT: Errno : 69 EUSERS = 68,
ESTALE: Errno : 70 EDQUOT = 69,
EBADRPC: Errno : 72 ESTALE = 70,
ERPCMISMATCH: Errno : 73 EBADRPC = 72,
EPROGUNAVAIL: Errno : 74 ERPCMISMATCH = 73,
EPROGMISMATCH: Errno : 75 EPROGUNAVAIL = 74,
EPROCUNAVAIL: Errno : 76 EPROGMISMATCH = 75,
ENOLCK: Errno : 77 EPROCUNAVAIL = 76,
ENOSYS: Errno : 78 ENOLCK = 77,
EFTYPE: Errno : 79 ENOSYS = 78,
EAUTH: Errno : 80 EFTYPE = 79,
ENEEDAUTH: Errno : 81 EAUTH = 80,
EIDRM: Errno : 82 ENEEDAUTH = 81,
ENOMSG: Errno : 83 EIDRM = 82,
EOVERFLOW: Errno : 84 ENOMSG = 83,
ECANCELED: Errno : 85 EOVERFLOW = 84,
EILSEQ: Errno : 86 ECANCELED = 85,
ENOATTR: Errno : 87 EILSEQ = 86,
EDOOFUS: Errno : 88 ENOATTR = 87,
EBADMSG: Errno : 89 EDOOFUS = 88,
EMULTIHOP: Errno : 90 EBADMSG = 89,
ENOLINK: Errno : 91 EMULTIHOP = 90,
EPROTO: Errno : 92 ENOLINK = 91,
ENOTCAPABLE: Errno : 93 EPROTO = 92,
ECAPMODE: Errno : 94 ENOTCAPABLE = 93,
ENOTRECOVERABLE: Errno : 95 ECAPMODE = 94,
EOWNERDEAD: Errno : 96 ENOTRECOVERABLE = 95,
EOWNERDEAD = 96,
}
EPERM :: Platform_Error.EPERM
ENOENT :: Platform_Error.ENOENT
ESRCH :: Platform_Error.ESRCH
EINTR :: Platform_Error.EINTR
EIO :: Platform_Error.EIO
ENXIO :: Platform_Error.ENXIO
E2BIG :: Platform_Error.E2BIG
ENOEXEC :: Platform_Error.ENOEXEC
EBADF :: Platform_Error.EBADF
ECHILD :: Platform_Error.ECHILD
EBEADLK :: Platform_Error.EBEADLK
ENOMEM :: Platform_Error.ENOMEM
EACCESS :: Platform_Error.EACCESS
EFAULT :: Platform_Error.EFAULT
ENOTBLK :: Platform_Error.ENOTBLK
EBUSY :: Platform_Error.EBUSY
EEXIST :: Platform_Error.EEXIST
EXDEV :: Platform_Error.EXDEV
ENODEV :: Platform_Error.ENODEV
ENOTDIR :: Platform_Error.ENOTDIR
EISDIR :: Platform_Error.EISDIR
EINVAL :: Platform_Error.EINVAL
ENFILE :: Platform_Error.ENFILE
EMFILE :: Platform_Error.EMFILE
ENOTTY :: Platform_Error.ENOTTY
ETXTBSY :: Platform_Error.ETXTBSY
EFBIG :: Platform_Error.EFBIG
ENOSPC :: Platform_Error.ENOSPC
ESPIPE :: Platform_Error.ESPIPE
EROFS :: Platform_Error.EROFS
EMLINK :: Platform_Error.EMLINK
EPIPE :: Platform_Error.EPIPE
EDOM :: Platform_Error.EDOM
ERANGE :: Platform_Error.ERANGE
EAGAIN :: Platform_Error.EAGAIN
EINPROGRESS :: Platform_Error.EINPROGRESS
EALREADY :: Platform_Error.EALREADY
ENOTSOCK :: Platform_Error.ENOTSOCK
EDESTADDRREQ :: Platform_Error.EDESTADDRREQ
EMSGSIZE :: Platform_Error.EMSGSIZE
EPROTOTYPE :: Platform_Error.EPROTOTYPE
ENOPROTOOPT :: Platform_Error.ENOPROTOOPT
EPROTONOSUPPORT :: Platform_Error.EPROTONOSUPPORT
ESOCKTNOSUPPORT :: Platform_Error.ESOCKTNOSUPPORT
EOPNOTSUPP :: Platform_Error.EOPNOTSUPP
EPFNOSUPPORT :: Platform_Error.EPFNOSUPPORT
EAFNOSUPPORT :: Platform_Error.EAFNOSUPPORT
EADDRINUSE :: Platform_Error.EADDRINUSE
EADDRNOTAVAIL :: Platform_Error.EADDRNOTAVAIL
ENETDOWN :: Platform_Error.ENETDOWN
ENETUNREACH :: Platform_Error.ENETUNREACH
ENETRESET :: Platform_Error.ENETRESET
ECONNABORTED :: Platform_Error.ECONNABORTED
ECONNRESET :: Platform_Error.ECONNRESET
ENOBUFS :: Platform_Error.ENOBUFS
EISCONN :: Platform_Error.EISCONN
ENOTCONN :: Platform_Error.ENOTCONN
ESHUTDOWN :: Platform_Error.ESHUTDOWN
ETIMEDOUT :: Platform_Error.ETIMEDOUT
ECONNREFUSED :: Platform_Error.ECONNREFUSED
ELOOP :: Platform_Error.ELOOP
ENAMETOOLING :: Platform_Error.ENAMETOOLING
EHOSTDOWN :: Platform_Error.EHOSTDOWN
EHOSTUNREACH :: Platform_Error.EHOSTUNREACH
ENOTEMPTY :: Platform_Error.ENOTEMPTY
EPROCLIM :: Platform_Error.EPROCLIM
EUSERS :: Platform_Error.EUSERS
EDQUOT :: Platform_Error.EDQUOT
ESTALE :: Platform_Error.ESTALE
EBADRPC :: Platform_Error.EBADRPC
ERPCMISMATCH :: Platform_Error.ERPCMISMATCH
EPROGUNAVAIL :: Platform_Error.EPROGUNAVAIL
EPROGMISMATCH :: Platform_Error.EPROGMISMATCH
EPROCUNAVAIL :: Platform_Error.EPROCUNAVAIL
ENOLCK :: Platform_Error.ENOLCK
ENOSYS :: Platform_Error.ENOSYS
EFTYPE :: Platform_Error.EFTYPE
EAUTH :: Platform_Error.EAUTH
ENEEDAUTH :: Platform_Error.ENEEDAUTH
EIDRM :: Platform_Error.EIDRM
ENOMSG :: Platform_Error.ENOMSG
EOVERFLOW :: Platform_Error.EOVERFLOW
ECANCELED :: Platform_Error.ECANCELED
EILSEQ :: Platform_Error.EILSEQ
ENOATTR :: Platform_Error.ENOATTR
EDOOFUS :: Platform_Error.EDOOFUS
EBADMSG :: Platform_Error.EBADMSG
EMULTIHOP :: Platform_Error.EMULTIHOP
ENOLINK :: Platform_Error.ENOLINK
EPROTO :: Platform_Error.EPROTO
ENOTCAPABLE :: Platform_Error.ENOTCAPABLE
ECAPMODE :: Platform_Error.ECAPMODE
ENOTRECOVERABLE :: Platform_Error.ENOTRECOVERABLE
EOWNERDEAD :: Platform_Error.EOWNERDEAD
O_RDONLY :: 0x00000 O_RDONLY :: 0x00000
O_WRONLY :: 0x00001 O_WRONLY :: 0x00001
@@ -324,8 +419,8 @@ is_path_separator :: proc(r: rune) -> bool {
return r == '/' return r == '/'
} }
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__errno_location()^) return Error(__errno_location()^)
} }
open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) {
+6 -8
View File
@@ -10,16 +10,14 @@ import "core:sys/haiku"
Handle :: i32 Handle :: i32
Pid :: i32 Pid :: i32
File_Time :: i64 File_Time :: i64
Errno :: i32 _Platform_Error :: haiku.Errno
MAX_PATH :: haiku.PATH_MAX MAX_PATH :: haiku.PATH_MAX
ENOSYS :: int(haiku.Errno.POSIX_ERROR_BASE) + 9 ENOSYS :: _Platform_Error(i32(haiku.Errno.POSIX_ERROR_BASE) + 9)
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno: 0
stdin: Handle = 0 stdin: Handle = 0
stdout: Handle = 1 stdout: Handle = 1
stderr: Handle = 2 stderr: Handle = 2
@@ -183,8 +181,8 @@ is_path_separator :: proc(r: rune) -> bool {
return r == '/' return r == '/'
} }
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__error()^) return Error(__error()^)
} }
fork :: proc() -> (Pid, Errno) { fork :: proc() -> (Pid, Errno) {
@@ -391,8 +389,8 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) {
} }
defer _unix_free(path_ptr) defer _unix_free(path_ptr)
path_cstr := transmute(cstring)path_ptr path_cstr := cstring(path_ptr)
path = strings.clone( string(path_cstr) ) path = strings.clone(string(path_cstr))
return path, ERROR_NONE return path, ERROR_NONE
} }
+62 -30
View File
@@ -161,7 +161,40 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F
Handle :: distinct uintptr Handle :: distinct uintptr
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct int
_Platform_Error :: enum i32 {
NONE = 0,
FILE_NOT_FOUND = 2,
PATH_NOT_FOUND = 3,
ACCESS_DENIED = 5,
INVALID_HANDLE = 6,
NOT_ENOUGH_MEMORY = 8,
NO_MORE_FILES = 18,
HANDLE_EOF = 38,
NETNAME_DELETED = 64,
FILE_EXISTS = 80,
INVALID_PARAMETER = 87,
BROKEN_PIPE = 109,
BUFFER_OVERFLOW = 111,
INSUFFICIENT_BUFFER = 122,
MOD_NOT_FOUND = 126,
PROC_NOT_FOUND = 127,
DIR_NOT_EMPTY = 145,
ALREADY_EXISTS = 183,
ENVVAR_NOT_FOUND = 203,
MORE_DATA = 234,
OPERATION_ABORTED = 995,
IO_PENDING = 997,
NOT_FOUND = 1168,
PRIVILEGE_NOT_HELD = 1314,
WSAEACCES = 10013,
WSAECONNRESET = 10054,
// Windows reserves errors >= 1<<29 for application use
FILE_IS_PIPE = 1<<29 + 0,
FILE_IS_NOT_DIR = 1<<29 + 1,
NEGATIVE_OFFSET = 1<<29 + 2,
}
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
@@ -182,37 +215,36 @@ O_ASYNC :: 0x02000
O_CLOEXEC :: 0x80000 O_CLOEXEC :: 0x80000
ERROR_NONE: Errno : 0 ERROR_FILE_NOT_FOUND :: Platform_Error.FILE_NOT_FOUND
ERROR_FILE_NOT_FOUND: Errno : 2 ERROR_PATH_NOT_FOUND :: Platform_Error.PATH_NOT_FOUND
ERROR_PATH_NOT_FOUND: Errno : 3 ERROR_ACCESS_DENIED :: Platform_Error.ACCESS_DENIED
ERROR_ACCESS_DENIED: Errno : 5 ERROR_INVALID_HANDLE :: Platform_Error.INVALID_HANDLE
ERROR_INVALID_HANDLE: Errno : 6 ERROR_NOT_ENOUGH_MEMORY :: Platform_Error.NOT_ENOUGH_MEMORY
ERROR_NOT_ENOUGH_MEMORY: Errno : 8 ERROR_NO_MORE_FILES :: Platform_Error.NO_MORE_FILES
ERROR_NO_MORE_FILES: Errno : 18 ERROR_HANDLE_EOF :: Platform_Error.HANDLE_EOF
ERROR_HANDLE_EOF: Errno : 38 ERROR_NETNAME_DELETED :: Platform_Error.NETNAME_DELETED
ERROR_NETNAME_DELETED: Errno : 64 ERROR_FILE_EXISTS :: Platform_Error.FILE_EXISTS
ERROR_FILE_EXISTS: Errno : 80 ERROR_INVALID_PARAMETER :: Platform_Error.INVALID_PARAMETER
ERROR_INVALID_PARAMETER: Errno : 87 ERROR_BROKEN_PIPE :: Platform_Error.BROKEN_PIPE
ERROR_BROKEN_PIPE: Errno : 109 ERROR_BUFFER_OVERFLOW :: Platform_Error.BUFFER_OVERFLOW
ERROR_BUFFER_OVERFLOW: Errno : 111 ERROR_INSUFFICIENT_BUFFER :: Platform_Error.INSUFFICIENT_BUFFER
ERROR_INSUFFICIENT_BUFFER: Errno : 122 ERROR_MOD_NOT_FOUND :: Platform_Error.MOD_NOT_FOUND
ERROR_MOD_NOT_FOUND: Errno : 126 ERROR_PROC_NOT_FOUND :: Platform_Error.PROC_NOT_FOUND
ERROR_PROC_NOT_FOUND: Errno : 127 ERROR_DIR_NOT_EMPTY :: Platform_Error.DIR_NOT_EMPTY
ERROR_DIR_NOT_EMPTY: Errno : 145 ERROR_ALREADY_EXISTS :: Platform_Error.ALREADY_EXISTS
ERROR_ALREADY_EXISTS: Errno : 183 ERROR_ENVVAR_NOT_FOUND :: Platform_Error.ENVVAR_NOT_FOUND
ERROR_ENVVAR_NOT_FOUND: Errno : 203 ERROR_MORE_DATA :: Platform_Error.MORE_DATA
ERROR_MORE_DATA: Errno : 234 ERROR_OPERATION_ABORTED :: Platform_Error.OPERATION_ABORTED
ERROR_OPERATION_ABORTED: Errno : 995 ERROR_IO_PENDING :: Platform_Error.IO_PENDING
ERROR_IO_PENDING: Errno : 997 ERROR_NOT_FOUND :: Platform_Error.NOT_FOUND
ERROR_NOT_FOUND: Errno : 1168 ERROR_PRIVILEGE_NOT_HELD :: Platform_Error.PRIVILEGE_NOT_HELD
ERROR_PRIVILEGE_NOT_HELD: Errno : 1314 WSAEACCES :: Platform_Error.WSAEACCES
WSAEACCES: Errno : 10013 WSAECONNRESET :: Platform_Error.WSAECONNRESET
WSAECONNRESET: Errno : 10054
// Windows reserves errors >= 1<<29 for application use // Windows reserves errors >= 1<<29 for application use
ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0 ERROR_FILE_IS_PIPE :: Platform_Error.FILE_IS_PIPE
ERROR_FILE_IS_NOT_DIR: Errno : 1<<29 + 1 ERROR_FILE_IS_NOT_DIR :: Platform_Error.FILE_IS_NOT_DIR
ERROR_NEGATIVE_OFFSET: Errno : 1<<29 + 2 ERROR_NEGATIVE_OFFSET :: Platform_Error.NEGATIVE_OFFSET
// "Argv" arguments converted to Odin strings // "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments() args := _alloc_command_line_arguments()
+128 -128
View File
@@ -20,148 +20,148 @@ import "base:intrinsics"
// all that about compatibility. But we don't want to push experimental changes // all that about compatibility. But we don't want to push experimental changes
// and have people's code break while it's still work in progress. // and have people's code break while it's still work in progress.
import unix "core:sys/unix" import unix "core:sys/unix"
import linux "core:sys/linux"
Handle :: distinct i32 Handle :: distinct i32
Pid :: distinct i32 Pid :: distinct i32
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct i32
Socket :: distinct int Socket :: distinct int
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno : 0 _Platform_Error :: linux.Errno
EPERM: Errno : 1 EPERM :: Platform_Error.EPERM
ENOENT: Errno : 2 ENOENT :: Platform_Error.ENOENT
ESRCH: Errno : 3 ESRCH :: Platform_Error.ESRCH
EINTR: Errno : 4 EINTR :: Platform_Error.EINTR
EIO: Errno : 5 EIO :: Platform_Error.EIO
ENXIO: Errno : 6 ENXIO :: Platform_Error.ENXIO
EBADF: Errno : 9 EBADF :: Platform_Error.EBADF
EAGAIN: Errno : 11 EAGAIN :: Platform_Error.EAGAIN
ENOMEM: Errno : 12 ENOMEM :: Platform_Error.ENOMEM
EACCES: Errno : 13 EACCES :: Platform_Error.EACCES
EFAULT: Errno : 14 EFAULT :: Platform_Error.EFAULT
EEXIST: Errno : 17 EEXIST :: Platform_Error.EEXIST
ENODEV: Errno : 19 ENODEV :: Platform_Error.ENODEV
ENOTDIR: Errno : 20 ENOTDIR :: Platform_Error.ENOTDIR
EISDIR: Errno : 21 EISDIR :: Platform_Error.EISDIR
EINVAL: Errno : 22 EINVAL :: Platform_Error.EINVAL
ENFILE: Errno : 23 ENFILE :: Platform_Error.ENFILE
EMFILE: Errno : 24 EMFILE :: Platform_Error.EMFILE
ETXTBSY: Errno : 26 ETXTBSY :: Platform_Error.ETXTBSY
EFBIG: Errno : 27 EFBIG :: Platform_Error.EFBIG
ENOSPC: Errno : 28 ENOSPC :: Platform_Error.ENOSPC
ESPIPE: Errno : 29 ESPIPE :: Platform_Error.ESPIPE
EROFS: Errno : 30 EROFS :: Platform_Error.EROFS
EPIPE: Errno : 32 EPIPE :: Platform_Error.EPIPE
ERANGE: Errno : 34 /* Result too large */ ERANGE :: Platform_Error.ERANGE /* Result too large */
EDEADLK: Errno : 35 /* Resource deadlock would occur */ EDEADLK :: Platform_Error.EDEADLK /* Resource deadlock would occur */
ENAMETOOLONG: Errno : 36 /* File name too long */ ENAMETOOLONG :: Platform_Error.ENAMETOOLONG /* File name too long */
ENOLCK: Errno : 37 /* No record locks available */ ENOLCK :: Platform_Error.ENOLCK /* No record locks available */
ENOSYS: Errno : 38 /* Invalid system call number */ ENOSYS :: Platform_Error.ENOSYS /* Invalid system call number */
ENOTEMPTY: Errno : 39 /* Directory not empty */ ENOTEMPTY :: Platform_Error.ENOTEMPTY /* Directory not empty */
ELOOP: Errno : 40 /* Too many symbolic links encountered */ ELOOP :: Platform_Error.ELOOP /* Too many symbolic links encountered */
EWOULDBLOCK: Errno : EAGAIN /* Operation would block */ EWOULDBLOCK :: Platform_Error.EWOULDBLOCK /* Operation would block */
ENOMSG: Errno : 42 /* No message of desired type */ ENOMSG :: Platform_Error.ENOMSG /* No message of desired type */
EIDRM: Errno : 43 /* Identifier removed */ EIDRM :: Platform_Error.EIDRM /* Identifier removed */
ECHRNG: Errno : 44 /* Channel number out of range */ ECHRNG :: Platform_Error.ECHRNG /* Channel number out of range */
EL2NSYNC: Errno : 45 /* Level 2 not synchronized */ EL2NSYNC :: Platform_Error.EL2NSYNC /* Level 2 not synchronized */
EL3HLT: Errno : 46 /* Level 3 halted */ EL3HLT :: Platform_Error.EL3HLT /* Level 3 halted */
EL3RST: Errno : 47 /* Level 3 reset */ EL3RST :: Platform_Error.EL3RST /* Level 3 reset */
ELNRNG: Errno : 48 /* Link number out of range */ ELNRNG :: Platform_Error.ELNRNG /* Link number out of range */
EUNATCH: Errno : 49 /* Protocol driver not attached */ EUNATCH :: Platform_Error.EUNATCH /* Protocol driver not attached */
ENOCSI: Errno : 50 /* No CSI structure available */ ENOCSI :: Platform_Error.ENOCSI /* No CSI structure available */
EL2HLT: Errno : 51 /* Level 2 halted */ EL2HLT :: Platform_Error.EL2HLT /* Level 2 halted */
EBADE: Errno : 52 /* Invalid exchange */ EBADE :: Platform_Error.EBADE /* Invalid exchange */
EBADR: Errno : 53 /* Invalid request descriptor */ EBADR :: Platform_Error.EBADR /* Invalid request descriptor */
EXFULL: Errno : 54 /* Exchange full */ EXFULL :: Platform_Error.EXFULL /* Exchange full */
ENOANO: Errno : 55 /* No anode */ ENOANO :: Platform_Error.ENOANO /* No anode */
EBADRQC: Errno : 56 /* Invalid request code */ EBADRQC :: Platform_Error.EBADRQC /* Invalid request code */
EBADSLT: Errno : 57 /* Invalid slot */ EBADSLT :: Platform_Error.EBADSLT /* Invalid slot */
EDEADLOCK: Errno : EDEADLK EDEADLOCK :: Platform_Error.EDEADLOCK
EBFONT: Errno : 59 /* Bad font file format */ EBFONT :: Platform_Error.EBFONT /* Bad font file format */
ENOSTR: Errno : 60 /* Device not a stream */ ENOSTR :: Platform_Error.ENOSTR /* Device not a stream */
ENODATA: Errno : 61 /* No data available */ ENODATA :: Platform_Error.ENODATA /* No data available */
ETIME: Errno : 62 /* Timer expired */ ETIME :: Platform_Error.ETIME /* Timer expired */
ENOSR: Errno : 63 /* Out of streams resources */ ENOSR :: Platform_Error.ENOSR /* Out of streams resources */
ENONET: Errno : 64 /* Machine is not on the network */ ENONET :: Platform_Error.ENONET /* Machine is not on the network */
ENOPKG: Errno : 65 /* Package not installed */ ENOPKG :: Platform_Error.ENOPKG /* Package not installed */
EREMOTE: Errno : 66 /* Object is remote */ EREMOTE :: Platform_Error.EREMOTE /* Object is remote */
ENOLINK: Errno : 67 /* Link has been severed */ ENOLINK :: Platform_Error.ENOLINK /* Link has been severed */
EADV: Errno : 68 /* Advertise error */ EADV :: Platform_Error.EADV /* Advertise error */
ESRMNT: Errno : 69 /* Srmount error */ ESRMNT :: Platform_Error.ESRMNT /* Srmount error */
ECOMM: Errno : 70 /* Communication error on send */ ECOMM :: Platform_Error.ECOMM /* Communication error on send */
EPROTO: Errno : 71 /* Protocol error */ EPROTO :: Platform_Error.EPROTO /* Protocol error */
EMULTIHOP: Errno : 72 /* Multihop attempted */ EMULTIHOP :: Platform_Error.EMULTIHOP /* Multihop attempted */
EDOTDOT: Errno : 73 /* RFS specific error */ EDOTDOT :: Platform_Error.EDOTDOT /* RFS specific error */
EBADMSG: Errno : 74 /* Not a data message */ EBADMSG :: Platform_Error.EBADMSG /* Not a data message */
EOVERFLOW: Errno : 75 /* Value too large for defined data type */ EOVERFLOW :: Platform_Error.EOVERFLOW /* Value too large for defined data type */
ENOTUNIQ: Errno : 76 /* Name not unique on network */ ENOTUNIQ :: Platform_Error.ENOTUNIQ /* Name not unique on network */
EBADFD: Errno : 77 /* File descriptor in bad state */ EBADFD :: Platform_Error.EBADFD /* File descriptor in bad state */
EREMCHG: Errno : 78 /* Remote address changed */ EREMCHG :: Platform_Error.EREMCHG /* Remote address changed */
ELIBACC: Errno : 79 /* Can not access a needed shared library */ ELIBACC :: Platform_Error.ELIBACC /* Can not access a needed shared library */
ELIBBAD: Errno : 80 /* Accessing a corrupted shared library */ ELIBBAD :: Platform_Error.ELIBBAD /* Accessing a corrupted shared library */
ELIBSCN: Errno : 81 /* .lib section in a.out corrupted */ ELIBSCN :: Platform_Error.ELIBSCN /* .lib section in a.out corrupted */
ELIBMAX: Errno : 82 /* Attempting to link in too many shared libraries */ ELIBMAX :: Platform_Error.ELIBMAX /* Attempting to link in too many shared libraries */
ELIBEXEC: Errno : 83 /* Cannot exec a shared library directly */ ELIBEXEC :: Platform_Error.ELIBEXEC /* Cannot exec a shared library directly */
EILSEQ: Errno : 84 /* Illegal byte sequence */ EILSEQ :: Platform_Error.EILSEQ /* Illegal byte sequence */
ERESTART: Errno : 85 /* Interrupted system call should be restarted */ ERESTART :: Platform_Error.ERESTART /* Interrupted system call should be restarted */
ESTRPIPE: Errno : 86 /* Streams pipe error */ ESTRPIPE :: Platform_Error.ESTRPIPE /* Streams pipe error */
EUSERS: Errno : 87 /* Too many users */ EUSERS :: Platform_Error.EUSERS /* Too many users */
ENOTSOCK: Errno : 88 /* Socket operation on non-socket */ ENOTSOCK :: Platform_Error.ENOTSOCK /* Socket operation on non-socket */
EDESTADDRREQ: Errno : 89 /* Destination address required */ EDESTADDRREQ :: Platform_Error.EDESTADDRREQ /* Destination address required */
EMSGSIZE: Errno : 90 /* Message too long */ EMSGSIZE :: Platform_Error.EMSGSIZE /* Message too long */
EPROTOTYPE: Errno : 91 /* Protocol wrong type for socket */ EPROTOTYPE :: Platform_Error.EPROTOTYPE /* Protocol wrong type for socket */
ENOPROTOOPT: Errno : 92 /* Protocol not available */ ENOPROTOOPT :: Platform_Error.ENOPROTOOPT /* Protocol not available */
EPROTONOSUPPORT:Errno : 93 /* Protocol not supported */ EPROTONOSUPPOR :: Platform_Error.EPROTONOSUPPORT /* Protocol not supported */
ESOCKTNOSUPPORT:Errno : 94 /* Socket type not supported */ ESOCKTNOSUPPOR :: Platform_Error.ESOCKTNOSUPPORT /* Socket type not supported */
EOPNOTSUPP: Errno : 95 /* Operation not supported on transport endpoint */ EOPNOTSUPP :: Platform_Error.EOPNOTSUPP /* Operation not supported on transport endpoint */
EPFNOSUPPORT: Errno : 96 /* Protocol family not supported */ EPFNOSUPPORT :: Platform_Error.EPFNOSUPPORT /* Protocol family not supported */
EAFNOSUPPORT: Errno : 97 /* Address family not supported by protocol */ EAFNOSUPPORT :: Platform_Error.EAFNOSUPPORT /* Address family not supported by protocol */
EADDRINUSE: Errno : 98 /* Address already in use */ EADDRINUSE :: Platform_Error.EADDRINUSE /* Address already in use */
EADDRNOTAVAIL: Errno : 99 /* Cannot assign requested address */ EADDRNOTAVAIL :: Platform_Error.EADDRNOTAVAIL /* Cannot assign requested address */
ENETDOWN: Errno : 100 /* Network is down */ ENETDOWN :: Platform_Error.ENETDOWN /* Network is down */
ENETUNREACH: Errno : 101 /* Network is unreachable */ ENETUNREACH :: Platform_Error.ENETUNREACH /* Network is unreachable */
ENETRESET: Errno : 102 /* Network dropped connection because of reset */ ENETRESET :: Platform_Error.ENETRESET /* Network dropped connection because of reset */
ECONNABORTED: Errno : 103 /* Software caused connection abort */ ECONNABORTED :: Platform_Error.ECONNABORTED /* Software caused connection abort */
ECONNRESET: Errno : 104 /* Connection reset by peer */ ECONNRESET :: Platform_Error.ECONNRESET /* Connection reset by peer */
ENOBUFS: Errno : 105 /* No buffer space available */ ENOBUFS :: Platform_Error.ENOBUFS /* No buffer space available */
EISCONN: Errno : 106 /* Transport endpoint is already connected */ EISCONN :: Platform_Error.EISCONN /* Transport endpoint is already connected */
ENOTCONN: Errno : 107 /* Transport endpoint is not connected */ ENOTCONN :: Platform_Error.ENOTCONN /* Transport endpoint is not connected */
ESHUTDOWN: Errno : 108 /* Cannot send after transport endpoint shutdown */ ESHUTDOWN :: Platform_Error.ESHUTDOWN /* Cannot send after transport endpoint shutdown */
ETOOMANYREFS: Errno : 109 /* Too many references: cannot splice */ ETOOMANYREFS :: Platform_Error.ETOOMANYREFS /* Too many references: cannot splice */
ETIMEDOUT: Errno : 110 /* Connection timed out */ ETIMEDOUT :: Platform_Error.ETIMEDOUT /* Connection timed out */
ECONNREFUSED: Errno : 111 /* Connection refused */ ECONNREFUSED :: Platform_Error.ECONNREFUSED /* Connection refused */
EHOSTDOWN: Errno : 112 /* Host is down */ EHOSTDOWN :: Platform_Error.EHOSTDOWN /* Host is down */
EHOSTUNREACH: Errno : 113 /* No route to host */ EHOSTUNREACH :: Platform_Error.EHOSTUNREACH /* No route to host */
EALREADY: Errno : 114 /* Operation already in progress */ EALREADY :: Platform_Error.EALREADY /* Operation already in progress */
EINPROGRESS: Errno : 115 /* Operation now in progress */ EINPROGRESS :: Platform_Error.EINPROGRESS /* Operation now in progress */
ESTALE: Errno : 116 /* Stale file handle */ ESTALE :: Platform_Error.ESTALE /* Stale file handle */
EUCLEAN: Errno : 117 /* Structure needs cleaning */ EUCLEAN :: Platform_Error.EUCLEAN /* Structure needs cleaning */
ENOTNAM: Errno : 118 /* Not a XENIX named type file */ ENOTNAM :: Platform_Error.ENOTNAM /* Not a XENIX named type file */
ENAVAIL: Errno : 119 /* No XENIX semaphores available */ ENAVAIL :: Platform_Error.ENAVAIL /* No XENIX semaphores available */
EISNAM: Errno : 120 /* Is a named type file */ EISNAM :: Platform_Error.EISNAM /* Is a named type file */
EREMOTEIO: Errno : 121 /* Remote I/O error */ EREMOTEIO :: Platform_Error.EREMOTEIO /* Remote I/O error */
EDQUOT: Errno : 122 /* Quota exceeded */ EDQUOT :: Platform_Error.EDQUOT /* Quota exceeded */
ENOMEDIUM: Errno : 123 /* No medium found */ ENOMEDIUM :: Platform_Error.ENOMEDIUM /* No medium found */
EMEDIUMTYPE: Errno : 124 /* Wrong medium type */ EMEDIUMTYPE :: Platform_Error.EMEDIUMTYPE /* Wrong medium type */
ECANCELED: Errno : 125 /* Operation Canceled */ ECANCELED :: Platform_Error.ECANCELED /* Operation Canceled */
ENOKEY: Errno : 126 /* Required key not available */ ENOKEY :: Platform_Error.ENOKEY /* Required key not available */
EKEYEXPIRED: Errno : 127 /* Key has expired */ EKEYEXPIRED :: Platform_Error.EKEYEXPIRED /* Key has expired */
EKEYREVOKED: Errno : 128 /* Key has been revoked */ EKEYREVOKED :: Platform_Error.EKEYREVOKED /* Key has been revoked */
EKEYREJECTED: Errno : 129 /* Key was rejected by service */ EKEYREJECTED :: Platform_Error.EKEYREJECTED /* Key was rejected by service */
/* for robust mutexes */ /* for robust mutexes */
EOWNERDEAD: Errno : 130 /* Owner died */ EOWNERDEAD :: Platform_Error.EOWNERDEAD /* Owner died */
ENOTRECOVERABLE: Errno : 131 /* State not recoverable */ ENOTRECOVERABLE :: Platform_Error.ENOTRECOVERABLE /* State not recoverable */
ERFKILL: Errno : 132 /* Operation not possible due to RF-kill */ ERFKILL :: Platform_Error.ERFKILL /* Operation not possible due to RF-kill */
EHWPOISON: Errno : 133 /* Memory page has hardware error */ EHWPOISON :: Platform_Error.EHWPOISON /* Memory page has hardware error */
ADDR_NO_RANDOMIZE :: 0x40000 ADDR_NO_RANDOMIZE :: 0x40000
@@ -520,8 +520,8 @@ _get_errno :: proc(res: int) -> Errno {
} }
// get errno from libc // get errno from libc
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__errno_location()^) return Error(__errno_location()^)
} }
personality :: proc(persona: u64) -> (Errno) { personality :: proc(persona: u64) -> (Errno) {
+243 -104
View File
@@ -9,148 +9,287 @@ import "core:c"
Handle :: distinct i32 Handle :: distinct i32
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct i32
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno : 0 /* No error */ _Platform_Error :: enum i32 {
EPERM: Errno : 1 /* Operation not permitted */ NONE = 0,
ENOENT: Errno : 2 /* No such file or directory */ EPERM = 1, /* Operation not permitted */
EINTR: Errno : 4 /* Interrupted system call */ ENOENT = 2, /* No such file or directory */
ESRCH: Errno : 3 /* No such process */ EINTR = 4, /* Interrupted system call */
EIO: Errno : 5 /* Input/output error */ ESRCH = 3, /* No such process */
ENXIO: Errno : 6 /* Device not configured */ EIO = 5, /* Input/output error */
E2BIG: Errno : 7 /* Argument list too long */ ENXIO = 6, /* Device not configured */
ENOEXEC: Errno : 8 /* Exec format error */ E2BIG = 7, /* Argument list too long */
EBADF: Errno : 9 /* Bad file descriptor */ ENOEXEC = 8, /* Exec format error */
ECHILD: Errno : 10 /* No child processes */ EBADF = 9, /* Bad file descriptor */
EDEADLK: Errno : 11 /* Resource deadlock avoided. 11 was EAGAIN */ ECHILD = 10, /* No child processes */
ENOMEM: Errno : 12 /* Cannot allocate memory */ EDEADLK = 11, /* Resource deadlock avoided. 11 was EAGAIN */
EACCES: Errno : 13 /* Permission denied */ ENOMEM = 12, /* Cannot allocate memory */
EFAULT: Errno : 14 /* Bad address */ EACCES = 13, /* Permission denied */
ENOTBLK: Errno : 15 /* Block device required */ EFAULT = 14, /* Bad address */
EBUSY: Errno : 16 /* Device busy */ ENOTBLK = 15, /* Block device required */
EEXIST: Errno : 17 /* File exists */ EBUSY = 16, /* Device busy */
EXDEV: Errno : 18 /* Cross-device link */ EEXIST = 17, /* File exists */
ENODEV: Errno : 19 /* Operation not supported by device */ EXDEV = 18, /* Cross-device link */
ENOTDIR: Errno : 20 /* Not a directory */ ENODEV = 19, /* Operation not supported by device */
EISDIR: Errno : 21 /* Is a directory */ ENOTDIR = 20, /* Not a directory */
EINVAL: Errno : 22 /* Invalid argument */ EISDIR = 21, /* Is a directory */
ENFILE: Errno : 23 /* Too many open files in system */ EINVAL = 22, /* Invalid argument */
EMFILE: Errno : 24 /* Too many open files */ ENFILE = 23, /* Too many open files in system */
ENOTTY: Errno : 25 /* Inappropriate ioctl for device */ EMFILE = 24, /* Too many open files */
ETXTBSY: Errno : 26 /* Text file busy */ ENOTTY = 25, /* Inappropriate ioctl for device */
EFBIG: Errno : 27 /* File too large */ ETXTBSY = 26, /* Text file busy */
ENOSPC: Errno : 28 /* No space left on device */ EFBIG = 27, /* File too large */
ESPIPE: Errno : 29 /* Illegal seek */ ENOSPC = 28, /* No space left on device */
EROFS: Errno : 30 /* Read-only file system */ ESPIPE = 29, /* Illegal seek */
EMLINK: Errno : 31 /* Too many links */ EROFS = 30, /* Read-only file system */
EPIPE: Errno : 32 /* Broken pipe */ EMLINK = 31, /* Too many links */
EPIPE = 32, /* Broken pipe */
/* math software */
EDOM = 33, /* Numerical argument out of domain */
ERANGE = 34, /* Result too large or too small */
/* non-blocking and interrupt i/o */
EAGAIN = 35, /* Resource temporarily unavailable */
EWOULDBLOCK = EAGAIN, /* Operation would block */
EINPROGRESS = 36, /* Operation now in progress */
EALREADY = 37, /* Operation already in progress */
/* ipc/network software -- argument errors */
ENOTSOCK = 38, /* Socket operation on non-socket */
EDESTADDRREQ = 39, /* Destination address required */
EMSGSIZE = 40, /* Message too long */
EPROTOTYPE = 41, /* Protocol wrong type for socket */
ENOPROTOOPT = 42, /* Protocol option not available */
EPROTONOSUPPORT = 43, /* Protocol not supported */
ESOCKTNOSUPPORT = 44, /* Socket type not supported */
EOPNOTSUPP = 45, /* Operation not supported */
EPFNOSUPPORT = 46, /* Protocol family not supported */
EAFNOSUPPORT = 47, /* Address family not supported by protocol family */
EADDRINUSE = 48, /* Address already in use */
EADDRNOTAVAIL = 49, /* Can't assign requested address */
/* ipc/network software -- operational errors */
ENETDOWN = 50, /* Network is down */
ENETUNREACH = 51, /* Network is unreachable */
ENETRESET = 52, /* Network dropped connection on reset */
ECONNABORTED = 53, /* Software caused connection abort */
ECONNRESET = 54, /* Connection reset by peer */
ENOBUFS = 55, /* No buffer space available */
EISCONN = 56, /* Socket is already connected */
ENOTCONN = 57, /* Socket is not connected */
ESHUTDOWN = 58, /* Can't send after socket shutdown */
ETOOMANYREFS = 59, /* Too many references: can't splice */
ETIMEDOUT = 60, /* Operation timed out */
ECONNREFUSED = 61, /* Connection refused */
ELOOP = 62, /* Too many levels of symbolic links */
ENAMETOOLONG = 63, /* File name too long */
/* should be rearranged */
EHOSTDOWN = 64, /* Host is down */
EHOSTUNREACH = 65, /* No route to host */
ENOTEMPTY = 66, /* Directory not empty */
/* quotas & mush */
EPROCLIM = 67, /* Too many processes */
EUSERS = 68, /* Too many users */
EDQUOT = 69, /* Disc quota exceeded */
/* Network File System */
ESTALE = 70, /* Stale NFS file handle */
EREMOTE = 71, /* Too many levels of remote in path */
EBADRPC = 72, /* RPC struct is bad */
ERPCMISMATCH = 73, /* RPC version wrong */
EPROGUNAVAIL = 74, /* RPC prog. not avail */
EPROGMISMATCH = 75, /* Program version wrong */
EPROCUNAVAIL = 76, /* Bad procedure for program */
ENOLCK = 77, /* No locks available */
ENOSYS = 78, /* Function not implemented */
EFTYPE = 79, /* Inappropriate file type or format */
EAUTH = 80, /* Authentication error */
ENEEDAUTH = 81, /* Need authenticator */
/* SystemV IPC */
EIDRM = 82, /* Identifier removed */
ENOMSG = 83, /* No message of desired type */
EOVERFLOW = 84, /* Value too large to be stored in data type */
/* Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 */
EILSEQ = 85, /* Illegal byte sequence */
/* From IEEE Std 1003.1-2001 */
/* Base, Realtime, Threads or Thread Priority Scheduling option errors */
ENOTSUP = 86, /* Not supported */
/* Realtime option errors */
ECANCELED = 87, /* Operation canceled */
/* Realtime, XSI STREAMS option errors */
EBADMSG = 88, /* Bad or Corrupt message */
/* XSI STREAMS option errors */
ENODATA = 89, /* No message available */
ENOSR = 90, /* No STREAM resources */
ENOSTR = 91, /* Not a STREAM */
ETIME = 92, /* STREAM ioctl timeout */
/* File system extended attribute errors */
ENOATTR = 93, /* Attribute not found */
/* Realtime, XSI STREAMS option errors */
EMULTIHOP = 94, /* Multihop attempted */
ENOLINK = 95, /* Link has been severed */
EPROTO = 96, /* Protocol error */
/* Robust mutexes */
EOWNERDEAD = 97, /* Previous owner died */
ENOTRECOVERABLE = 98, /* State not recoverable */
ELAST = 98, /* Must equal largest errno */
}
EPERM :: Platform_Error.EPERM /* Operation not permitted */
ENOENT :: Platform_Error.ENOENT /* No such file or directory */
EINTR :: Platform_Error.EINTR /* Interrupted system call */
ESRCH :: Platform_Error.ESRCH /* No such process */
EIO :: Platform_Error.EIO /* Input/output error */
ENXIO :: Platform_Error.ENXIO /* Device not configured */
E2BIG :: Platform_Error.E2BIG /* Argument list too long */
ENOEXEC :: Platform_Error.ENOEXEC /* Exec format error */
EBADF :: Platform_Error.EBADF /* Bad file descriptor */
ECHILD :: Platform_Error.ECHILD /* No child processes */
EDEADLK :: Platform_Error.EDEADLK /* Resource deadlock avoided. 11 was EAGAIN */
ENOMEM :: Platform_Error.ENOMEM /* Cannot allocate memory */
EACCES :: Platform_Error.EACCES /* Permission denied */
EFAULT :: Platform_Error.EFAULT /* Bad address */
ENOTBLK :: Platform_Error.ENOTBLK /* Block device required */
EBUSY :: Platform_Error.EBUSY /* Device busy */
EEXIST :: Platform_Error.EEXIST /* File exists */
EXDEV :: Platform_Error.EXDEV /* Cross-device link */
ENODEV :: Platform_Error.ENODEV /* Operation not supported by device */
ENOTDIR :: Platform_Error.ENOTDIR /* Not a directory */
EISDIR :: Platform_Error.EISDIR /* Is a directory */
EINVAL :: Platform_Error.EINVAL /* Invalid argument */
ENFILE :: Platform_Error.ENFILE /* Too many open files in system */
EMFILE :: Platform_Error.EMFILE /* Too many open files */
ENOTTY :: Platform_Error.ENOTTY /* Inappropriate ioctl for device */
ETXTBSY :: Platform_Error.ETXTBSY /* Text file busy */
EFBIG :: Platform_Error.EFBIG /* File too large */
ENOSPC :: Platform_Error.ENOSPC /* No space left on device */
ESPIPE :: Platform_Error.ESPIPE /* Illegal seek */
EROFS :: Platform_Error.EROFS /* Read-only file system */
EMLINK :: Platform_Error.EMLINK /* Too many links */
EPIPE :: Platform_Error.EPIPE /* Broken pipe */
/* math software */ /* math software */
EDOM: Errno : 33 /* Numerical argument out of domain */ EDOM :: Platform_Error.EDOM /* Numerical argument out of domain */
ERANGE: Errno : 34 /* Result too large or too small */ ERANGE :: Platform_Error.ERANGE /* Result too large or too small */
/* non-blocking and interrupt i/o */ /* non-blocking and interrupt i/o */
EAGAIN: Errno : 35 /* Resource temporarily unavailable */ EAGAIN :: Platform_Error.EAGAIN /* Resource temporarily unavailable */
EWOULDBLOCK: Errno : EAGAIN /* Operation would block */ EWOULDBLOCK :: EAGAIN /* Operation would block */
EINPROGRESS: Errno : 36 /* Operation now in progress */ EINPROGRESS :: Platform_Error.EINPROGRESS /* Operation now in progress */
EALREADY: Errno : 37 /* Operation already in progress */ EALREADY :: Platform_Error.EALREADY /* Operation already in progress */
/* ipc/network software -- argument errors */ /* ipc/network software -- argument errors */
ENOTSOCK: Errno : 38 /* Socket operation on non-socket */ ENOTSOCK :: Platform_Error.ENOTSOCK /* Socket operation on non-socket */
EDESTADDRREQ: Errno : 39 /* Destination address required */ EDESTADDRREQ :: Platform_Error.EDESTADDRREQ /* Destination address required */
EMSGSIZE: Errno : 40 /* Message too long */ EMSGSIZE :: Platform_Error.EMSGSIZE /* Message too long */
EPROTOTYPE: Errno : 41 /* Protocol wrong type for socket */ EPROTOTYPE :: Platform_Error.EPROTOTYPE /* Protocol wrong type for socket */
ENOPROTOOPT: Errno : 42 /* Protocol option not available */ ENOPROTOOPT :: Platform_Error.ENOPROTOOPT /* Protocol option not available */
EPROTONOSUPPORT: Errno : 43 /* Protocol not supported */ EPROTONOSUPPORT :: Platform_Error.EPROTONOSUPPORT /* Protocol not supported */
ESOCKTNOSUPPORT: Errno : 44 /* Socket type not supported */ ESOCKTNOSUPPORT :: Platform_Error.ESOCKTNOSUPPORT /* Socket type not supported */
EOPNOTSUPP: Errno : 45 /* Operation not supported */ EOPNOTSUPP :: Platform_Error.EOPNOTSUPP /* Operation not supported */
EPFNOSUPPORT: Errno : 46 /* Protocol family not supported */ EPFNOSUPPORT :: Platform_Error.EPFNOSUPPORT /* Protocol family not supported */
EAFNOSUPPORT: Errno : 47 /* Address family not supported by protocol family */ EAFNOSUPPORT :: Platform_Error.EAFNOSUPPORT /* Address family not supported by protocol family */
EADDRINUSE: Errno : 48 /* Address already in use */ EADDRINUSE :: Platform_Error.EADDRINUSE /* Address already in use */
EADDRNOTAVAIL: Errno : 49 /* Can't assign requested address */ EADDRNOTAVAIL :: Platform_Error.EADDRNOTAVAIL /* Can't assign requested address */
/* ipc/network software -- operational errors */ /* ipc/network software -- operational errors */
ENETDOWN: Errno : 50 /* Network is down */ ENETDOWN :: Platform_Error.ENETDOWN /* Network is down */
ENETUNREACH: Errno : 51 /* Network is unreachable */ ENETUNREACH :: Platform_Error.ENETUNREACH /* Network is unreachable */
ENETRESET: Errno : 52 /* Network dropped connection on reset */ ENETRESET :: Platform_Error.ENETRESET /* Network dropped connection on reset */
ECONNABORTED: Errno : 53 /* Software caused connection abort */ ECONNABORTED :: Platform_Error.ECONNABORTED /* Software caused connection abort */
ECONNRESET: Errno : 54 /* Connection reset by peer */ ECONNRESET :: Platform_Error.ECONNRESET /* Connection reset by peer */
ENOBUFS: Errno : 55 /* No buffer space available */ ENOBUFS :: Platform_Error.ENOBUFS /* No buffer space available */
EISCONN: Errno : 56 /* Socket is already connected */ EISCONN :: Platform_Error.EISCONN /* Socket is already connected */
ENOTCONN: Errno : 57 /* Socket is not connected */ ENOTCONN :: Platform_Error.ENOTCONN /* Socket is not connected */
ESHUTDOWN: Errno : 58 /* Can't send after socket shutdown */ ESHUTDOWN :: Platform_Error.ESHUTDOWN /* Can't send after socket shutdown */
ETOOMANYREFS: Errno : 59 /* Too many references: can't splice */ ETOOMANYREFS :: Platform_Error.ETOOMANYREFS /* Too many references: can't splice */
ETIMEDOUT: Errno : 60 /* Operation timed out */ ETIMEDOUT :: Platform_Error.ETIMEDOUT /* Operation timed out */
ECONNREFUSED: Errno : 61 /* Connection refused */ ECONNREFUSED :: Platform_Error.ECONNREFUSED /* Connection refused */
ELOOP: Errno : 62 /* Too many levels of symbolic links */ ELOOP :: Platform_Error.ELOOP /* Too many levels of symbolic links */
ENAMETOOLONG: Errno : 63 /* File name too long */ ENAMETOOLONG :: Platform_Error.ENAMETOOLONG /* File name too long */
/* should be rearranged */ /* should be rearranged */
EHOSTDOWN: Errno : 64 /* Host is down */ EHOSTDOWN :: Platform_Error.EHOSTDOWN /* Host is down */
EHOSTUNREACH: Errno : 65 /* No route to host */ EHOSTUNREACH :: Platform_Error.EHOSTUNREACH /* No route to host */
ENOTEMPTY: Errno : 66 /* Directory not empty */ ENOTEMPTY :: Platform_Error.ENOTEMPTY /* Directory not empty */
/* quotas & mush */ /* quotas & mush */
EPROCLIM: Errno : 67 /* Too many processes */ EPROCLIM :: Platform_Error.EPROCLIM /* Too many processes */
EUSERS: Errno : 68 /* Too many users */ EUSERS :: Platform_Error.EUSERS /* Too many users */
EDQUOT: Errno : 69 /* Disc quota exceeded */ EDQUOT :: Platform_Error.EDQUOT /* Disc quota exceeded */
/* Network File System */ /* Network File System */
ESTALE: Errno : 70 /* Stale NFS file handle */ ESTALE :: Platform_Error.ESTALE /* Stale NFS file handle */
EREMOTE: Errno : 71 /* Too many levels of remote in path */ EREMOTE :: Platform_Error.EREMOTE /* Too many levels of remote in path */
EBADRPC: Errno : 72 /* RPC struct is bad */ EBADRPC :: Platform_Error.EBADRPC /* RPC struct is bad */
ERPCMISMATCH: Errno : 73 /* RPC version wrong */ ERPCMISMATCH :: Platform_Error.ERPCMISMATCH /* RPC version wrong */
EPROGUNAVAIL: Errno : 74 /* RPC prog. not avail */ EPROGUNAVAIL :: Platform_Error.EPROGUNAVAIL /* RPC prog. not avail */
EPROGMISMATCH: Errno : 75 /* Program version wrong */ EPROGMISMATCH :: Platform_Error.EPROGMISMATCH /* Program version wrong */
EPROCUNAVAIL: Errno : 76 /* Bad procedure for program */ EPROCUNAVAIL :: Platform_Error.EPROCUNAVAIL /* Bad procedure for program */
ENOLCK: Errno : 77 /* No locks available */ ENOLCK :: Platform_Error.ENOLCK /* No locks available */
ENOSYS: Errno : 78 /* Function not implemented */ ENOSYS :: Platform_Error.ENOSYS /* Function not implemented */
EFTYPE: Errno : 79 /* Inappropriate file type or format */ EFTYPE :: Platform_Error.EFTYPE /* Inappropriate file type or format */
EAUTH: Errno : 80 /* Authentication error */ EAUTH :: Platform_Error.EAUTH /* Authentication error */
ENEEDAUTH: Errno : 81 /* Need authenticator */ ENEEDAUTH :: Platform_Error.ENEEDAUTH /* Need authenticator */
/* SystemV IPC */ /* SystemV IPC */
EIDRM: Errno : 82 /* Identifier removed */ EIDRM :: Platform_Error.EIDRM /* Identifier removed */
ENOMSG: Errno : 83 /* No message of desired type */ ENOMSG :: Platform_Error.ENOMSG /* No message of desired type */
EOVERFLOW: Errno : 84 /* Value too large to be stored in data type */ EOVERFLOW :: Platform_Error.EOVERFLOW /* Value too large to be stored in data type */
/* Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 */ /* Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 */
EILSEQ: Errno : 85 /* Illegal byte sequence */ EILSEQ :: Platform_Error.EILSEQ /* Illegal byte sequence */
/* From IEEE Std 1003.1-2001 */ /* From IEEE Std 1003.1-2001 */
/* Base, Realtime, Threads or Thread Priority Scheduling option errors */ /* Base, Realtime, Threads or Thread Priority Scheduling option errors */
ENOTSUP: Errno : 86 /* Not supported */ ENOTSUP :: Platform_Error.ENOTSUP /* Not supported */
/* Realtime option errors */ /* Realtime option errors */
ECANCELED: Errno : 87 /* Operation canceled */ ECANCELED :: Platform_Error.ECANCELED /* Operation canceled */
/* Realtime, XSI STREAMS option errors */ /* Realtime, XSI STREAMS option errors */
EBADMSG: Errno : 88 /* Bad or Corrupt message */ EBADMSG :: Platform_Error.EBADMSG /* Bad or Corrupt message */
/* XSI STREAMS option errors */ /* XSI STREAMS option errors */
ENODATA: Errno : 89 /* No message available */ ENODATA :: Platform_Error.ENODATA /* No message available */
ENOSR: Errno : 90 /* No STREAM resources */ ENOSR :: Platform_Error.ENOSR /* No STREAM resources */
ENOSTR: Errno : 91 /* Not a STREAM */ ENOSTR :: Platform_Error.ENOSTR /* Not a STREAM */
ETIME: Errno : 92 /* STREAM ioctl timeout */ ETIME :: Platform_Error.ETIME /* STREAM ioctl timeout */
/* File system extended attribute errors */ /* File system extended attribute errors */
ENOATTR: Errno : 93 /* Attribute not found */ ENOATTR :: Platform_Error.ENOATTR /* Attribute not found */
/* Realtime, XSI STREAMS option errors */ /* Realtime, XSI STREAMS option errors */
EMULTIHOP: Errno : 94 /* Multihop attempted */ EMULTIHOP :: Platform_Error.EMULTIHOP /* Multihop attempted */
ENOLINK: Errno : 95 /* Link has been severed */ ENOLINK :: Platform_Error.ENOLINK /* Link has been severed */
EPROTO: Errno : 96 /* Protocol error */ EPROTO :: Platform_Error.EPROTO /* Protocol error */
/* Robust mutexes */ /* Robust mutexes */
EOWNERDEAD: Errno : 97 /* Previous owner died */ EOWNERDEAD :: Platform_Error.EOWNERDEAD /* Previous owner died */
ENOTRECOVERABLE: Errno : 98 /* State not recoverable */ ENOTRECOVERABLE :: Platform_Error.ENOTRECOVERABLE /* State not recoverable */
ELAST: Errno : 98 /* Must equal largest errno */ ELAST :: Platform_Error.ELAST /* Must equal largest errno */
/* end of errno */ /* end of errno */
@@ -338,8 +477,8 @@ is_path_separator :: proc(r: rune) -> bool {
return r == '/' return r == '/'
} }
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__errno_location()^) return Error(__errno_location()^)
} }
open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) {
+197 -100
View File
@@ -9,108 +9,205 @@ import "base:runtime"
Handle :: distinct i32 Handle :: distinct i32
Pid :: distinct i32 Pid :: distinct i32
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct i32
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
ERROR_NONE: Errno: 0 _Platform_Error :: enum i32 {
NONE = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EWOULDBLOCK = EAGAIN,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
EOPNOTSUPP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EIPSEC = 82,
ENOATTR = 83,
EILSEQ = 84,
ENOMEDIUM = 85,
EMEDIUMTYPE = 86,
EOVERFLOW = 87,
ECANCELED = 88,
EIDRM = 89,
ENOMSG = 90,
ENOTSUP = 91,
EBADMSG = 92,
ENOTRECOVERABLE = 93,
EOWNERDEAD = 94,
EPROTO = 95,
}
EPERM: Errno: 1 EPERM :: Platform_Error.EPERM
ENOENT: Errno: 2 ENOENT :: Platform_Error.ENOENT
ESRCH: Errno: 3 ESRCH :: Platform_Error.ESRCH
EINTR: Errno: 4 EINTR :: Platform_Error.EINTR
EIO: Errno: 5 EIO :: Platform_Error.EIO
ENXIO: Errno: 6 ENXIO :: Platform_Error.ENXIO
E2BIG: Errno: 7 E2BIG :: Platform_Error.E2BIG
ENOEXEC: Errno: 8 ENOEXEC :: Platform_Error.ENOEXEC
EBADF: Errno: 9 EBADF :: Platform_Error.EBADF
ECHILD: Errno: 10 ECHILD :: Platform_Error.ECHILD
EDEADLK: Errno: 11 EDEADLK :: Platform_Error.EDEADLK
ENOMEM: Errno: 12 ENOMEM :: Platform_Error.ENOMEM
EACCES: Errno: 13 EACCES :: Platform_Error.EACCES
EFAULT: Errno: 14 EFAULT :: Platform_Error.EFAULT
ENOTBLK: Errno: 15 ENOTBLK :: Platform_Error.ENOTBLK
EBUSY: Errno: 16 EBUSY :: Platform_Error.EBUSY
EEXIST: Errno: 17 EEXIST :: Platform_Error.EEXIST
EXDEV: Errno: 18 EXDEV :: Platform_Error.EXDEV
ENODEV: Errno: 19 ENODEV :: Platform_Error.ENODEV
ENOTDIR: Errno: 20 ENOTDIR :: Platform_Error.ENOTDIR
EISDIR: Errno: 21 EISDIR :: Platform_Error.EISDIR
EINVAL: Errno: 22 EINVAL :: Platform_Error.EINVAL
ENFILE: Errno: 23 ENFILE :: Platform_Error.ENFILE
EMFILE: Errno: 24 EMFILE :: Platform_Error.EMFILE
ENOTTY: Errno: 25 ENOTTY :: Platform_Error.ENOTTY
ETXTBSY: Errno: 26 ETXTBSY :: Platform_Error.ETXTBSY
EFBIG: Errno: 27 EFBIG :: Platform_Error.EFBIG
ENOSPC: Errno: 28 ENOSPC :: Platform_Error.ENOSPC
ESPIPE: Errno: 29 ESPIPE :: Platform_Error.ESPIPE
EROFS: Errno: 30 EROFS :: Platform_Error.EROFS
EMLINK: Errno: 31 EMLINK :: Platform_Error.EMLINK
EPIPE: Errno: 32 EPIPE :: Platform_Error.EPIPE
EDOM: Errno: 33 EDOM :: Platform_Error.EDOM
ERANGE: Errno: 34 ERANGE :: Platform_Error.ERANGE
EAGAIN: Errno: 35 EAGAIN :: Platform_Error.EAGAIN
EWOULDBLOCK: Errno: EAGAIN EWOULDBLOCK :: Platform_Error.EWOULDBLOCK
EINPROGRESS: Errno: 36 EINPROGRESS :: Platform_Error.EINPROGRESS
EALREADY: Errno: 37 EALREADY :: Platform_Error.EALREADY
ENOTSOCK: Errno: 38 ENOTSOCK :: Platform_Error.ENOTSOCK
EDESTADDRREQ: Errno: 39 EDESTADDRREQ :: Platform_Error.EDESTADDRREQ
EMSGSIZE: Errno: 40 EMSGSIZE :: Platform_Error.EMSGSIZE
EPROTOTYPE: Errno: 41 EPROTOTYPE :: Platform_Error.EPROTOTYPE
ENOPROTOOPT: Errno: 42 ENOPROTOOPT :: Platform_Error.ENOPROTOOPT
EPROTONOSUPPORT: Errno: 43 EPROTONOSUPPORT :: Platform_Error.EPROTONOSUPPORT
ESOCKTNOSUPPORT: Errno: 44 ESOCKTNOSUPPORT :: Platform_Error.ESOCKTNOSUPPORT
EOPNOTSUPP: Errno: 45 EOPNOTSUPP :: Platform_Error.EOPNOTSUPP
EPFNOSUPPORT: Errno: 46 EPFNOSUPPORT :: Platform_Error.EPFNOSUPPORT
EAFNOSUPPORT: Errno: 47 EAFNOSUPPORT :: Platform_Error.EAFNOSUPPORT
EADDRINUSE: Errno: 48 EADDRINUSE :: Platform_Error.EADDRINUSE
EADDRNOTAVAIL: Errno: 49 EADDRNOTAVAIL :: Platform_Error.EADDRNOTAVAIL
ENETDOWN: Errno: 50 ENETDOWN :: Platform_Error.ENETDOWN
ENETUNREACH: Errno: 51 ENETUNREACH :: Platform_Error.ENETUNREACH
ENETRESET: Errno: 52 ENETRESET :: Platform_Error.ENETRESET
ECONNABORTED: Errno: 53 ECONNABORTED :: Platform_Error.ECONNABORTED
ECONNRESET: Errno: 54 ECONNRESET :: Platform_Error.ECONNRESET
ENOBUFS: Errno: 55 ENOBUFS :: Platform_Error.ENOBUFS
EISCONN: Errno: 56 EISCONN :: Platform_Error.EISCONN
ENOTCONN: Errno: 57 ENOTCONN :: Platform_Error.ENOTCONN
ESHUTDOWN: Errno: 58 ESHUTDOWN :: Platform_Error.ESHUTDOWN
ETOOMANYREFS: Errno: 59 ETOOMANYREFS :: Platform_Error.ETOOMANYREFS
ETIMEDOUT: Errno: 60 ETIMEDOUT :: Platform_Error.ETIMEDOUT
ECONNREFUSED: Errno: 61 ECONNREFUSED :: Platform_Error.ECONNREFUSED
ELOOP: Errno: 62 ELOOP :: Platform_Error.ELOOP
ENAMETOOLONG: Errno: 63 ENAMETOOLONG :: Platform_Error.ENAMETOOLONG
EHOSTDOWN: Errno: 64 EHOSTDOWN :: Platform_Error.EHOSTDOWN
EHOSTUNREACH: Errno: 65 EHOSTUNREACH :: Platform_Error.EHOSTUNREACH
ENOTEMPTY: Errno: 66 ENOTEMPTY :: Platform_Error.ENOTEMPTY
EPROCLIM: Errno: 67 EPROCLIM :: Platform_Error.EPROCLIM
EUSERS: Errno: 68 EUSERS :: Platform_Error.EUSERS
EDQUOT: Errno: 69 EDQUOT :: Platform_Error.EDQUOT
ESTALE: Errno: 70 ESTALE :: Platform_Error.ESTALE
EREMOTE: Errno: 71 EREMOTE :: Platform_Error.EREMOTE
EBADRPC: Errno: 72 EBADRPC :: Platform_Error.EBADRPC
ERPCMISMATCH: Errno: 73 ERPCMISMATCH :: Platform_Error.ERPCMISMATCH
EPROGUNAVAIL: Errno: 74 EPROGUNAVAIL :: Platform_Error.EPROGUNAVAIL
EPROGMISMATCH: Errno: 75 EPROGMISMATCH :: Platform_Error.EPROGMISMATCH
EPROCUNAVAIL: Errno: 76 EPROCUNAVAIL :: Platform_Error.EPROCUNAVAIL
ENOLCK: Errno: 77 ENOLCK :: Platform_Error.ENOLCK
ENOSYS: Errno: 78 ENOSYS :: Platform_Error.ENOSYS
EFTYPE: Errno: 79 EFTYPE :: Platform_Error.EFTYPE
EAUTH: Errno: 80 EAUTH :: Platform_Error.EAUTH
ENEEDAUTH: Errno: 81 ENEEDAUTH :: Platform_Error.ENEEDAUTH
EIPSEC: Errno: 82 EIPSEC :: Platform_Error.EIPSEC
ENOATTR: Errno: 83 ENOATTR :: Platform_Error.ENOATTR
EILSEQ: Errno: 84 EILSEQ :: Platform_Error.EILSEQ
ENOMEDIUM: Errno: 85 ENOMEDIUM :: Platform_Error.ENOMEDIUM
EMEDIUMTYPE: Errno: 86 EMEDIUMTYPE :: Platform_Error.EMEDIUMTYPE
EOVERFLOW: Errno: 87 EOVERFLOW :: Platform_Error.EOVERFLOW
ECANCELED: Errno: 88 ECANCELED :: Platform_Error.ECANCELED
EIDRM: Errno: 89 EIDRM :: Platform_Error.EIDRM
ENOMSG: Errno: 90 ENOMSG :: Platform_Error.ENOMSG
ENOTSUP: Errno: 91 ENOTSUP :: Platform_Error.ENOTSUP
EBADMSG: Errno: 92 EBADMSG :: Platform_Error.EBADMSG
ENOTRECOVERABLE: Errno: 93 ENOTRECOVERABLE :: Platform_Error.ENOTRECOVERABLE
EOWNERDEAD: Errno: 94 EOWNERDEAD :: Platform_Error.EOWNERDEAD
EPROTO: Errno: 95 EPROTO :: Platform_Error.EPROTO
O_RDONLY :: 0x00000 O_RDONLY :: 0x00000
O_WRONLY :: 0x00001 O_WRONLY :: 0x00001
@@ -295,8 +392,8 @@ is_path_separator :: proc(r: rune) -> bool {
return r == '/' return r == '/'
} }
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> Error {
return int(__error()^) return Error(__error()^)
} }
fork :: proc() -> (Pid, Errno) { fork :: proc() -> (Pid, Errno) {
+4 -2
View File
@@ -4,11 +4,13 @@ import "core:sys/wasm/wasi"
import "base:runtime" import "base:runtime"
Handle :: distinct i32 Handle :: distinct i32
Errno :: distinct i32 _Platform_Error :: enum i32 {
NONE = 0,
}
INVALID_HANDLE :: -1 INVALID_HANDLE :: -1
ERROR_NONE :: Errno(wasi.errno_t.SUCCESS) // ERROR_NONE :: Errno(wasi.errno_t.SUCCESS) // that is a weird error code. Probably better to remap it
O_RDONLY :: 0x00000 O_RDONLY :: 0x00000
O_WRONLY :: 0x00001 O_WRONLY :: 0x00001
+29 -30
View File
@@ -7,7 +7,6 @@ import "base:intrinsics"
Handle :: distinct uintptr Handle :: distinct uintptr
File_Time :: distinct u64 File_Time :: distinct u64
Errno :: distinct int
INVALID_HANDLE :: ~Handle(0) INVALID_HANDLE :: ~Handle(0)
@@ -27,38 +26,38 @@ O_SYNC :: 0x01000
O_ASYNC :: 0x02000 O_ASYNC :: 0x02000
O_CLOEXEC :: 0x80000 O_CLOEXEC :: 0x80000
_Platform_Error :: win32.System_Error
ERROR_NONE: Errno : 0 ERROR_FILE_NOT_FOUND :: _Platform_Error(2)
ERROR_FILE_NOT_FOUND: Errno : 2 ERROR_PATH_NOT_FOUND :: _Platform_Error(3)
ERROR_PATH_NOT_FOUND: Errno : 3 ERROR_ACCESS_DENIED :: _Platform_Error(5)
ERROR_ACCESS_DENIED: Errno : 5 ERROR_INVALID_HANDLE :: _Platform_Error(6)
ERROR_INVALID_HANDLE: Errno : 6 ERROR_NOT_ENOUGH_MEMORY :: _Platform_Error(8)
ERROR_NOT_ENOUGH_MEMORY: Errno : 8 ERROR_NO_MORE_FILES :: _Platform_Error(18)
ERROR_NO_MORE_FILES: Errno : 18 ERROR_HANDLE_EOF :: _Platform_Error(38)
ERROR_HANDLE_EOF: Errno : 38 ERROR_NETNAME_DELETED :: _Platform_Error(64)
ERROR_NETNAME_DELETED: Errno : 64 ERROR_FILE_EXISTS :: _Platform_Error(80)
ERROR_FILE_EXISTS: Errno : 80 ERROR_INVALID_PARAMETER :: _Platform_Error(87)
ERROR_INVALID_PARAMETER: Errno : 87 ERROR_BROKEN_PIPE :: _Platform_Error(109)
ERROR_BROKEN_PIPE: Errno : 109 ERROR_BUFFER_OVERFLOW :: _Platform_Error(111)
ERROR_BUFFER_OVERFLOW: Errno : 111 ERROR_INSUFFICIENT_BUFFER :: _Platform_Error(122)
ERROR_INSUFFICIENT_BUFFER: Errno : 122 ERROR_MOD_NOT_FOUND :: _Platform_Error(126)
ERROR_MOD_NOT_FOUND: Errno : 126 ERROR_PROC_NOT_FOUND :: _Platform_Error(127)
ERROR_PROC_NOT_FOUND: Errno : 127 ERROR_DIR_NOT_EMPTY :: _Platform_Error(145)
ERROR_DIR_NOT_EMPTY: Errno : 145 ERROR_ALREADY_EXISTS :: _Platform_Error(183)
ERROR_ALREADY_EXISTS: Errno : 183 ERROR_ENVVAR_NOT_FOUND :: _Platform_Error(203)
ERROR_ENVVAR_NOT_FOUND: Errno : 203 ERROR_MORE_DATA :: _Platform_Error(234)
ERROR_MORE_DATA: Errno : 234 ERROR_OPERATION_ABORTED :: _Platform_Error(995)
ERROR_OPERATION_ABORTED: Errno : 995 ERROR_IO_PENDING :: _Platform_Error(997)
ERROR_IO_PENDING: Errno : 997 ERROR_NOT_FOUND :: _Platform_Error(1168)
ERROR_NOT_FOUND: Errno : 1168 ERROR_PRIVILEGE_NOT_HELD :: _Platform_Error(1314)
ERROR_PRIVILEGE_NOT_HELD: Errno : 1314 WSAEACCES :: _Platform_Error(10013)
WSAEACCES: Errno : 10013 WSAECONNRESET :: _Platform_Error(10054)
WSAECONNRESET: Errno : 10054
// Windows reserves errors >= 1<<29 for application use // Windows reserves errors >= 1<<29 for application use
ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0 ERROR_FILE_IS_PIPE :: _Platform_Error(1<<29 + 0)
ERROR_FILE_IS_NOT_DIR: Errno : 1<<29 + 1 ERROR_FILE_IS_NOT_DIR :: _Platform_Error(1<<29 + 1)
ERROR_NEGATIVE_OFFSET: Errno : 1<<29 + 2 ERROR_NEGATIVE_OFFSET :: _Platform_Error(1<<29 + 2)
// "Argv" arguments converted to Odin strings // "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments() args := _alloc_command_line_arguments()
+2 -2
View File
@@ -23,8 +23,8 @@ foreign libc {
} }
@(no_instrumentation) @(no_instrumentation)
get_last_error :: proc "contextless" () -> int { get_last_error :: proc "contextless" () -> os.Platform_Error {
return int(__error()^) return os.Platform_Error(__error()^)
} }
MAX_RW :: 0x7fffffff MAX_RW :: 0x7fffffff
+5 -6
View File
@@ -2,7 +2,6 @@
package sync package sync
import "core:c" import "core:c"
import "base:runtime"
import "core:sys/haiku" import "core:sys/haiku"
import "core:sys/unix" import "core:sys/unix"
import "core:time" import "core:time"
@@ -86,10 +85,10 @@ _futex_wait :: proc "contextless" (f: ^Futex, expect: u32) -> (ok: bool) {
waiter.prev.next = waiter.next waiter.prev.next = waiter.next
waiter.next.prev = waiter.prev waiter.next.prev = waiter.prev
unix.pthread_sigmask(haiku.SIG_SETMASK, &old_mask, nil) _ = unix.pthread_sigmask(haiku.SIG_SETMASK, &old_mask, nil)
// FIXME: Add error handling! // FIXME: Add error handling!
return return
} }
_futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expect: u32, duration: time.Duration) -> (ok: bool) { _futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expect: u32, duration: time.Duration) -> (ok: bool) {
@@ -133,10 +132,10 @@ _futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expect: u32, duration
waiter.prev.next = waiter.next waiter.prev.next = waiter.next
waiter.next.prev = waiter.prev waiter.next.prev = waiter.prev
unix.pthread_sigmask(haiku.SIG_SETMASK, &old_mask, nil) unix.pthread_sigmask(haiku.SIG_SETMASK, &old_mask, nil)
// FIXME: Add error handling! // FIXME: Add error handling!
return return
} }
_futex_signal :: proc "contextless" (f: ^Futex) { _futex_signal :: proc "contextless" (f: ^Futex) {
+1 -1
View File
@@ -399,7 +399,7 @@ cpu_topology_node_info :: struct {
}, },
_package: struct { _package: struct {
vendor: cpu_vendor, vendor: cpu_vendor,
cache_line_size: u32 cache_line_size: u32,
}, },
_core: struct { _core: struct {
model: u32, model: u32,
+21
View File
@@ -127,6 +127,8 @@ gb_internal bool complete_soa_type(Checker *checker, Type *t, bool wait_to_finis
gb_internal bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y); gb_internal bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y);
gb_internal bool is_exact_value_zero(ExactValue const &v);
enum LoadDirectiveResult { enum LoadDirectiveResult {
LoadDirective_Success = 0, LoadDirective_Success = 0,
LoadDirective_Error = 1, LoadDirective_Error = 1,
@@ -4364,6 +4366,25 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
} }
switch (t->kind) { switch (t->kind) {
// IMPORTANT NOTE HACK(bill): This is just to allow for comparisons against `0` with the `os.Error` type
// as a kind of transition period
case Type_Enum:
if (operand->mode == Addressing_Constant &&
target_type->kind == Type_Named &&
target_type->Named.name == "Error") {
Entity *e = target_type->Named.type_name;
if (e->pkg && e->pkg->name == "os") {
if (is_exact_value_zero(operand->value)) {
check_is_expressible(c, operand, t);
if (operand->mode == Addressing_Invalid) {
return;
}
update_untyped_expr_value(c, operand->expr, operand->value);
}
}
}
break;
case Type_Basic: case Type_Basic:
if (operand->mode == Addressing_Constant) { if (operand->mode == Addressing_Constant) {
check_is_expressible(c, operand, t); check_is_expressible(c, operand, t);