diff --git a/Makefile b/Makefile index 307132f..dde7e2b 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,8 @@ endif ifeq ($(UNAME),Windows) CFLAGS += -DATHR_OS_WIN32 CFLAGS += -DATHR_TERMINAL_WIN32 + SRC := $(filter-out athr_terminal_ioctl.c,$(SRC)) + HDR := $(filter-out athr_terminal_ioctl.h,$(SRC)) else CFLAGS += -DATHR_OS_UNIX ifeq ($(CURSES_FOUND),true) @@ -58,9 +60,9 @@ $(info CC = $(CC)) $(info PKG_CONFIG_FOUND = $(PKG_CONFIG_FOUND)) $(info CURSES_FOUND = $(CURSES_FOUND)) $(info CURSES_LIBS = $(CURSES_LIBS)) -$(info ATHR_TERMINAL = $(ATHR_TERMINAL)) $(info CFLAGS = $(CFLAGS)) +.PHONY: all all: $(LIB) $(LIB): $(OBJ) @@ -74,6 +76,7 @@ $(LIB): $(OBJ) $(TEST_TARGET): %: %.o $(LIB) $(CC) $(CFLAGS) $< -L. -lathr $(CURSES_LIBS) -lm -o $@ +.PHONY: check check: $(TEST_TARGET) for test in $(TEST_TARGET); do ./$$test || exit 1; done @@ -82,9 +85,10 @@ install: $(LIB) $(HDR) install -m 0755 $(LIB) $(PREFIX)/lib/ install -m 0644 $(HDR) $(PREFIX)/include/ +.PHONY: uninstall uninstall: rm -f $(PREFIX)/lib/$(LIB) $(HDR:%=$(PREFIX)/include/%) -.PHONY: all clean check uninstall +.PHONY: clean clean: rm -f $(OBJ) $(LIB) $(TEST_OBJ) $(TEST_TARGET) *.d diff --git a/athr.c b/athr.c index 69f72ce..79d917f 100644 --- a/athr.c +++ b/athr.c @@ -2,7 +2,7 @@ #include "athr_elapsed.h" #include "athr_ema.h" #include "athr_logger.h" -#include "athr_thr.h" +#include "athr_thread.h" #include "athr_widget_bar.h" #include "athr_widget_eta.h" #include "athr_widget_main.h" diff --git a/athr.h b/athr.h index bbb39b2..4235ace 100644 --- a/athr.h +++ b/athr.h @@ -3,7 +3,7 @@ #include "athr_ema.h" #include "athr_option.h" -#include "athr_thr.h" +#include "athr_thread.h" #include "athr_widget_main.h" #include diff --git a/athr_thr.c b/athr_thread.c similarity index 76% rename from athr_thr.c rename to athr_thread.c index 9fef8d8..8283381 100644 --- a/athr_thr.c +++ b/athr_thread.c @@ -1,4 +1,4 @@ -#include "athr_thr.h" +#include "athr_thread.h" #if defined(ATHR_OS_WIN32) #define WRAPPER_RETURN DWORD WINAPI @@ -10,8 +10,8 @@ static WRAPPER_RETURN __thr_wrapper(WRAPPER_ARG_T arg) { - struct athr_thread *thr = (struct athr_thread *)arg; - thr->func(thr->arg); + struct athr_thread *x = (struct athr_thread *)arg; + x->func(x->arg); #if defined(ATHR_OS_WIN32) ExitThread(0); @@ -30,8 +30,8 @@ int athr_thread_create(struct athr_thread *x, athr_thread_start *func, void *arg int rc = 0; #if defined(ATHR_OS_WIN32) - thr->handle = CreateThread(NULL, 0, __thr_wrapper, (LPVOID)thr, 0, NULL); - rc = !thr->handle; + x->handle = CreateThread(NULL, 0, __thr_wrapper, (LPVOID)x, 0, NULL); + rc = !x->handle; #elif defined(ATHR_OS_UNIX) rc = pthread_create(&x->handle, 0, __thr_wrapper, (void *)x); #endif @@ -43,7 +43,7 @@ void athr_thread_detach(struct athr_thread *x) { if (!x->has_been_created) return; #if defined(ATHR_OS_WIN32) - CloseHandle(thr->handle); + CloseHandle(x->handle); #elif defined(ATHR_OS_UNIX) pthread_detach(x->handle); #endif @@ -52,8 +52,8 @@ void athr_thread_detach(struct athr_thread *x) int athr_thread_join(struct athr_thread *x) { #if defined(ATHR_OS_WIN32) - if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED) return 1; - CloseHandle(thr->handle); + if (WaitForSingleObject(x, INFINITE) == WAIT_FAILED) return 1; + CloseHandle(x->handle); return 0; #elif defined(ATHR_OS_UNIX) void *pres = NULL; diff --git a/athr_thr.h b/athr_thread.h similarity index 100% rename from athr_thr.h rename to athr_thread.h