Skip to content

Commit a497c1e

Browse files
committed
Support SHA256_Transform_shani() with MSVC
1 parent bd77462 commit a497c1e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

ext/hash/hash_sha_ni.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@
2727
#include "php_hash.h"
2828
#include "php_hash_sha.h"
2929

30-
#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IMMINTRIN_H)
30+
#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IMMINTRIN_H) || defined(_M_X64) || defined(_M_IX86)
3131

3232
# include <immintrin.h>
3333

34-
# if PHP_HASH_INTRIN_SHA_RESOLVER
35-
static __m128i be32dec_128(const uint8_t * src) __attribute__((target("ssse3")));
36-
void SHA256_Transform_shani(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64]) __attribute__((target("ssse3,sha")));
37-
# endif
38-
3934
/* Original implementation from libcperciva follows.
4035
*
4136
* Modified to use `PHP_STATIC_RESTRICT` for MSVC compatibility.

ext/hash/php_hash_sha.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, size
5656
void SHA256_Transform_sse2(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64], uint32_t W[PHP_STATIC_RESTRICT 64], uint32_t S[PHP_STATIC_RESTRICT 8]);
5757
#endif
5858

59-
#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IMMINTRIN_H)
59+
#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IMMINTRIN_H) || defined(_M_X64) || defined(_M_IX86)
6060
# if defined(__SSSE3__) && defined(__SHA__)
6161
# define PHP_HASH_INTRIN_SHA_NATIVE 1
62-
# elif defined(HAVE_FUNC_ATTRIBUTE_TARGET)
62+
# elif defined(ZEND_INTRIN_SSSE3_RESOLVER)
6363
# define PHP_HASH_INTRIN_SHA_RESOLVER 1
6464
# endif
6565

0 commit comments

Comments
 (0)