@@ -34,7 +34,7 @@ index 3cfc92533..9c487ac45 100644
3434
3535 #ifdef ANDROID
3636 # include <android/log.h>
37- + #elif defined(OHOS )
37+ + #elif defined(XP_OHOS )
3838+ # include <hilog/log.h>
3939 #endif
4040 #ifdef MOZ_WIDGET_ANDROID
@@ -46,7 +46,7 @@ index 3cfc92533..9c487ac45 100644
4646- #ifndef ANDROID
4747+ #ifdef ANDROID
4848+ __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
49- + #elif defined(OHOS )
49+ + #elif defined(XP_OHOS )
5050+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko",
5151+ "mozalloc_abort: %{public}s\n", msg);
5252+ #else
@@ -65,7 +65,7 @@ index 0b7395177..e84d76aba 100644
6565 #endif
6666 #ifdef ANDROID
6767 # include <android/log.h>
68- + #elif defined(OHOS )
68+ + #elif defined(XP_OHOS )
6969+ # include <hilog/log.h>
7070 #endif
7171
@@ -74,24 +74,26 @@ index 0b7395177..e84d76aba 100644
7474 MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(),
7575 /* aMaxFrames */ 0);
7676 # endif
77- + #elif defined(OHOS )
77+ + #elif defined(XP_OHOS )
7878+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert",
7979+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",
8080+ aStr, aFilename, aLine);
8181 #else
8282 # if defined(MOZ_BUFFER_STDERR)
8383 char msg[1024] = "";
84- @@ -144,6 +150,10 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash(
84+ @@ -144,8 +150,12 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash(
8585 __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
8686 "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr,
8787 aFilename, aLine);
88- + #elif defined(OHOS)
89- + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
90- + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
91- + aStr, aFilename, aLine);
9288 # if defined(MOZ_DUMP_ASSERTION_STACK)
9389 MozWalkTheStackWithWriter(MOZ_CrashPrintFrame, CallerPC(),
9490 /* aMaxFrames */ 0);
91+ # endif
92+ + #elif defined(XP_OHOS)
93+ + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
94+ + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
95+ + aStr, aFilename, aLine);
96+ #else
9597diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h
9698index 3247b993c..c7039d5f8 100644
9799--- a/mfbt/DbgMacro.h
@@ -103,7 +105,7 @@ index 3247b993c..c7039d5f8 100644
103105- #ifdef ANDROID
104106+ #if defined(ANDROID)
105107 # include <android/log.h>
106- + #elif defined(OHOS )
108+ + #elif defined(XP_OHOS )
107109+ # include <hilog/log.h>
108110 #endif
109111
@@ -115,7 +117,7 @@ index 3247b993c..c7039d5f8 100644
115117- #ifdef ANDROID
116118+ #if defined(ANDROID)
117119 __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str());
118- + #elif defined(OHOS )
120+ + #elif defined(XP_OHOS )
119121+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str());
120122 #else
121123 fputs(s.str().c_str(), stderr);
@@ -128,20 +130,20 @@ index c3a2ca89e..3fea33f4b 100644
128130
129131 #ifdef ANDROID
130132 # include <android/log.h>
131- + #elif defined(OHOS )
133+ + #elif defined(XP_OHOS )
132134+ # include <hilog/log.h>
133135 #endif
134136
135137- #ifndef ANDROID
136- + #if ! (defined(ANDROID) || defined(OHOS ))
138+ + #if ! (defined(ANDROID) || defined(XP_OHOS ))
137139 static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) {
138140 // Avoid interleaving by writing to an on-stack buffer and then writing in one
139141 // go with fputs, as long as the output fits into the buffer.
140142@@ -66,6 +68,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
141143 MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
142144 __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs);
143145 }
144- + #elif defined(OHOS )
146+ + #elif defined(XP_OHOS )
145147+ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
146148+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs);
147149+ }
@@ -153,14 +155,14 @@ index c3a2ca89e..3fea33f4b 100644
153155
154156 MFBT_API void print_stderr(std::stringstream& aStr) {
155157- #if defined(ANDROID)
156- + #if defined(ANDROID) || defined(OHOS )
158+ + #if defined(ANDROID) || defined(XP_OHOS )
157159 // On Android logcat output is truncated to 1024 chars per line, and
158160 // we usually use std::stringstream to build up giant multi-line gobs
159161 // of output. So to avoid the truncation we find the newlines and
160162 // print the lines individually.
161163 std::string line;
162164 while (std::getline(aStr, line)) {
163- + # ifdef OHOS
165+ + # ifdef XP_OHOS
164166+ printf_stderr("%{public}s\n", line.c_str());
165167+ # else
166168 printf_stderr("%s\n", line.c_str());
@@ -179,7 +181,7 @@ index 52bd6abc5..781402d56 100644
179181- #ifdef ANDROID
180182+ #if defined(ANDROID)
181183 # include <android/log.h>
182- + #elif defined(OHOS )
184+ + #elif defined(XP_OHOS )
183185+ # include <hilog/log.h>
184186 #endif
185187
@@ -188,7 +190,7 @@ index 52bd6abc5..781402d56 100644
188190 PR_Write(fd, buf, nb); \
189191 } \
190192 PR_END_MACRO
191- + #elif defined(OHOS )
193+ + #elif defined(XP_OHOS )
192194+ #define _PUT_LOG(fd, buf, nb) \
193195+ PR_BEGIN_MACRO \
194196+ if (fd == _pr_stderr) { \
@@ -208,7 +210,7 @@ index 52bd6abc5..781402d56 100644
208210 PR_LogPrint("Aborting");
209211 #ifdef ANDROID
210212 __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
211- + #elif defined(OHOS )
213+ + #elif defined(XP_OHOS )
212214+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n");
213215 #endif
214216 abort();
@@ -217,7 +219,7 @@ index 52bd6abc5..781402d56 100644
217219 #elif defined(ANDROID)
218220 __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s,
219221 file, ln);
220- + #elif defined(OHOS )
222+ + #elif defined(XP_OHOS )
221223+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog",
222224+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
223225 #endif
0 commit comments