diff options
author | Johannes Schlüter <johannes@php.net> | 2010-02-09 21:58:13 +0000 |
---|---|---|
committer | Johannes Schlüter <johannes@php.net> | 2010-02-09 21:58:13 +0000 |
commit | f732d74f6ba4799457129f056164c650a2d88534 (patch) | |
tree | f4e0d7ba41667752f7889e703c12498ecc5f8c1a /ext/standard/crypt_sha512.c | |
parent | 480c327ff55ecd640c2a25341b558a758f2d913f (diff) | |
download | php-git-f732d74f6ba4799457129f056164c650a2d88534.tar.gz |
Detect if we can rely on compiler-specific alignment features else use custom
workarounds. Fixes #50753
Diffstat (limited to 'ext/standard/crypt_sha512.c')
-rw-r--r-- | ext/standard/crypt_sha512.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c index 8d2f017bae..ba9a639180 100644 --- a/ext/standard/crypt_sha512.c +++ b/ext/standard/crypt_sha512.c @@ -17,6 +17,15 @@ # elif HAVE_STDINT_H # include <stdint.h> # endif +# ifndef HAVE_ALIGNOF +# 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> @@ -370,10 +379,8 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) __declspec(align(64)) unsigned char temp_result[64]; # endif #else - unsigned char alt_result[64] - __attribute__ ((__aligned__ (__alignof__ (uint64_t)))); - unsigned char temp_result[64] - __attribute__ ((__aligned__ (__alignof__ (uint64_t)))); + unsigned char alt_result[64] ALIGNED(__alignof__ (uint64_t)); + unsigned char temp_result[64] ALIGNED(__alignof__ (uint64_t)); #endif struct sha512_ctx ctx; struct sha512_ctx alt_ctx; |