@@ -109,8 +109,22 @@ when defined(windows):
109
109
else :
110
110
proc c_fseek (f: File , offset: int64 , whence: cint ): cint {.
111
111
importc : " _fseeki64" , header : " <stdio.h>" , tags : [].}
112
- proc c_ftell (f: File ): int64 {.
113
- importc : " _ftelli64" , header : " <stdio.h>" , tags : [].}
112
+ when defined (tcc):
113
+ proc c_fsetpos (f: File , pos: var int64 ): int32 {.
114
+ importc : " fsetpos" , header : " <stdio.h>" , tags : [].}
115
+ proc c_fgetpos (f: File , pos: var int64 ): int32 {.
116
+ importc : " fgetpos" , header : " <stdio.h>" , tags : [].}
117
+ proc c_telli64 (f: cint ): int64 {.
118
+ importc : " _telli64" , header : " <io.h>" , tags : [].}
119
+ proc c_ftell (f: File ): int64 =
120
+ # Taken from https://pt.osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.4-trunk/mingwrt/mingwex/stdio/ftelli64.c
121
+ result = - 1 'i64
122
+ var pos: int64
123
+ if c_fgetpos (f, pos) == 0 and c_fsetpos (f, pos) == 0 :
124
+ result = c_telli64 (c_fileno (f))
125
+ else :
126
+ proc c_ftell (f: File ): int64 {.
127
+ importc : " _ftelli64" , header : " <stdio.h>" , tags : [].}
114
128
else :
115
129
proc c_fseek (f: File , offset: int64 , whence: cint ): cint {.
116
130
importc : " fseeko" , header : " <stdio.h>" , tags : [].}
0 commit comments