Skip to content

Commit adfaa4c

Browse files
authored
Improve Julia 1.0 compat, use GC.safepoint if >= Julia 1.4 (#124)
* Improve Julia 1.0 compat, use GC.safepoint if >= Julia 1.4 * Run CI on master branch pushes
1 parent b1e9c80 commit adfaa4c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22
on:
33
push:
44
branches:
5-
- main
5+
- master
66
tags: '*'
77
pull_request:
88
concurrency:
@@ -18,6 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
version:
21+
- '1.0'
2122
- '1.6'
2223
- '1.7'
2324
- 'nightly'

src/stream.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ function Base.unsafe_read(stream::TranscodingStream, output::Ptr{UInt8}, nbytes:
360360
m = min(buffersize(buffer), p_end - p)
361361
copydata!(p, buffer, m)
362362
p += m
363-
GC.safepoint()
363+
@static if VERSION >= v"1.4"
364+
GC.safepoint()
365+
end
364366
end
365367
if p < p_end && eof(stream)
366368
throw(EOFError())
@@ -463,7 +465,9 @@ function Base.unsafe_write(stream::TranscodingStream, input::Ptr{UInt8}, nbytes:
463465
m = min(marginsize(buffer1), p_end - p)
464466
copydata!(buffer1, p, m)
465467
p += m
466-
GC.safepoint()
468+
@static if VERSION >= v"1.4"
469+
GC.safepoint()
470+
end
467471
end
468472
return Int(p - input)
469473
end
@@ -696,9 +700,13 @@ function writedata!(output::IO, input::Buffer)
696700
n = GC.@preserve input Base.unsafe_write(output, bufferptr(input), buffersize(input))
697701
consumed!(input, n)
698702
nwritten += n
703+
@static if VERSION >= v"1.4"
704+
GC.safepoint()
705+
end
706+
end
707+
@static if VERSION >= v"1.4"
699708
GC.safepoint()
700709
end
701-
GC.safepoint()
702710
return nwritten
703711
end
704712

0 commit comments

Comments
 (0)