--- /dev/null
+#!/bin/sh
+set -e
+cd -- "$(dirname -- "${0}")/../../.."
+
+if [ -z "${cc_path}" ]; then
+ cc_path="/usr/local/bin/gcc12"
+fi
+
+mk_slunk() {
+ gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} STATIC=1 STRIP=1
+ cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
+}
+
+rm -rf "out" && mkdir -p "out"
+
+gmake CC="${cc_path}" clean
+
+mk_slunk 32 "i686" "pentiumpro" "pentium3"
+mk_slunk 64 "x86_64" "x86-64" "nocona"
+
+echo "Build completed successfully."
--- /dev/null
+#!/bin/bash
+set -e
+cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
+
+if [ -z "${cc_path}" ]; then
+ cc_path="/usr/gcc/11/bin/gcc"
+fi
+
+mk_slunk() {
+ gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} FLTO=1 STRIP=1
+ cp -f "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
+}
+
+rm -rf "out" && mkdir -p "out"
+
+gmake CC="${cc_path}" clean
+
+mk_slunk 32 "i686" "pentiumpro" "pentium3"
+mk_slunk 64 "x86_64" "x86-64" "nocona"
+
+echo "Build completed successfully."
#else
# include <unistd.h>
# include <sched.h>
+# include <strings.h>
+#endif
+
+#if defined(__APPLE__) && defined(__MACH__)
+# include <sys/random.h>
#endif
/* detect compiler destructor support */
#undef HAVE_WIN32RTLGENRANDOM
#if defined(_WIN32)
# define HAVE_WIN32RTLGENRANDOM 1
-#elif (defined(__linux__) && !defined(__UCLIBC__)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4))
+#elif (defined(__linux__) && !defined(__UCLIBC__)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4)) || (defined(__APPLE__) && defined(__MACH__))
# define HAVE_GETENTROPY 1
#else
# pragma message("Function getentropy() is *not* available -> using fallback!")
/* detect sched_yield() or Sleep() support */
#ifdef _WIN32
-# define SCHED_YIELD() Sleep(0)
+# define THREAD_YIELD() Sleep(0)
#else
-# define SCHED_YIELD() sched_yield()
+# define THREAD_YIELD() sched_yield()
#endif
// ==========================================================================
/* atomic memory access */
#if defined(_MSC_VER) && (!defined(__GNUC__))
+# define ONCE_FLAG_T LONG
# define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) InterlockedCompareExchange((X),(Y),(Z))
# define ATOMIC_EXCHANGE(X,Y) InterlockedExchange((X),(Y))
#else
+# define ONCE_FLAG_T int
# define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) __sync_val_compare_and_swap((X),(Z),(Y))
# define ATOMIC_EXCHANGE(X,Y) __sync_lock_test_and_set((X),(Y))
#endif
-/* execute initialization function once */
-static INLINE void initialize_once(volatile long *const once_flag, void (*const init_routine)(void))
+/* execute init routine once */
+static INLINE void initialize_once(volatile ONCE_FLAG_T *const once_control, void (*const init_routine)(void))
{
- long state;
- while ((state = ATOMIC_COMPARE_EXCHANGE(once_flag, -1, 0)) != 0)
+ ONCE_FLAG_T state;
+ while ((state = ATOMIC_COMPARE_EXCHANGE(once_control, -1, 0)) != 0)
{
if (state > 0)
{
return; /*already initialized*/
}
- SCHED_YIELD();
+ THREAD_YIELD();
}
init_routine();
- ATOMIC_EXCHANGE(once_flag, 1);
+ ATOMIC_EXCHANGE(once_control, 1);
}
// ==========================================================================
#define MAX_COUNT 1048576U
/* Global state */
-static volatile long s_random_is_initialized = 0L;
+static volatile ONCE_FLAG_T s_random_is_initialized = 0;
#if defined(_WIN32)
typedef BOOLEAN(WINAPI *ptr_genrandom_t)(void *buffer, ULONG length);
static HMODULE s_advapi32 = NULL;