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 {...@@ -151,11 +151,7 @@ pub const ucontext_t = extern struct {
151 __mcontext_data: mcontext_t,151 __mcontext_data: mcontext_t,
152};152};
153153
154pub const mcontext_t = extern struct {154pub const mcontext_t = arch_bits.mcontext_t;
155 es: arch_bits.exception_state,
156 ss: arch_bits.thread_state,
157 fs: arch_bits.float_state,
158};
159155
160extern "c" fn __error() *c_int;156extern "c" fn __error() *c_int;
161pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;157pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
lib/std/c/darwin/aarch64.zig+13
...@@ -1,5 +1,12 @@...@@ -1,5 +1,12 @@
1// See C headers in1// See C headers in
2// lib/libc/include/aarch64-macos.12-gnu/mach/arm/_structs.h2// 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
4pub const exception_state = extern struct {11pub const exception_state = extern struct {
5 far: u64, // Virtual Fault Address12 far: u64, // Virtual Fault Address
...@@ -17,6 +24,12 @@ pub const thread_state = extern struct {...@@ -17,6 +24,12 @@ pub const thread_state = extern struct {
17 __pad: u32,24 __pad: u32,
18};25};
1926
27pub const neon_state = extern struct {
28 q: [32]u128,
29 fpsr: u32,
30 fpcr: u32,
31};
32
20pub const EXC_TYPES_COUNT = 14;33pub const EXC_TYPES_COUNT = 14;
21pub const EXC_MASK_MACHINE = 0;34pub const EXC_MASK_MACHINE = 0;
2235
lib/std/c/darwin/x86_64.zig+6
...@@ -1,5 +1,11 @@...@@ -1,5 +1,11 @@
1const c = @import("../darwin.zig");1const 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
3pub const exception_state = extern struct {9pub const exception_state = extern struct {
4 trapno: u16,10 trapno: u16,
5 cpu: u16,11 cpu: u16,
lib/std/debug.zig+8-1
...@@ -445,7 +445,14 @@ pub inline fn getContext(context: *StackTraceContext) bool {...@@ -445,7 +445,14 @@ pub inline fn getContext(context: *StackTraceContext) bool {
445 }445 }
446446
447 const result = have_getcontext and os.system.getcontext(context) == 0;447 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
450 return result;457 return result;
451}458}