Skip to content

Commit

Permalink
Merge pull request #201 from JuliaLang/yyc/unsafe_write
Browse files Browse the repository at this point in the history
Compat for unsafe_write
  • Loading branch information
yuyichao committed May 14, 2016
2 parents 8788cef + 3c52b41 commit b21ef68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `symbol` is now `Symbol` [#16154](https://github.com/JuliaLang/julia/pull/16154); use `@compat Symbol(...)` if you need Julia 0.3 compatibility.

* `write(::IO, ::Ptr, len)` is now `unsafe_write` [#14766](https://github.com/JuliaLang/julia/pull/14766).

## New macros

* `@inline` and `@noinline` have been added. On 0.3, these are "no-ops," meaning they don't actually do anything.
Expand Down
6 changes: 6 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,10 @@ else
import Base.AsyncCondition
end

# 0.5.0-dev+2301, JuliaLang/julia#14766
if !isdefined(Base, :unsafe_write)
const unsafe_write = write
export unsafe_write
end

end # module
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1136,3 +1136,8 @@ let async, c = false
sleep(0.1)
@test c
end

let io = IOBuffer(), s = "hello"
unsafe_write(io, pointer(s), length(s))
@test takebuf_string(io) == s
end

0 comments on commit b21ef68

Please sign in to comment.