summary refs log tree commit diff stats
path: root/lib/system/sysio.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-12-23 20:12:13 +0100
committerAraq <rumpf_a@web.de>2013-12-23 20:12:13 +0100
commit32ef1f8f323044c0d92f1beef396ce3223a96231 (patch)
tree3cc51a89964ec655b6edecad581881bb47a3954b /lib/system/sysio.nim
parent4447c1b7e323443a26189140410814195eee18a9 (diff)
downloadNim-32ef1f8f323044c0d92f1beef396ce3223a96231.tar.gz
vm: FFI improvements
Diffstat (limited to 'lib/system/sysio.nim')
-rw-r--r--lib/system/sysio.nim20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 5af1c96d4..23f4e874c 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -45,9 +45,17 @@ proc setvbuf(stream: TFile, buf: pointer, typ, size: cint): cint {.
 proc write(f: TFile, c: cstring) = fputs(c, f)
 {.pop.}
 
-var
-  IOFBF {.importc: "_IOFBF", nodecl.}: cint
-  IONBF {.importc: "_IONBF", nodecl.}: cint
+when NoFakeVars:
+  when defined(windows):
+    const
+      IOFBF = cint(0)

+      IONBF = cint(4)
+  else:
+    {.error: "IOFBF not ported to your platform".}
+else:
+  var
+    IOFBF {.importc: "_IOFBF", nodecl.}: cint
+    IONBF {.importc: "_IONBF", nodecl.}: cint
 
 const
   buf_size = 4000
@@ -149,7 +157,7 @@ proc writeFile(filename, content: string) =
   finally:
     close(f)
 
-proc EndOfFile(f: TFile): bool =
+proc endOfFile(f: TFile): bool =
   # do not blame me; blame the ANSI C standard this is so brain-damaged
   var c = fgetc(f)
   ungetc(c, f)
@@ -223,10 +231,10 @@ proc fwrite(buf: Pointer, size, n: int, f: TFile): int {.
 proc readBuffer(f: TFile, buffer: pointer, len: int): int =
   result = fread(buffer, 1, len, f)
 
-proc ReadBytes(f: TFile, a: var openarray[int8], start, len: int): int =
+proc readBytes(f: TFile, a: var openarray[int8], start, len: int): int =
   result = readBuffer(f, addr(a[start]), len)
 
-proc ReadChars(f: TFile, a: var openarray[char], start, len: int): int =
+proc readChars(f: TFile, a: var openarray[char], start, len: int): int =
   result = readBuffer(f, addr(a[start]), len)
 
 {.push stackTrace:off, profiler:off.}