summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authoralaviss <leorize+oss@disroot.org>2020-07-20 04:17:33 +0000
committerGitHub <noreply@github.com>2020-07-20 00:17:33 -0400
commitbb1adf6a706190883fa57a0208ba8e3118235256 (patch)
tree8222f6dcf8444ef53397fdd19bdcb14a9f21cf98 /lib/system
parentb16284633e449a92db58f8431491e25e732875bf (diff)
downloadNim-bb1adf6a706190883fa57a0208ba8e3118235256.tar.gz
io: fix SetHandleInformation signature to match Windows' (#15017)
* io: fix SetHandleInformation signature to match Windows'

Fixes #14980

* rename Handle -> IoHandle because system.nim is a mess
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/io.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/system/io.nim b/lib/system/io.nim
index 482057214..0b624de8f 100644
--- a/lib/system/io.nim
+++ b/lib/system/io.nim
@@ -282,7 +282,11 @@ elif defined(windows):
   proc getOsfhandle(fd: cint): int {.
     importc: "_get_osfhandle", header: "<io.h>".}
 
-  proc setHandleInformation(handle: int, mask, flags: culong): cint {.
+  type
+    IoHandle = distinct pointer
+      ## Windows' HANDLE type. Defined as an untyped pointer but is **not**
+      ## one. Named like this to avoid collision with other `system` modules.
+  proc setHandleInformation(handle: IoHandle, mask, flags: culong): cint {.
     importc: "SetHandleInformation", header: "<handleapi.h>".}
 
 const
@@ -339,7 +343,8 @@ when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(w
       flags = if inheritable: flags and not FD_CLOEXEC else: flags or FD_CLOEXEC
       result = c_fcntl(f, F_SETFD, flags) != -1
     else:
-      result = setHandleInformation(f.int, HANDLE_FLAG_INHERIT, culong inheritable) != 0
+      result = setHandleInformation(cast[IoHandle](f), HANDLE_FLAG_INHERIT,
+                                    culong inheritable) != 0
 
 proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
               benign.} =