authorgravatar for sentrycraft123@gmail.comJan200101 <sentrycraft123@gmail.com> 2020-08-22 15:08:34+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-08-22 16:38:03+03:00
log9605e5363b22874550687f5f96dc6cc8bf462115
tree83ad776ba3b5e6dade2a3ac96e8f899f83245635
parent69de1a51cd4f43e1d7a1fab3208b835b6841579d

update update_glibc and process_headers to latest zig


2 files changed, 23 insertions(+), 22 deletions(-)

tools/process_headers.zig+3-2
...@@ -15,6 +15,7 @@ const Arch = std.Target.Cpu.Arch;...@@ -15,6 +15,7 @@ const Arch = std.Target.Cpu.Arch;
15const Abi = std.Target.Abi;15const Abi = std.Target.Abi;
16const OsTag = std.Target.Os.Tag;16const OsTag = std.Target.Os.Tag;
17const assert = std.debug.assert;17const assert = std.debug.assert;
18const Sha256 = std.crypto.hash.sha2.Sha256;
1819
19const LibCTarget = struct {20const LibCTarget = struct {
20 name: []const u8,21 name: []const u8,
...@@ -313,7 +314,7 @@ pub fn main() !void {...@@ -313,7 +314,7 @@ pub fn main() !void {
313 var max_bytes_saved: usize = 0;314 var max_bytes_saved: usize = 0;
314 var total_bytes: usize = 0;315 var total_bytes: usize = 0;
315316
316 var hasher = std.crypto.hash.sha2.Sha256.init(.{});317 var hasher = Sha256.init(.{});
317318
318 for (libc_targets) |libc_target| {319 for (libc_targets) |libc_target| {
319 const dest_target = DestTarget{320 const dest_target = DestTarget{
...@@ -359,7 +360,7 @@ pub fn main() !void {...@@ -359,7 +360,7 @@ pub fn main() !void {
359 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");360 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
360 total_bytes += raw_bytes.len;361 total_bytes += raw_bytes.len;
361 const hash = try allocator.alloc(u8, 32);362 const hash = try allocator.alloc(u8, 32);
362 hasher.reset();363 hasher = Sha256.init(.{});
363 hasher.update(rel_path);364 hasher.update(rel_path);
364 hasher.update(trimmed);365 hasher.update(trimmed);
365 hasher.final(hash);366 hasher.final(hash);
tools/update_glibc.zig+20-20
...@@ -148,12 +148,12 @@ pub fn main() !void {...@@ -148,12 +148,12 @@ pub fn main() !void {
148 for (abi_lists) |*abi_list| {148 for (abi_lists) |*abi_list| {
149 const target_funcs_gop = try target_functions.getOrPut(@ptrToInt(abi_list));149 const target_funcs_gop = try target_functions.getOrPut(@ptrToInt(abi_list));
150 if (!target_funcs_gop.found_existing) {150 if (!target_funcs_gop.found_existing) {
151 target_funcs_gop.kv.value = FunctionSet{151 target_funcs_gop.entry.value = FunctionSet{
152 .list = std.ArrayList(VersionedFn).init(allocator),152 .list = std.ArrayList(VersionedFn).init(allocator),
153 .fn_vers_list = FnVersionList.init(allocator),153 .fn_vers_list = FnVersionList.init(allocator),
154 };154 };
155 }155 }
156 const fn_set = &target_funcs_gop.kv.value.list;156 const fn_set = &target_funcs_gop.entry.value.list;
157157
158 for (lib_names) |lib_name, lib_name_index| {158 for (lib_names) |lib_name, lib_name_index| {
159 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";159 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
...@@ -203,11 +203,11 @@ pub fn main() !void {...@@ -203,11 +203,11 @@ pub fn main() !void {
203 _ = try global_ver_set.put(ver, undefined);203 _ = try global_ver_set.put(ver, undefined);
204 const gop = try global_fn_set.getOrPut(name);204 const gop = try global_fn_set.getOrPut(name);
205 if (gop.found_existing) {205 if (gop.found_existing) {
206 if (!std.mem.eql(u8, gop.kv.value.lib, "c")) {206 if (!std.mem.eql(u8, gop.entry.value.lib, "c")) {
207 gop.kv.value.lib = lib_name;207 gop.entry.value.lib = lib_name;
208 }208 }
209 } else {209 } else {
210 gop.kv.value = Function{210 gop.entry.value = Function{
211 .name = name,211 .name = name,
212 .lib = lib_name,212 .lib = lib_name,
213 .index = undefined,213 .index = undefined,
...@@ -224,14 +224,14 @@ pub fn main() !void {...@@ -224,14 +224,14 @@ pub fn main() !void {
224 const global_fn_list = blk: {224 const global_fn_list = blk: {
225 var list = std.ArrayList([]const u8).init(allocator);225 var list = std.ArrayList([]const u8).init(allocator);
226 var it = global_fn_set.iterator();226 var it = global_fn_set.iterator();
227 while (it.next()) |kv| try list.append(kv.key);227 while (it.next()) |entry| try list.append(entry.key);
228 std.sort.sort([]const u8, list.span(), {}, strCmpLessThan);228 std.sort.sort([]const u8, list.span(), {}, strCmpLessThan);
229 break :blk list.span();229 break :blk list.span();
230 };230 };
231 const global_ver_list = blk: {231 const global_ver_list = blk: {
232 var list = std.ArrayList([]const u8).init(allocator);232 var list = std.ArrayList([]const u8).init(allocator);
233 var it = global_ver_set.iterator();233 var it = global_ver_set.iterator();
234 while (it.next()) |kv| try list.append(kv.key);234 while (it.next()) |entry| try list.append(entry.key);
235 std.sort.sort([]const u8, list.span(), {}, versionLessThan);235 std.sort.sort([]const u8, list.span(), {}, versionLessThan);
236 break :blk list.span();236 break :blk list.span();
237 };237 };
...@@ -254,9 +254,9 @@ pub fn main() !void {...@@ -254,9 +254,9 @@ pub fn main() !void {
254 var buffered = std.io.bufferedOutStream(fns_txt_file.outStream());254 var buffered = std.io.bufferedOutStream(fns_txt_file.outStream());
255 const fns_txt = buffered.outStream();255 const fns_txt = buffered.outStream();
256 for (global_fn_list) |name, i| {256 for (global_fn_list) |name, i| {
257 const kv = global_fn_set.get(name).?;257 const entry = global_fn_set.getEntry(name).?;
258 kv.value.index = i;258 entry.value.index = i;
259 try fns_txt.print("{} {}\n", .{ name, kv.value.lib });259 try fns_txt.print("{} {}\n", .{ name, entry.value.lib });
260 }260 }
261 try buffered.flush();261 try buffered.flush();
262 }262 }
...@@ -264,16 +264,16 @@ pub fn main() !void {...@@ -264,16 +264,16 @@ pub fn main() !void {
264 // Now the mapping of version and function to integer index is complete.264 // Now the mapping of version and function to integer index is complete.
265 // Here we create a mapping of function name to list of versions.265 // Here we create a mapping of function name to list of versions.
266 for (abi_lists) |*abi_list, abi_index| {266 for (abi_lists) |*abi_list, abi_index| {
267 const kv = target_functions.get(@ptrToInt(abi_list)).?;267 const entry = target_functions.getEntry(@ptrToInt(abi_list)).?;
268 const fn_vers_list = &kv.value.fn_vers_list;268 const fn_vers_list = &entry.value.fn_vers_list;
269 for (kv.value.list.span()) |*ver_fn| {269 for (entry.value.list.span()) |*ver_fn| {
270 const gop = try fn_vers_list.getOrPut(ver_fn.name);270 const gop = try fn_vers_list.getOrPut(ver_fn.name);
271 if (!gop.found_existing) {271 if (!gop.found_existing) {
272 gop.kv.value = std.ArrayList(usize).init(allocator);272 gop.entry.value = std.ArrayList(usize).init(allocator);
273 }273 }
274 const ver_index = global_ver_set.get(ver_fn.ver).?.value;274 const ver_index = global_ver_set.getEntry(ver_fn.ver).?.value;
275 if (std.mem.indexOfScalar(usize, gop.kv.value.span(), ver_index) == null) {275 if (std.mem.indexOfScalar(usize, gop.entry.value.span(), ver_index) == null) {
276 try gop.kv.value.append(ver_index);276 try gop.entry.value.append(ver_index);
277 }277 }
278 }278 }
279 }279 }
...@@ -287,7 +287,7 @@ pub fn main() !void {...@@ -287,7 +287,7 @@ pub fn main() !void {
287287
288 // first iterate over the abi lists288 // first iterate over the abi lists
289 for (abi_lists) |*abi_list, abi_index| {289 for (abi_lists) |*abi_list, abi_index| {
290 const fn_vers_list = &target_functions.get(@ptrToInt(abi_list)).?.value.fn_vers_list;290 const fn_vers_list = &target_functions.getEntry(@ptrToInt(abi_list)).?.value.fn_vers_list;
291 for (abi_list.targets) |target, it_i| {291 for (abi_list.targets) |target, it_i| {
292 if (it_i != 0) try abilist_txt.writeByte(' ');292 if (it_i != 0) try abilist_txt.writeByte(' ');
293 try abilist_txt.print("{}-linux-{}", .{ @tagName(target.arch), @tagName(target.abi) });293 try abilist_txt.print("{}-linux-{}", .{ @tagName(target.arch), @tagName(target.abi) });
...@@ -295,11 +295,11 @@ pub fn main() !void {...@@ -295,11 +295,11 @@ pub fn main() !void {
295 try abilist_txt.writeByte('\n');295 try abilist_txt.writeByte('\n');
296 // next, each line implicitly corresponds to a function296 // next, each line implicitly corresponds to a function
297 for (global_fn_list) |name| {297 for (global_fn_list) |name| {
298 const kv = fn_vers_list.get(name) orelse {298 const entry = fn_vers_list.getEntry(name) orelse {
299 try abilist_txt.writeByte('\n');299 try abilist_txt.writeByte('\n');
300 continue;300 continue;
301 };301 };
302 for (kv.value.span()) |ver_index, it_i| {302 for (entry.value.span()) |ver_index, it_i| {
303 if (it_i != 0) try abilist_txt.writeByte(' ');303 if (it_i != 0) try abilist_txt.writeByte(' ');
304 try abilist_txt.print("{d}", .{ver_index});304 try abilist_txt.print("{d}", .{ver_index});
305 }305 }