]> granicus.if.org Git - php/commitdiff
Reuse new alignment macros
authorAnatol Belski <ab@php.net>
Mon, 19 Mar 2018 13:38:41 +0000 (14:38 +0100)
committerAnatol Belski <ab@php.net>
Mon, 19 Mar 2018 13:38:41 +0000 (14:38 +0100)
ext/standard/crypt_sha256.c
ext/standard/crypt_sha512.c

index 6a380bdf6af399333ea0a169cf3f99165e73a96f..7b45f7301977d15ac4231ebf82f9fe68a99b79cf 100644 (file)
 #  include <stddef.h>
 #  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 <stdio.h>
@@ -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;
index 337318292104dc8c8dd9e3307945f20dc590d79a..f71c69e5ec6120b9a58a1d8da561d61ad05ee704 100644 (file)
 #  include <stddef.h>
 #  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 <stdio.h>
@@ -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;