authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-11-30 22:16:06+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-05 14:52:48+01:00
log834ac8122bfdf7bb982b2f2e8d83b4825c44224c
treec1fb0071db3ed38319fa37106991f3347822932b
parent962903e0fa222ee002355832e17144f66ec8d6ec
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

process_headers: add openbsd support


1 files changed, 36 insertions(+), 3 deletions(-)

tools/process_headers.zig+36-3
......@@ -6,8 +6,8 @@
66//! this tool.
77//!
88//! First, use the glibc, musl, FreeBSD, and NetBSD build systems to create installations of all the
9//! targets in the `glibc_targets`, `musl_targets`, `freebsd_targets`, and `netbsd_targets`
10//! variables. Next, run this tool to create a new directory which puts .h files into
9//! targets in the `glibc_targets`, `musl_targets`, `freebsd_targets`, `netbsd_targets`, and
10//! `openbsd_targets` variables. Next, run this tool to create a new directory which puts .h files into
1111//! <arch> subdirectories, with `generic` being files that apply to all architectures.
1212//! You'll then have to manually update Zig source repo with these new files.
1313
......@@ -104,6 +104,19 @@ const netbsd_targets = [_]LibCTarget{
104104 .{ .arch = .x86_64, .abi = .none },
105105};
106106
107const openbsd_targets = [_]LibCTarget{
108 .{ .arch = .arm, .abi = .eabi },
109 .{ .arch = .aarch64, .abi = .none },
110 .{ .arch = .mips64, .abi = .none },
111 .{ .arch = .mips64el, .abi = .none },
112 .{ .arch = .powerpc, .abi = .eabihf },
113 .{ .arch = .powerpc64, .abi = .none },
114 .{ .arch = .riscv64, .abi = .none },
115 .{ .arch = .sparc64, .abi = .none },
116 .{ .arch = .x86, .abi = .none },
117 .{ .arch = .x86_64, .abi = .none },
118};
119
107120const Contents = struct {
108121 bytes: []const u8,
109122 hit_count: usize,
......@@ -125,6 +138,7 @@ const LibCVendor = enum {
125138 glibc,
126139 freebsd,
127140 netbsd,
141 openbsd,
128142};
129143
130144pub fn main(init: std.process.Init) !void {
......@@ -176,6 +190,7 @@ pub fn main(init: std.process.Init) !void {
176190 .musl => &musl_targets,
177191 .freebsd => &freebsd_targets,
178192 .netbsd => &netbsd_targets,
193 .openbsd => &openbsd_targets,
179194 };
180195
181196 var path_table = PathTable.init(arena);
......@@ -215,6 +230,22 @@ pub fn main(init: std.process.Init) !void {
215230 .sparc64,
216231 => |a| @tagName(a),
217232
233 else => unreachable,
234 },
235 .openbsd => switch (libc_target.arch) {
236 .arm => "armv7",
237 .aarch64 => "arm64",
238 .mips64 => "octeon",
239 .mips64el => "loongson",
240 .powerpc => "macppc",
241 .x86 => "i386",
242 .x86_64 => "amd64",
243
244 .powerpc64,
245 .riscv64,
246 .sparc64,
247 => |a| @tagName(a),
248
218249 else => unreachable,
219250 },
220251 };
......@@ -225,6 +256,7 @@ pub fn main(init: std.process.Init) !void {
225256 .musl, .glibc => "linux",
226257 .freebsd => "freebsd",
227258 .netbsd => "netbsd",
259 .openbsd => "openbsd",
228260 },
229261 @tagName(libc_target.abi),
230262 });
......@@ -234,6 +266,7 @@ pub fn main(init: std.process.Init) !void {
234266 .glibc,
235267 .freebsd,
236268 .netbsd,
269 .openbsd,
237270 => &[_][]const u8{ search_path, libc_dir, "usr", "include" },
238271 .musl => &[_][]const u8{ search_path, libc_dir, "usr", "local", "musl", "include" },
239272 };
......@@ -370,6 +403,6 @@ fn usageAndExit(arg0: []const u8) noreturn {
370403 std.debug.print("--search-path can be used any number of times.\n", .{});
371404 std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{});
372405 std.debug.print("--out is a dir that will be created, and populated with the results\n", .{});
373 std.debug.print("--abi is either glibc, musl, freebsd, or netbsd\n", .{});
406 std.debug.print("--abi is either glibc, musl, freebsd, netbsd, or openbsd\n", .{});
374407 std.process.exit(1);
375408}