Add sideEffect pragma to importC procs in posix, winlean and time module (#13370)

* Add sideEffect pragma to procs in winlean
* Add sideEffect pragma to procs in posix
* Add test for #13306
* Add sideEffect pragma to procs in times
* Fixes #13306
This commit is contained in:
Tomohiro 2020-02-09 04:09:49 +09:00 • committed by GitHub
commit 2a4aa24620
4 changed files with 144 additions and 132 deletions

View file

@ -232,7 +232,7 @@ elif defined(posix):
when defined(macosx):
proc gettimeofday(tp: var Timeval, unused: pointer = nil)
{.importc: "gettimeofday", header: "<sys/time.h>".}
{.importc: "gettimeofday", header: "<sys/time.h>", sideEffect.}
elif defined(windows):
import winlean, std/time_t
@ -254,7 +254,7 @@ elif defined(windows):
tm_yday*: cint ## Day of year [0,365].
tm_isdst*: cint ## Daylight Savings flag.
proc localtime(a1: var CTime): ptr Tm {.importc, header: "<time.h>".}
proc localtime(a1: var CTime): ptr Tm {.importc, header: "<time.h>", sideEffect.}
type
Month* = enum ## Represents a month. Note that the enum starts at ``1``,
@ -2527,7 +2527,7 @@ when not defined(js):
Clock {.importc: "clock_t".} = distinct int
proc getClock(): Clock
{.importc: "clock", header: "<time.h>", tags: [TimeEffect], used.}
{.importc: "clock", header: "<time.h>", tags: [TimeEffect], used, sideEffect.}
var
clocksPerSec {.importc: "CLOCKS_PER_SEC", nodecl, used.}: int