Skip to content

Commit ffbfa04

Browse files
committed
Deprecate is_<os> functions in favor of Sys.is<os>
This makes them consistent with the vast majority of Base predicates, which simply prefix with `is` rather than `is_`. It also moves to requiring the `Sys.` prefix, which helps explain the intent behind the function names.
1 parent 2c85595 commit ffbfa04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+341
-329
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ Deprecated or removed
120120
* The `corrected` positional argument to `cov` has been deprecated in favor of
121121
a keyword argument with the same name (#21709).
122122

123+
* The operation identification functions: `is_linux`, `is_bsd`, `is_apple`, `is_unix`, and
124+
`is_windows`, have been deprecated in favor of `Sys.islinux`, `Sys.isbsd`, `Sys.isapple`,
125+
`Sys.isunix`, and `Sys.iswindows`, respectively ([#22182]).
126+
123127

124128
Julia v0.6.0 Release Notes
125129
==========================
@@ -913,6 +917,7 @@ Command-line option changes
913917
[#22038]: https://github.com/JuliaLang/julia/issues/22038
914918
[#22062]: https://github.com/JuliaLang/julia/issues/22062
915919
[#22064]: https://github.com/JuliaLang/julia/issues/22064
920+
[#22182]: https://github.com/JuliaLang/julia/issues/22182
916921
[#22187]: https://github.com/JuliaLang/julia/issues/22187
917922
[#22188]: https://github.com/JuliaLang/julia/issues/22188
918923
[#22224]: https://github.com/JuliaLang/julia/issues/22224

base/c.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Equivalent to the native `char` c-type.
1818
"""
1919
Cchar
2020

21-
if is_windows()
21+
if Sys.iswindows()
2222
const Clong = Int32
2323
const Culong = UInt32
2424
const Cwchar_t = UInt16
@@ -49,7 +49,7 @@ Equivalent to the native `wchar_t` c-type ([`Int32`](@ref)).
4949
"""
5050
Cwchar_t
5151

52-
if !is_windows()
52+
if !Sys.iswindows()
5353
const sizeof_mode_t = ccall(:jl_sizeof_mode_t, Cint, ())
5454
if sizeof_mode_t == 2
5555
const Cmode_t = Int16
@@ -118,7 +118,7 @@ end
118118
# symbols are guaranteed not to contain embedded NUL
119119
convert(::Type{Cstring}, s::Symbol) = Cstring(unsafe_convert(Ptr{Cchar}, s))
120120

121-
if is_windows()
121+
if Sys.iswindows()
122122
"""
123123
Base.cwstring(s)
124124

base/client.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ function repl_cmd(cmd, out)
102102
end
103103
cd(ENV["OLDPWD"])
104104
else
105-
cd(@static is_windows() ? dir : readchomp(`$shell -c "echo $(shell_escape(dir))"`))
105+
cd(@static Sys.iswindows() ? dir : readchomp(`$shell -c "echo $(shell_escape(dir))"`))
106106
end
107107
else
108108
cd()
109109
end
110110
ENV["OLDPWD"] = new_oldpwd
111111
println(out, pwd())
112112
else
113-
run(ignorestatus(@static is_windows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)))
113+
run(ignorestatus(@static Sys.iswindows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)))
114114
end
115115
nothing
116116
end
@@ -385,7 +385,7 @@ function _start()
385385
global is_interactive |= !isa(STDIN, Union{File, IOStream})
386386
color_set || (global have_color = false)
387387
else
388-
term = Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
388+
term = Terminals.TTYTerminal(get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
389389
global is_interactive = true
390390
color_set || (global have_color = Terminals.hascolor(term))
391391
quiet || REPL.banner(term,term)

base/dSFMT.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ end
163163

164164
## Windows entropy
165165

166-
if is_windows()
166+
if Sys.iswindows()
167167
function win32_SystemFunction036!(a::Array)
168168
ccall((:SystemFunction036, :Advapi32), stdcall, UInt8, (Ptr{Void}, UInt32), a, sizeof(a))
169169
end

base/datafmt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ readdlm_auto(input::IO, dlm::Char, T::Type, eol::Char, auto::Bool; opts...) =
120120
readdlm_string(readstring(input), dlm, T, eol, auto, val_opts(opts))
121121
function readdlm_auto(input::AbstractString, dlm::Char, T::Type, eol::Char, auto::Bool; opts...)
122122
optsd = val_opts(opts)
123-
use_mmap = get(optsd, :use_mmap, is_windows() ? false : true)
123+
use_mmap = get(optsd, :use_mmap, Sys.iswindows() ? false : true)
124124
fsz = filesize(input)
125125
if use_mmap && fsz > 0 && fsz < typemax(Int)
126126
a = open(input, "r") do f

base/deprecated.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,13 @@ export conv, conv2, deconv, filt, filt!, xcorr
14911491
@deprecate cov(X::AbstractVector, Y::AbstractVector, corrected::Bool) cov(X, Y, corrected=corrected)
14921492
@deprecate cov(X::AbstractVecOrMat, Y::AbstractVecOrMat, vardim::Int, corrected::Bool) cov(X, Y, vardim, corrected=corrected)
14931493

1494+
# PR #22182
1495+
@deprecate is_apple Sys.isapple
1496+
@deprecate is_bsd Sys.isbsd
1497+
@deprecate is_linux Sys.islinux
1498+
@deprecate is_unix Sys.isunix
1499+
@deprecate is_windows Sys.iswindows
1500+
14941501
# END 0.7 deprecations
14951502

14961503
# BEGIN 1.0 deprecations

base/distributed/cluster.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ end
960960
function disable_nagle(sock)
961961
# disable nagle on all OSes
962962
ccall(:uv_tcp_nodelay, Cint, (Ptr{Void}, Cint), sock.handle, 1)
963-
@static if is_linux()
963+
@static if Sys.islinux()
964964
# tcp_quickack is a linux only option
965965
if ccall(:jl_tcp_quickack, Cint, (Ptr{Void}, Cint), sock.handle, 1) < 0
966966
warn_once("Networking unoptimized ( Error enabling TCP_QUICKACK : ", Libc.strerror(Libc.errno()), " )")

base/distributed/managers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function socket_reuse_port()
459459
s = TCPSocket(delay = false)
460460

461461
# Some systems (e.g. Linux) require the port to be bound before setting REUSEPORT
462-
bind_early = is_linux()
462+
bind_early = Sys.islinux()
463463

464464
bind_early && bind_client_port(s)
465465
rc = ccall(:jl_tcp_reuseport, Int32, (Ptr{Void},), s.handle)

base/env.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
if is_windows()
3+
if Sys.iswindows()
44
const ERROR_ENVVAR_NOT_FOUND = UInt32(203)
55

66
_getenvlen(var::Vector{UInt16}) = ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32),var,C_NULL,0)
@@ -84,7 +84,7 @@ delete!(::EnvHash, k::AbstractString) = (_unsetenv(k); ENV)
8484
setindex!(::EnvHash, v, k::AbstractString) = _setenv(k,string(v))
8585
push!(::EnvHash, k::AbstractString, v) = setindex!(ENV, v, k)
8686

87-
if is_windows()
87+
if Sys.iswindows()
8888
start(hash::EnvHash) = (pos = ccall(:GetEnvironmentStringsW,stdcall,Ptr{UInt16},()); (pos,pos))
8989
function done(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
9090
if unsafe_load(block[1]) == 0

base/event.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function wait()
247247
# unreachable
248248
end
249249

250-
if is_windows()
250+
if Sys.iswindows()
251251
pause() = ccall(:Sleep, stdcall, Void, (UInt32,), 0xffffffff)
252252
else
253253
pause() = ccall(:pause, Void, ())

0 commit comments

Comments
 (0)