Skip to content

Commit

Permalink
add note about macOS share and exec policy
Browse files Browse the repository at this point in the history
fix whitespaces
  • Loading branch information
fatteneder committed Mar 3, 2024
1 parent 21a2a0c commit b0502e4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ will be visible to other processes mapping the same file.
The `exec` keyword argument specifies whether the underlying mmap data will be executable.
!!! note
On MacOS `exec=true` implies `shared=false`, because each thread has its own access permissions to `mmap` regions.
For example, the following code
```julia
Expand Down Expand Up @@ -220,12 +224,12 @@ function _mmap(io::IO,
if exec && !iswritable(io)
throw(ArgumentError("$io must be writeable to mmap with exec = true"))
end
@static if Sys.isapple()
# on MacOS each thread has its own access permissions, so we can't share when exec=true
# https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon#Disable-Write-Protections-Before-You-Generate-Instructions
exec && (shared = false)
end
@static if Sys.isapple()
# on MacOS each thread has its own access permissions, so we can't share when exec=true
# https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon#Disable-Write-Protections-Before-You-Generate-Instructions
exec && (shared = false)
end

len = sizeof(T)
for l in dims
len, overflow = Base.Checked.mul_with_overflow(promote(len, l)...)
Expand Down

0 comments on commit b0502e4

Please sign in to comment.