keccak-fast.c

Minimal SIMD keccak implementation
git clone git://git.finwo.net/lib/keccak-fast.c
Log | Files | Refs | README | LICENSE

commit 8f6255672bde3fc70777926d7610d0daf5dd80e3
parent ac6c9d81ddd20adbc4c4ce392428cead428c881c
Author: finwo <finwo@pm.me>
Date:   Sun, 11 Oct 2026 05:45:32 +0200

Fix bench table alignment, ditch memset_s shim for now

Diffstat:
Mbench/bench.c | 6+++---
Mexport.mk | 6+-----
Msrc/backend/arm_sha3.c | 10+---------
Msrc/backend/scalar-impl.h | 10+---------
4 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/bench/bench.c b/bench/bench.c @@ -124,13 +124,13 @@ static void case_all(const char *title, const oneshot_t *os, int nos, printf("%s\n", title); if (donor != NULL) { - printf(" %-10s %9.2f ns/hash %9.3f Mh/s\n", "donor", bd, 1000.0 / bd); + printf(" %-12s %9.2f ns/hash %9.3f Mh/s\n", "donor", bd, 1000.0 / bd); } for (int i = 0; i < nos; i++) - printf(" %-10s %9.2f ns/hash %9.3f Mh/s\n", os[i].label, bos[i], + printf(" %-12s %9.2f ns/hash %9.3f Mh/s\n", os[i].label, bos[i], 1000.0 / bos[i]); for (int i = 0; i < nbs; i++) - printf(" %-10s %9.2f ns/hash %9.3f Mh/s\n", bs[i].label, bbs[i], + printf(" %-12s %9.2f ns/hash %9.3f Mh/s\n", bs[i].label, bbs[i], 1000.0 / bbs[i]); printf("\n"); } diff --git a/export.mk b/export.mk @@ -1,6 +1,2 @@ SRC+={{module.dirname}}/src/keccak-fast.c -SRC+={{module.dirname}}/src/backend/scalar.c -SRC+={{module.dirname}}/src/backend/scalar_bmi.c -SRC+={{module.dirname}}/src/backend/avx2.c -SRC+={{module.dirname}}/src/backend/avx512.c -SRC+={{module.dirname}}/src/backend/arm_sha3.c +SRC+=$(wildcard {{module.dirname}}/src/backend/*.c) diff --git a/src/backend/arm_sha3.c b/src/backend/arm_sha3.c @@ -46,14 +46,6 @@ static const uint64_t RC[24] = { #define KF_CAT(a, b) KF_CAT2(a, b) #define KF_FN(name) KF_CAT(KF_PREFIX, name) -#if !defined(__STDC_LIB_EXT1__) -static inline int memset_s(void *dest, size_t destsz, int ch, size_t count) { - (void)destsz; - memset(dest, ch, count); - return 0; -} -#endif - #define _(S) do { S } while (0) #define FOR(i, ST, L, S) \ _(for (size_t i = 0; i < L; i += ST) { S; }) @@ -88,7 +80,7 @@ mkapply_sd(setout, dst[i] = src[i]) PERM(a); \ foldP(out, outlen, setout, PERM); \ setout(a, out, outlen); \ - memset_s(a, 200, 0, 200); \ + memset(a, 0, 200); \ return 0 static inline int kf_hash24(uint8_t *out, size_t outlen, const uint8_t *in, diff --git a/src/backend/scalar-impl.h b/src/backend/scalar-impl.h @@ -9,14 +9,6 @@ #define KF_CAT(a, b) KF_CAT2(a, b) #define KF_FN(name) KF_CAT(KF_PREFIX, name) -#if !defined(__STDC_LIB_EXT1__) -static inline int memset_s(void *dest, size_t destsz, int ch, size_t count) { - (void)destsz; - memset(dest, ch, count); - return 0; -} -#endif - static const uint64_t RC[24] = { 1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, @@ -63,7 +55,7 @@ mkapply_sd(setout, dst[i] = src[i]) PERM(a); \ foldP(out, outlen, setout, PERM); \ setout(a, out, outlen); \ - memset_s(a, 200, 0, 200); \ + memset(a, 0, 200); \ return 0 static inline int kf_hash24(uint8_t *out, size_t outlen, const uint8_t *in,