From: Mat Berchtold Date: Thu, 29 Oct 2015 14:40:16 +0000 (+0100) Subject: Add-ALIGNED_-macro-to-support-MSVC X-Git-Tag: 1.9.9-b1~793^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb0346add9c4944425384b3a74b85e9f9c6f5c4a;p=thirdparty%2Fzlib-ng.git Add-ALIGNED_-macro-to-support-MSVC --- diff --git a/arch/x86/crc_folding.c b/arch/x86/crc_folding.c index 32a37c38f..b1fb6ec3a 100644 --- a/arch/x86/crc_folding.c +++ b/arch/x86/crc_folding.c @@ -190,7 +190,7 @@ local void fold_4(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, *xmm_crc3 = _mm_castps_si128(ps_res3); } -local const unsigned __attribute__((aligned(32))) pshufb_shf_table[60] = { +local const unsigned ALIGNED_(32) pshufb_shf_table[60] = { 0x84838281, 0x88878685, 0x8c8b8a89, 0x008f8e8d, /* shl 15 (16 - 1)/shr1 */ 0x85848382, 0x89888786, 0x8d8c8b8a, 0x01008f8e, /* shl 14 (16 - 3)/shr2 */ 0x86858483, 0x8a898887, 0x8e8d8c8b, 0x0201008f, /* shl 13 (16 - 4)/shr3 */ @@ -378,7 +378,7 @@ done: CRC_SAVE(s) } -local const unsigned __attribute__((aligned(16))) crc_k[] = { +local const unsigned ALIGNED_(16) crc_k[] = { 0xccaa009e, 0x00000000, /* rk1 */ 0x751997d0, 0x00000001, /* rk2 */ 0xccaa009e, 0x00000000, /* rk5 */ @@ -387,11 +387,11 @@ local const unsigned __attribute__((aligned(16))) crc_k[] = { 0xdb710640, 0x00000001 /* rk8 */ }; -local const unsigned __attribute__((aligned(16))) crc_mask[4] = { +local const unsigned ALIGNED_(16) crc_mask[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000 }; -local const unsigned __attribute__((aligned(16))) crc_mask2[4] = { +local const unsigned ALIGNED_(16) crc_mask2[4] = { 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; diff --git a/deflate.h b/deflate.h index 32e65ab61..107bb4276 100644 --- a/deflate.h +++ b/deflate.h @@ -113,7 +113,7 @@ typedef struct internal_state { int last_flush; /* value of flush param for previous deflate call */ #ifdef X86_PCLMULQDQ_CRC - unsigned __attribute__((aligned(16))) crc0[4 * 5]; + unsigned ALIGNED_(16) crc0[4 * 5]; #endif /* used by deflate.c: */ diff --git a/zutil.h b/zutil.h index db6858e22..9f86c61d9 100644 --- a/zutil.h +++ b/zutil.h @@ -172,4 +172,12 @@ void ZLIB_INTERNAL zcfree(void *opaque, void *ptr); # endif #endif /* (un)likely */ +#if defined(_MSC_VER) +#define ALIGNED_(x) __declspec(align(x)) +#else +#if defined(__GNUC__) +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif +#endif + #endif /* ZUTIL_H_ */