Merge pull request #2583 from JamesDSource/master

Correct Timeval struct to use microseconds on darwin and linux (Issue #2489)
This commit is contained in:
Jeroen van Rijn
2023-06-08 09:39:25 +02:00
committed by GitHub
4 changed files with 11 additions and 11 deletions

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -355,7 +355,7 @@ in6_addr :: struct #packed {
Timeval :: struct {
seconds: i64,
nanoseconds: int,
microseconds: int,
}
Linger :: struct {

View File

@@ -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
}
}