From: Anatol Belski Date: Mon, 19 Mar 2018 13:38:41 +0000 (+0100) Subject: Reuse new alignment macros X-Git-Tag: php-7.3.0alpha1~167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd8d56102ffb869f15a4919ab4850e80da2b619f;p=php Reuse new alignment macros --- diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c index 6a380bdf6a..7b45f73019 100644 --- a/ext/standard/crypt_sha256.c +++ b/ext/standard/crypt_sha256.c @@ -16,11 +16,6 @@ # include # define __alignof__(type) offsetof (struct { char c; type member;}, member) # endif -# if HAVE_ATTRIBUTE_ALIGNED -# define ALIGNED(size) __attribute__ ((__aligned__ (size))) -# else -# define ALIGNED(size) -# endif #endif #include @@ -334,18 +329,11 @@ static const char b64t[64] = char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen) { #ifdef PHP_WIN32 -# if _MSC <= 1300 -# pragma pack(push, 16) - unsigned char alt_result[32]; - unsigned char temp_result[32]; -# pragma pack(pop) -# else - __declspec(align(32)) unsigned char alt_result[32]; - __declspec(align(32)) unsigned char temp_result[32]; -# endif + ZEND_SET_ALIGNED(32, unsigned char alt_result[32]); + ZEND_SET_ALIGNED(32, unsigned char temp_result[32]); #else - unsigned char alt_result[32] ALIGNED(__alignof__ (uint32_t)); - unsigned char temp_result[32] ALIGNED(__alignof__ (uint32_t)); + ZEND_SET_ALIGNED(__alignof__ (uint32_t), unsigned char alt_result[32]); + ZEND_SET_ALIGNED(__alignof__ (uint32_t), unsigned char temp_result[32]); #endif struct sha256_ctx ctx; diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c index 3373182921..f71c69e5ec 100644 --- a/ext/standard/crypt_sha512.c +++ b/ext/standard/crypt_sha512.c @@ -15,11 +15,6 @@ # include # define __alignof__(type) offsetof (struct { char c; type member;}, member) # endif -# if HAVE_ATTRIBUTE_ALIGNED -# define ALIGNED(size) __attribute__ ((__aligned__ (size))) -# else -# define ALIGNED(size) -# endif #endif #include @@ -368,18 +363,11 @@ static const char b64t[64] = char * php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) { #ifdef PHP_WIN32 -# if _MSC <= 1300 -# pragma pack(push, 16) - unsigned char alt_result[64]; - unsigned char temp_result[64]; -# pragma pack(pop) -# else - __declspec(align(64)) unsigned char alt_result[64]; - __declspec(align(64)) unsigned char temp_result[64]; -# endif + ZEND_SET_ALIGNED(64, unsigned char alt_result[64]); + ZEND_SET_ALIGNED(64, unsigned char temp_result[64]); #else - unsigned char alt_result[64] ALIGNED(__alignof__ (uint64_t)); - unsigned char temp_result[64] ALIGNED(__alignof__ (uint64_t)); + ZEND_SET_ALIGNED(__alignof__ (uint64_t), unsigned char alt_result[64]); + ZEND_SET_ALIGNED(__alignof__ (uint64_t), unsigned char temp_result[64]); #endif struct sha512_ctx ctx; struct sha512_ctx alt_ctx;