From 69bbb0d823771bc84ed1ba96381a91e06847c428 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Fri, 17 Jan 2020 19:04:20 -0800 Subject: Standardize insert_string functionality across architectures. Added unaligned conditionally compiled code for insert_string and quick_insert_string. Unify sse42 crc32 assembly between insert_string and quick_insert_string. Modified quick_insert_string to work across architectures. --- insert_string.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 insert_string.c (limited to 'insert_string.c') diff --git a/insert_string.c b/insert_string.c new file mode 100644 index 0000000000..4e4c628bfb --- /dev/null +++ b/insert_string.c @@ -0,0 +1,39 @@ +/* insert_string_c -- insert_string variant for c + * + * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + */ + +#include "zbuild.h" +#include "deflate.h" + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ + +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86) +# define UPDATE_HASH(s, h, val) \ + do {\ + if (s->level < TRIGGER_LEVEL)\ + h = (3483 * ((val) & 0xff) +\ + 23081* (((val) >> 8) & 0xff) +\ + 6954 * (((val) >> 16) & 0xff) +\ + 20947* (((val) >> 24) & 0xff));\ + else\ + h = (25881* (((val)) & 0xff) +\ + 24674* (((val) >> 8) & 0xff) +\ + 25811* (((val) >> 16) & 0xff));\ + } while (0) +#else +# define UPDATE_HASH(s, h, val)\ + h = (s->ins_h = ((s->ins_h << s->hash_shift) ^ ((val) >> ((MIN_MATCH - 1) * 8))) & s->hash_mask) +#endif + +#define INSERT_STRING insert_string_c +#define QUICK_INSERT_STRING quick_insert_string_c + +#include "insert_string_tpl.h" -- cgit 0.0.5-2-1-g0f52