]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add-ALIGNED_-macro-to-support-MSVC
authorMat Berchtold <mberchtold@gmail.com>
Thu, 29 Oct 2015 14:40:16 +0000 (15:40 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 2 Nov 2015 12:05:32 +0000 (13:05 +0100)
arch/x86/crc_folding.c
deflate.h
zutil.h

index 32a37c38f5265e4c2b495fdea67bf05ab82d8e4e..b1fb6ec3a35a7ed52564043b720e2e7eec82e258 100644 (file)
@@ -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
 };
 
index 32e65ab618fff3a5a4d24c320ec689c4ff5e0421..107bb4276d926f9c5e57281bb5f6ea1bf314ee6e 100644 (file)
--- 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 db6858e227d74684778c028ea9523ca0d42df4ca..9f86c61d9abd43f0b437567b787fa9dc214aacea 100644 (file)
--- 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_ */