From: Hans Kristian Rosbach Date: Thu, 23 Feb 2017 08:04:48 +0000 (+0100) Subject: Let all platforms defining UNALIGNED_OK use the optimized put_short X-Git-Tag: 1.9.9-b1~675 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47c616ce343c47b406e20ce6ae7cf644c3e8f6cf;p=thirdparty%2Fzlib-ng.git Let all platforms defining UNALIGNED_OK use the optimized put_short implementation. Also change from pre-increment to post-increment to prevent a double-store on non-x86 platforms. --- diff --git a/deflate.h b/deflate.h index acd342d10..37e559680 100644 --- a/deflate.h +++ b/deflate.h @@ -307,7 +307,7 @@ typedef enum { * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ -#if defined(__x86_64) || defined(__i386_) +#ifdef UNALIGNED_OK /* Compared to the else-clause's implementation, there are few advantages: * - s->pending is loaded only once (else-clause's implementation needs to * load s->pending twice due to the alias between s->pending and @@ -318,8 +318,8 @@ typedef enum { * cost of penalty of potentially unaligned access. */ #define put_short(s, w) { \ + *(uint16_t*)(&s->pending_buf[s->pending]) = (w) ; \ s->pending += 2; \ - *(uint16_t*)(&s->pending_buf[s->pending - 2]) = (w) ; \ } #else #define put_short(s, w) { \