Skip to content

std: add arch bits for m68k-linux #23376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1601,10 +1601,6 @@ pub const MSF = switch (native_os) {
},
else => void,
};
pub const MMAP2_UNIT = switch (native_os) {
.linux => linux.MMAP2_UNIT,
else => void,
};
pub const NAME_MAX = switch (native_os) {
.linux => linux.NAME_MAX,
.emscripten => emscripten.NAME_MAX,
Expand Down
43 changes: 32 additions & 11 deletions lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const arch_bits = switch (native_arch) {
.riscv64 => @import("linux/riscv64.zig"),
.sparc64 => @import("linux/sparc64.zig"),
.loongarch64 => @import("linux/loongarch64.zig"),
.m68k => @import("linux/m68k.zig"),
.mips, .mipsel => @import("linux/mips.zig"),
.mips64, .mips64el => @import("linux/mips64.zig"),
.powerpc, .powerpcle => @import("linux/powerpc.zig"),
Expand Down Expand Up @@ -92,7 +93,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx;
pub const F = arch_bits.F;
pub const Flock = arch_bits.Flock;
pub const HWCAP = arch_bits.HWCAP;
pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT;
pub const REG = arch_bits.REG;
pub const SC = arch_bits.SC;
pub const Stat = arch_bits.Stat;
Expand Down Expand Up @@ -279,7 +279,7 @@ pub const MAP = switch (native_arch) {
UNINITIALIZED: bool = false,
_: u5 = 0,
},
.hexagon, .s390x => packed struct(u32) {
.hexagon, .m68k, .s390x => packed struct(u32) {
TYPE: MAP_TYPE,
FIXED: bool = false,
ANONYMOUS: bool = false,
Expand Down Expand Up @@ -333,7 +333,7 @@ pub const O = switch (native_arch) {
SYNC: bool = false,
PATH: bool = false,
TMPFILE: bool = false,
_: u9 = 0,
_23: u9 = 0,
},
.x86, .riscv32, .riscv64, .loongarch64 => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -355,7 +355,7 @@ pub const O = switch (native_arch) {
SYNC: bool = false,
PATH: bool = false,
TMPFILE: bool = false,
_: u9 = 0,
_23: u9 = 0,
},
.aarch64, .aarch64_be, .arm, .armeb, .thumb, .thumbeb => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -377,7 +377,7 @@ pub const O = switch (native_arch) {
SYNC: bool = false,
PATH: bool = false,
TMPFILE: bool = false,
_: u9 = 0,
_23: u9 = 0,
},
.sparc64 => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -402,7 +402,7 @@ pub const O = switch (native_arch) {
SYNC: bool = false,
PATH: bool = false,
TMPFILE: bool = false,
_: u6 = 0,
_27: u6 = 0,
},
.mips, .mipsel, .mips64, .mips64el => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -426,7 +426,7 @@ pub const O = switch (native_arch) {
_20: u1 = 0,
PATH: bool = false,
TMPFILE: bool = false,
_: u9 = 0,
_23: u9 = 0,
},
.powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -448,7 +448,7 @@ pub const O = switch (native_arch) {
SYNC: bool = false,
PATH: bool = false,
TMPFILE: bool = false,
_: u9 = 0,
_23: u9 = 0,
},
.hexagon, .s390x => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
Expand All @@ -467,15 +467,36 @@ pub const O = switch (native_arch) {
NOFOLLOW: bool = false,
NOATIME: bool = false,
CLOEXEC: bool = false,
_17: u1 = 0,
_20: u1 = 0,
PATH: bool = false,
_: u10 = 0,
_22: u10 = 0,

// #define O_RSYNC 04010000
// #define O_SYNC 04010000
// #define O_TMPFILE 020200000
// #define O_NDELAY O_NONBLOCK
},
.m68k => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
_2: u4 = 0,
CREAT: bool = false,
EXCL: bool = false,
NOCTTY: bool = false,
TRUNC: bool = false,
APPEND: bool = false,
NONBLOCK: bool = false,
DSYNC: bool = false,
ASYNC: bool = false,
DIRECTORY: bool = false,
NOFOLLOW: bool = false,
DIRECT: bool = false,
LARGEFILE: bool = false,
NOATIME: bool = false,
CLOEXEC: bool = false,
_20: u1 = 0,
PATH: bool = false,
_22: u10 = 0,
},
else => @compileError("missing std.os.linux.O constants for this architecture"),
};

Expand Down Expand Up @@ -906,7 +927,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of
prot,
@as(u32, @bitCast(flags)),
@bitCast(@as(isize, fd)),
@truncate(@as(u64, @bitCast(offset)) / MMAP2_UNIT),
@truncate(@as(u64, @bitCast(offset)) / std.heap.pageSize()),
);
} else {
// The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
Expand Down
2 changes: 0 additions & 2 deletions lib/std/os/linux/arm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ pub fn restore_rt() callconv(.naked) noreturn {
}
}

pub const MMAP2_UNIT = 4096;

pub const F = struct {
pub const DUPFD = 0;
pub const GETFD = 1;
Expand Down
2 changes: 0 additions & 2 deletions lib/std/os/linux/hexagon.zig
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ pub const Stat = extern struct {

pub const Elf_Symndx = u32;

pub const MMAP2_UNIT = 4096;

pub const VDSO = void;

/// TODO
Expand Down
Loading