Skip to content

Commit c92bdcd

Browse files
committed
Merge branch 'aa/iszero' into patch-1
2 parents fb45cd7 + b3a99ad commit c92bdcd

29 files changed

+525
-196
lines changed

LICENSE.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The following components of Julia's standard library have separate licenses:
7373
- base/fftw.jl (see [FFTW](http://fftw.org/doc/License-and-Copyright.html))
7474
- base/linalg/umfpack.jl (see [SUITESPARSE](http://faculty.cse.tamu.edu/davis/suitesparse.html))
7575
- base/linalg/cholmod.jl (see [SUITESPARSE](http://faculty.cse.tamu.edu/davis/suitesparse.html))
76+
- base/special/exp.jl (see [FREEBSD MSUN](https://github.com/freebsd/freebsd) [FreeBSD/2-clause BSD/Simplified BSD License])
7677

7778

7879
Julia's build process uses the following external tools:

base/broadcast.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ Note that `dest` is only used to store the result, and does not supply
202202
arguments to `f` unless it is also listed in the `As`,
203203
as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`.
204204
"""
205-
@inline function broadcast!{N}(f, C::AbstractArray, A, Bs::Vararg{Any,N})
205+
@inline broadcast!{N}(f, C::AbstractArray, A, Bs::Vararg{Any,N}) =
206+
broadcast_c!(f, containertype(C, A, Bs...), C, A, Bs...)
207+
@inline function broadcast_c!{N}(f, ::Type, C::AbstractArray, A, Bs::Vararg{Any,N})
206208
shape = indices(C)
207209
@boundscheck check_broadcast_indices(shape, A, Bs...)
208210
keeps, Idefaults = map_newindexer(shape, A, Bs)

base/deprecated.jl

+18-3
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,9 @@ for (Bsig, A1sig, A2sig, gbb, funcname) in
12421242
end # let broadcast_cache
12431243
end
12441244
_broadcast_zpreserving!(args...) = broadcast!(args...)
1245-
_broadcast_zpreserving(f, As...) = broadcast!(f, similar(Array{promote_op(f, map(eltype, As)...)}, Base.Broadcast.broadcast_indices(As...)), As...)
1245+
# note: promote_eltype_op also deprecated, defined later in this file
1246+
_broadcast_zpreserving(f, As...) =
1247+
broadcast!(f, similar(Array{_promote_eltype_op(f, As...)}, Base.Broadcast.broadcast_indices(As...)), As...)
12461248
_broadcast_zpreserving{Tv1,Ti1,Tv2,Ti2}(f::Function, A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) =
12471249
_broadcast_zpreserving!(f, spzeros(promote_type(Tv1, Tv2), promote_type(Ti1, Ti2), Base.to_shape(Base.Broadcast.broadcast_indices(A_1, A_2))), A_1, A_2)
12481250
_broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union{Array,BitArray,Number}) =
@@ -1502,8 +1504,21 @@ function frexp{T<:AbstractFloat}(A::Array{T})
15021504
return (F, E)
15031505
end
15041506

1505-
# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op
1506-
@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...)
1507+
# Deprecate promote_eltype_op (#19814, #19937)
1508+
_promote_eltype_op(::Any) = Any
1509+
_promote_eltype_op(op, A) = (@_inline_meta; promote_op(op, eltype(A)))
1510+
_promote_eltype_op(op, A, B) = (@_inline_meta; promote_op(op, eltype(A), eltype(B)))
1511+
_promote_eltype_op(op, A, B, C, D...) = (@_inline_meta; _promote_eltype_op(op, eltype(A), _promote_eltype_op(op, B, C, D...)))
1512+
@inline function promote_eltype_op(args...)
1513+
depwarn("""
1514+
`promote_eltype_op` is deprecated and should not be used.
1515+
See https://github.com/JuliaLang/julia/issues/19669.""",
1516+
:promote_eltype_op)
1517+
_promote_eltype_op(args...)
1518+
end
1519+
1520+
# Rename LibGit2.Oid to LibGit2.GitHash (part of #19839)
1521+
eval(Base.LibGit2, :(Base.@deprecate_binding Oid GitHash))
15071522

15081523
function unsafe_wrap(::Type{String}, p::Union{Ptr{UInt8},Ptr{Int8}}, len::Integer, own::Bool=false)
15091524
Base.depwarn("unsafe_wrap(String, ...) is deprecated; use `unsafe_string` instead.", :unsafe_wrap)

base/exports.jl

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export
361361
isimag,
362362
iszero,
363363
issubnormal,
364+
iszero,
364365
lcm,
365366
ldexp,
366367
leading_ones,

base/float.jl

+9
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,18 @@ exponent_one(::Type{Float16}) = 0x3c00
738738
exponent_half(::Type{Float16}) = 0x3800
739739
significand_mask(::Type{Float16}) = 0x03ff
740740

741+
# integer size of float
742+
fpinttype(::Type{Float64}) = UInt64
743+
fpinttype(::Type{Float32}) = UInt32
744+
fpinttype(::Type{Float16}) = UInt16
745+
741746
@pure significand_bits{T<:AbstractFloat}(::Type{T}) = trailing_ones(significand_mask(T))
742747
@pure exponent_bits{T<:AbstractFloat}(::Type{T}) = sizeof(T)*8 - significand_bits(T) - 1
743748
@pure exponent_bias{T<:AbstractFloat}(::Type{T}) = Int(exponent_one(T) >> significand_bits(T))
749+
# maximum float exponent
750+
@pure exponent_max{T<:AbstractFloat}(::Type{T}) = Int(exponent_mask(T) >> significand_bits(T)) - exponent_bias(T)
751+
# maximum float exponent without bias
752+
@pure exponent_raw_max{T<:AbstractFloat}(::Type{T}) = Int(exponent_mask(T) >> significand_bits(T))
744753

745754
## Array operations on floating point numbers ##
746755

base/libgit2/blob.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ function Base.length(blob::GitBlob)
88
return ccall((:git_blob_rawsize, :libgit2), Int64, (Ptr{Void},), blob.ptr)
99
end
1010

11-
function lookup(repo::GitRepo, oid::Oid)
11+
function lookup(repo::GitRepo, oid::GitHash)
1212
blob_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
1313
@check ccall((:git_blob_lookup, :libgit2), Cint,
14-
(Ptr{Ptr{Void}}, Ptr{Void}, Ref{Oid}),
14+
(Ptr{Ptr{Void}}, Ptr{Void}, Ref{GitHash}),
1515
blob_ptr_ptr, repo.ptr, Ref(oid))
1616
return GitBlob(blob_ptr_ptr[])
1717
end

base/libgit2/callbacks.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ function credentials_callback(libgit2credptr::Ptr{Ptr{Void}}, url_ptr::Cstring,
255255
end
256256

257257
function fetchhead_foreach_callback(ref_name::Cstring, remote_url::Cstring,
258-
oid::Ptr{Oid}, is_merge::Cuint, payload::Ptr{Void})
258+
oid::Ptr{GitHash}, is_merge::Cuint, payload::Ptr{Void})
259259
fhead_vec = unsafe_pointer_to_objref(payload)::Vector{FetchHead}
260-
push!(fhead_vec, FetchHead(unsafe_string(ref_name), unsafe_string(remote_url), Oid(oid), is_merge == 1))
260+
push!(fhead_vec, FetchHead(unsafe_string(ref_name), unsafe_string(remote_url), GitHash(oid), is_merge == 1))
261261
return Cint(0)
262262
end
263263

@@ -266,4 +266,4 @@ mirror_cb() = cfunction(mirror_callback, Cint, (Ptr{Ptr{Void}}, Ptr{Void}, Cstri
266266
"C function pointer for `credentials_callback`"
267267
credentials_cb() = cfunction(credentials_callback, Cint, (Ptr{Ptr{Void}}, Cstring, Cstring, Cuint, Ptr{Void}))
268268
"C function pointer for `fetchhead_foreach_callback`"
269-
fetchhead_foreach_cb() = cfunction(fetchhead_foreach_callback, Cint, (Cstring, Cstring, Ptr{Oid}, Cuint, Ptr{Void}))
269+
fetchhead_foreach_cb() = cfunction(fetchhead_foreach_callback, Cint, (Cstring, Cstring, Ptr{GitHash}, Cuint, Ptr{Void}))

base/libgit2/commit.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ function commit(repo::GitRepo,
3030
committer::GitSignature,
3131
tree::GitTree,
3232
parents::GitCommit...)
33-
commit_id_ptr = Ref(Oid())
33+
commit_id_ptr = Ref(GitHash())
3434
nparents = length(parents)
3535
parentptrs = Ptr{Void}[c.ptr for c in parents]
3636
@check ccall((:git_commit_create, :libgit2), Cint,
37-
(Ptr{Oid}, Ptr{Void}, Ptr{UInt8},
37+
(Ptr{GitHash}, Ptr{Void}, Ptr{UInt8},
3838
Ptr{SignatureStruct}, Ptr{SignatureStruct},
3939
Ptr{UInt8}, Ptr{UInt8}, Ptr{Void},
4040
Csize_t, Ptr{Ptr{Void}}),
@@ -50,8 +50,8 @@ function commit(repo::GitRepo, msg::AbstractString;
5050
refname::AbstractString=Consts.HEAD_FILE,
5151
author::Signature = Signature(repo),
5252
committer::Signature = Signature(repo),
53-
tree_id::Oid = Oid(),
54-
parent_ids::Vector{Oid}=Oid[])
53+
tree_id::GitHash = GitHash(),
54+
parent_ids::Vector{GitHash}=GitHash[])
5555
# Retrieve tree identifier
5656
if iszero(tree_id)
5757
tree_id = with(GitIndex, repo) do idx; write_tree!(idx) end
@@ -60,12 +60,12 @@ function commit(repo::GitRepo, msg::AbstractString;
6060
# Retrieve parents from HEAD
6161
if isempty(parent_ids)
6262
try # if throws then HEAD not found -> empty repo
63-
push!(parent_ids, Oid(repo, refname))
63+
push!(parent_ids, GitHash(repo, refname))
6464
end
6565
end
6666

6767
# return commit id
68-
commit_id = Oid()
68+
commit_id = GitHash()
6969

7070
# get necessary objects
7171
tree = get(GitTree, repo, tree_id)

base/libgit2/index.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function write!(idx::GitIndex)
1818
end
1919

2020
function write_tree!(idx::GitIndex)
21-
oid_ptr = Ref(Oid())
21+
oid_ptr = Ref(GitHash())
2222
@check ccall((:git_index_write_tree, :libgit2), Cint,
23-
(Ptr{Oid}, Ptr{Void}), oid_ptr, idx.ptr)
23+
(Ptr{GitHash}, Ptr{Void}), oid_ptr, idx.ptr)
2424
return oid_ptr[]
2525
end
2626

@@ -29,7 +29,7 @@ function owner(idx::GitIndex)
2929
return Base.get(idx.nrepo)
3030
end
3131

32-
function read_tree!(idx::GitIndex, tree_id::Oid)
32+
function read_tree!(idx::GitIndex, tree_id::GitHash)
3333
repo = owner(idx)
3434
tree = get(GitTree, repo, tree_id)
3535
try

base/libgit2/libgit2.jl

+13-13
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ include("callbacks.jl")
3535
using .Error
3636

3737
immutable State
38-
head::Oid
39-
index::Oid
40-
work::Oid
38+
head::GitHash
39+
index::GitHash
40+
work::GitHash
4141
end
4242

43-
"""Return HEAD Oid as string"""
43+
"""Return HEAD GitHash as string"""
4444
function head(pkg::AbstractString)
4545
with(GitRepo, pkg) do repo
4646
string(head_oid(repo))
@@ -213,18 +213,18 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
213213
if branch_rmt_ref === nothing
214214
with(head(repo)) do head_ref
215215
with(peel(GitCommit, head_ref)) do hrc
216-
Oid(hrc)
216+
GitHash(hrc)
217217
end
218218
end
219219
else
220220
tmpcmt = with(peel(GitCommit, branch_rmt_ref)) do hrc
221-
Oid(hrc)
221+
GitHash(hrc)
222222
end
223223
close(branch_rmt_ref)
224224
tmpcmt
225225
end
226226
else
227-
Oid(commit)
227+
GitHash(commit)
228228
end
229229
iszero(commit_id) && return
230230
cmt = get(GitCommit, repo, commit_id)
@@ -278,13 +278,13 @@ function checkout!(repo::GitRepo, commit::AbstractString = "";
278278
head_name = shortname(head_ref)
279279
# if it is HEAD use short OID instead
280280
if head_name == Consts.HEAD_FILE
281-
head_name = string(Oid(head_ref))
281+
head_name = string(GitHash(head_ref))
282282
end
283283
end
284284
end
285285

286286
# search for commit to get a commit object
287-
obj = get(GitUnknownObject, repo, Oid(commit))
287+
obj = get(GitUnknownObject, repo, GitHash(commit))
288288
obj === nothing && return
289289
try
290290
peeled = peel(obj, Consts.OBJ_COMMIT)
@@ -293,7 +293,7 @@ function checkout!(repo::GitRepo, commit::AbstractString = "";
293293
CheckoutOptions()
294294
try
295295
# detach commit
296-
obj_oid = Oid(peeled)
296+
obj_oid = GitHash(peeled)
297297
ref = GitReference(repo, obj_oid, force=force,
298298
msg="libgit2.checkout: moving from $head_name to $(string(obj_oid))")
299299
close(ref)
@@ -340,7 +340,7 @@ function reset!(repo::GitRepo, committish::AbstractString, pathspecs::AbstractSt
340340
end
341341

342342
""" git reset [--soft | --mixed | --hard] <commit> """
343-
function reset!(repo::GitRepo, commit::Oid, mode::Cint = Consts.RESET_MIXED)
343+
function reset!(repo::GitRepo, commit::GitHash, mode::Cint = Consts.RESET_MIXED)
344344
obj = get(GitUnknownObject, repo, commit)
345345
# object must exist for reset
346346
obj === nothing && throw(GitError(Error.Object, Error.ERROR, "Commit `$(string(commit))` object not found"))
@@ -425,7 +425,7 @@ function merge!(repo::GitRepo;
425425
LibGit2.get(String, cfg, "branch.$branchname.remote")
426426
end
427427
obj = with(GitReference(repo, "refs/remotes/$remotename/$branchname")) do ref
428-
LibGit2.Oid(ref)
428+
LibGit2.GitHash(ref)
429429
end
430430
with(get(GitCommit, repo, obj)) do cmt
431431
LibGit2.create_branch(repo, branchname, cmt)
@@ -528,7 +528,7 @@ function authors(repo::GitRepo)
528528
end
529529

530530
function snapshot(repo::GitRepo)
531-
head = Oid(repo, Consts.HEAD_FILE)
531+
head = GitHash(repo, Consts.HEAD_FILE)
532532
index = with(GitIndex, repo) do idx; write_tree!(idx) end
533533
work = try
534534
with(GitIndex, repo) do idx

base/libgit2/merge.jl

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3-
function GitAnnotated(repo::GitRepo, commit_id::Oid)
3+
function GitAnnotated(repo::GitRepo, commit_id::GitHash)
44
ann_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
55
@check ccall((:git_annotated_commit_lookup, :libgit2), Cint,
6-
(Ptr{Ptr{Void}}, Ptr{Void}, Ptr{Oid}),
6+
(Ptr{Ptr{Void}}, Ptr{Void}, Ptr{GitHash}),
77
ann_ptr_ptr, repo.ptr, Ref(commit_id))
88
return GitAnnotated(repo, ann_ptr_ptr[])
99
end
@@ -19,7 +19,7 @@ end
1919
function GitAnnotated(repo::GitRepo, fh::FetchHead)
2020
ann_ref_ref = Ref{Ptr{Void}}(C_NULL)
2121
@check ccall((:git_annotated_commit_from_fetchhead, :libgit2), Cint,
22-
(Ptr{Ptr{Void}}, Ptr{Void}, Cstring, Cstring, Ptr{Oid}),
22+
(Ptr{Ptr{Void}}, Ptr{Void}, Cstring, Cstring, Ptr{GitHash}),
2323
ann_ref_ref, repo.ptr, fh.name, fh.url, Ref(fh.oid))
2424
return GitAnnotated(repo, ann_ref_ref[])
2525
end
@@ -29,14 +29,14 @@ function GitAnnotated(repo::GitRepo, comittish::AbstractString)
2929
try
3030
cmt = peel(obj, Consts.OBJ_COMMIT)
3131
cmt === nothing && return nothing
32-
return GitAnnotated(repo, Oid(cmt))
32+
return GitAnnotated(repo, GitHash(cmt))
3333
finally
3434
close(obj)
3535
end
3636
end
3737

3838
function commit(ann::GitAnnotated)
39-
return Oid(ccall((:git_annotated_commit_id, :libgit2), Ptr{Oid}, (Ptr{Void},), ann.ptr))
39+
return GitHash(ccall((:git_annotated_commit_id, :libgit2), Ptr{GitHash}, (Ptr{Void},), ann.ptr))
4040
end
4141

4242
function merge_analysis(repo::GitRepo, anns::Vector{GitAnnotated})
@@ -58,7 +58,7 @@ function ffmerge!(repo::GitRepo, ann::GitAnnotated)
5858
try
5959
checkout_tree(repo, cmt)
6060
with(head(repo)) do head_ref
61-
cmt_oid = Oid(cmt)
61+
cmt_oid = GitHash(cmt)
6262
msg = "libgit2.merge: fastforward $(string(cmt_oid)) into $(name(head_ref))"
6363
new_head_ref = if reftype(head_ref) == Consts.REF_OID
6464
target!(head_ref, cmt_oid, msg=msg)
@@ -148,17 +148,17 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated}, fastforward::Bool;
148148
end
149149

150150
function merge_base(repo::GitRepo, one::AbstractString, two::AbstractString)
151-
oid1_ptr = Ref(Oid(one))
152-
oid2_ptr = Ref(Oid(two))
153-
moid_ptr = Ref(Oid())
151+
oid1_ptr = Ref(GitHash(one))
152+
oid2_ptr = Ref(GitHash(two))
153+
moid_ptr = Ref(GitHash())
154154
moid = try
155155
@check ccall((:git_merge_base, :libgit2), Cint,
156-
(Ptr{Oid}, Ptr{Void}, Ptr{Oid}, Ptr{Oid}),
156+
(Ptr{GitHash}, Ptr{Void}, Ptr{GitHash}, Ptr{GitHash}),
157157
moid_ptr, repo.ptr, oid1_ptr, oid2_ptr)
158158
moid_ptr[]
159159
catch e
160160
#warn("Pkg:",path(repo),"=>",e.msg)
161-
Oid()
161+
GitHash()
162162
end
163163
return moid
164164
end

0 commit comments

Comments
 (0)