Windows terminal support

This commit is contained in:
2026-02-27 20:30:39 -06:00
parent b64aa67741
commit f68476b4a0
2 changed files with 30 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
# Compiler Flags # Compiler Flags
CC := gcc CC := gcc
CFLAGS := -g -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -fno-omit-frame-pointer CFLAGS := -g -Wall -Wextra -Werror -pedantic -fno-omit-frame-pointer
# Directory variables # Directory variables
LIBDIR := lib LIBDIR := lib
@@ -54,23 +54,32 @@ $(TEST)/bin:
mkdir $@ mkdir $@
# Run the tests in the bin folder and track results # Run the tests in the bin folder and track results
test: $(LIB) $(TEST)/bin $(TESTBINS) test: $(LIB) $(TESTBINS)
@SUCCESS_COUNT=0; FAILURE_COUNT=0; \ @SUCCESS=0; FAILURE=0; \
for test in $(TESTBINS); do \ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'; \
./$$test; \ for t in $(TESTBINS); do \
EXIT_CODE=$$?; \ NAME=$$(basename $$t); \
TEST_NAME=$(notdir $$test); \ START=$$(date +%s%N); \
if [ $$EXIT_CODE -eq 0 ]; then \ if $$t; then \
echo "\033[0;32m$$TEST_NAME: EXIT CODE: $$EXIT_CODE (SUCCESS)\033[0m"; \ RET=0; \
SUCCESS_COUNT=$$((SUCCESS_COUNT + 1)); \
else \ else \
echo "\033[0;31m$$TEST_NAME: EXIT CODE: $$EXIT_CODE (FAILURE)\033[0m"; \ RET=$$?; \
FAILURE_COUNT=$$((FAILURE_COUNT + 1)); \ fi; \
END=$$(date +%s%N); \
ELAPSED_NS=$$((END - START)); \
ELAPSED_MS=$$((ELAPSED_NS / 1000000)); \
if [ $$RET -eq 0 ]; then \
printf "%-20s %bPASS%b (%b%4d ms%b)\n" "$$NAME" "$$GREEN" "$$NC" "$$YELLOW" "$$ELAPSED_MS" "$$NC"; \
SUCCESS=$$((SUCCESS + 1)); \
else \
printf "%-20s %bFAIL%b (%b%4d ms%b)\n" "$$NAME" "$$RED" "$$NC" "$$YELLOW" "$$ELAPSED_MS" "$$NC"; \
FAILURE=$$((FAILURE + 1)); \
fi; \ fi; \
done; \ done; \
echo "\n\nTests completed"; \ printf "\nTests completed\n"; \
echo "SUCCESS: $$SUCCESS_COUNT"; \ printf "SUCCESS: %b%d%b\n" "$$GREEN" "$$SUCCESS" "$$NC"; \
echo "FAILURE: $$FAILURE_COUNT"; printf "FAILURE: %b%d%b\n" "$$RED" "$$FAILURE" "$$NC"; \
test $$FAILURE -eq 0
clean: clean:
$(RM) -r $(LIBDIR) $(OBJ) $(TEST)/bin/ $(RM) -r $(LIBDIR) $(OBJ) $(TEST)/bin/

View File

@@ -17,7 +17,7 @@ void except_raise(const struct Exception *e, const char *file,int line)
#ifdef WIN32 #ifdef WIN32
Except_Frame *p; Except_Frame *p;
if (except_index == -1) if (except_index == TLS_OUT_OF_INDEXES)
except_init(); except_init();
p = TlsGetValue(except_index); p = TlsGetValue(except_index);
#else #else
@@ -46,6 +46,8 @@ void except_raise(const struct Exception *e, const char *file,int line)
#endif #endif
longjmp(p->env, EXCEPT_STATE_RAISED); longjmp(p->env, EXCEPT_STATE_RAISED);
} }
#ifdef WIN32 #ifdef WIN32
_CRTIMP void __cdecl _assert(void *, void *, unsigned); _CRTIMP void __cdecl _assert(void *, void *, unsigned);
#undef assert #undef assert
@@ -61,7 +63,7 @@ void except_init(void) {
assert(cond == TRUE); assert(cond == TRUE);
} }
void Except_push(Except_Frame *fp) { void except_push(Except_Frame *fp) {
BOOL cond; BOOL cond;
fp->prev = TlsGetValue(except_index); fp->prev = TlsGetValue(except_index);
@@ -69,7 +71,7 @@ void Except_push(Except_Frame *fp) {
assert(cond == TRUE); assert(cond == TRUE);
} }
void Except_pop(void) { void except_pop(void) {
BOOL cond; BOOL cond;
Except_Frame *tos = TlsGetValue(except_index); Except_Frame *tos = TlsGetValue(except_index);