authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-21 14:50:16+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-22 12:47:38+00:00
log9ae4e38ca27e1b14e84f58594b8be4513f1fcfbe
treefd152e4f544f4b83485067c878be7028ed3b6dd8
parent2046e0f4be23028d18009a61a517d0712e2ca164
signaturelock-open Commit is signed but in an unrecognized format.

tools: replace thread pool with `std.Io`


1 files changed, 24 insertions(+), 27 deletions(-)

tools/update_cpu_features.zig+24-27
...@@ -1882,10 +1882,18 @@ const targets = [_]ArchTarget{...@@ -1882,10 +1882,18 @@ const targets = [_]ArchTarget{
1882};1882};
18831883
1884pub fn main() anyerror!void {1884pub fn main() anyerror!void {
1885 var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);1885 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
1886 defer _ = debug_allocator.deinit();
1887 const gpa = debug_allocator.allocator();
1888
1889 var arena_state: std.heap.ArenaAllocator = .init(gpa);
1886 defer arena_state.deinit();1890 defer arena_state.deinit();
1887 const arena = arena_state.allocator();1891 const arena = arena_state.allocator();
18881892
1893 var threaded: std.Io.Threaded = .init(gpa);
1894 defer threaded.deinit();
1895 const io = threaded.io();
1896
1889 var args = try std.process.argsWithAllocator(arena);1897 var args = try std.process.argsWithAllocator(arena);
1890 const args0 = args.next().?;1898 const args0 = args.next().?;
18911899
...@@ -1925,34 +1933,23 @@ pub fn main() anyerror!void {...@@ -1925,34 +1933,23 @@ pub fn main() anyerror!void {
1925 const root_progress = std.Progress.start(.{ .estimated_total_items = targets.len });1933 const root_progress = std.Progress.start(.{ .estimated_total_items = targets.len });
1926 defer root_progress.end();1934 defer root_progress.end();
19271935
1928 if (builtin.single_threaded) {1936 var group: std.Io.Group = .init;
1929 for (targets) |target| {1937 defer group.cancel(io);
1930 if (filter) |zig_name| if (!std.mem.eql(u8, target.zig_name, zig_name)) continue;1938
1931 try processOneTarget(.{1939 for (targets) |target| {
1932 .llvm_tblgen_exe = llvm_tblgen_exe,1940 if (filter) |zig_name| {
1933 .llvm_src_root = llvm_src_root,1941 if (!std.mem.eql(u8, target.zig_name, zig_name)) continue;
1934 .zig_src_dir = zig_src_dir,
1935 .root_progress = root_progress,
1936 .target = target,
1937 });
1938 }
1939 } else {
1940 var pool: std.Thread.Pool = undefined;
1941 try pool.init(.{ .allocator = arena, .n_jobs = targets.len });
1942 defer pool.deinit();
1943
1944 for (targets) |target| {
1945 if (filter) |zig_name| if (!std.mem.eql(u8, target.zig_name, zig_name)) continue;
1946 const job = Job{
1947 .llvm_tblgen_exe = llvm_tblgen_exe,
1948 .llvm_src_root = llvm_src_root,
1949 .zig_src_dir = zig_src_dir,
1950 .root_progress = root_progress,
1951 .target = target,
1952 };
1953 try pool.spawn(processOneTarget, .{job});
1954 }1942 }
1943 group.async(io, processOneTarget, .{.{
1944 .llvm_tblgen_exe = llvm_tblgen_exe,
1945 .llvm_src_root = llvm_src_root,
1946 .zig_src_dir = zig_src_dir,
1947 .root_progress = root_progress,
1948 .target = target,
1949 }});
1955 }1950 }
1951
1952 group.wait(io);
1956}1953}
19571954
1958const Job = struct {1955const Job = struct {