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
signaturebadge-question-mark 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 {...@@ -336,6 +336,13 @@ pub const StackIterator = struct {
336 fp: usize,336 fp: usize,
337337
338 pub fn init(first_address: ?usize, fp: ?usize) StackIterator {338 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
339 return StackIterator{346 return StackIterator{
340 .first_address = first_address,347 .first_address = first_address,
341 .fp = fp orelse @frameAddress(),348 .fp = fp orelse @frameAddress(),
...@@ -343,18 +350,18 @@ pub const StackIterator = struct {...@@ -343,18 +350,18 @@ pub const StackIterator = struct {
343 }350 }
344351
345 // Offset of the saved BP wrt the frame pointer.352 // 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())
347 // On RISC-V the frame pointer points to the top of the saved register354 // On RISC-V the frame pointer points to the top of the saved register
348 // area, on pretty much every other architecture it points to the stack355 // area, on pretty much every other architecture it points to the stack
349 // slot where the previous frame pointer is saved.356 // slot where the previous frame pointer is saved.
350 2 * @sizeOf(usize)357 2 * @sizeOf(usize)
351 else if (builtin.arch.isSPARC())358 else if (comptime builtin.arch.isSPARC())
352 // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.359 // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.
353 14 * @sizeOf(usize)360 14 * @sizeOf(usize)
354 else361 else
355 0;362 0;
356363
357 const fp_bias = if (builtin.arch.isSPARC())364 const fp_bias = if (comptime builtin.arch.isSPARC())
358 // On SPARC frame pointers are biased by a constant.365 // On SPARC frame pointers are biased by a constant.
359 2047366 2047
360 else367 else
...@@ -380,7 +387,7 @@ pub const StackIterator = struct {...@@ -380,7 +387,7 @@ pub const StackIterator = struct {
380 }387 }
381388
382 fn next_internal(self: *StackIterator) ?usize {389 fn next_internal(self: *StackIterator) ?usize {
383 const fp = if (builtin.arch.isSPARC())390 const fp = if (comptime builtin.arch.isSPARC())
384 // On SPARC the offset is positive. (!)391 // On SPARC the offset is positive. (!)
385 math.add(usize, self.fp, fp_offset) catch return null392 math.add(usize, self.fp, fp_offset) catch return null
386 else393 else
lib/std/os/linux/tls.zig+2-2
...@@ -248,7 +248,7 @@ fn initTLS() void {...@@ -248,7 +248,7 @@ fn initTLS() void {
248 tls_data = @intToPtr([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz];248 tls_data = @intToPtr([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz];
249 tls_data_alloc_size = phdr.p_memsz;249 tls_data_alloc_size = phdr.p_memsz;
250 } else {250 } else {
251 tls_align_factor = @alignOf(*usize);251 tls_align_factor = @alignOf(usize);
252 tls_data = &[_]u8{};252 tls_data = &[_]u8{};
253 tls_data_alloc_size = 0;253 tls_data_alloc_size = 0;
254 }254 }
...@@ -308,7 +308,7 @@ fn initTLS() void {...@@ -308,7 +308,7 @@ fn initTLS() void {
308}308}
309309
310fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T {310fn 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));
312}312}
313313
314/// Initializes all the fields of the static TLS area and returns the computed314/// Initializes all the fields of the static TLS area and returns the computed