|
42 | 42 | #include "../../gc-incl.inc"
|
43 | 43 | #include "win_util.c"
|
44 | 44 |
|
45 |
| -/* From winerror.h */ |
46 |
| -// |
47 |
| -// Note: There is a slightly modified layout for HRESULT values below, |
48 |
| -// after the heading "COM Error Codes". |
49 |
| -// |
50 |
| -// Search for "**** Available SYSTEM error codes ****" to find where to |
51 |
| -// insert new error codes |
52 |
| -// |
53 |
| -// Values are 32 bit values laid out as follows: |
54 |
| -// |
55 |
| -// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 |
56 |
| -// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 |
57 |
| -// +---+-+-+-----------------------+-------------------------------+ |
58 |
| -// |Sev|C|R| Facility | Code | |
59 |
| -// +---+-+-+-----------------------+-------------------------------+ |
60 |
| -// |
61 |
| -// where |
62 |
| -// |
63 |
| -// Sev - is the severity code |
64 |
| -// |
65 |
| -// 00 - Success |
66 |
| -// 01 - Informational |
67 |
| -// 10 - Warning |
68 |
| -// 11 - Error |
69 |
| -// |
70 |
| -// C - is the Customer code flag |
71 |
| -// |
72 |
| -// R - is a reserved bit |
73 |
| -// |
74 |
| -// Facility - is the facility code |
75 |
| -// |
76 |
| -// Code - is the facility's status code |
77 |
| -// |
78 |
| -// |
79 |
| -// Define the facility codes |
80 |
| -// |
81 |
| -#define MAKE_HRESULT_CODE(sev, fac, code) \ |
82 |
| - ((DWORD)( ((sev) << 30) | /* sev code */ \ |
83 |
| - (1 << 29) | /* 1 = customer */ \ |
84 |
| - (0 << 28) | /* R */ \ |
85 |
| - ((fac) << 16) | /* facility */ \ |
86 |
| - ((code) << 0 ) /* code */ \ |
87 |
| - )) |
88 |
| -#define SEV_ERROR 0x03 |
89 |
| -#define TERMINATION_CODE MAKE_HRESULT_CODE(SEV_ERROR, 0xBAD, 0xDEAD) |
90 |
| -#define SIZEOF_EXCEPTION_INFO 2 |
| 45 | +#define EXCEPTION_INFO_N SG_TERMINATION_INFO_N |
91 | 46 | #define EXCEPTION_CANCEL 0
|
92 | 47 | #define EXCEPTION_EXIT 1
|
93 | 48 |
|
@@ -123,9 +78,9 @@ void Sg_DestroyMutex(SgInternalMutex *mutex)
|
123 | 78 | static DWORD exception_filter(EXCEPTION_POINTERS *ep, ULONG_PTR *ei)
|
124 | 79 | {
|
125 | 80 | switch (ep->ExceptionRecord->ExceptionCode) {
|
126 |
| - case TERMINATION_CODE: { |
| 81 | + case SG_THREAD_TERMINAT_CODE: { |
127 | 82 | DWORD i;
|
128 |
| - DWORD n = min(ep->ExceptionRecord->NumberParameters, SIZEOF_EXCEPTION_INFO); |
| 83 | + DWORD n = min(ep->ExceptionRecord->NumberParameters, EXCEPTION_INFO_N); |
129 | 84 | for (i = 0; i < n; i++) {
|
130 | 85 | ei[i] = ep->ExceptionRecord->ExceptionInformation[i];
|
131 | 86 | }
|
@@ -163,7 +118,7 @@ static unsigned int __stdcall win32_thread_entry(void *params)
|
163 | 118 | {
|
164 | 119 | unsigned int status;
|
165 | 120 | SgInternalThread *me = ((ThreadParams *)params)->me;
|
166 |
| - ULONG_PTR ei[SIZEOF_EXCEPTION_INFO]; |
| 121 | + ULONG_PTR ei[EXCEPTION_INFO_N]; |
167 | 122 | __try {
|
168 | 123 | status = win32_thread_entry_inner(params);
|
169 | 124 | } __except(exception_filter(GetExceptionInformation(), ei)) {
|
@@ -368,11 +323,11 @@ int Sg_WaitWithTimeout(SgInternalCond *cond, SgInternalMutex *mutex,
|
368 | 323 |
|
369 | 324 | static void throw_exception(int code, int status)
|
370 | 325 | {
|
371 |
| - ULONG_PTR exceptionInfo[SIZEOF_EXCEPTION_INFO]; |
| 326 | + ULONG_PTR exceptionInfo[EXCEPTION_INFO_N]; |
372 | 327 | exceptionInfo[0] = code;
|
373 | 328 | exceptionInfo[1] = status;
|
374 | 329 |
|
375 |
| - RaiseException(TERMINATION_CODE, 0, SIZEOF_EXCEPTION_INFO, exceptionInfo); |
| 330 | + RaiseException(SG_THREAD_TERMINAT_CODE, 0, EXCEPTION_INFO_N, exceptionInfo); |
376 | 331 | }
|
377 | 332 |
|
378 | 333 | void Sg_ExitThread(SgInternalThread *thread, void *ret)
|
|
0 commit comments