Skip to content

Commit 81f7b32

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 bbc516c commit 81f7b32

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

+339
-333
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ Deprecated or removed
127127
Ternaries must now include some amount of whitespace, e.g. `x ? a : b` rather than
128128
`x? a : b` ([#22523]).
129129

130+
* The operating system identification functions: `is_linux`, `is_bsd`, `is_apple`, `is_unix`,
131+
and `is_windows`, have been deprecated in favor of `Sys.islinux`, `Sys.isbsd`, `Sys.isapple`,
132+
`Sys.isunix`, and `Sys.iswindows`, respectively ([#22182]).
133+
130134

131135
Julia v0.6.0 Release Notes
132136
==========================
@@ -920,6 +924,7 @@ Command-line option changes
920924
[#22038]: https://github.com/JuliaLang/julia/issues/22038
921925
[#22062]: https://github.com/JuliaLang/julia/issues/22062
922926
[#22064]: https://github.com/JuliaLang/julia/issues/22064
927+
[#22182]: https://github.com/JuliaLang/julia/issues/22182
923928
[#22187]: https://github.com/JuliaLang/julia/issues/22187
924929
[#22188]: https://github.com/JuliaLang/julia/issues/22188
925930
[#22224]: https://github.com/JuliaLang/julia/issues/22224

base/c.jl

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

21-
if is_windows()
21+
# The ccall is equivalent to Sys.iswindows(), but that's not defined yet
22+
if ccall(:jl_get_UNAME, Any, ()) === :NT
2223
const Clong = Int32
2324
const Culong = UInt32
2425
const Cwchar_t = UInt16
@@ -49,7 +50,7 @@ Equivalent to the native `wchar_t` c-type ([`Int32`](@ref)).
4950
"""
5051
Cwchar_t
5152

52-
if !is_windows()
53+
if ccall(:jl_get_UNAME, Any, ()) !== :NT
5354
const sizeof_mode_t = ccall(:jl_sizeof_mode_t, Cint, ())
5455
if sizeof_mode_t == 2
5556
const Cmode_t = Int16
@@ -118,7 +119,7 @@ end
118119
# symbols are guaranteed not to contain embedded NUL
119120
convert(::Type{Cstring}, s::Symbol) = Cstring(unsafe_convert(Ptr{Cchar}, s))
120121

121-
if is_windows()
122+
if ccall(:jl_get_UNAME, Any, ()) === :NT
122123
"""
123124
Base.cwstring(s)
124125

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
@@ -1503,6 +1503,13 @@ function bkfact!(A::StridedMatrix, uplo::Symbol, symmetric::Bool = issymmetric(A
15031503
return bkfact!(symmetric ? Symmetric(A, uplo) : Hermitian(A, uplo), rook)
15041504
end
15051505

1506+
# PR #22182
1507+
@deprecate is_apple Sys.isapple
1508+
@deprecate is_bsd Sys.isbsd
1509+
@deprecate is_linux Sys.islinux
1510+
@deprecate is_unix Sys.isunix
1511+
@deprecate is_windows Sys.iswindows
1512+
15061513
# END 0.7 deprecations
15071514

15081515
# 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)