Skip to content

Commit 31e223a

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 ff781e5 commit 31e223a

Some content is hidden

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

75 files changed

+340
-334
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ Deprecated or removed
151151
* `Bidiagonal` constructors now use a `Symbol` (`:U` or `:L`) for the upper/lower
152152
argument, instead of a `Bool` or a `Char` ([#22703]).
153153

154+
* The operating system identification functions: `is_linux`, `is_bsd`, `is_apple`, `is_unix`,
155+
and `is_windows`, have been deprecated in favor of `Sys.islinux`, `Sys.isbsd`, `Sys.isapple`,
156+
`Sys.isunix`, and `Sys.iswindows`, respectively ([#22182]).
157+
154158

155159
Julia v0.6.0 Release Notes
156160
==========================
@@ -945,6 +949,7 @@ Command-line option changes
945949
[#22038]: https://github.com/JuliaLang/julia/issues/22038
946950
[#22062]: https://github.com/JuliaLang/julia/issues/22062
947951
[#22064]: https://github.com/JuliaLang/julia/issues/22064
952+
[#22182]: https://github.com/JuliaLang/julia/issues/22182
948953
[#22187]: https://github.com/JuliaLang/julia/issues/22187
949954
[#22188]: https://github.com/JuliaLang/julia/issues/22188
950955
[#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 here is equivalent to Sys.iswindows(), but that's not defined yet
22+
@static 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+
@static 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+
@static 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
@@ -390,7 +390,7 @@ function _start()
390390
global is_interactive |= !isa(STDIN, Union{File, IOStream})
391391
color_set || (global have_color = false)
392392
else
393-
term = Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
393+
term = Terminals.TTYTerminal(get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
394394
global is_interactive = true
395395
color_set || (global have_color = Terminals.hascolor(term))
396396
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
@@ -1560,6 +1560,13 @@ end
15601560
@deprecate Bidiagonal(dv::AbstractVector, ev::AbstractVector, uplo::Char) Bidiagonal(dv, ev, ifelse(uplo == 'U', :U, :L))
15611561
@deprecate Bidiagonal(A::AbstractMatrix, isupper::Bool) Bidiagonal(A, ifelse(isupper, :U, :L))
15621562

1563+
# PR #22182
1564+
@deprecate is_apple Sys.isapple
1565+
@deprecate is_bsd Sys.isbsd
1566+
@deprecate is_linux Sys.islinux
1567+
@deprecate is_unix Sys.isunix
1568+
@deprecate is_windows Sys.iswindows
1569+
15631570
# END 0.7 deprecations
15641571

15651572
# BEGIN 1.0 deprecations

base/distributed/cluster.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ end
975975
function disable_nagle(sock)
976976
# disable nagle on all OSes
977977
ccall(:uv_tcp_nodelay, Cint, (Ptr{Void}, Cint), sock.handle, 1)
978-
@static if is_linux()
978+
@static if Sys.islinux()
979979
# tcp_quickack is a linux only option
980980
if ccall(:jl_tcp_quickack, Cint, (Ptr{Void}, Cint), sock.handle, 1) < 0
981981
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
@@ -460,7 +460,7 @@ function socket_reuse_port()
460460
s = TCPSocket(delay = false)
461461

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

465465
bind_early && bind_client_port(s)
466466
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)