diff options
author | rockcavera <rockcavera@gmail.com> | 2021-12-08 02:48:34 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 06:48:34 +0100 |
commit | 7806ec525eec83d250141a32cfa197949ea1a42b (patch) | |
tree | a166290c70e3236afb3dc03a135020fce8329c93 /lib/system/io.nim | |
parent | cd592ed85ba3bf440d7b24a4bc5b117d1a5f8725 (diff) | |
download | Nim-7806ec525eec83d250141a32cfa197949ea1a42b.tar.gz |
Making TCC work again on Windows --cpu:amd64 - fix #16326 (#19221)
* fix #16326 * removing comments
Diffstat (limited to 'lib/system/io.nim')
-rw-r--r-- | lib/system/io.nim | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/system/io.nim b/lib/system/io.nim index 2ad43acdb..661d1a9ba 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -109,8 +109,22 @@ when defined(windows): else: proc c_fseek(f: File, offset: int64, whence: cint): cint {. importc: "_fseeki64", header: "<stdio.h>", tags: [].} - proc c_ftell(f: File): int64 {. - importc: "_ftelli64", header: "<stdio.h>", tags: [].} + when defined(tcc): + proc c_fsetpos(f: File, pos: var int64): int32 {. + importc: "fsetpos", header: "<stdio.h>", tags: [].} + proc c_fgetpos(f: File, pos: var int64): int32 {. + importc: "fgetpos", header: "<stdio.h>", tags: [].} + proc c_telli64(f: cint): int64 {. + importc: "_telli64", header: "<io.h>", tags: [].} + proc c_ftell(f: File): int64 = + # Taken from https://pt.osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.4-trunk/mingwrt/mingwex/stdio/ftelli64.c + result = -1'i64 + var pos: int64 + if c_fgetpos(f, pos) == 0 and c_fsetpos(f, pos) == 0: + result = c_telli64(c_fileno(f)) + else: + proc c_ftell(f: File): int64 {. + importc: "_ftelli64", header: "<stdio.h>", tags: [].} else: proc c_fseek(f: File, offset: int64, whence: cint): cint {. importc: "fseeko", header: "<stdio.h>", tags: [].} |