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/net | |
| 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/net')
| -rw-r--r-- | core/net/socket_darwin.odin | 8 | ||||
| -rw-r--r-- | core/net/socket_linux.odin | 8 |
2 files changed, 8 insertions, 8 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 +} |