diff --git a/Makefile b/Makefile index 9332f7b..8f26ff6 100644 --- a/Makefile +++ b/Makefile @@ -33,13 +33,13 @@ endif MACHINE := $(shell $(CC) -dumpmachine) -ifneq ($(filter %-mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),) +ifneq ($(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),) SUFFIX := .exe else SUFFIX := endif -ifeq ($(filter %-mingw32 %-windows-gnu,$(MACHINE)),) +ifeq ($(filter %mingw32 %-windows-gnu,$(MACHINE)),) LDFLGS += -lpthread endif diff --git a/libslunkcrypt/src/junk.c b/libslunkcrypt/src/junk.c index 98a4f1b..869028c 100644 --- a/libslunkcrypt/src/junk.c +++ b/libslunkcrypt/src/junk.c @@ -20,6 +20,15 @@ # include #endif +/* Compiler compatibility */ +#if defined(__GNUC__) || defined(__clang__) +# define AT_EXIT(X) ((void)0) +# define DESTRUCTOR __attribute__((destructor)) +#else +# define AT_EXIT(X) atexit((X)) +# define DESTRUCTOR +#endif + // ========================================================================== // One-time init // ========================================================================== @@ -82,7 +91,7 @@ static int s_random_fd = -1; #endif /* Close down CSRNG */ -static void exit_random_source(void) +static DESTRUCTOR void exit_random_source(void) { #if defined(_WIN32) s_rtl_genrandom = NULL; @@ -117,7 +126,7 @@ static void init_random_source(void) } } #endif - atexit(exit_random_source); + AT_EXIT(exit_random_source); } /* Generate random bytes */