aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-07 11:44:42 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-07 11:44:42 +0000
commit703e1aa2bcf6bb059a3dd0e12a02cf02ed5449cf (patch)
treed67712be7ccd274efa9f0042415356e769b12dec /core
parentb1e35b6da3e335376339965ad2e26d7e275de3c5 (diff)
Fix core library; Disable adding entity definitions for blank identifiersv0.0.5e
Diffstat (limited to 'core')
-rw-r--r--core/_preload.odin2
-rw-r--r--core/mem.odin33
-rw-r--r--core/os_windows.odin77
-rw-r--r--core/sys/windows.odin2
4 files changed, 47 insertions, 67 deletions
diff --git a/core/_preload.odin b/core/_preload.odin
index d65f3d8e4..0d73e5462 100644
--- a/core/_preload.odin
+++ b/core/_preload.odin
@@ -308,7 +308,7 @@ __bounds_check_error :: proc(file: string, line, column: int, index, count: int)
if 0 <= index && index < count {
return;
}
- fmt.fprintf(os.stderr, "%(%:%) Index % is out of bounds range [0, %)\n",
+ fmt.fprintf(os.stderr, "%(%:%) Index % is out of bounds range 0..<%\n",
file, line, column, index, count);
__debug_trap();
}
diff --git a/core/mem.odin b/core/mem.odin
index f163a219f..ee358fef4 100644
--- a/core/mem.odin
+++ b/core/mem.odin
@@ -26,37 +26,16 @@ copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr #link_name "_
}
compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" {
- // Translation of http://mgronhol.github.io/fast-strcmp/
a := slice_ptr(dst as ^byte, n);
b := slice_ptr(src as ^byte, n);
-
- fast := n/size_of(int) + 1;
- offset := (fast-1)*size_of(int);
- curr_block := 0;
- if n <= size_of(int) {
- fast = 0;
- }
-
- la := slice_ptr(^a[0] as ^int, fast);
- lb := slice_ptr(^b[0] as ^int, fast);
-
- for _ : curr_block ..< fast {
- if (la[curr_block] ~ lb[curr_block]) != 0 {
- for pos : curr_block*size_of(int) ..< n {
- if (a[pos] ~ b[pos]) != 0 {
- return a[pos] as int - b[pos] as int;
- }
- }
+ for i : 0..<n {
+ match {
+ case a[i] < b[i]:
+ return -1;
+ case a[i] > b[i]:
+ return +1;
}
-
}
-
- for _ : offset ..< n {
- if (a[offset] ~ b[offset]) != 0 {
- return a[offset] as int - b[offset] as int;
- }
- }
-
return 0;
}
diff --git a/core/os_windows.odin b/core/os_windows.odin
index e63d3d8a7..8836504ce 100644
--- a/core/os_windows.odin
+++ b/core/os_windows.odin
@@ -2,11 +2,11 @@
#import "fmt.odin";
-Handle :: uint;
+Handle :: int;
File_Time :: u64;
-Error :: int;
+Errno :: int;
-INVALID_HANDLE: Handle : ~(0 as Handle);
+INVALID_HANDLE: Handle : -1;
O_RDONLY :: 0x00000;
@@ -22,37 +22,37 @@ O_SYNC :: 0x01000;
O_ASYNC :: 0x02000;
O_CLOEXEC :: 0x80000;
-ERROR_NONE: Error : 0;
-ERROR_FILE_NOT_FOUND: Error : 2;
-ERROR_PATH_NOT_FOUND: Error : 3;
-ERROR_ACCESS_DENIED: Error : 5;
-ERROR_NO_MORE_FILES: Error : 18;
-ERROR_HANDLE_EOF: Error : 38;
-ERROR_NETNAME_DELETED: Error : 64;
-ERROR_FILE_EXISTS: Error : 80;
-ERROR_BROKEN_PIPE: Error : 109;
-ERROR_BUFFER_OVERFLOW: Error : 111;
-ERROR_INSUFFICIENT_BUFFER: Error : 122;
-ERROR_MOD_NOT_FOUND: Error : 126;
-ERROR_PROC_NOT_FOUND: Error : 127;
-ERROR_DIR_NOT_EMPTY: Error : 145;
-ERROR_ALREADY_EXISTS: Error : 183;
-ERROR_ENVVAR_NOT_FOUND: Error : 203;
-ERROR_MORE_DATA: Error : 234;
-ERROR_OPERATION_ABORTED: Error : 995;
-ERROR_IO_PENDING: Error : 997;
-ERROR_NOT_FOUND: Error : 1168;
-ERROR_PRIVILEGE_NOT_HELD: Error : 1314;
-WSAEACCES: Error : 10013;
-WSAECONNRESET: Error : 10054;
+ERROR_NONE: Errno : 0;
+ERROR_FILE_NOT_FOUND: Errno : 2;
+ERROR_PATH_NOT_FOUND: Errno : 3;
+ERROR_ACCESS_DENIED: Errno : 5;
+ERROR_NO_MORE_FILES: Errno : 18;
+ERROR_HANDLE_EOF: Errno : 38;
+ERROR_NETNAME_DELETED: Errno : 64;
+ERROR_FILE_EXISTS: Errno : 80;
+ERROR_BROKEN_PIPE: Errno : 109;
+ERROR_BUFFER_OVERFLOW: Errno : 111;
+ERROR_INSUFFICIENT_BUFFER: Errno : 122;
+ERROR_MOD_NOT_FOUND: Errno : 126;
+ERROR_PROC_NOT_FOUND: Errno : 127;
+ERROR_DIR_NOT_EMPTY: Errno : 145;
+ERROR_ALREADY_EXISTS: Errno : 183;
+ERROR_ENVVAR_NOT_FOUND: Errno : 203;
+ERROR_MORE_DATA: Errno : 234;
+ERROR_OPERATION_ABORTED: Errno : 995;
+ERROR_IO_PENDING: Errno : 997;
+ERROR_NOT_FOUND: Errno : 1168;
+ERROR_PRIVILEGE_NOT_HELD: Errno : 1314;
+WSAEACCES: Errno : 10013;
+WSAECONNRESET: Errno : 10054;
// Windows reserves errors >= 1<<29 for application use
-ERROR_FILE_IS_PIPE: Error : 1<<29 + 0;
+ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0;
-open :: proc(path: string, mode: int, perm: u32) -> (Handle, Error) {
+open :: proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
using win32;
if path.count == 0 {
return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
@@ -98,37 +98,38 @@ open :: proc(path: string, mode: int, perm: u32) -> (Handle, Error) {
copy(buf[:], path as []byte);
handle := CreateFileA(^buf[0], access, share_mode, sa, create_mode, FILE_ATTRIBUTE_NORMAL, nil) as Handle;
- if handle == INVALID_HANDLE {
+ if handle != INVALID_HANDLE {
return handle, ERROR_NONE;
}
err := GetLastError();
- return INVALID_HANDLE, err as Error;
+ return INVALID_HANDLE, err as Errno;
}
close :: proc(fd: Handle) {
win32.CloseHandle(fd as win32.HANDLE);
}
-write :: proc(fd: Handle, data: []byte) -> (int, Error) {
+write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
bytes_written: i32;
e := win32.WriteFile(fd as win32.HANDLE, data.data, data.count as i32, ^bytes_written, nil);
- if e != 0 {
- return 0, e as Error;
+ if e == win32.FALSE {
+ err := win32.GetLastError();
+ return 0, err as Errno;
}
return bytes_written as int, ERROR_NONE;
}
-read :: proc(fd: Handle, data: []byte) -> (int, Error) {
+read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
bytes_read: i32;
e := win32.ReadFile(fd as win32.HANDLE, data.data, data.count as u32, ^bytes_read, nil);
- if e != win32.FALSE {
+ if e == win32.FALSE {
err := win32.GetLastError();
- return 0, err as Error;
+ return 0, err as Errno;
}
return bytes_read as int, ERROR_NONE;
}
-seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
+seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
using win32;
w: u32;
match whence {
@@ -145,7 +146,7 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
dw_ptr := SetFilePointer(fd as HANDLE, lo, ^hi, w);
if dw_ptr == INVALID_SET_FILE_POINTER {
err := GetLastError();
- return 0, err as Error;
+ return 0, err as Errno;
}
return (hi as i64)<<32 + (dw_ptr as i64), ERROR_NONE;
}
diff --git a/core/sys/windows.odin b/core/sys/windows.odin
index 09b3eb68e..c5355b91c 100644
--- a/core/sys/windows.odin
+++ b/core/sys/windows.odin
@@ -175,7 +175,7 @@ CreateFileA :: proc(filename: ^u8, desired_access, share_mode: u32,
security: rawptr,
creation, flags_and_attribs: u32, template_file: HANDLE) -> HANDLE #foreign #dll_import
ReadFile :: proc(h: HANDLE, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> BOOL #foreign #dll_import
-WriteFile :: proc(h: HANDLE, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> i32 #foreign #dll_import
+WriteFile :: proc(h: HANDLE, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> BOOL #foreign #dll_import
GetFileSizeEx :: proc(file_handle: HANDLE, file_size: ^i64) -> BOOL #foreign #dll_import
GetFileAttributesExA :: proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> BOOL #foreign #dll_import