diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-11 09:25:11 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-11 09:25:11 +0100 |
commit | 7510f5b16df9493e24f7ec8291c64e521811c53a (patch) | |
tree | 15271c3cde9f0a9878626ab425ddee5d848a4204 | |
parent | typo (diff) | |
download | sha3sum-7510f5b16df9493e24f7ec8291c64e521811c53a.tar.gz sha3sum-7510f5b16df9493e24f7ec8291c64e521811c53a.tar.bz2 sha3sum-7510f5b16df9493e24f7ec8291c64e521811c53a.tar.xz |
add thread support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | c/sha3.c | 36 |
2 files changed, 25 insertions, 14 deletions
@@ -24,6 +24,9 @@ CFLAGS=-W{all,extra} -pedantic $(C_OPTIMISE) -fPIC ifeq ($(WITH_C99),yes) CFLAGS+=-std=c99 -DWITH_C99 endif +ifeq ($(WITH_THREADLOCAL),yes) + CFLAGS+=-DWITH_THREADLOCAL +endif SOFLAGS=-W{all,extra} -pedantic $(C_OPTIMISE) -shared CPPFLAGS= LDFLAGS= @@ -25,6 +25,14 @@ #define static_inline inline #endif +#ifdef WITH_THREADLOCAL + #define threadlocal __thread + /* This is compiler dependent, if your compiler does + * not support this you need to define __thread yourself. */ +#else + #define threadlocal /* no threading support */ +#endif + #define null 0 #define true 1 #define false 0 @@ -55,74 +63,74 @@ static const llong RC[] = { /** * Keccak-f round temporary */ -static llong B[25]; +static threadlocal llong B[25]; /** * Keccak-f round temporary */ -static llong C[5]; +static threadlocal llong C[5]; /** * The bitrate */ -static long r = 0; +static threadlocal long r = 0; /** * The capacity */ -static long c = 0; +static threadlocal long c = 0; /** * The output size */ -static long n = 0; +static threadlocal long n = 0; /** * The state size */ -static long b = 0; +static threadlocal long b = 0; /** * The word size */ -static long w = 0; +static threadlocal long w = 0; /** * The word mask */ -static llong wmod = 0; +static threadlocal llong wmod = 0; /** * ℓ, the binary logarithm of the word size */ -static long l = 0; +static threadlocal long l = 0; /** * 12 + 2ℓ, the number of rounds */ -static long nr = 0; +static threadlocal long nr = 0; /** * The current state */ -static llong* S = null; +static threadlocal llong* S = null; /** * Left over water to fill the sponge with at next update */ -static byte* M = null; +static threadlocal byte* M = null; /** * Pointer for {@link #M} */ -static long mptr = 0; +static threadlocal long mptr = 0; /** * Size of {@link #M} */ -static long mlen = 0; +static threadlocal long mlen = 0; |