summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2022-12-25 04:27:45 +0300
committerDr.Smile <vabnick@gmail.com>2023-04-02 06:06:19 +0300
commit44e31ff59b424b3aafc14c38b272e33ddb786ff2 (patch)
tree3bfa9ec9d4491a86b79bdd2f389d6b70bee734db
parent5a1eb47e2b09d2724250e8513430c6585845b651 (diff)
downloadlibass-44e31ff59b424b3aafc14c38b272e33ddb786ff2.tar.bz2
libass-44e31ff59b424b3aafc14c38b272e33ddb786ff2.tar.xz
checkasm: fix non-desktop windows
-rw-r--r--checkasm/checkasm.c6
-rw-r--r--checkasm/checkasm.h14
2 files changed, 15 insertions, 5 deletions
diff --git a/checkasm/checkasm.c b/checkasm/checkasm.c
index b82567b..0539bfb 100644
--- a/checkasm/checkasm.c
+++ b/checkasm/checkasm.c
@@ -240,6 +240,7 @@ static void color_printf(const int color, const char *const fmt, ...) {
va_list arg;
#ifdef _WIN32
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
static HANDLE con;
static WORD org_attributes;
@@ -257,6 +258,7 @@ static void color_printf(const int color, const char *const fmt, ...) {
if (use_color)
SetConsoleTextAttribute(con, (org_attributes & 0xfff0) |
(color & 0x0f));
+#endif
#else
if (use_color < 0) {
const char *const term = getenv("TERM");
@@ -272,7 +274,9 @@ static void color_printf(const int color, const char *const fmt, ...) {
if (use_color) {
#ifdef _WIN32
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
SetConsoleTextAttribute(con, org_attributes);
+#endif
#else
fprintf(stderr, "\x1b[0m");
#endif
@@ -443,6 +447,7 @@ checkasm_context checkasm_context_buf;
/* Crash handling: attempt to catch crashes and handle them
* gracefully instead of just aborting abruptly. */
#ifdef _WIN32
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
static LONG NTAPI signal_handler(EXCEPTION_POINTERS *const e) {
if (!state.catch_signals)
return EXCEPTION_CONTINUE_SEARCH;
@@ -472,6 +477,7 @@ static LONG NTAPI signal_handler(EXCEPTION_POINTERS *const e) {
checkasm_load_context();
return EXCEPTION_CONTINUE_EXECUTION; /* never reached, but shuts up gcc */
}
+#endif
#else
static void signal_handler(const int s) {
if (state.catch_signals) {
diff --git a/checkasm/checkasm.h b/checkasm/checkasm.h
index 29c1dbe..26ae045 100644
--- a/checkasm/checkasm.h
+++ b/checkasm/checkasm.h
@@ -33,7 +33,12 @@
#include <stdint.h>
#include <stdlib.h>
-#if ARCH_X86_64 && defined(_WIN32)
+#if !ARCH_X86_64 || !defined(_WIN32)
+#include <setjmp.h>
+#define checkasm_context jmp_buf
+#define checkasm_save_context() setjmp(checkasm_context_buf)
+#define checkasm_load_context() longjmp(checkasm_context_buf, 1)
+#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
/* setjmp/longjmp on 64-bit Windows will try to use SEH to unwind the stack,
* which doesn't work for assembly functions without unwind information. */
#include <windows.h>
@@ -41,10 +46,9 @@
#define checkasm_save_context() RtlCaptureContext(&checkasm_context_buf)
#define checkasm_load_context() RtlRestoreContext(&checkasm_context_buf, NULL)
#else
-#include <setjmp.h>
-#define checkasm_context jmp_buf
-#define checkasm_save_context() setjmp(checkasm_context_buf)
-#define checkasm_load_context() longjmp(checkasm_context_buf, 1)
+#define checkasm_context char
+#define checkasm_save_context()
+#define checkasm_load_context()
#endif
#include "include/common/attributes.h"