From bee04aebab38066201719a62afe37b69016f117e Mon Sep 17 00:00:00 2001 From: green-br Date: Tue, 30 Sep 2025 08:59:00 +0100 Subject: [PATCH 1/5] Update runtests.jl Seek file back to beginning before running next text in mmap. --- stdlib/Mmap/test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/Mmap/test/runtests.jl b/stdlib/Mmap/test/runtests.jl index 4ab04bf733190..ee273e8debc13 100644 --- a/stdlib/Mmap/test/runtests.jl +++ b/stdlib/Mmap/test/runtests.jl @@ -268,6 +268,7 @@ A2 = mmap(s, Matrix{Int}, (m,n)) seek(s, 0) A3 = mmap(s, Matrix{Int}, (m,n), convert(Int64, 2*sizeof(Int))) @test A == A3 +seek(s, 0) A4 = mmap(s, Matrix{Int}, (m,150), convert(Int64, (2+150*m)*sizeof(Int))) @test A[:, 151:end] == A4 close(s) From dd7f328ec2f914e13c715de41e9efec5d6ef8999 Mon Sep 17 00:00:00 2001 From: green-br Date: Tue, 30 Sep 2025 12:11:30 +0100 Subject: [PATCH 2/5] Update Mmap.jl Seemed to be 4096 on a system with 64k pagesize. Removing const allowed it to be re-evaluated at runtime. --- stdlib/Mmap/src/Mmap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/Mmap/src/Mmap.jl b/stdlib/Mmap/src/Mmap.jl index c527123d51bb8..ad67f989cc545 100644 --- a/stdlib/Mmap/src/Mmap.jl +++ b/stdlib/Mmap/src/Mmap.jl @@ -9,7 +9,7 @@ import Base: OS_HANDLE, INVALID_OS_HANDLE export mmap -const PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ())) +PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ())) # for mmaps not backed by files mutable struct Anonymous <: IO From 5e82dc1d2270e3a266edbfb124eebad864f71d24 Mon Sep 17 00:00:00 2001 From: green-br Date: Wed, 1 Oct 2025 22:58:32 +0100 Subject: [PATCH 3/5] Update sysinfo.jl Add PAGESIZE. --- base/sysinfo.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 5bd3573fb4736..8b3b386fc235d 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -144,6 +144,13 @@ Note: Included in the detailed system information via `versioninfo(verbose=true) """ global JIT::String +""" + Sys.PAGESIZE::Clong + +A number providing the pagesize of the given OS. Common values being 4kb or 64kb on Linux. +""" +global PAGESIZE::Clong + function __init__() env_threads = nothing if haskey(ENV, "JULIA_CPU_THREADS") @@ -162,6 +169,7 @@ function __init__() global SC_CLK_TCK = ccall(:jl_SC_CLK_TCK, Clong, ()) global CPU_NAME = ccall(:jl_get_cpu_name, Ref{String}, ()) global JIT = ccall(:jl_get_JIT, Ref{String}, ()) + global PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ())) __init_build() nothing end From e878c256a8e35af72ca6cb609d0c5329ebef107e Mon Sep 17 00:00:00 2001 From: green-br Date: Wed, 1 Oct 2025 23:00:00 +0100 Subject: [PATCH 4/5] Update sysinfo.jl Export PAGESIZE --- base/sysinfo.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 8b3b386fc235d..0db396c9a42d3 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -14,6 +14,7 @@ export BINDIR, MACHINE, KERNEL, JIT, + PAGESIZE, cpu_info, cpu_summary, sysimage_target, From 28b9a5b3ad3a353c7f89c262c6408c7a1296726c Mon Sep 17 00:00:00 2001 From: green-br Date: Wed, 1 Oct 2025 23:04:34 +0100 Subject: [PATCH 5/5] Update Mmap.jl Use new PAGESIZE location --- stdlib/Mmap/src/Mmap.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/Mmap/src/Mmap.jl b/stdlib/Mmap/src/Mmap.jl index ad67f989cc545..4802ede3af5d9 100644 --- a/stdlib/Mmap/src/Mmap.jl +++ b/stdlib/Mmap/src/Mmap.jl @@ -6,11 +6,10 @@ Low level module for mmap (memory mapping of files). module Mmap import Base: OS_HANDLE, INVALID_OS_HANDLE +using Sys: PAGESIZE export mmap -PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ())) - # for mmaps not backed by files mutable struct Anonymous <: IO name::String