summaryrefslogtreecommitdiff
path: root/ext/standard/crypt_sha256.c
diff options
context:
space:
mode:
authorJohannes Schlüter <johannes@php.net>2010-02-09 21:58:13 +0000
committerJohannes Schlüter <johannes@php.net>2010-02-09 21:58:13 +0000
commitf732d74f6ba4799457129f056164c650a2d88534 (patch)
treef4e0d7ba41667752f7889e703c12498ecc5f8c1a /ext/standard/crypt_sha256.c
parent480c327ff55ecd640c2a25341b558a758f2d913f (diff)
downloadphp-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_sha256.c')
-rw-r--r--ext/standard/crypt_sha256.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c
index 30f913f9a6..3e234cee91 100644
--- a/ext/standard/crypt_sha256.c
+++ b/ext/standard/crypt_sha256.c
@@ -18,6 +18,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>
@@ -342,10 +351,8 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
__declspec(align(32)) unsigned char temp_result[32];
# endif
#else
- unsigned char alt_result[32]
- __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
- unsigned char temp_result[32]
- __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+ unsigned char alt_result[32] ALIGNED(__alignof__ (uint32_t));
+ unsigned char temp_result[32] ALIGNED(__alignof__ (uint32_t));
#endif
struct sha256_ctx ctx;