Use __attribute__((destructor)), if supported by the compiler.
This commit is contained in:
parent
9e1894b539
commit
9c08cb9dd4
4
Makefile
4
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
|
||||
|
||||
|
@ -20,6 +20,15 @@
|
||||
# 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
|
||||
// ==========================================================================
|
||||
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user