Skip to content

Commit 26c0d9f

Browse files
Merge pull request #69 from Thomas008/main
adaptions to Windows: readline(), added sleep_win()
2 parents 918a4be + 2086cbf commit 26c0d9f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/llvmio.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,12 @@ end
741741
linelen += 1
742742
c = getc(fp)
743743
end
744-
fseek(fp, (c < 0) - linelen - 1)
744+
offset_fseek = Sys.iswindows() ? 2 : 1
745+
fseek(fp, (c < 0) - linelen - offset_fseek)
745746
str = MallocString(undef, linelen + 1) # str[end] == 0x00
746747
if linelen > 0
747748
gets!(str, fp, linelen)
748-
fseek(fp, 1) # Advance by 1
749+
fseek(fp, offset_fseek) # Advance by the offset
749750
end
750751
return str
751752
end

src/llvmlibc.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,24 @@ julia> usleep(1000000)
321321
end
322322

323323

324+
"""
325+
```julia
326+
sleep_win(sec::Real)
327+
```
328+
sleep function for Windows using Sleep()
329+
330+
## Examples
331+
```julia
332+
julia> sleep_win(2.5)
333+
0
334+
```
335+
"""
336+
function sleep_win(secs::Real)
337+
millisecs = round(Int, secs * 1000)
338+
@symbolcall Sleep(millisecs :: Int) :: Int
339+
end
340+
341+
324342
"""
325343
```julia
326344
system(s)

0 commit comments

Comments
 (0)