From 882d13a34db5c117dae9ca87d5db02d6b3a12b18 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Wed, 21 May 2025 10:07:37 +0800 Subject: [PATCH 1/2] ohos: Use custom domain when logging with hilog This modifies the existing patch to redirect log messages to hilog to use a non-zero domain, which allows us to filter logs via the domain on ohos devices. We set 0xE0C3 for Rust code in servo, using a different number allows us to seperate spidermonkey from servo logs if wanted. Signed-off-by: Jonathan Schwender --- mozjs-sys/Cargo.toml | 2 +- ...irect_errors_to_hilog_on_OpenHarmony.patch | 21 ++++++++++--------- .../mozjs/build/moz.configure/init.configure | 1 + .../mozjs/memory/mozalloc/mozalloc_abort.cpp | 2 +- mozjs-sys/mozjs/mfbt/Assertions.h | 4 ++-- mozjs-sys/mozjs/mfbt/DbgMacro.h | 2 +- mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 2 +- mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c | 6 +++--- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/mozjs-sys/Cargo.toml b/mozjs-sys/Cargo.toml index a76589358c..376e8a7edc 100644 --- a/mozjs-sys/Cargo.toml +++ b/mozjs-sys/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs_sys" description = "System crate for the Mozilla SpiderMonkey JavaScript engine." repository.workspace = true -version = "0.128.9-2" +version = "0.128.9-3" authors = ["Mozilla"] links = "mozjs" build = "build.rs" diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index f691d05dcb..13e7b24903 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -2,14 +2,16 @@ diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.confi index e0e14bf60..179de2592 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure -@@ -956,6 +956,7 @@ def target_is_ohos(target): +@@ -956,7 +956,9 @@ def target_is_ohos(target): set_define("XP_OHOS", target_is_ohos) +set_config("OHOS", target_is_ohos) ++set_define("OHOS_LOG_DOMAIN", "0xE0C4", when=target_is_ohos) @depends(target) + def target_is_openbsd(target): diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild index 471599f17..a89f0ca7a 100644 --- a/config/system-headers.mozbuild @@ -47,7 +49,7 @@ index 3cfc92533..9c487ac45 100644 +#ifdef ANDROID + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", ++ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko", + "mozalloc_abort: %{public}s\n", msg); +#else fputs(msg, stderr); @@ -75,7 +77,7 @@ index 0b7395177..e84d76aba 100644 /* aMaxFrames */ 0); # endif +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", ++ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else @@ -86,7 +88,7 @@ index 0b7395177..e84d76aba 100644 "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", ++ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH", + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else @@ -116,7 +118,7 @@ index 3247b993c..c7039d5f8 100644 +#if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); ++ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); #endif @@ -143,7 +145,7 @@ index c3a2ca89e..3fea33f4b 100644 } +#elif defined(OHOS) +MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); ++ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs); +} #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { @@ -194,7 +196,7 @@ index 52bd6abc5..781402d56 100644 + if (fd == _pr_stderr) { \ + char savebyte = buf[nb]; \ + buf[nb] = '\0'; \ -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \ ++ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "PRLog", \ + "%{public}s\n", buf); \ + buf[nb] = savebyte; \ + } else { \ @@ -209,7 +211,7 @@ index 52bd6abc5..781402d56 100644 #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); ++ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n"); #endif abort(); } @@ -218,11 +220,10 @@ index 52bd6abc5..781402d56 100644 __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); +#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", ++ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif abort(); } -- 2.45.2 - diff --git a/mozjs-sys/mozjs/build/moz.configure/init.configure b/mozjs-sys/mozjs/build/moz.configure/init.configure index 179de25920..45ef1a961f 100644 --- a/mozjs-sys/mozjs/build/moz.configure/init.configure +++ b/mozjs-sys/mozjs/build/moz.configure/init.configure @@ -957,6 +957,7 @@ def target_is_ohos(target): set_define("XP_OHOS", target_is_ohos) set_config("OHOS", target_is_ohos) +set_define("OHOS_LOG_DOMAIN", "0xE0C4", when=target_is_ohos) @depends(target) diff --git a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp index 9c487ac450..1ef506fc21 100644 --- a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp +++ b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp @@ -26,7 +26,7 @@ void mozalloc_abort(const char* const msg) { #ifdef ANDROID __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko", "mozalloc_abort: %{public}s\n", msg); #else fputs(msg, stderr); diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index e84d76abac..64bc657e9e 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -123,7 +123,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, /* aMaxFrames */ 0); # endif #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert", "Assertion failure: %{public}s, at %{public}s:%{public}d\n", aStr, aFilename, aLine); #else @@ -151,7 +151,7 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH", "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", aStr, aFilename, aLine); #else diff --git a/mozjs-sys/mozjs/mfbt/DbgMacro.h b/mozjs-sys/mozjs/mfbt/DbgMacro.h index c7039d5f83..d41dd66598 100644 --- a/mozjs-sys/mozjs/mfbt/DbgMacro.h +++ b/mozjs-sys/mozjs/mfbt/DbgMacro.h @@ -101,7 +101,7 @@ auto&& MozDbg(const char* aFile, int aLine, const char* aExpression, #if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); + (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); #endif diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index 3fea33f4b4..daab12e45c 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -70,7 +70,7 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { } #elif defined(OHOS) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); + (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs); } #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { diff --git a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c index 781402d56d..b4563c386e 100644 --- a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c +++ b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c @@ -116,7 +116,7 @@ static void OutputDebugStringA(const char* msg) { if (fd == _pr_stderr) { \ char savebyte = buf[nb]; \ buf[nb] = '\0'; \ - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \ + (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "PRLog", \ "%{public}s\n", buf); \ buf[nb] = savebyte; \ } else { \ @@ -567,7 +567,7 @@ PR_IMPLEMENT(void) PR_Abort(void) #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n"); #endif abort(); } @@ -585,7 +585,7 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); #elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif abort(); From 04b67af079f6c06ae68f7b96bd8faab5516fe84c Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 22 May 2025 10:15:24 +0800 Subject: [PATCH 2/2] Fix OHOS define Signed-off-by: Jonathan Schwender --- ...ild__Add_compile_definition_for_ohos.patch | 6 ++-- ...irect_errors_to_hilog_on_OpenHarmony.patch | 30 +++++++++---------- .../mozjs/build/moz.configure/init.configure | 4 ++- .../mozjs/memory/mozalloc/mozalloc_abort.cpp | 4 +-- mozjs-sys/mozjs/mfbt/Assertions.h | 6 ++-- mozjs-sys/mozjs/mfbt/DbgMacro.h | 4 +-- mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 8 ++--- mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c | 8 ++--- 8 files changed, 37 insertions(+), 33 deletions(-) diff --git a/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch b/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch index a5903822c9..d80b55cb1a 100644 --- a/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch +++ b/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch @@ -1,13 +1,15 @@ diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure --- a/build/moz.configure/init.configure (revision dbffebd0937c14d3c73ce9be4798da15cb2f369d) +++ b/build/moz.configure/init.configure (revision 8a1dbb7da45148151dbb0d05d969118103cfa8d0) -@@ -950,6 +950,14 @@ +@@ -950,6 +950,16 @@ set_define("ANDROID", target_is_android) +@depends(target) +def target_is_ohos(target): -+ return target.raw_os.endswith("-ohos") ++ if target.raw_os.endswith("-ohos"): ++ return True ++ return None + + +set_define("XP_OHOS", target_is_ohos) diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index 13e7b24903..7b00c98273 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -36,7 +36,7 @@ index 3cfc92533..9c487ac45 100644 #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif #ifdef MOZ_WIDGET_ANDROID @@ -48,7 +48,7 @@ index 3cfc92533..9c487ac45 100644 -#ifndef ANDROID +#ifdef ANDROID + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko", + "mozalloc_abort: %{public}s\n", msg); +#else @@ -67,7 +67,7 @@ index 0b7395177..e84d76aba 100644 #endif #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -76,7 +76,7 @@ index 0b7395177..e84d76aba 100644 MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(), /* aMaxFrames */ 0); # endif -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n", + aStr, aFilename, aLine); @@ -87,7 +87,7 @@ index 0b7395177..e84d76aba 100644 __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH", + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", + aStr, aFilename, aLine); @@ -105,7 +105,7 @@ index 3247b993c..c7039d5f8 100644 -#ifdef ANDROID +#if defined(ANDROID) # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -117,7 +117,7 @@ index 3247b993c..c7039d5f8 100644 -#ifdef ANDROID +#if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); @@ -130,12 +130,12 @@ index c3a2ca89e..3fea33f4b 100644 #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif -#ifndef ANDROID -+#if ! (defined(ANDROID) || defined(OHOS)) ++#if ! (defined(ANDROID) || defined(XP_OHOS)) static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) { // Avoid interleaving by writing to an on-stack buffer and then writing in one // go with fputs, as long as the output fits into the buffer. @@ -143,7 +143,7 @@ index c3a2ca89e..3fea33f4b 100644 MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs); } -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { + (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs); +} @@ -155,7 +155,7 @@ index c3a2ca89e..3fea33f4b 100644 MFBT_API void print_stderr(std::stringstream& aStr) { -#if defined(ANDROID) -+#if defined(ANDROID) || defined(OHOS) ++#if defined(ANDROID) || defined(XP_OHOS) // On Android logcat output is truncated to 1024 chars per line, and // we usually use std::stringstream to build up giant multi-line gobs // of output. So to avoid the truncation we find the newlines and @@ -181,7 +181,7 @@ index 52bd6abc5..781402d56 100644 -#ifdef ANDROID +#if defined(ANDROID) #include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -190,7 +190,7 @@ index 52bd6abc5..781402d56 100644 PR_Write(fd, buf, nb); \ } \ PR_END_MACRO -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +#define _PUT_LOG(fd, buf, nb) \ + PR_BEGIN_MACRO \ + if (fd == _pr_stderr) { \ @@ -210,7 +210,7 @@ index 52bd6abc5..781402d56 100644 PR_LogPrint("Aborting"); #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n"); #endif abort(); @@ -219,7 +219,7 @@ index 52bd6abc5..781402d56 100644 #elif defined(ANDROID) __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif diff --git a/mozjs-sys/mozjs/build/moz.configure/init.configure b/mozjs-sys/mozjs/build/moz.configure/init.configure index 45ef1a961f..8b90a663f5 100644 --- a/mozjs-sys/mozjs/build/moz.configure/init.configure +++ b/mozjs-sys/mozjs/build/moz.configure/init.configure @@ -952,7 +952,9 @@ set_define("ANDROID", target_is_android) @depends(target) def target_is_ohos(target): - return target.raw_os.endswith("-ohos") + if target.raw_os.endswith("-ohos"): + return True + return None set_define("XP_OHOS", target_is_ohos) diff --git a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp index 1ef506fc21..76751d4950 100644 --- a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp +++ b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp @@ -9,7 +9,7 @@ #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif #ifdef MOZ_WIDGET_ANDROID @@ -25,7 +25,7 @@ void mozalloc_abort(const char* const msg) { #ifdef ANDROID __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko", "mozalloc_abort: %{public}s\n", msg); #else diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index 64bc657e9e..d3c7075c52 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -88,7 +88,7 @@ MOZ_END_EXTERN_C #endif #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -122,7 +122,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(), /* aMaxFrames */ 0); # endif -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert", "Assertion failure: %{public}s, at %{public}s:%{public}d\n", aStr, aFilename, aLine); @@ -150,7 +150,7 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH", "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", aStr, aFilename, aLine); diff --git a/mozjs-sys/mozjs/mfbt/DbgMacro.h b/mozjs-sys/mozjs/mfbt/DbgMacro.h index d41dd66598..955d3e9180 100644 --- a/mozjs-sys/mozjs/mfbt/DbgMacro.h +++ b/mozjs-sys/mozjs/mfbt/DbgMacro.h @@ -20,7 +20,7 @@ class nsTSubstring; #if defined(ANDROID) # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -100,7 +100,7 @@ auto&& MozDbg(const char* aFile, int aLine, const char* aExpression, s << '\n'; #if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index daab12e45c..d2244dc0f5 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -18,11 +18,11 @@ #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif -#if ! (defined(ANDROID) || defined(OHOS)) +#if ! (defined(ANDROID) || defined(XP_OHOS)) static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) { // Avoid interleaving by writing to an on-stack buffer and then writing in one // go with fputs, as long as the output fits into the buffer. @@ -68,7 +68,7 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs); } -#elif defined(OHOS) +#elif defined(XP_OHOS) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs); } @@ -106,7 +106,7 @@ MFBT_API void fprintf_stderr(FILE* aFile, const char* aFmt, ...) { } MFBT_API void print_stderr(std::stringstream& aStr) { -#if defined(ANDROID) || defined(OHOS) +#if defined(ANDROID) || defined(XP_OHOS) // On Android logcat output is truncated to 1024 chars per line, and // we usually use std::stringstream to build up giant multi-line gobs // of output. So to avoid the truncation we find the newlines and diff --git a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c index b4563c386e..c7b835456c 100644 --- a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c +++ b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c @@ -10,7 +10,7 @@ #include #if defined(ANDROID) #include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -110,7 +110,7 @@ static void OutputDebugStringA(const char* msg) { PR_Write(fd, buf, nb); \ } \ PR_END_MACRO -#elif defined(OHOS) +#elif defined(XP_OHOS) #define _PUT_LOG(fd, buf, nb) \ PR_BEGIN_MACRO \ if (fd == _pr_stderr) { \ @@ -566,7 +566,7 @@ PR_IMPLEMENT(void) PR_Abort(void) PR_LogPrint("Aborting"); #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n"); #endif abort(); @@ -584,7 +584,7 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) #elif defined(ANDROID) __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif