Small code clean-up + improved the Makefile + detect GNU/Hurd operating system.

This commit is contained in:
LoRd_MuldeR 2022-04-23 17:30:51 +02:00
parent 5fbe240b51
commit afdce47caa
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
4 changed files with 13 additions and 12 deletions

View File

@ -26,7 +26,7 @@ SUBDIR_LIB := libslunkcrypt
# ---------------------------------------------------------------------------
CONFIG =
LDFLGS =
LDFLGS = -lpthread
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall
ifneq ($(CPU),0)
@ -71,8 +71,8 @@ else
SUFFIX :=
endif
ifneq ($(MACHINE),$(filter %mingw32 %-windows-gnu,$(MACHINE)))
LDFLGS += -lpthread
ifeq ($(THREAD),0)
CFLAGS += -DSLUNKBUILD_NOTHREADS
endif
ifneq ($(STRIP),0)
@ -87,10 +87,6 @@ ifeq ($(MACHINE),$(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)))
LDFLGS += -mconsole -municode
endif
ifeq ($(THREAD),0)
CFLAGS += -DSLUNKBUILD_NOTHREADS
endif
# ---------------------------------------------------------------------------
# File names
# ---------------------------------------------------------------------------

View File

@ -26,6 +26,7 @@ The SlunkCrypt library and the command-line application currently run on the fol
* **Linux** (kernel version 3.17, or later) — 32-Bit (i686) and 64-Bit (AMD64)
* **Various BSD flavors** (tested on NetBSD 9.2, FreeBSD 13.0 and OpenBSD 7.0) — 32-Bit (i686) and 64-Bit (AMD64)
* **Solaris** (tested on Solaris 11.4 and OmniOS/illumos) — 32-Bit (i686) and 64-Bit (AMD64)
* **GNU/Hurd** (tested on Debian GNU/Hurd 0.9) — 32-Bit (i686)
* **Mac OS X** (tested on macOS 11 “Big Sur”) — Intel x86-64 (AMD64) and Apple Silicon (AArch64)
The SlunkCrypt GUI application currently runs on the following platforms:

View File

@ -25,6 +25,8 @@
# define OS_TYPE_NAME "Cygwin"
#elif defined(__linux__)
# define OS_TYPE_NAME "Linux"
#elif defined(__gnu_hurd__)
# define OS_TYPE_NAME "GNU/Hurd"
#elif defined(__FreeBSD__)
# define OS_TYPE_NAME "FreeBSD"
#elif defined(__DragonFly__)

View File

@ -21,14 +21,16 @@ uint128_t;
// 128-Bit math support
// ==========================================================================
#define READ_U128(X) ((((__uint128_t)(X).hi) << 64U) | ((__uint128_t)(X).lo))
#if defined(__GNUC__) && defined(__SIZEOF_INT128__)
# define HAVE_UINT128_SUPPORT 1
# define PACK_U128(X) ((((__uint128_t)(X).hi) << 64) | (X).lo)
#endif
static INLINE void multiply_u128(uint128_t *const out, const uint128_t lhs, const uint128_t rhs)
{
#if defined(__GNUC__) && defined(__SIZEOF_INT128__)
const __uint128_t tmp = READ_U128(lhs) * READ_U128(rhs);
out->hi = (uint64_t)(tmp >> 64U);
out->lo = (uint64_t)(tmp & 0xFFFFFFFFFFFFFFFF);
#ifdef HAVE_UINT128_SUPPORT
const __uint128_t product = PACK_U128(lhs) * PACK_U128(rhs);
*out = (uint128_t) { product >> 64, product };
#else
const uint64_t lolo = (lhs.lo & 0xFFFFFFFF) * (rhs.lo & 0xFFFFFFFF);
const uint64_t hilo = (lhs.lo >> 32U) * (rhs.lo & 0xFFFFFFFF);