Skip to content

Commit

Permalink
remove Base.UNAME
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed May 16, 2016
1 parent 9824d09 commit 1f8eecb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ elseif is_windows()
end

else
clipboard(x="") = error("`clipboard` function not implemented for $(OSNAME)")
clipboard(x="") = error("`clipboard` function not implemented for $(Sys.KERNEL)")
end

# system information
Expand Down Expand Up @@ -195,7 +195,7 @@ function versioninfo(io::IO=STDOUT, verbose::Bool=false)
println(io, "DEBUG build")
end
println(io, "Platform Info:")
println(io, " System: ", OSNAME, " (", Sys.KERNEL, " ", Sys.MACHINE, ")")
println(io, " System: ", Sys.KERNEL, " (", Sys.MACHINE, ")")

cpu = Sys.cpu_info()
println(io, " CPU: ", cpu[1].model)
Expand Down
33 changes: 14 additions & 19 deletions base/osutils.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

let UNAME = ccall(:jl_get_UNAME, Any, ())
# change some `uname -s` values to "friendly" names
# for internal usage
global OSNAME
if UNAME == :Darwin
OSNAME = :Apple
elseif UNAME == :WINNT
OSNAME = :Windows
else
OSNAME = UNAME
end
end


"""
is_unix([os])
Predicate for testing if the OS provides a Unix-like interface.
See documentation :ref:`Handling Operating System Variation <man-handling-operating-system-variation>`\ .
"""
function is_unix(os::Symbol = OSNAME)
function is_unix(os::Symbol)
if is_windows(os)
return false
elseif is_linux(os) || is_bsd(os)
Expand All @@ -36,31 +22,31 @@ end
Predicate for testing if the OS is a derivative of Linux.
See documentation :ref:`Handling Operating System Variation <man-handling-operating-system-variation>`\ .
"""
is_linux(os::Symbol = OSNAME) = (os == :Linux)
is_linux(os::Symbol) = (os == :Linux)

"""
is_bsd([os])
Predicate for testing if the OS is a derivative of BSD.
See documentation :ref:`Handling Operating System Variation <man-handling-operating-system-variation>`\ .
"""
is_bsd(os::Symbol = OSNAME) = (os == :FreeBSD || os == :OpenBSD || os == :NetBSD || os == :Darwin || os == :Apple)
is_bsd(os::Symbol) = (os == :FreeBSD || os == :OpenBSD || os == :NetBSD || os == :Darwin || os == :Apple)

"""
is_windows([os])
Predicate for testing if the OS is a derivative of Microsoft Windows NT.
See documentation :ref:`Handling Operating System Variation <man-handling-operating-system-variation>`\ .
"""
is_windows(os::Symbol = OSNAME) = (os == :Windows || os == :WINNT)
is_windows(os::Symbol) = (os == :Windows || os == :WINNT)

"""
is_apple([os])
Predicate for testing if the OS is a derivative of Apple Macintosh OS X or Darwin.
See documentation :ref:`Handling Operating System Variation <man-handling-operating-system-variation>`\ .
"""
is_apple(os::Symbol = OSNAME) = (os == :Apple || os == :Darwin)
is_apple(os::Symbol) = (os == :Apple || os == :Darwin)

"""
@static
Expand All @@ -86,3 +72,12 @@ macro static(ex)
end
throw(ArgumentError("invalid @static macro"))
end

let KERNEL = ccall(:jl_get_UNAME, Any, ())
# evaluate the zero-argument form of each of these functions
# as a function returning a static constant based on the build-time
# operating-system kernel
for f in (:is_unix, :is_linux, :is_bsd, :is_apple, :is_windows)
@eval $f() = $(getfield(current_module(),f)(KERNEL))
end
end

0 comments on commit 1f8eecb

Please sign in to comment.