diff options
author | Oscar NihlgÄrd <oscarnihlgard@gmail.com> | 2018-04-18 21:24:28 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-04-18 21:24:28 +0200 |
commit | fdf1d123804df3325211384e1c438295ea23bbd3 (patch) | |
tree | 74d91d6c9ef88ecfb384863709afc4ddbb16f739 /lib/pure | |
parent | b9cafe5752f0772b6c05b78c45cd72b8c0932de2 (diff) | |
download | Nim-fdf1d123804df3325211384e1c438295ea23bbd3.tar.gz |
Change type of `Timeval.tv_sec` to `posix.Time` (#7646)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/nativesockets.nim | 8 | ||||
-rw-r--r-- | lib/pure/os.nim | 2 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 2 | ||||
-rw-r--r-- | lib/pure/times.nim | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index 74b2c9741..09fa253f1 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -616,8 +616,12 @@ proc setBlocking*(s: SocketHandle, blocking: bool) = proc timeValFromMilliseconds(timeout = 500): Timeval = if timeout != -1: var seconds = timeout div 1000 - result.tv_sec = seconds.int32 - result.tv_usec = ((timeout - seconds * 1000) * 1000).int32 + when useWinVersion: + result.tv_sec = seconds.int32 + result.tv_usec = ((timeout - seconds * 1000) * 1000).int32 + else: + result.tv_sec = seconds.Time + result.tv_usec = ((timeout - seconds * 1000) * 1000).Suseconds proc createFdSet(fd: var TFdSet, s: seq[SocketHandle], m: var int) = FD_ZERO(fd) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 255a9a8de..8298024d6 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1660,7 +1660,7 @@ proc setLastModificationTime*(file: string, t: times.Time) = ## Sets the `file`'s last modification time. `OSError` is raised in case of ## an error. when defined(posix): - let unixt = t.toUnix.int + let unixt = posix.Time(t.toUnix) var timevals = [Timeval(tv_sec: unixt), Timeval(tv_sec: unixt)] # [last access, last modification] if utimes(file, timevals.addr) != 0: raiseOSError(osLastError()) else: diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index a51b1f5ab..bcab5ad3a 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -1289,7 +1289,7 @@ elif not defined(useNimRtl): proc select(readfds: var seq[Process], timeout = 500): int = var tv: Timeval - tv.tv_sec = 0 + tv.tv_sec = posix.Time(0) tv.tv_usec = timeout * 1000 var rd: TFdSet diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 29492379d..cad32b51a 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -1752,7 +1752,7 @@ when not defined(JS): when defined(posix): var a: Timeval gettimeofday(a) - result = toFloat(a.tv_sec) + toFloat(a.tv_usec)*0.00_0001 + result = toBiggestFloat(a.tv_sec.int64) + toFloat(a.tv_usec)*0.00_0001 elif defined(windows): var f: winlean.FILETIME getSystemTimeAsFileTime(f) |