authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-04 13:40:50-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-20 22:58:14-04:00
log576ffaa3298b4e99b7e46d4eccad4763b18985f8
tree5abb00cc3c329894f5d5bb2ad4743c3bd343481e
parent412cd789bf38a8fb6126803b8eab601b700e5a9e

darwin: update mcontext_t definition for aarch64 to add neon state


4 files changed, 28 insertions(+), 6 deletions(-)

lib/std/c/darwin.zig+1-5
......@@ -151,11 +151,7 @@ pub const ucontext_t = extern struct {
151151 __mcontext_data: mcontext_t,
152152};
153153
154pub const mcontext_t = extern struct {
155 es: arch_bits.exception_state,
156 ss: arch_bits.thread_state,
157 fs: arch_bits.float_state,
158};
154pub const mcontext_t = arch_bits.mcontext_t;
159155
160156extern "c" fn __error() *c_int;
161157pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
lib/std/c/darwin/aarch64.zig+13
......@@ -1,5 +1,12 @@
11// See C headers in
22// lib/libc/include/aarch64-macos.12-gnu/mach/arm/_structs.h
3// lib/libc/include/aarch64-macos.13-none/arm/_mcontext.h
4
5pub const mcontext_t = extern struct {
6 es: exception_state,
7 ss: thread_state,
8 ns: neon_state,
9};
310
411pub const exception_state = extern struct {
512 far: u64, // Virtual Fault Address
......@@ -17,6 +24,12 @@ pub const thread_state = extern struct {
1724 __pad: u32,
1825};
1926
27pub const neon_state = extern struct {
28 q: [32]u128,
29 fpsr: u32,
30 fpcr: u32,
31};
32
2033pub const EXC_TYPES_COUNT = 14;
2134pub const EXC_MASK_MACHINE = 0;
2235
lib/std/c/darwin/x86_64.zig+6
......@@ -1,5 +1,11 @@
11const c = @import("../darwin.zig");
22
3pub const mcontext_t = extern struct {
4 es: exception_state,
5 ss: thread_state,
6 fs: float_state,
7};
8
39pub const exception_state = extern struct {
410 trapno: u16,
511 cpu: u16,
lib/std/debug.zig+8-1
......@@ -445,7 +445,14 @@ pub inline fn getContext(context: *StackTraceContext) bool {
445445 }
446446
447447 const result = have_getcontext and os.system.getcontext(context) == 0;
448 if (native_os == .macos) assert(context.mcsize == @sizeOf(std.c.mcontext_t));
448 if (native_os == .macos) {
449 // TODO: Temp, to discover this size via aarch64 CI
450 if (context.mcsize != @sizeOf(std.c.mcontext_t)) {
451 print("context.mcsize does not match! {} vs {}\n", .{ context.mcsize, @sizeOf(std.c.mcontext_t)});
452 }
453
454 assert(context.mcsize == @sizeOf(std.c.mcontext_t));
455 }
449456
450457 return result;
451458}