Skip to content

Commit 22b2552

Browse files
committed
Style cleanup
1 parent b723b3f commit 22b2552

File tree

1 file changed

+151
-151
lines changed

1 file changed

+151
-151
lines changed

lib/std/os/win32/exception.c3

Lines changed: 151 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -6,118 +6,118 @@ const EXCEPTION_MAXIMUM_PARAMETERS = 15;
66

77
struct ExceptionRecord
88
{
9-
Win32_DWORD exception_code;
10-
Win32_DWORD exception_flags;
11-
ExceptionRecord* exception_record;
12-
void* exception_address;
13-
Win32_DWORD number_parameters;
14-
Win32_ULONG_PTR[EXCEPTION_MAXIMUM_PARAMETERS] exception_information;
9+
Win32_DWORD exception_code;
10+
Win32_DWORD exception_flags;
11+
ExceptionRecord* exception_record;
12+
void* exception_address;
13+
Win32_DWORD number_parameters;
14+
Win32_ULONG_PTR[EXCEPTION_MAXIMUM_PARAMETERS] exception_information;
1515
}
1616

1717
struct ExceptionContext @align(16)
1818
{
19-
Win32_DWORD64 p1_home;
20-
Win32_DWORD64 p2_home;
21-
Win32_DWORD64 p3_home;
22-
Win32_DWORD64 p4_home;
23-
Win32_DWORD64 p5_home;
24-
Win32_DWORD64 p6_home;
25-
26-
Win32_DWORD context_flags;
27-
Win32_DWORD mx_csr;
28-
29-
Win32_WORD seg_cs;
30-
Win32_WORD seg_ds;
31-
Win32_WORD seg_es;
32-
Win32_WORD seg_fs;
33-
Win32_WORD seg_gs;
34-
Win32_WORD seg_ss;
35-
Win32_DWORD eflags;
36-
37-
Win32_DWORD64 dr0;
38-
Win32_DWORD64 dr1;
39-
Win32_DWORD64 dr2;
40-
Win32_DWORD64 dr3;
41-
Win32_DWORD64 dr6;
42-
Win32_DWORD64 dr7;
43-
44-
Win32_DWORD64 rax;
45-
Win32_DWORD64 rcx;
46-
Win32_DWORD64 rdx;
47-
Win32_DWORD64 rbx;
48-
Win32_DWORD64 rsp;
49-
Win32_DWORD64 rbp;
50-
Win32_DWORD64 rsi;
51-
Win32_DWORD64 rdi;
52-
Win32_DWORD64 r8;
53-
Win32_DWORD64 r9;
54-
Win32_DWORD64 r10;
55-
Win32_DWORD64 r11;
56-
Win32_DWORD64 r12;
57-
Win32_DWORD64 r13;
58-
Win32_DWORD64 r14;
59-
Win32_DWORD64 r15;
60-
61-
Win32_DWORD64 rip;
62-
63-
union
64-
{
65-
struct flt_save @align(16)
66-
{
67-
Win32_WORD control_word;
68-
Win32_WORD status_word;
69-
Win32_BYTE tag_word;
70-
Win32_BYTE reserved1;
71-
Win32_WORD error_opcode;
72-
Win32_DWORD error_offset;
73-
Win32_WORD error_selector;
74-
Win32_WORD reserved2;
75-
Win32_DWORD data_offset;
76-
Win32_WORD data_selector;
77-
Win32_WORD reserved3;
78-
Win32_DWORD mx_csr;
79-
Win32_DWORD mx_csr_mask;
80-
81-
Win32_M128A[16] xmm_registers;
82-
Win32_BYTE[96] reserved4;
83-
}
84-
struct
85-
{
86-
Win32_M128A[2] header;
87-
Win32_M128A[8] legacy;
88-
Win32_M128A xmm0;
89-
Win32_M128A xmm1;
90-
Win32_M128A xmm2;
91-
Win32_M128A xmm3;
92-
Win32_M128A xmm4;
93-
Win32_M128A xmm5;
94-
Win32_M128A xmm6;
95-
Win32_M128A xmm7;
96-
Win32_M128A xmm8;
97-
Win32_M128A xmm9;
98-
Win32_M128A xmm10;
99-
Win32_M128A xmm11;
100-
Win32_M128A xmm12;
101-
Win32_M128A xmm13;
102-
Win32_M128A xmm14;
103-
Win32_M128A xmm15;
104-
}
105-
}
106-
107-
Win32_M128A[26] vector_registers;
108-
Win32_DWORD64 vector_control;
109-
110-
Win32_DWORD64 debug_control;
111-
Win32_DWORD64 last_branch_to_rip;
112-
Win32_DWORD64 last_branch_from_rip;
113-
Win32_DWORD64 last_exception_to_rip;
114-
Win32_DWORD64 last_exception_from_rip;
19+
Win32_DWORD64 p1_home;
20+
Win32_DWORD64 p2_home;
21+
Win32_DWORD64 p3_home;
22+
Win32_DWORD64 p4_home;
23+
Win32_DWORD64 p5_home;
24+
Win32_DWORD64 p6_home;
25+
26+
Win32_DWORD context_flags;
27+
Win32_DWORD mx_csr;
28+
29+
Win32_WORD seg_cs;
30+
Win32_WORD seg_ds;
31+
Win32_WORD seg_es;
32+
Win32_WORD seg_fs;
33+
Win32_WORD seg_gs;
34+
Win32_WORD seg_ss;
35+
Win32_DWORD eflags;
36+
37+
Win32_DWORD64 dr0;
38+
Win32_DWORD64 dr1;
39+
Win32_DWORD64 dr2;
40+
Win32_DWORD64 dr3;
41+
Win32_DWORD64 dr6;
42+
Win32_DWORD64 dr7;
43+
44+
Win32_DWORD64 rax;
45+
Win32_DWORD64 rcx;
46+
Win32_DWORD64 rdx;
47+
Win32_DWORD64 rbx;
48+
Win32_DWORD64 rsp;
49+
Win32_DWORD64 rbp;
50+
Win32_DWORD64 rsi;
51+
Win32_DWORD64 rdi;
52+
Win32_DWORD64 r8;
53+
Win32_DWORD64 r9;
54+
Win32_DWORD64 r10;
55+
Win32_DWORD64 r11;
56+
Win32_DWORD64 r12;
57+
Win32_DWORD64 r13;
58+
Win32_DWORD64 r14;
59+
Win32_DWORD64 r15;
60+
61+
Win32_DWORD64 rip;
62+
63+
union
64+
{
65+
struct flt_save @align(16)
66+
{
67+
Win32_WORD control_word;
68+
Win32_WORD status_word;
69+
Win32_BYTE tag_word;
70+
Win32_BYTE reserved1;
71+
Win32_WORD error_opcode;
72+
Win32_DWORD error_offset;
73+
Win32_WORD error_selector;
74+
Win32_WORD reserved2;
75+
Win32_DWORD data_offset;
76+
Win32_WORD data_selector;
77+
Win32_WORD reserved3;
78+
Win32_DWORD mx_csr;
79+
Win32_DWORD mx_csr_mask;
80+
81+
Win32_M128A[16] xmm_registers;
82+
Win32_BYTE[96] reserved4;
83+
}
84+
struct
85+
{
86+
Win32_M128A[2] header;
87+
Win32_M128A[8] legacy;
88+
Win32_M128A xmm0;
89+
Win32_M128A xmm1;
90+
Win32_M128A xmm2;
91+
Win32_M128A xmm3;
92+
Win32_M128A xmm4;
93+
Win32_M128A xmm5;
94+
Win32_M128A xmm6;
95+
Win32_M128A xmm7;
96+
Win32_M128A xmm8;
97+
Win32_M128A xmm9;
98+
Win32_M128A xmm10;
99+
Win32_M128A xmm11;
100+
Win32_M128A xmm12;
101+
Win32_M128A xmm13;
102+
Win32_M128A xmm14;
103+
Win32_M128A xmm15;
104+
}
105+
}
106+
107+
Win32_M128A[26] vector_registers;
108+
Win32_DWORD64 vector_control;
109+
110+
Win32_DWORD64 debug_control;
111+
Win32_DWORD64 last_branch_to_rip;
112+
Win32_DWORD64 last_branch_from_rip;
113+
Win32_DWORD64 last_exception_to_rip;
114+
Win32_DWORD64 last_exception_from_rip;
115115
}
116116

117117
struct ExceptionPointers
118118
{
119-
ExceptionRecord* exception_record;
120-
ExceptionContext* context_record;
119+
ExceptionRecord* exception_record;
120+
ExceptionContext* context_record;
121121
}
122122

123123
alias UnhandledExceptionFilter = fn Win32_LONG (ExceptionPointers* exception_info);
@@ -131,58 +131,58 @@ UnhandledExceptionFilter previous_filter;
131131
PanicFn previous_panic;
132132
bool has_panicked;
133133

134-
fn Win32_LONG exceptionHandler(ExceptionPointers* exception_info)
134+
fn Win32_LONG exception_handler(ExceptionPointers* exception_info)
135135
{
136-
if (!has_panicked)
137-
{
138-
@stack_mem(512; Allocator allocator)
139-
{
140-
DString s;
141-
s.init(allocator: allocator);
142-
Win32_DWORD code = exception_info.exception_record.exception_code;
143-
void* addr = exception_info.exception_record.exception_address;
144-
switch (code)
145-
{
146-
case 0x80000001: s.appendf("Guard page violation at address %p", addr);
147-
case 0x80000002: s.appendf("Datatype misalignment at address %p", addr);
148-
case 0xC0000005: s.appendf("Access Violation at address %p", addr);
149-
case 0xC0000006: s.appendf("In page error at address %p", addr);
150-
case 0xC000001D: s.appendf("Illegal instruction at address %p", addr);
151-
case 0xC000008C: s.appendf("Array bounds exceeded at address %p", addr);
152-
case 0xC000008D: s.appendf("Flt denormal operand at address %p", addr);
153-
case 0xC000008E: s.appendf("Flt divide by zero at address %p", addr);
154-
case 0xC0000090: s.appendf("Flt invalid operation at address %p", addr);
155-
case 0xC0000094: s.appendf("Integer divide by zero at address %p", addr);
156-
case 0xC00000FD: s.appendf("Stack overflow at address %p", addr);
157-
case 0xC0000096: s.appendf("Privileged instruction at address %p", addr);
158-
case 0xC0000374: s.appendf("Heap corruption detected at address %p", addr);
159-
case 0xC0000409: s.appendf("Stack buffer overflow at address %p", addr);
160-
case 0xC00004A2: s.appendf("Enclave violation at address %p", addr);
161-
default:
162-
s.appendf("Unhandled exception (%X) at %p", code, addr);
163-
}
164-
if (!builtin::print_backtrace(s.str_view(), 8))
165-
{
166-
io::eprintfn("\nERROR: %s", s.str_view());
167-
}
168-
};
169-
}
170-
if (previous_filter)
171-
{
172-
return previous_filter(exception_info);
173-
}
174-
return EXCEPTION_EXECUTE_HANDLER;
136+
if (!has_panicked)
137+
{
138+
@stack_mem(512; Allocator allocator)
139+
{
140+
DString s;
141+
s.init(allocator: allocator);
142+
Win32_DWORD code = exception_info.exception_record.exception_code;
143+
void* addr = exception_info.exception_record.exception_address;
144+
switch (code)
145+
{
146+
case 0x80000001: s.appendf("Guard page violation at address %p", addr);
147+
case 0x80000002: s.appendf("Datatype misalignment at address %p", addr);
148+
case 0xC0000005: s.appendf("Access Violation at address %p", addr);
149+
case 0xC0000006: s.appendf("In page error at address %p", addr);
150+
case 0xC000001D: s.appendf("Illegal instruction at address %p", addr);
151+
case 0xC000008C: s.appendf("Array bounds exceeded at address %p", addr);
152+
case 0xC000008D: s.appendf("Flt denormal operand at address %p", addr);
153+
case 0xC000008E: s.appendf("Flt divide by zero at address %p", addr);
154+
case 0xC0000090: s.appendf("Flt invalid operation at address %p", addr);
155+
case 0xC0000094: s.appendf("Integer divide by zero at address %p", addr);
156+
case 0xC00000FD: s.appendf("Stack overflow at address %p", addr);
157+
case 0xC0000096: s.appendf("Privileged instruction at address %p", addr);
158+
case 0xC0000374: s.appendf("Heap corruption detected at address %p", addr);
159+
case 0xC0000409: s.appendf("Stack buffer overflow at address %p", addr);
160+
case 0xC00004A2: s.appendf("Enclave violation at address %p", addr);
161+
default:
162+
s.appendf("Unhandled exception (%X) at %p", code, addr);
163+
}
164+
if (!builtin::print_backtrace(s.str_view(), 8))
165+
{
166+
io::eprintfn("\nERROR: %s", s.str_view());
167+
}
168+
};
169+
}
170+
if (previous_filter)
171+
{
172+
return previous_filter(exception_info);
173+
}
174+
return EXCEPTION_EXECUTE_HANDLER;
175175
}
176176

177-
fn void panicTracker(String message, String file, String function, uint line)
177+
fn void panic_tracker(String message, String file, String function, uint line)
178178
{
179-
has_panicked = true;
180-
previous_panic(message, file, function, line);
179+
has_panicked = true;
180+
previous_panic(message, file, function, line);
181181
}
182182

183-
fn void initExceptionHandler() @init
183+
fn void init_exception_handler() @init
184184
{
185-
previous_filter = setUnhandledExceptionFilter(&exceptionHandler);
186-
previous_panic = builtin::panic;
187-
builtin::panic = &panicTracker;
185+
previous_filter = setUnhandledExceptionFilter(&exception_handler);
186+
previous_panic = builtin::panic;
187+
builtin::panic = &panic_tracker;
188188
}

0 commit comments

Comments
 (0)