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
# include <pthread.h>
#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
// ==========================================================================
#endif
/* Close down CSRNG */
-static void exit_random_source(void)
+static DESTRUCTOR void exit_random_source(void)
{
#if defined(_WIN32)
s_rtl_genrandom = NULL;
}
}
#endif
- atexit(exit_random_source);
+ AT_EXIT(exit_random_source);
}
/* Generate random bytes */