Skip to content

Commit a333176

Browse files
committed
use alignas instead of ZEND_SET_ALIGNED() when possible
Sadly we cannot fully remove ZEND_SET_ALIGNED() as alignas is not allowed in typedefs.
1 parent dfabb8c commit a333176

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎Zend/zend_string.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ZEND_API zend_string *zend_one_char_string[256];
5353
ZEND_API zend_string **zend_known_strings = NULL;
5454

5555
/* this is read-only, so it's ok */
56-
ZEND_SET_ALIGNED(16, static const char zend_hexconvtab[]) = "0123456789abcdef";
56+
alignas(16) static const char zend_hexconvtab[] = "0123456789abcdef";
5757

5858
static zend_always_inline void zend_bin2hex_impl(char *out, const unsigned char *in, size_t in_len, const char *hexconvtab)
5959
{

‎ext/opcache/ZendAccelerator.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ typedef struct _zend_accel_shared_globals {
292292
const void **jit_exit_groups;
293293

294294
/* Interned Strings Support (must be the last element) */
295-
ZEND_SET_ALIGNED(ZEND_STRING_TABLE_POS_ALIGNMENT, zend_string_table interned_strings);
295+
alignas(ZEND_STRING_TABLE_POS_ALIGNMENT) zend_string_table interned_strings;
296296
} zend_accel_shared_globals;
297297

298298
#ifdef ZEND_WIN32

‎ext/random/random.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ PHPAPI void *php_random_default_status(void)
316316
/* }}} */
317317

318318
/* this is read-only, so it's ok */
319-
ZEND_SET_ALIGNED(16, static const char hexconvtab[]) = "0123456789abcdef";
319+
alignas(16) static const char hexconvtab[] = "0123456789abcdef";
320320

321321
/* {{{ php_random_bin2hex_le */
322322
/* stolen from standard/string.c */

‎ext/standard/crypt_sha256.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ static const char b64t[64] ZEND_NONSTRING =
302302

303303
char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
304304
{
305-
ZEND_SET_ALIGNED(alignof(uint32_t), unsigned char alt_result[32]);
306-
ZEND_SET_ALIGNED(alignof(uint32_t), unsigned char temp_result[32]);
305+
alignas(uint32_t) unsigned char alt_result[32];
306+
alignas(uint32_t) unsigned char temp_result[32];
307307

308308
struct sha256_ctx ctx;
309309
struct sha256_ctx alt_ctx;

‎ext/standard/crypt_sha512.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ static const char b64t[64] ZEND_NONSTRING =
341341

342342
char *
343343
php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) {
344-
ZEND_SET_ALIGNED(alignof(uint64_t), unsigned char alt_result[64]);
345-
ZEND_SET_ALIGNED(alignof(uint64_t), unsigned char temp_result[64]);
344+
alignas(uint64_t) unsigned char alt_result[64];
345+
alignas(uint64_t) unsigned char temp_result[64];
346346
struct sha512_ctx ctx;
347347
struct sha512_ctx alt_ctx;
348348
size_t salt_len;

‎ext/standard/string.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4076,7 +4076,7 @@ PHPAPI zend_string *php_addslashes(zend_string *str) /* {{{ */
40764076
zend_string *php_addslashes_sse42(zend_string *str)
40774077
# endif
40784078
{
4079-
ZEND_SET_ALIGNED(16, static const char slashchars[16]) = "\'\"\\\0";
4079+
alignas(16) static const char slashchars[16] = "\'\"\\\0";
40804080
__m128i w128, s128;
40814081
uint32_t res = 0;
40824082
/* maximum string length, worst case situation */

0 commit comments

Comments
 (0)