authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-26 14:32:45-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-04-26 14:32:45-04:00
log528a83dd6b0d73e450fca9594846fde233aa2e7a
tree1ac352741ee6433a8941f1ad090b1dab40e079c3
parentddf9ff79bd2eccadafcdf12b191c62c66b247b64
parentdc29d866490e9d886f838e23cb085a9e28c0143b
signature Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8618 from LemonBoy/mini-stuff

Two small patches

2 files changed, 13 insertions(+), 6 deletions(-)

lib/std/debug.zig+11-4
......@@ -336,6 +336,13 @@ pub const StackIterator = struct {
336336 fp: usize,
337337
338338 pub fn init(first_address: ?usize, fp: ?usize) StackIterator {
339 if (builtin.arch == .sparcv9) {
340 // Flush all the register windows on stack.
341 asm volatile (
342 \\ flushw
343 ::: "memory");
344 }
345
339346 return StackIterator{
340347 .first_address = first_address,
341348 .fp = fp orelse @frameAddress(),
......@@ -343,18 +350,18 @@ pub const StackIterator = struct {
343350 }
344351
345352 // Offset of the saved BP wrt the frame pointer.
346 const fp_offset = if (builtin.arch.isRISCV())
353 const fp_offset = if (comptime builtin.arch.isRISCV())
347354 // On RISC-V the frame pointer points to the top of the saved register
348355 // area, on pretty much every other architecture it points to the stack
349356 // slot where the previous frame pointer is saved.
350357 2 * @sizeOf(usize)
351 else if (builtin.arch.isSPARC())
358 else if (comptime builtin.arch.isSPARC())
352359 // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.
353360 14 * @sizeOf(usize)
354361 else
355362 0;
356363
357 const fp_bias = if (builtin.arch.isSPARC())
364 const fp_bias = if (comptime builtin.arch.isSPARC())
358365 // On SPARC frame pointers are biased by a constant.
359366 2047
360367 else
......@@ -380,7 +387,7 @@ pub const StackIterator = struct {
380387 }
381388
382389 fn next_internal(self: *StackIterator) ?usize {
383 const fp = if (builtin.arch.isSPARC())
390 const fp = if (comptime builtin.arch.isSPARC())
384391 // On SPARC the offset is positive. (!)
385392 math.add(usize, self.fp, fp_offset) catch return null
386393 else
lib/std/os/linux/tls.zig+2-2
......@@ -248,7 +248,7 @@ fn initTLS() void {
248248 tls_data = @intToPtr([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz];
249249 tls_data_alloc_size = phdr.p_memsz;
250250 } else {
251 tls_align_factor = @alignOf(*usize);
251 tls_align_factor = @alignOf(usize);
252252 tls_data = &[_]u8{};
253253 tls_data_alloc_size = 0;
254254 }
......@@ -308,7 +308,7 @@ fn initTLS() void {
308308}
309309
310310fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T {
311 return @ptrCast(*T, @alignCast(@alignOf(*T), ptr));
311 return @ptrCast(*T, @alignCast(@alignOf(T), ptr));
312312}
313313
314314/// Initializes all the fields of the static TLS area and returns the computed