diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 6c8d4fc265..7ab0b5248e 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -95,6 +95,13 @@ Error, UINTPTR_MAX is undefined #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) #endif +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + // Hints to the compiler about likely/unlikely branches. #if defined (__GNUC__) || defined(__clang__) #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) @@ -10983,7 +10990,8 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx, * initialized to zeroes. * * We have to allocate an extra pointer for upb's internal metadata. */ -static const char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0}; +static UPB_ALIGN_AS(8) const + char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0}; const char* kUpbDefOptDefault = &opt_default_buf[sizeof(void*)]; const char* _upb_DefBuilder_FullToShort(const char* fullname) { @@ -15794,6 +15802,7 @@ const char* _upb_WireReader_SkipGroup(const char* ptr, uint32_t tag, #undef UPB_ALIGN_DOWN #undef UPB_ALIGN_MALLOC #undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index d31ab2d530..87af0ee6e5 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -94,6 +94,13 @@ Error, UINTPTR_MAX is undefined #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) #endif +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + // Hints to the compiler about likely/unlikely branches. #if defined (__GNUC__) || defined(__clang__) #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) @@ -13968,6 +13975,7 @@ UPB_INLINE const char* upb_WireReader_SkipValue( #undef UPB_ALIGN_DOWN #undef UPB_ALIGN_MALLOC #undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index efd6dd089e..bcfca4d07e 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -95,6 +95,13 @@ Error, UINTPTR_MAX is undefined #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) #endif +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + // Hints to the compiler about likely/unlikely branches. #if defined (__GNUC__) || defined(__clang__) #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) @@ -10499,7 +10506,8 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx, * initialized to zeroes. * * We have to allocate an extra pointer for upb's internal metadata. */ -static const char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0}; +static UPB_ALIGN_AS(8) const + char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0}; const char* kUpbDefOptDefault = &opt_default_buf[sizeof(void*)]; const char* _upb_DefBuilder_FullToShort(const char* fullname) { @@ -15310,6 +15318,7 @@ const char* _upb_WireReader_SkipGroup(const char* ptr, uint32_t tag, #undef UPB_ALIGN_DOWN #undef UPB_ALIGN_MALLOC #undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 3e2d23cc18..005e2349c2 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -96,6 +96,13 @@ Error, UINTPTR_MAX is undefined #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member) #endif +#ifdef _MSC_VER +// Some versions of our Windows compiler don't support the C11 syntax. +#define UPB_ALIGN_AS(x) __declspec(align(x)) +#else +#define UPB_ALIGN_AS(x) _Alignas(x) +#endif + // Hints to the compiler about likely/unlikely branches. #if defined (__GNUC__) || defined(__clang__) #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1) @@ -13787,6 +13794,7 @@ UPB_INLINE const char* upb_WireReader_SkipValue( #undef UPB_ALIGN_DOWN #undef UPB_ALIGN_MALLOC #undef UPB_ALIGN_OF +#undef UPB_ALIGN_AS #undef UPB_MALLOC_ALIGN #undef UPB_LIKELY #undef UPB_UNLIKELY