summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2017-04-13 05:10:54 +0800
committerAndreas Rumpf <rumpf_a@web.de>2017-04-12 23:10:54 +0200
commitce86b4ad78aae11f62c50e4f46e8ab2a124356b4 (patch)
tree2b3dfa6ef21907689d60dbf6f74041e1ce389546 /lib/pure
parente512358bc96b7be58bf4f2d5a2c5de75f119138a (diff)
downloadNim-ce86b4ad78aae11f62c50e4f46e8ab2a124356b4.tar.gz
Posix from detect (#5697)
* refactor posix.nim
* types move to separate files for platform-specifc and generic
("other')
* consts move to separate files that get autogenerated by detect.nim
* proc's stay where they are for now, though in a second stage might
move as well
* fix missing when
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/asyncfile.nim5
-rw-r--r--lib/pure/nativesockets.nim12
-rw-r--r--lib/pure/os.nim2
3 files changed, 10 insertions, 9 deletions
diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim
index 86cd8d1be..9bd060e30 100644
--- a/lib/pure/asyncfile.nim
+++ b/lib/pure/asyncfile.nim
@@ -312,7 +312,7 @@ proc setFilePos*(f: AsyncFile, pos: int64) =
   ## operations. The file's first byte has the index zero.
   f.offset = pos
   when not defined(windows) and not defined(nimdoc):
-    let ret = lseek(f.fd.cint, pos, SEEK_SET)
+    let ret = lseek(f.fd.cint, pos.Off, SEEK_SET)
     if ret == -1:
       raiseOSError(osLastError())
 
@@ -481,7 +481,8 @@ proc setFileSize*(f: AsyncFile, length: int64) =
        (setEndOfFile(f.fd.Handle) == 0):
       raiseOSError(osLastError())
   else:
-    if ftruncate(f.fd.cint, length) == -1:
+    # will truncate if Off is a 32-bit type!
+    if ftruncate(f.fd.cint, length.Off) == -1:
       raiseOSError(osLastError())
 
 proc close*(f: AsyncFile) =
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim
index a9c72286d..fa3fa4aea 100644
--- a/lib/pure/nativesockets.nim
+++ b/lib/pure/nativesockets.nim
@@ -113,7 +113,7 @@ proc `==`*(a, b: Port): bool {.borrow.}
 proc `$`*(p: Port): string {.borrow.}
   ## returns the port number as a string
 
-proc toInt*(domain: Domain): cint
+proc toInt*(domain: Domain): cshort
   ## Converts the Domain enum to a platform-dependent ``cint``.
 
 proc toInt*(typ: SockType): cint
@@ -123,11 +123,11 @@ proc toInt*(p: Protocol): cint
   ## Converts the Protocol enum to a platform-dependent ``cint``.
 
 when not useWinVersion:
-  proc toInt(domain: Domain): cint =
+  proc toInt(domain: Domain): cshort =
     case domain
-    of AF_UNIX:        result = posix.AF_UNIX
-    of AF_INET:        result = posix.AF_INET
-    of AF_INET6:       result = posix.AF_INET6
+    of AF_UNIX:        result = posix.AF_UNIX.cshort
+    of AF_INET:        result = posix.AF_INET.cshort
+    of AF_INET6:       result = posix.AF_INET6.cshort
     else: discard
 
   proc toInt(typ: SockType): cint =
@@ -149,7 +149,7 @@ when not useWinVersion:
     else: discard
 
 else:
-  proc toInt(domain: Domain): cint =
+  proc toInt(domain: Domain): cshort =
     result = toU16(ord(domain))
 
   proc toInt(typ: SockType): cint =
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 82acb2a59..98b6aa309 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1716,7 +1716,7 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
         formalInfo.permissions.incl(formalMode)
     formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
     formalInfo.size = rawInfo.st_size
-    formalInfo.linkCount = rawInfo.st_Nlink
+    formalInfo.linkCount = rawInfo.st_Nlink.BiggestInt
     formalInfo.lastAccessTime = rawInfo.st_atime
     formalInfo.lastWriteTime = rawInfo.st_mtime
     formalInfo.creationTime = rawInfo.st_ctime