From 375c4055156960c6a85753d9606a0a2876bd8b59 Mon Sep 17 00:00:00 2001 From: zhangcui Date: Fri, 21 Oct 2022 06:39:43 +0000 Subject: [PATCH 1/3] || defined(__OHOS__ Signed-off-by: zhangcui --- BUILD.gn | 3 +++ src/google/protobuf/stubs/mutex.h | 3 +++ src/google/protobuf/stubs/platform_macros.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index a6ec37f..1533332 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,9 @@ import("//developtools/profiler/build/config.gni") config("protobuf_config") { include_dirs = [ "src" ] + if (is_ohos) { + cflags_cc = [ "-D__OHOS__" ] + } } ohos_shared_library("protobuf_lite") { diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h index b222ff7..2741955 100644 --- a/src/google/protobuf/stubs/mutex.h +++ b/src/google/protobuf/stubs/mutex.h @@ -31,6 +31,9 @@ #define GOOGLE_PROTOBUF_STUBS_MUTEX_H_ #include +#if defined(HAVE_PTHREAD) +#include +#endif #ifdef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index ce1b1e3..01615e7 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -118,7 +118,7 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR #undef GOOGLE_PROTOBUF_PLATFORM_ERROR -#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__) +#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__ || defined(__OHOS__) // Android ndk does not support the __thread keyword very well yet. Here // we use pthread_key_create()/pthread_getspecific()/... methods for // TLS support on android. -- Gitee From 766a7c847587e4b64a5f962c60e5ceb549a5cf24 Mon Sep 17 00:00:00 2001 From: zhangcui Date: Fri, 21 Oct 2022 07:33:01 +0000 Subject: [PATCH 2/3] update Signed-off-by: zhangcui --- src/google/protobuf/stubs/platform_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index 01615e7..e4fb136 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -118,7 +118,7 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR #undef GOOGLE_PROTOBUF_PLATFORM_ERROR -#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__ || defined(__OHOS__) +#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__ || defined(__OHOS__)) // Android ndk does not support the __thread keyword very well yet. Here // we use pthread_key_create()/pthread_getspecific()/... methods for // TLS support on android. -- Gitee From 30f07a1816534436da08a9ce3ce49cacbc359ea2 Mon Sep 17 00:00:00 2001 From: zhangcui Date: Fri, 21 Oct 2022 07:56:29 +0000 Subject: [PATCH 3/3] update Signed-off-by: zhangcui --- src/google/protobuf/stubs/platform_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index e4fb136..23c61ee 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -118,7 +118,7 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR #undef GOOGLE_PROTOBUF_PLATFORM_ERROR -#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__ || defined(__OHOS__)) +#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__) || defined(__OHOS__) // Android ndk does not support the __thread keyword very well yet. Here // we use pthread_key_create()/pthread_getspecific()/... methods for // TLS support on android. -- Gitee