From 801f81271498b438b6c2b641e630acf8bbc3f5ae Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Fri, 12 Nov 2021 20:40:51 +0100 Subject: [PATCH] Replaced 'glibc' checks with more general 'linux' checks in order to better support alternative C libraries (e.g. musl libc). --- Makefile | 2 +- libslunkcrypt/src/junk.c | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 8e74d83..ac0f02e 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ ifneq ($(NALYZE),0) CFLAGS += -fanalyzer endif -MACHINE := $(shell $(CC) -dumpmachine) +MACHINE := $(shell $(CC) -dumpmachine || echo unknown) ifeq ($(MACHINE),$(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE))) SUFFIX := .exe diff --git a/libslunkcrypt/src/junk.c b/libslunkcrypt/src/junk.c index 86af2af..e593eb9 100644 --- a/libslunkcrypt/src/junk.c +++ b/libslunkcrypt/src/junk.c @@ -41,23 +41,15 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ? /* detect getentropy() support */ #undef GETENTROPY -#if defined(__linux__) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25) -# define GETENTROPY getentropy -#elif defined(__FreeBSD__) && (__FreeBSD__ >= 12) -# define GETENTROPY getentropy -#elif defined(__OpenBSD__) && (__OpenBSD__ >= 1) +#if (defined(__linux__) && (__linux__ >= 1)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || (defined(__OpenBSD__) && (__OpenBSD__ >= 1)) # define GETENTROPY getentropy #endif /* detect explicit_bzero() support */ #undef EXPLICIT_BZERO -#if defined(_WIN32) && defined(SecureZeroMemory) +#if defined(_WIN32) && (_WIN32 >= 1) && defined(SecureZeroMemory) # define EXPLICIT_BZERO SecureZeroMemory -#elif defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25) -# define EXPLICIT_BZERO explicit_bzero -#elif defined(__FreeBSD__) && (__FreeBSD__ >= 11) -# define EXPLICIT_BZERO explicit_bzero -#elif defined(__OpenBSD__) && (__OpenBSD__ >= 1) +#elif (defined(__linux__) && (__linux__ >= 1)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 11)) || (defined(__OpenBSD__) && (__OpenBSD__ >= 1)) # define EXPLICIT_BZERO explicit_bzero #endif