Skip to content

Commit

Permalink
move Mmap and SharedArrays to stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 29, 2017
1 parent 68e3901 commit b6fde00
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 324 deletions.
12 changes: 4 additions & 8 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1014,14 +1014,6 @@ isempty(::Task) = error("isempty not defined for Tasks")
@deprecate Array(::Type{T}, m::Integer,n::Integer) where {T} Array{T}(Int(m),Int(n))
@deprecate Array(::Type{T}, m::Integer,n::Integer,o::Integer) where {T} Array{T}(Int(m),Int(n),Int(o))

# Likewise for SharedArrays
@deprecate SharedArray(::Type{T}, dims::Dims{N}; kwargs...) where {T,N} SharedArray{T}(dims; kwargs...)
@deprecate SharedArray(::Type{T}, dims::Int...; kwargs...) where {T} SharedArray{T}(dims...; kwargs...)
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, offset; kwargs...) where {T,N},
SharedArray{T}(filename, dims, offset; kwargs...))
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple, offset; kwargs...) where {T},
SharedArray{T}(filename, dims, offset; kwargs...))

@noinline function is_intrinsic_expr(@nospecialize(x))
Base.depwarn("is_intrinsic_expr is deprecated. There are no intrinsic functions anymore.", :is_intrinsic_expr)
return false
Expand Down Expand Up @@ -1381,6 +1373,10 @@ end
export Test
deprecate(@__MODULE__, :Test)

@deprecate_moved SharedArray "SharedArrays" true true

@deprecate_binding Mmap nothing true ", run `using Mmap` instead"

# PR #21709
@deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected)
@deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected)
Expand Down
9 changes: 0 additions & 9 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export
Sys,
Libc,
Libdl,
Mmap,
LinAlg,
BLAS,
LAPACK,
Expand Down Expand Up @@ -104,9 +103,6 @@ export
AbstractSerializer,
SerializationState,
Set,
SharedArray,
SharedMatrix,
SharedVector,
StepRange,
StepRangeLen,
StridedArray,
Expand Down Expand Up @@ -1088,11 +1084,6 @@ export
HTML,
Text,

# shared arrays
sdata,
indexpids,
localindexes,

# paths and file names
abspath,
basename,
Expand Down
5 changes: 0 additions & 5 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ using .Serializer
import .Serializer: serialize, deserialize
include("channels.jl")

# memory-mapped and shared arrays
include("mmap.jl")
import .Mmap

# utilities - timing, help, edit
include("deepcopy.jl")
include("interactiveutil.jl")
Expand Down Expand Up @@ -413,7 +409,6 @@ include("asyncmap.jl")

include("distributed/Distributed.jl")
using .Distributed
include("sharedarray.jl")

# code loading
include("loading.jl")
Expand Down
8 changes: 6 additions & 2 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ end
if Sys.iswindows()
cp("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
cp("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
cp("../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
cp("../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
else
symlink("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
symlink("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
symlink("../../../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
symlink("../../../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
end

const PAGES = [
Expand Down Expand Up @@ -126,11 +130,11 @@ const PAGES = [
],
]

using DelimitedFiles, Test
using DelimitedFiles, Test, Mmap, SharedArrays

makedocs(
build = joinpath(pwd(), "_build/html/en"),
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test],
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays],
clean = false,
doctest = "doctest" in ARGS,
linkcheck = "linkcheck" in ARGS,
Expand Down
2 changes: 2 additions & 0 deletions doc/src/stdlib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
delimitedfiles.md
test.md
mmap.md
sharedarrays.md
8 changes: 0 additions & 8 deletions doc/src/stdlib/io-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ Base.Multimedia.TextDisplay
Base.Multimedia.istextmime
```

## Memory-mapped I/O

```@docs
Base.Mmap.Anonymous
Base.Mmap.mmap
Base.Mmap.sync!
```

## Network I/O

```@docs
Expand Down
2 changes: 2 additions & 0 deletions stdlib/DelimitedFiles/src/DelimitedFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ __precompile__(true)

module DelimitedFiles

using Mmap

import Base: _default_delims, tryparse_internal, show

export readdlm, writedlm
Expand Down
7 changes: 7 additions & 0 deletions stdlib/Mmap/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Memory-mapped I/O

```@docs
Mmap.Anonymous
Mmap.mmap
Mmap.sync!
```
File renamed without changes.
2 changes: 2 additions & 0 deletions test/mmap.jl → stdlib/Mmap/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, Mmap

file = tempname()
write(file, "Hello World\n")
t = b"Hello World"
Expand Down
9 changes: 9 additions & 0 deletions stdlib/SharedArrays/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Shared Arrays

```@docs
SharedArrays.SharedArray
SharedArrays.procs(::SharedArray)
SharedArrays.sdata
SharedArrays.indexpids
SharedArrays.localindexes
```
27 changes: 24 additions & 3 deletions base/sharedarray.jl → stdlib/SharedArrays/src/SharedArrays.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

import .Serializer: serialize_cycle_header, serialize_type, writetag, UNDEFREF_TAG
import .Distributed: RRID, procs
module SharedArrays

using Mmap, Base.Distributed

import Base: length, size, ndims, IndexStyle, reshape, convert, deepcopy_internal, serialize, deserialize,
show, getindex, setindex!, fill!, rand!, similar, reduce, map!, copy!, unsafe_convert
import Base.Random
import Base.Serializer: serialize_cycle_header, serialize_type, writetag, UNDEFREF_TAG
import Base.Distributed: RRID, procs
import Base.Filesystem: JL_O_CREAT, JL_O_RDWR, S_IRUSR, S_IWUSR

export SharedArray, SharedVector, SharedMatrix, sdata, indexpids, localindexes

mutable struct SharedArray{T,N} <: DenseArray{T,N}
id::RRID
Expand Down Expand Up @@ -663,6 +673,17 @@ end

shm_unlink(shm_seg_name) = ccall(:shm_unlink, Cint, (Cstring,), shm_seg_name)
shm_open(shm_seg_name, oflags, permissions) = ccall(:shm_open, Cint,
(Cstring, Cint, Cmode_t), shm_seg_name, oflags, permissions)
(Cstring, Cint, Base.Cmode_t), shm_seg_name, oflags, permissions)

end # os-test

# 0.7 deprecations

@deprecate SharedArray(::Type{T}, dims::Dims{N}; kwargs...) where {T,N} SharedArray{T}(dims; kwargs...)
@deprecate SharedArray(::Type{T}, dims::Int...; kwargs...) where {T} SharedArray{T}(dims...; kwargs...)
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, offset; kwargs...) where {T,N},
SharedArray{T}(filename, dims, offset; kwargs...))
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple, offset; kwargs...) where {T},
SharedArray{T}(filename, dims, offset; kwargs...))

end # module
Loading

0 comments on commit b6fde00

Please sign in to comment.