summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-03-19 14:38:41 +0100
committerAnatol Belski <ab@php.net>2018-03-19 14:38:41 +0100
commitcd8d56102ffb869f15a4919ab4850e80da2b619f (patch)
treee67f3ac949e9f532489ac3021810b0ad9fdb84a0
parent18750a2238e11edffced0cc5c8c6d159cfd8a781 (diff)
downloadphp-git-cd8d56102ffb869f15a4919ab4850e80da2b619f.tar.gz
Reuse new alignment macros
-rw-r--r--ext/standard/crypt_sha256.c20
-rw-r--r--ext/standard/crypt_sha512.c20
2 files changed, 8 insertions, 32 deletions
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 <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;
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 <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;