xref: /aosp_15_r20/external/cronet/third_party/protobuf/patches/0030-workaround-windows-constinit.patch (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
2index 8bd06d340f7c3..cae9ebe01ec2c 100644
3--- a/src/google/protobuf/port_def.inc
4+++ b/src/google/protobuf/port_def.inc
5@@ -434,19 +434,26 @@
6 #  define PROTOBUF_EXPORT __declspec(dllexport)
7 #  define PROTOBUF_EXPORT_TEMPLATE_DECLARE
8 #  define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
9+#  define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT
10 # else
11 #  define PROTOBUF_EXPORT __declspec(dllimport)
12 #  define PROTOBUF_EXPORT_TEMPLATE_DECLARE
13 #  define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
14+// Pointers to dllimport extern variables on Windows require a static
15+// initialization and cannot be constant-initialized. This macro disables
16+// constinit in files where we cannot support it.
17+#  define PROTOBUF_CONSTINIT_WITH_PTR
18 # endif  // defined(LIBPROTOBUF_EXPORTS)
19 #elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
20 # define PROTOBUF_EXPORT __attribute__((visibility("default")))
21 # define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
22 # define PROTOBUF_EXPORT_TEMPLATE_DEFINE
23+# define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT
24 #else
25 # define PROTOBUF_EXPORT
26 # define PROTOBUF_EXPORT_TEMPLATE_DECLARE
27 # define PROTOBUF_EXPORT_TEMPLATE_DEFINE
28+# define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT
29 #endif
30
31 #ifdef PROTOC_EXPORT
32diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
33index 58136a4b47350..056c9b790ba4d 100644
34--- a/src/google/protobuf/port_undef.inc
35+++ b/src/google/protobuf/port_undef.inc
36@@ -80,6 +80,7 @@
37 #undef PROTOBUF_THREAD_LOCAL
38 #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
39 #undef PROTOBUF_CONSTINIT
40+#undef PROTOBUF_CONSTINIT_WITH_PTR
41 #undef PROTOBUF_CONSTEXPR
42 #undef PROTOBUF_ATTRIBUTE_WEAK
43 #undef PROTOBUF_HAVE_ATTRIBUTE_WEAK
44--
452.37.0.rc0.104.g0611611a94-goog
46