mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 14:55:24 +00:00
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:
@@ -166,23 +166,23 @@ proc IN6ADDR_LOOPBACK_INIT* (): In6Addr {.importc, header: "<netinet/in.h>".}
|
||||
|
||||
# dirent.h
|
||||
proc closedir*(a1: ptr DIR): cint {.importc, header: "<dirent.h>".}
|
||||
proc opendir*(a1: cstring): ptr DIR {.importc, header: "<dirent.h>".}
|
||||
proc readdir*(a1: ptr DIR): ptr Dirent {.importc, header: "<dirent.h>".}
|
||||
proc opendir*(a1: cstring): ptr DIR {.importc, header: "<dirent.h>", sideEffect.}
|
||||
proc readdir*(a1: ptr DIR): ptr Dirent {.importc, header: "<dirent.h>", sideEffect.}
|
||||
proc readdir_r*(a1: ptr DIR, a2: ptr Dirent, a3: ptr ptr Dirent): cint {.
|
||||
importc, header: "<dirent.h>".}
|
||||
importc, header: "<dirent.h>", sideEffect.}
|
||||
proc rewinddir*(a1: ptr DIR) {.importc, header: "<dirent.h>".}
|
||||
proc seekdir*(a1: ptr DIR, a2: int) {.importc, header: "<dirent.h>".}
|
||||
proc telldir*(a1: ptr DIR): int {.importc, header: "<dirent.h>".}
|
||||
|
||||
# dlfcn.h
|
||||
proc dlclose*(a1: pointer): cint {.importc, header: "<dlfcn.h>".}
|
||||
proc dlerror*(): cstring {.importc, header: "<dlfcn.h>".}
|
||||
proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "<dlfcn.h>".}
|
||||
proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "<dlfcn.h>".}
|
||||
proc dlclose*(a1: pointer): cint {.importc, header: "<dlfcn.h>", sideEffect.}
|
||||
proc dlerror*(): cstring {.importc, header: "<dlfcn.h>", sideEffect.}
|
||||
proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "<dlfcn.h>", sideEffect.}
|
||||
proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "<dlfcn.h>", sideEffect.}
|
||||
|
||||
proc creat*(a1: cstring, a2: Mode): cint {.importc, header: "<fcntl.h>".}
|
||||
proc fcntl*(a1: cint | SocketHandle, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".}
|
||||
proc open*(a1: cstring, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".}
|
||||
proc creat*(a1: cstring, a2: Mode): cint {.importc, header: "<fcntl.h>", sideEffect.}
|
||||
proc fcntl*(a1: cint | SocketHandle, a2: cint): cint {.varargs, importc, header: "<fcntl.h>", sideEffect.}
|
||||
proc open*(a1: cstring, a2: cint): cint {.varargs, importc, header: "<fcntl.h>", sideEffect.}
|
||||
proc posix_fadvise*(a1: cint, a2, a3: Off, a4: cint): cint {.
|
||||
importc, header: "<fcntl.h>".}
|
||||
proc posix_fallocate*(a1: cint, a2, a3: Off): cint {.
|
||||
@@ -205,7 +205,7 @@ when not (defined(linux) and defined(amd64)) and not defined(nintendoswitch):
|
||||
|
||||
proc glob*(a1: cstring, a2: cint,
|
||||
a3: proc (x1: cstring, x2: cint): cint {.noconv.},
|
||||
a4: ptr Glob): cint {.importc, header: "<glob.h>".}
|
||||
a4: ptr Glob): cint {.importc, header: "<glob.h>", sideEffect.}
|
||||
## Filename globbing. Use `os.walkPattern() <os.html#glob_1>`_ and similar.
|
||||
|
||||
proc globfree*(a1: ptr Glob) {.importc, header: "<glob.h>".}
|
||||
@@ -234,7 +234,7 @@ proc dirname*(a1: cstring): cstring {.importc, header: "<libgen.h>".}
|
||||
|
||||
proc localeconv*(): ptr Lconv {.importc, header: "<locale.h>".}
|
||||
proc setlocale*(a1: cint, a2: cstring): cstring {.
|
||||
importc, header: "<locale.h>".}
|
||||
importc, header: "<locale.h>", sideEffect.}
|
||||
|
||||
proc strfmon*(a1: cstring, a2: int, a3: cstring): int {.varargs,
|
||||
importc, header: "<monetary.h>".}
|
||||
@@ -459,54 +459,54 @@ proc dup*(a1: cint): cint {.importc, header: "<unistd.h>".}
|
||||
proc dup2*(a1, a2: cint): cint {.importc, header: "<unistd.h>".}
|
||||
proc encrypt*(a1: array[0..63, char], a2: cint) {.importc, header: "<unistd.h>".}
|
||||
|
||||
proc execl*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
|
||||
proc execle*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
|
||||
proc execlp*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
|
||||
proc execv*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>".}
|
||||
proc execl*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execle*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execlp*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execv*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execve*(a1: cstring, a2, a3: cstringArray): cint {.
|
||||
importc, header: "<unistd.h>".}
|
||||
proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>".}
|
||||
proc execvpe*(a1: cstring, a2: cstringArray, a3: cstringArray): cint {.importc, header: "<unistd.h>".}
|
||||
proc fchown*(a1: cint, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".}
|
||||
proc fchdir*(a1: cint): cint {.importc, header: "<unistd.h>".}
|
||||
importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc execvpe*(a1: cstring, a2: cstringArray, a3: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc fchown*(a1: cint, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc fchdir*(a1: cint): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc fdatasync*(a1: cint): cint {.importc, header: "<unistd.h>".}
|
||||
proc fork*(): Pid {.importc, header: "<unistd.h>".}
|
||||
proc fork*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc fpathconf*(a1, a2: cint): int {.importc, header: "<unistd.h>".}
|
||||
proc fsync*(a1: cint): cint {.importc, header: "<unistd.h>".}
|
||||
## synchronize a file's buffer cache to the storage device
|
||||
|
||||
proc ftruncate*(a1: cint, a2: Off): cint {.importc, header: "<unistd.h>".}
|
||||
proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "<unistd.h>".}
|
||||
proc getuid*(): Uid {.importc, header: "<unistd.h>".}
|
||||
proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc getuid*(): Uid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the real user ID of the calling process
|
||||
|
||||
proc geteuid*(): Uid {.importc, header: "<unistd.h>".}
|
||||
proc geteuid*(): Uid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the effective user ID of the calling process
|
||||
|
||||
proc getgid*(): Gid {.importc, header: "<unistd.h>".}
|
||||
proc getgid*(): Gid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the real group ID of the calling process
|
||||
|
||||
proc getegid*(): Gid {.importc, header: "<unistd.h>".}
|
||||
proc getegid*(): Gid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the effective group ID of the calling process
|
||||
|
||||
proc getgroups*(a1: cint, a2: ptr array[0..255, Gid]): cint {.
|
||||
importc, header: "<unistd.h>".}
|
||||
proc gethostid*(): int {.importc, header: "<unistd.h>".}
|
||||
proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".}
|
||||
proc getlogin*(): cstring {.importc, header: "<unistd.h>".}
|
||||
proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".}
|
||||
proc gethostid*(): int {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc getlogin*(): cstring {.importc, header: "<unistd.h>", sideEffect.}
|
||||
proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>", sideEffect.}
|
||||
|
||||
proc getopt*(a1: cint, a2: cstringArray, a3: cstring): cint {.
|
||||
importc, header: "<unistd.h>".}
|
||||
proc getpgid*(a1: Pid): Pid {.importc, header: "<unistd.h>".}
|
||||
proc getpgrp*(): Pid {.importc, header: "<unistd.h>".}
|
||||
proc getpid*(): Pid {.importc, header: "<unistd.h>".}
|
||||
proc getpid*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the process ID (PID) of the calling process
|
||||
|
||||
proc getppid*(): Pid {.importc, header: "<unistd.h>".}
|
||||
proc getppid*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the process ID of the parent of the calling process
|
||||
|
||||
proc getsid*(a1: Pid): Pid {.importc, header: "<unistd.h>".}
|
||||
proc getsid*(a1: Pid): Pid {.importc, header: "<unistd.h>", sideEffect.}
|
||||
## returns the session ID of the calling process
|
||||
|
||||
proc getwd*(a1: cstring): cstring {.importc, header: "<unistd.h>".}
|
||||
@@ -584,11 +584,11 @@ proc statvfs*(a1: cstring, a2: var Statvfs): cint {.
|
||||
proc fstatvfs*(a1: cint, a2: var Statvfs): cint {.
|
||||
importc, header: "<sys/statvfs.h>".}
|
||||
|
||||
proc chmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".}
|
||||
proc fchmod*(a1: cint, a2: Mode): cint {.importc, header: "<sys/stat.h>".}
|
||||
proc fstat*(a1: cint, a2: var Stat): cint {.importc, header: "<sys/stat.h>".}
|
||||
proc lstat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>".}
|
||||
proc mkdir*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".}
|
||||
proc chmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
|
||||
proc fchmod*(a1: cint, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
|
||||
proc fstat*(a1: cint, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}
|
||||
proc lstat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}
|
||||
proc mkdir*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
|
||||
## Use `os.createDir() <os.html#createDir,string>`_ and similar.
|
||||
|
||||
proc mkfifo*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".}
|
||||
@@ -649,17 +649,17 @@ proc shm_unlink*(a1: cstring): cint {.importc, header: "<sys/mman.h>".}
|
||||
proc asctime*(a1: var Tm): cstring{.importc, header: "<time.h>".}
|
||||
|
||||
proc asctime_r*(a1: var Tm, a2: cstring): cstring {.importc, header: "<time.h>".}
|
||||
proc clock*(): Clock {.importc, header: "<time.h>".}
|
||||
proc clock*(): Clock {.importc, header: "<time.h>", sideEffect.}
|
||||
proc clock_getcpuclockid*(a1: Pid, a2: var ClockId): cint {.
|
||||
importc, header: "<time.h>".}
|
||||
importc, header: "<time.h>", sideEffect.}
|
||||
proc clock_getres*(a1: ClockId, a2: var Timespec): cint {.
|
||||
importc, header: "<time.h>".}
|
||||
importc, header: "<time.h>", sideEffect.}
|
||||
proc clock_gettime*(a1: ClockId, a2: var Timespec): cint {.
|
||||
importc, header: "<time.h>".}
|
||||
importc, header: "<time.h>", sideEffect.}
|
||||
proc clock_nanosleep*(a1: ClockId, a2: cint, a3: var Timespec,
|
||||
a4: var Timespec): cint {.importc, header: "<time.h>".}
|
||||
a4: var Timespec): cint {.importc, header: "<time.h>", sideEffect.}
|
||||
proc clock_settime*(a1: ClockId, a2: var Timespec): cint {.
|
||||
importc, header: "<time.h>".}
|
||||
importc, header: "<time.h>", sideEffect.}
|
||||
|
||||
proc `==`*(a, b: Time): bool {.borrow.}
|
||||
proc `-`*(a, b: Time): Time {.borrow.}
|
||||
@@ -673,11 +673,11 @@ proc localtime*(a1: var Time): ptr Tm {.importc, header: "<time.h>".}
|
||||
proc localtime_r*(a1: var Time, a2: var Tm): ptr Tm {.importc, header: "<time.h>".}
|
||||
proc mktime*(a1: var Tm): Time {.importc, header: "<time.h>".}
|
||||
proc timegm*(a1: var Tm): Time {.importc, header: "<time.h>".}
|
||||
proc nanosleep*(a1, a2: var Timespec): cint {.importc, header: "<time.h>".}
|
||||
proc nanosleep*(a1, a2: var Timespec): cint {.importc, header: "<time.h>", sideEffect.}
|
||||
proc strftime*(a1: cstring, a2: int, a3: cstring,
|
||||
a4: var Tm): int {.importc, header: "<time.h>".}
|
||||
proc strptime*(a1, a2: cstring, a3: var Tm): cstring {.importc, header: "<time.h>".}
|
||||
proc time*(a1: var Time): Time {.importc, header: "<time.h>".}
|
||||
proc time*(a1: var Time): Time {.importc, header: "<time.h>", sideEffect.}
|
||||
proc timer_create*(a1: ClockId, a2: var SigEvent,
|
||||
a3: var Timer): cint {.importc, header: "<time.h>".}
|
||||
proc timer_delete*(a1: Timer): cint {.importc, header: "<time.h>".}
|
||||
@@ -689,11 +689,11 @@ proc timer_settime*(a1: Timer, a2: cint, a3: var Itimerspec,
|
||||
proc tzset*() {.importc, header: "<time.h>".}
|
||||
|
||||
|
||||
proc wait*(a1: ptr cint): Pid {.importc, discardable, header: "<sys/wait.h>".}
|
||||
proc wait*(a1: ptr cint): Pid {.importc, discardable, header: "<sys/wait.h>", sideEffect.}
|
||||
proc waitid*(a1: cint, a2: Id, a3: var SigInfo, a4: cint): cint {.
|
||||
importc, header: "<sys/wait.h>".}
|
||||
importc, header: "<sys/wait.h>", sideEffect.}
|
||||
proc waitpid*(a1: Pid, a2: var cint, a3: cint): Pid {.
|
||||
importc, header: "<sys/wait.h>".}
|
||||
importc, header: "<sys/wait.h>", sideEffect.}
|
||||
|
||||
type Rusage* {.importc: "struct rusage", header: "<sys/resource.h>",
|
||||
bycopy.} = object
|
||||
@@ -704,7 +704,7 @@ type Rusage* {.importc: "struct rusage", header: "<sys/resource.h>",
|
||||
ru_nsignals*, ru_nvcsw*, ru_nivcsw*: clong # switching activity
|
||||
|
||||
proc wait4*(pid: Pid, status: ptr cint, options: cint, rusage: ptr Rusage): Pid
|
||||
{.importc, header: "<sys/wait.h>".}
|
||||
{.importc, header: "<sys/wait.h>", sideEffect.}
|
||||
|
||||
const
|
||||
RUSAGE_SELF* = cint(0)
|
||||
@@ -717,8 +717,8 @@ proc getrusage*(who: cint, rusage: ptr Rusage): cint
|
||||
|
||||
proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {.
|
||||
importc, header: "<signal.h>".}
|
||||
proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>".}
|
||||
proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>".}
|
||||
proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
|
||||
proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
|
||||
proc pthread_kill*(a1: Pthread, a2: cint): cint {.importc, header: "<signal.h>".}
|
||||
proc pthread_sigmask*(a1: cint, a2, a3: var Sigset): cint {.
|
||||
importc, header: "<signal.h>".}
|
||||
@@ -892,7 +892,7 @@ const
|
||||
proc `==`*(x, y: SocketHandle): bool {.borrow.}
|
||||
|
||||
proc accept*(a1: SocketHandle, a2: ptr SockAddr, a3: ptr SockLen): SocketHandle {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
|
||||
proc bindSocket*(a1: SocketHandle, a2: ptr SockAddr, a3: SockLen): cint {.
|
||||
importc: "bind", header: "<sys/socket.h>".}
|
||||
@@ -909,21 +909,21 @@ proc getsockopt*(a1: SocketHandle, a2, a3: cint, a4: pointer, a5: ptr SockLen):
|
||||
importc, header: "<sys/socket.h>".}
|
||||
|
||||
proc listen*(a1: SocketHandle, a2: cint): cint {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc recv*(a1: SocketHandle, a2: pointer, a3: int, a4: cint): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc recvfrom*(a1: SocketHandle, a2: pointer, a3: int, a4: cint,
|
||||
a5: ptr SockAddr, a6: ptr SockLen): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc recvmsg*(a1: SocketHandle, a2: ptr Tmsghdr, a3: cint): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc send*(a1: SocketHandle, a2: pointer, a3: int, a4: cint): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc sendmsg*(a1: SocketHandle, a2: ptr Tmsghdr, a3: cint): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc sendto*(a1: SocketHandle, a2: pointer, a3: int, a4: cint, a5: ptr SockAddr,
|
||||
a6: SockLen): int {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
importc, header: "<sys/socket.h>", sideEffect.}
|
||||
proc setsockopt*(a1: SocketHandle, a2, a3: cint, a4: pointer, a5: SockLen): cint {.
|
||||
importc, header: "<sys/socket.h>".}
|
||||
proc shutdown*(a1: SocketHandle, a2: cint): cint {.
|
||||
@@ -1021,21 +1021,21 @@ proc setprotoent*(a1: cint) {.importc, header: "<netdb.h>".}
|
||||
proc setservent*(a1: cint) {.importc, header: "<netdb.h>".}
|
||||
|
||||
proc poll*(a1: ptr TPollfd, a2: Tnfds, a3: int): cint {.
|
||||
importc, header: "<poll.h>".}
|
||||
importc, header: "<poll.h>", sideEffect.}
|
||||
|
||||
proc realpath*(name, resolved: cstring): cstring {.
|
||||
importc: "realpath", header: "<stdlib.h>".}
|
||||
|
||||
proc mkstemp*(tmpl: cstring): cint {.importc, header: "<stdlib.h>".}
|
||||
proc mkstemp*(tmpl: cstring): cint {.importc, header: "<stdlib.h>", sideEffect.}
|
||||
## Creates a unique temporary file.
|
||||
##
|
||||
## **Warning**: The `tmpl` argument is written to by `mkstemp` and thus
|
||||
## can't be a string literal. If in doubt copy the string before passing it.
|
||||
|
||||
proc mkdtemp*(tmpl: cstring): pointer {.importc, header: "<stdlib.h>".}
|
||||
proc mkdtemp*(tmpl: cstring): pointer {.importc, header: "<stdlib.h>", sideEffect.}
|
||||
|
||||
proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {.
|
||||
importc: "utimes", header: "<sys/time.h>".}
|
||||
importc: "utimes", header: "<sys/time.h>", sideEffect.}
|
||||
## Sets file access and modification times.
|
||||
##
|
||||
## Pass the filename and an array of times to set the access and modification
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -129,34 +129,36 @@ const
|
||||
CREATE_NO_WINDOW* = 0x08000000'i32
|
||||
|
||||
when useWinUnicode:
|
||||
proc getVersionExW*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.stdcall, dynlib: "kernel32", importc: "GetVersionExW".}
|
||||
proc getVersionExW*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.
|
||||
stdcall, dynlib: "kernel32", importc: "GetVersionExW", sideEffect.}
|
||||
else:
|
||||
proc getVersionExA*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.stdcall, dynlib: "kernel32", importc: "GetVersionExA".}
|
||||
proc getVersionExA*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.
|
||||
stdcall, dynlib: "kernel32", importc: "GetVersionExA", sideEffect.}
|
||||
|
||||
proc getVersion*(): DWORD {.stdcall, dynlib: "kernel32", importc: "GetVersion".}
|
||||
proc getVersion*(): DWORD {.stdcall, dynlib: "kernel32", importc: "GetVersion", sideEffect.}
|
||||
|
||||
proc closeHandle*(hObject: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
|
||||
importc: "CloseHandle".}
|
||||
|
||||
proc readFile*(hFile: Handle, buffer: pointer, nNumberOfBytesToRead: int32,
|
||||
lpNumberOfBytesRead: ptr int32, lpOverlapped: pointer): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "ReadFile".}
|
||||
stdcall, dynlib: "kernel32", importc: "ReadFile", sideEffect.}
|
||||
|
||||
proc writeFile*(hFile: Handle, buffer: pointer, nNumberOfBytesToWrite: int32,
|
||||
lpNumberOfBytesWritten: ptr int32,
|
||||
lpOverlapped: pointer): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "WriteFile".}
|
||||
stdcall, dynlib: "kernel32", importc: "WriteFile", sideEffect.}
|
||||
|
||||
proc createPipe*(hReadPipe, hWritePipe: var Handle,
|
||||
lpPipeAttributes: var SECURITY_ATTRIBUTES,
|
||||
nSize: int32): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "CreatePipe".}
|
||||
stdcall, dynlib: "kernel32", importc: "CreatePipe", sideEffect.}
|
||||
|
||||
proc createNamedPipe*(lpName: WideCString,
|
||||
dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize,
|
||||
nInBufferSize, nDefaultTimeOut: int32,
|
||||
lpSecurityAttributes: ptr SECURITY_ATTRIBUTES): Handle {.
|
||||
stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW".}
|
||||
stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW", sideEffect.}
|
||||
|
||||
proc peekNamedPipe*(hNamedPipe: Handle, lpBuffer: pointer=nil,
|
||||
nBufferSize: int32 = 0,
|
||||
@@ -173,7 +175,7 @@ when useWinUnicode:
|
||||
lpEnvironment, lpCurrentDirectory: WideCString,
|
||||
lpStartupInfo: var STARTUPINFO,
|
||||
lpProcessInformation: var PROCESS_INFORMATION): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "CreateProcessW".}
|
||||
stdcall, dynlib: "kernel32", importc: "CreateProcessW", sideEffect.}
|
||||
|
||||
else:
|
||||
proc createProcessA*(lpApplicationName, lpCommandLine: cstring,
|
||||
@@ -183,19 +185,19 @@ else:
|
||||
lpEnvironment: pointer, lpCurrentDirectory: cstring,
|
||||
lpStartupInfo: var STARTUPINFO,
|
||||
lpProcessInformation: var PROCESS_INFORMATION): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
|
||||
stdcall, dynlib: "kernel32", importc: "CreateProcessA", sideEffect.}
|
||||
|
||||
|
||||
proc suspendThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
|
||||
importc: "SuspendThread".}
|
||||
importc: "SuspendThread", sideEffect.}
|
||||
proc resumeThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
|
||||
importc: "ResumeThread".}
|
||||
importc: "ResumeThread", sideEffect.}
|
||||
|
||||
proc waitForSingleObject*(hHandle: Handle, dwMilliseconds: int32): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".}
|
||||
stdcall, dynlib: "kernel32", importc: "WaitForSingleObject", sideEffect.}
|
||||
|
||||
proc terminateProcess*(hProcess: Handle, uExitCode: int): WINBOOL {.stdcall,
|
||||
dynlib: "kernel32", importc: "TerminateProcess".}
|
||||
dynlib: "kernel32", importc: "TerminateProcess", sideEffect.}
|
||||
|
||||
proc getExitCodeProcess*(hProcess: Handle, lpExitCode: var int32): WINBOOL {.
|
||||
stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}
|
||||
@@ -203,15 +205,15 @@ proc getExitCodeProcess*(hProcess: Handle, lpExitCode: var int32): WINBOOL {.
|
||||
proc getStdHandle*(nStdHandle: int32): Handle {.stdcall, dynlib: "kernel32",
|
||||
importc: "GetStdHandle".}
|
||||
proc setStdHandle*(nStdHandle: int32, hHandle: Handle): WINBOOL {.stdcall,
|
||||
dynlib: "kernel32", importc: "SetStdHandle".}
|
||||
dynlib: "kernel32", importc: "SetStdHandle", sideEffect.}
|
||||
proc flushFileBuffers*(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
|
||||
importc: "FlushFileBuffers".}
|
||||
importc: "FlushFileBuffers", sideEffect.}
|
||||
|
||||
proc getLastError*(): int32 {.importc: "GetLastError",
|
||||
stdcall, dynlib: "kernel32".}
|
||||
stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc setLastError*(error: int32) {.importc: "SetLastError",
|
||||
stdcall, dynlib: "kernel32".}
|
||||
stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
when useWinUnicode:
|
||||
proc formatMessageW*(dwFlags: int32, lpSource: pointer,
|
||||
@@ -232,30 +234,30 @@ proc localFree*(p: pointer) {.
|
||||
when useWinUnicode:
|
||||
proc getCurrentDirectoryW*(nBufferLength: int32,
|
||||
lpBuffer: WideCString): int32 {.
|
||||
importc: "GetCurrentDirectoryW", dynlib: "kernel32", stdcall.}
|
||||
importc: "GetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc setCurrentDirectoryW*(lpPathName: WideCString): int32 {.
|
||||
importc: "SetCurrentDirectoryW", dynlib: "kernel32", stdcall.}
|
||||
importc: "SetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc createDirectoryW*(pathName: WideCString, security: pointer=nil): int32 {.
|
||||
importc: "CreateDirectoryW", dynlib: "kernel32", stdcall.}
|
||||
importc: "CreateDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc removeDirectoryW*(lpPathName: WideCString): int32 {.
|
||||
importc: "RemoveDirectoryW", dynlib: "kernel32", stdcall.}
|
||||
importc: "RemoveDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc setEnvironmentVariableW*(lpName, lpValue: WideCString): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW".}
|
||||
stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW", sideEffect.}
|
||||
|
||||
proc getModuleFileNameW*(handle: Handle, buf: WideCString,
|
||||
size: int32): int32 {.importc: "GetModuleFileNameW",
|
||||
dynlib: "kernel32", stdcall.}
|
||||
else:
|
||||
proc getCurrentDirectoryA*(nBufferLength: int32, lpBuffer: cstring): int32 {.
|
||||
importc: "GetCurrentDirectoryA", dynlib: "kernel32", stdcall.}
|
||||
importc: "GetCurrentDirectoryA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc setCurrentDirectoryA*(lpPathName: cstring): int32 {.
|
||||
importc: "SetCurrentDirectoryA", dynlib: "kernel32", stdcall.}
|
||||
importc: "SetCurrentDirectoryA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc createDirectoryA*(pathName: cstring, security: pointer=nil): int32 {.
|
||||
importc: "CreateDirectoryA", dynlib: "kernel32", stdcall.}
|
||||
importc: "CreateDirectoryA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc removeDirectoryA*(lpPathName: cstring): int32 {.
|
||||
importc: "RemoveDirectoryA", dynlib: "kernel32", stdcall.}
|
||||
importc: "RemoveDirectoryA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc setEnvironmentVariableA*(lpName, lpValue: cstring): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableA".}
|
||||
stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableA", sideEffect.}
|
||||
|
||||
proc getModuleFileNameA*(handle: Handle, buf: cstring, size: int32): int32 {.
|
||||
importc: "GetModuleFileNameA", dynlib: "kernel32", stdcall.}
|
||||
@@ -263,17 +265,17 @@ else:
|
||||
when useWinUnicode:
|
||||
proc createSymbolicLinkW*(lpSymlinkFileName, lpTargetFileName: WideCString,
|
||||
flags: DWORD): int32 {.
|
||||
importc:"CreateSymbolicLinkW", dynlib: "kernel32", stdcall.}
|
||||
importc:"CreateSymbolicLinkW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc createHardLinkW*(lpFileName, lpExistingFileName: WideCString,
|
||||
security: pointer=nil): int32 {.
|
||||
importc:"CreateHardLinkW", dynlib: "kernel32", stdcall.}
|
||||
importc:"CreateHardLinkW", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
else:
|
||||
proc createSymbolicLinkA*(lpSymlinkFileName, lpTargetFileName: cstring,
|
||||
flags: DWORD): int32 {.
|
||||
importc:"CreateSymbolicLinkA", dynlib: "kernel32", stdcall.}
|
||||
importc:"CreateSymbolicLinkA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
proc createHardLinkA*(lpFileName, lpExistingFileName: cstring,
|
||||
security: pointer=nil): int32 {.
|
||||
importc:"CreateHardLinkA", dynlib: "kernel32", stdcall.}
|
||||
importc:"CreateHardLinkA", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
|
||||
const
|
||||
FILE_ATTRIBUTE_READONLY* = 0x00000001'i32
|
||||
@@ -327,17 +329,17 @@ type
|
||||
when useWinUnicode:
|
||||
proc findFirstFileW*(lpFileName: WideCString,
|
||||
lpFindFileData: var WIN32_FIND_DATA): Handle {.
|
||||
stdcall, dynlib: "kernel32", importc: "FindFirstFileW".}
|
||||
stdcall, dynlib: "kernel32", importc: "FindFirstFileW", sideEffect.}
|
||||
proc findNextFileW*(hFindFile: Handle,
|
||||
lpFindFileData: var WIN32_FIND_DATA): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "FindNextFileW".}
|
||||
stdcall, dynlib: "kernel32", importc: "FindNextFileW", sideEffect.}
|
||||
else:
|
||||
proc findFirstFileA*(lpFileName: cstring,
|
||||
lpFindFileData: var WIN32_FIND_DATA): Handle {.
|
||||
stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
|
||||
stdcall, dynlib: "kernel32", importc: "FindFirstFileA", sideEffect.}
|
||||
proc findNextFileA*(hFindFile: Handle,
|
||||
lpFindFileData: var WIN32_FIND_DATA): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
|
||||
stdcall, dynlib: "kernel32", importc: "FindNextFileA", sideEffect.}
|
||||
|
||||
proc findClose*(hFindFile: Handle) {.stdcall, dynlib: "kernel32",
|
||||
importc: "FindClose".}
|
||||
@@ -347,61 +349,61 @@ when useWinUnicode:
|
||||
lpBuffer: WideCString,
|
||||
lpFilePart: var WideCString): int32 {.
|
||||
stdcall, dynlib: "kernel32",
|
||||
importc: "GetFullPathNameW".}
|
||||
importc: "GetFullPathNameW", sideEffect.}
|
||||
proc getFileAttributesW*(lpFileName: WideCString): int32 {.
|
||||
stdcall, dynlib: "kernel32",
|
||||
importc: "GetFileAttributesW".}
|
||||
importc: "GetFileAttributesW", sideEffect.}
|
||||
proc setFileAttributesW*(lpFileName: WideCString,
|
||||
dwFileAttributes: int32): WINBOOL {.
|
||||
stdcall, dynlib: "kernel32", importc: "SetFileAttributesW".}
|
||||
stdcall, dynlib: "kernel32", importc: "SetFileAttributesW", sideEffect.}
|
||||
|
||||
proc copyFileW*(lpExistingFileName, lpNewFileName: WideCString,
|
||||
bFailIfExists: WINBOOL): WINBOOL {.
|
||||
importc: "CopyFileW", stdcall, dynlib: "kernel32".}
|
||||
importc: "CopyFileW", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc moveFileW*(lpExistingFileName, lpNewFileName: WideCString): WINBOOL {.
|
||||
importc: "MoveFileW", stdcall, dynlib: "kernel32".}
|
||||
importc: "MoveFileW", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
proc moveFileExW*(lpExistingFileName, lpNewFileName: WideCString,
|
||||
flags: DWORD): WINBOOL {.
|
||||
importc: "MoveFileExW", stdcall, dynlib: "kernel32".}
|
||||
importc: "MoveFileExW", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc getEnvironmentStringsW*(): WideCString {.
|
||||
stdcall, dynlib: "kernel32", importc: "GetEnvironmentStringsW".}
|
||||
stdcall, dynlib: "kernel32", importc: "GetEnvironmentStringsW", sideEffect.}
|
||||
proc freeEnvironmentStringsW*(para1: WideCString): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "FreeEnvironmentStringsW".}
|
||||
stdcall, dynlib: "kernel32", importc: "FreeEnvironmentStringsW", sideEffect.}
|
||||
|
||||
proc getCommandLineW*(): WideCString {.importc: "GetCommandLineW",
|
||||
stdcall, dynlib: "kernel32".}
|
||||
stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
else:
|
||||
proc getFullPathNameA*(lpFileName: cstring, nBufferLength: int32,
|
||||
lpBuffer: cstring, lpFilePart: var cstring): int32 {.
|
||||
stdcall, dynlib: "kernel32",
|
||||
importc: "GetFullPathNameA".}
|
||||
importc: "GetFullPathNameA", sideEffect.}
|
||||
proc getFileAttributesA*(lpFileName: cstring): int32 {.
|
||||
stdcall, dynlib: "kernel32",
|
||||
importc: "GetFileAttributesA".}
|
||||
importc: "GetFileAttributesA", sideEffect.}
|
||||
proc setFileAttributesA*(lpFileName: cstring,
|
||||
dwFileAttributes: int32): WINBOOL {.
|
||||
stdcall, dynlib: "kernel32", importc: "SetFileAttributesA".}
|
||||
stdcall, dynlib: "kernel32", importc: "SetFileAttributesA", sideEffect.}
|
||||
|
||||
proc copyFileA*(lpExistingFileName, lpNewFileName: cstring,
|
||||
bFailIfExists: cint): cint {.
|
||||
importc: "CopyFileA", stdcall, dynlib: "kernel32".}
|
||||
importc: "CopyFileA", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc moveFileA*(lpExistingFileName, lpNewFileName: cstring): WINBOOL {.
|
||||
importc: "MoveFileA", stdcall, dynlib: "kernel32".}
|
||||
importc: "MoveFileA", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
proc moveFileExA*(lpExistingFileName, lpNewFileName: cstring,
|
||||
flags: DWORD): WINBOOL {.
|
||||
importc: "MoveFileExA", stdcall, dynlib: "kernel32".}
|
||||
importc: "MoveFileExA", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc getEnvironmentStringsA*(): cstring {.
|
||||
stdcall, dynlib: "kernel32", importc: "GetEnvironmentStringsA".}
|
||||
stdcall, dynlib: "kernel32", importc: "GetEnvironmentStringsA", sideEffect.}
|
||||
proc freeEnvironmentStringsA*(para1: cstring): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "FreeEnvironmentStringsA".}
|
||||
stdcall, dynlib: "kernel32", importc: "FreeEnvironmentStringsA", sideEffect.}
|
||||
|
||||
proc getCommandLineA*(): cstring {.
|
||||
importc: "GetCommandLineA", stdcall, dynlib: "kernel32".}
|
||||
importc: "GetCommandLineA", stdcall, dynlib: "kernel32", sideEffect.}
|
||||
|
||||
proc rdFileTime*(f: FILETIME): int64 =
|
||||
result = ze64(f.dwLowDateTime) or (ze64(f.dwHighDateTime) shl 32)
|
||||
@@ -410,26 +412,26 @@ proc rdFileSize*(f: WIN32_FIND_DATA): int64 =
|
||||
result = ze64(f.nFileSizeLow) or (ze64(f.nFileSizeHigh) shl 32)
|
||||
|
||||
proc getSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var FILETIME) {.
|
||||
importc: "GetSystemTimeAsFileTime", dynlib: "kernel32", stdcall.}
|
||||
importc: "GetSystemTimeAsFileTime", dynlib: "kernel32", stdcall, sideEffect.}
|
||||
|
||||
proc sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32",
|
||||
importc: "Sleep".}
|
||||
importc: "Sleep", sideEffect.}
|
||||
|
||||
when useWinUnicode:
|
||||
proc shellExecuteW*(hwnd: Handle, lpOperation, lpFile,
|
||||
lpParameters, lpDirectory: WideCString,
|
||||
nShowCmd: int32): Handle{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW", sideEffect.}
|
||||
|
||||
else:
|
||||
proc shellExecuteA*(hwnd: Handle, lpOperation, lpFile,
|
||||
lpParameters, lpDirectory: cstring,
|
||||
nShowCmd: int32): Handle{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA", sideEffect.}
|
||||
|
||||
proc getFileInformationByHandle*(hFile: Handle,
|
||||
lpFileInformation: ptr BY_HANDLE_FILE_INFORMATION): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle".}
|
||||
stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle", sideEffect.}
|
||||
|
||||
const
|
||||
WSADESCRIPTION_LEN* = 256
|
||||
@@ -444,7 +446,7 @@ const
|
||||
|
||||
ws2dll = "Ws2_32.dll"
|
||||
|
||||
proc wsaGetLastError*(): cint {.importc: "WSAGetLastError", dynlib: ws2dll.}
|
||||
proc wsaGetLastError*(): cint {.importc: "WSAGetLastError", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
type
|
||||
SocketHandle* = distinct int
|
||||
@@ -557,19 +559,19 @@ var
|
||||
proc `==`*(x, y: SocketHandle): bool {.borrow.}
|
||||
|
||||
proc getservbyname*(name, proto: cstring): ptr Servent {.
|
||||
stdcall, importc: "getservbyname", dynlib: ws2dll.}
|
||||
stdcall, importc: "getservbyname", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
proc getservbyport*(port: cint, proto: cstring): ptr Servent {.
|
||||
stdcall, importc: "getservbyport", dynlib: ws2dll.}
|
||||
stdcall, importc: "getservbyport", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
proc gethostbyaddr*(ip: ptr InAddr, len: cuint, theType: cint): ptr Hostent {.
|
||||
stdcall, importc: "gethostbyaddr", dynlib: ws2dll.}
|
||||
stdcall, importc: "gethostbyaddr", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
proc gethostbyname*(name: cstring): ptr Hostent {.
|
||||
stdcall, importc: "gethostbyname", dynlib: ws2dll.}
|
||||
stdcall, importc: "gethostbyname", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
proc gethostname*(hostname: cstring, len: cint): cint {.
|
||||
stdcall, importc: "gethostname", dynlib: ws2dll.}
|
||||
stdcall, importc: "gethostname", dynlib: ws2dll, sideEffect.}
|
||||
|
||||
proc socket*(af, typ, protocol: cint): SocketHandle {.
|
||||
stdcall, importc: "socket", dynlib: ws2dll.}
|
||||
|
||||
10
tests/pragmas/t13306.nim
Normal file
10
tests/pragmas/t13306.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
discard """
|
||||
errormsg: "'testEpo' can have side effects"
|
||||
line: 8
|
||||
"""
|
||||
|
||||
import times
|
||||
|
||||
func testEpo(x: float): float = epochTime() + x
|
||||
|
||||
echo testEpo(1.0)
|
||||
Reference in New Issue
Block a user