Skip to content

add an API to the standard library to learn the system page size #11308

Closed
@gpanders

Description

@gpanders

Zig Version

0.10.0-dev.1434+676652865

Steps to Reproduce

I am running Linux on a MacBook Pro which uses 16 KiB pages; however, Zig's std lib always assumes 4 KiB pages on Linux running on aarch64.

Expected Behavior

Zig should infer/detect the correct page size.

Actual Behavior

Zig assumes 4 KiB pages, which results in errors in calls to msync or mmap (e.g. in std.debug.captureStackTrace).

#4082 is mentioned in the source code, so I'm guessing that is the long term solution. That issue also mentions a "hacky" solution of using madvise to check for a valid page size. A short term solution could be to check madvise at compile time when running Linux on aarch64 to check between all possible page sizes (ARM64 can also support 64 KiB pages). If this is acceptable I can open a PR. EDIT: It looks like syscalls can't run at comptime so I don't think this would work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions