Browse Source

Revert os_windows.odin behaviour

gingerBill 5 years ago
parent
commit
2ce1f4ba9f
2 changed files with 12 additions and 12 deletions
  1. 5 5
      core/os/os_windows.odin
  2. 7 7
      core/sys/win32/kernel32.odin

+ 5 - 5
core/os/os_windows.odin

@@ -123,17 +123,17 @@ close :: proc(fd: Handle) -> Errno {
 write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
 	if len(data) == 0 do return 0, ERROR_NONE;
 
-	single_write_length: u32;
+	single_write_length: i32;
 	total_write: i64;
 	length := i64(len(data));
 
 	for total_write < length {
 		remaining := length - total_write;
 		MAX :: 1<<31-1;
-		to_write: u32 = min(u32(remaining), MAX);
+		to_write: i32 = min(i32(remaining), MAX);
 
 		e := win32.write_file(win32.Handle(fd), &data[total_write], to_write, &single_write_length, nil);
-		if single_write_length == 0 || !e {
+		if single_write_length <= 0 || !e {
 			err := Errno(win32.get_last_error());
 			return int(total_write), err;
 		}
@@ -145,7 +145,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
 read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
 	if len(data) == 0 do return 0, ERROR_NONE;
 
-	single_read_length: u32;
+	single_read_length: i32;
 	total_read: i64;
 	length := i64(len(data));
 
@@ -155,7 +155,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
 		to_read: u32 = min(u32(remaining), MAX);
 
 		e := win32.read_file(win32.Handle(fd), &data[total_read], to_read, &single_read_length, nil);
-		if single_read_length == 0 || !e {
+		if single_read_length <= 0 || !e {
 			err := Errno(win32.get_last_error());
 			return int(total_read), err;
 		}

+ 7 - 7
core/sys/win32/kernel32.odin

@@ -10,11 +10,11 @@ foreign kernel32 {
 	                                                              				 inherit_handle: Bool, creation_flags: u32, environment: rawptr,
 	                                                              				 current_direcotry: cstring, startup_info: ^Startup_Info,
 	                                                              				 process_information: ^Process_Information) -> Bool ---;
-    @(link_name="CreateProcessW")            create_process_w             :: proc(application_name, command_line: Wstring,
-                                                                                 process_attributes, thread_attributes: ^Security_Attributes,
-                                                                                 inherit_handle: Bool, creation_flags: u32, environment: rawptr,
-                                                                                 current_direcotry: cstring, startup_info: ^Startup_Info,
-                                                                                 process_information: ^Process_Information) -> Bool ---;
+	@(link_name="CreateProcessW")            create_process_w             :: proc(application_name, command_line: Wstring,
+	                                                                             process_attributes, thread_attributes: ^Security_Attributes,
+	                                                                             inherit_handle: Bool, creation_flags: u32, environment: rawptr,
+	                                                                             current_direcotry: cstring, startup_info: ^Startup_Info,
+	                                                                             process_information: ^Process_Information) -> Bool ---;
 	@(link_name="GetExitCodeProcess")		 get_exit_code_process        :: proc(process: Handle, exit: ^u32) -> Bool ---;
 	@(link_name="ExitProcess")               exit_process                 :: proc(exit_code: u32) ---;
 	@(link_name="GetModuleHandleA")          get_module_handle_a          :: proc(module_name: cstring) -> Hmodule ---;
@@ -58,8 +58,8 @@ foreign kernel32 {
 	                      creation, flags_and_attribs: u32, template_file: Handle) -> Handle ---;
 
 
-	@(link_name="ReadFile")  read_file  :: proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^u32, overlapped: rawptr) -> Bool ---;
-	@(link_name="WriteFile") write_file :: proc(h: Handle, buf: rawptr, len: u32, written_result: ^u32, overlapped: rawptr) -> Bool ---;
+	@(link_name="ReadFile")  read_file  :: proc(h: Handle, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> Bool ---;
+	@(link_name="WriteFile") write_file :: proc(h: Handle, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> Bool ---;
 
 	@(link_name="GetFileSizeEx")              get_file_size_ex               :: proc(file_handle: Handle, file_size: ^i64) -> Bool ---;
 	@(link_name="GetFileInformationByHandle") get_file_information_by_handle :: proc(file_handle: Handle, file_info: ^By_Handle_File_Information) -> Bool ---;