diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2023-06-08 09:39:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-08 09:39:25 +0200 |
| commit | eac53fed59bec2ec8bd0a8efff39bd2a195d9d45 (patch) | |
| tree | a3c283f1daa306ac8d77e200ca4ed5a3005fa31d /core | |
| parent | 21c1618d945a16ad5dcaa7ae4917672712564a6a (diff) | |
| parent | fed0c2ea26665d183818b07a884d3b48c1a60e36 (diff) | |
Merge pull request #2583 from JamesDSource/master
Correct Timeval struct to use microseconds on darwin and linux (Issue #2489)
Diffstat (limited to 'core')
| -rw-r--r-- | core/net/socket_darwin.odin | 8 | ||||
| -rw-r--r-- | core/net/socket_linux.odin | 8 | ||||
| -rw-r--r-- | core/os/os_darwin.odin | 2 | ||||
| -rw-r--r-- | core/os/os_linux.odin | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/core/net/socket_darwin.odin b/core/net/socket_darwin.odin index f00be9915..081892afd 100644 --- a/core/net/socket_darwin.odin +++ b/core/net/socket_darwin.odin @@ -268,9 +268,9 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca t, ok := value.(time.Duration) if !ok do panic("set_option() value must be a time.Duration here", loc) - nanos := time.duration_nanoseconds(t) - timeval_value.nanoseconds = int(nanos % 1e9) - timeval_value.seconds = (nanos - i64(timeval_value.nanoseconds)) / 1e9 + micros := i64(time.duration_microseconds(t)) + timeval_value.microseconds = int(micros % 1e6) + timeval_value.seconds = (micros - i64(timeval_value.microseconds)) / 1e6 ptr = &timeval_value len = size_of(timeval_value) @@ -368,4 +368,4 @@ _sockaddr_to_endpoint :: proc(native_addr: ^os.SOCKADDR_STORAGE_LH) -> (ep: Endp panic("native_addr is neither IP4 or IP6 address") } return -}
\ No newline at end of file +} diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin index 690e09ab7..b7141e8ba 100644 --- a/core/net/socket_linux.odin +++ b/core/net/socket_linux.odin @@ -283,9 +283,9 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca t, ok := value.(time.Duration) if !ok do panic("set_option() value must be a time.Duration here", loc) - nanos := time.duration_nanoseconds(t) - timeval_value.nanoseconds = int(nanos % 1e9) - timeval_value.seconds = (nanos - i64(timeval_value.nanoseconds)) / 1e9 + micros := i64(time.duration_microseconds(t)) + timeval_value.microseconds = int(micros % 1e6) + timeval_value.seconds = (micros - i64(timeval_value.microseconds)) / 1e6 ptr = &timeval_value len = size_of(timeval_value) @@ -404,4 +404,4 @@ _sockaddr_basic_to_endpoint :: proc(native_addr: ^os.SOCKADDR) -> (ep: Endpoint) panic("native_addr is neither IP4 or IP6 address") } return -}
\ No newline at end of file +} diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index a2d68aeed..adb438f60 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -355,7 +355,7 @@ in6_addr :: struct #packed { Timeval :: struct { seconds: i64, - nanoseconds: int, + microseconds: int, } Linger :: struct { diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 3dc48087a..7a0a4b1dd 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -241,7 +241,7 @@ socklen_t :: c.int Timeval :: struct { seconds: i64, - nanoseconds: int, + microseconds: int, } // "Argv" arguments converted to Odin strings @@ -1086,4 +1086,4 @@ fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) { return 0, _get_errno(result) } return result, ERROR_NONE -}
\ No newline at end of file +} |