aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorProtobuf Team Bot <protobuf-github-bot@google.com>2024-05-08 12:23:44 -0700
committerCopybara-Service <copybara-worker@google.com>2024-05-08 12:27:42 -0700
commitec126a5069fbb81a857e41c8b2cfbe71ace35993 (patch)
tree775d39a0206463f0081eae544aa95d987af4b77c
parent64580b29c1dfdd580052a01a5ccd3fb1c0a22f5c (diff)
downloadprotobuf-ec126a5069fbb81a857e41c8b2cfbe71ace35993.tar.gz
Replace the single user of `PROTOBUF_ALIGNAS` with `alignas` and remove the now
dead macro. This reduces the compile time cost of port_def.inc PiperOrigin-RevId: 631886181
-rw-r--r--src/google/protobuf/arena.h2
-rw-r--r--src/google/protobuf/port_def.inc33
-rw-r--r--src/google/protobuf/port_undef.inc1
3 files changed, 1 insertions, 35 deletions
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index c8ccfe24a..f32f6d8c1 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -142,7 +142,7 @@ struct ArenaOptions {
// This is a thread-safe implementation: multiple threads may allocate from the
// arena concurrently. Destruction is not thread-safe and the destructing
// thread must synchronize with users of the arena first.
-class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
+class PROTOBUF_EXPORT alignas(8) Arena final {
public:
// Default constructor with sensible default options, tuned for average
// use-cases.
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 2be3e2073..1e05aad17 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -403,39 +403,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#error PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION was previously defined
#endif
-// Specify memory alignment for structs, classes, etc.
-// Use like:
-// class PROTOBUF_ALIGNAS(16) MyClass { ... }
-// PROTOBUF_ALIGNAS(16) int array[4];
-//
-// In most places you can use the C++11 keyword "alignas", which is preferred.
-//
-// But compilers have trouble mixing __attribute__((...)) syntax with
-// alignas(...) syntax.
-//
-// Doesn't work in clang or gcc:
-// struct alignas(16) __attribute__((packed)) S { char c; };
-// Works in clang but not gcc:
-// struct __attribute__((packed)) alignas(16) S2 { char c; };
-// Works in clang and gcc:
-// struct alignas(16) S3 { char c; } __attribute__((packed));
-//
-// There are also some attributes that must be specified *before* a class
-// definition: visibility (used for exporting functions/classes) is one of
-// these attributes. This means that it is not possible to use alignas() with a
-// class that is marked as exported.
-#ifdef PROTOBUF_ALIGNAS
-#error PROTOBUF_ALIGNAS was previously defined
-#endif
-#if defined(_MSC_VER)
-#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
-#elif defined(__GNUC__)
-#define PROTOBUF_ALIGNAS(byte_alignment) \
- __attribute__((aligned(byte_alignment)))
-#else
-#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
-#endif
-
#ifdef PROTOBUF_THREAD_LOCAL
#error PROTOBUF_THREAD_LOCAL was previously defined
#endif
diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
index 83f8a8c57..9d72db2f5 100644
--- a/src/google/protobuf/port_undef.inc
+++ b/src/google/protobuf/port_undef.inc
@@ -50,7 +50,6 @@
#undef PROTOBUF_ASSUME
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
-#undef PROTOBUF_ALIGNAS
#undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_CONSTINIT
#undef PROTOBUF_CONSTEXPR