Small code clean-up + improved the Makefile + detect GNU/Hurd operating system.
This commit is contained in:
parent
5fbe240b51
commit
afdce47caa
10
Makefile
10
Makefile
@ -26,7 +26,7 @@ SUBDIR_LIB := libslunkcrypt
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
CONFIG =
|
CONFIG =
|
||||||
LDFLGS =
|
LDFLGS = -lpthread
|
||||||
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall
|
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall
|
||||||
|
|
||||||
ifneq ($(CPU),0)
|
ifneq ($(CPU),0)
|
||||||
@ -71,8 +71,8 @@ else
|
|||||||
SUFFIX :=
|
SUFFIX :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(MACHINE),$(filter %mingw32 %-windows-gnu,$(MACHINE)))
|
ifeq ($(THREAD),0)
|
||||||
LDFLGS += -lpthread
|
CFLAGS += -DSLUNKBUILD_NOTHREADS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(STRIP),0)
|
ifneq ($(STRIP),0)
|
||||||
@ -87,10 +87,6 @@ ifeq ($(MACHINE),$(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)))
|
|||||||
LDFLGS += -mconsole -municode
|
LDFLGS += -mconsole -municode
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(THREAD),0)
|
|
||||||
CFLAGS += -DSLUNKBUILD_NOTHREADS
|
|
||||||
endif
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# File names
|
# File names
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
@ -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)
|
* **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)
|
* **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)
|
* **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)
|
* **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:
|
The SlunkCrypt GUI application currently runs on the following platforms:
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
# define OS_TYPE_NAME "Cygwin"
|
# define OS_TYPE_NAME "Cygwin"
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
# define OS_TYPE_NAME "Linux"
|
# define OS_TYPE_NAME "Linux"
|
||||||
|
#elif defined(__gnu_hurd__)
|
||||||
|
# define OS_TYPE_NAME "GNU/Hurd"
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
# define OS_TYPE_NAME "FreeBSD"
|
# define OS_TYPE_NAME "FreeBSD"
|
||||||
#elif defined(__DragonFly__)
|
#elif defined(__DragonFly__)
|
||||||
|
@ -21,14 +21,16 @@ uint128_t;
|
|||||||
// 128-Bit math support
|
// 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)
|
static INLINE void multiply_u128(uint128_t *const out, const uint128_t lhs, const uint128_t rhs)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__) && defined(__SIZEOF_INT128__)
|
#ifdef HAVE_UINT128_SUPPORT
|
||||||
const __uint128_t tmp = READ_U128(lhs) * READ_U128(rhs);
|
const __uint128_t product = PACK_U128(lhs) * PACK_U128(rhs);
|
||||||
out->hi = (uint64_t)(tmp >> 64U);
|
*out = (uint128_t) { product >> 64, product };
|
||||||
out->lo = (uint64_t)(tmp & 0xFFFFFFFFFFFFFFFF);
|
|
||||||
#else
|
#else
|
||||||
const uint64_t lolo = (lhs.lo & 0xFFFFFFFF) * (rhs.lo & 0xFFFFFFFF);
|
const uint64_t lolo = (lhs.lo & 0xFFFFFFFF) * (rhs.lo & 0xFFFFFFFF);
|
||||||
const uint64_t hilo = (lhs.lo >> 32U) * (rhs.lo & 0xFFFFFFFF);
|
const uint64_t hilo = (lhs.lo >> 32U) * (rhs.lo & 0xFFFFFFFF);
|
||||||
|
Loading…
Reference in New Issue
Block a user