Skip to content

Commit 79183e7

Browse files
committed
Update patches
Signed-off-by: Jonathan Schwender <[email protected]>
1 parent 4225d83 commit 79183e7

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h
6161
index 0b7395177..e84d76aba 100644
6262
--- a/mfbt/Assertions.h
6363
+++ b/mfbt/Assertions.h
64-
@@ -88,6 +88,8 @@ MOZ_END_EXTERN_C
64+
@@ -88,6 +88,9 @@ MOZ_END_EXTERN_C
6565
#endif
6666
#ifdef ANDROID
6767
# include <android/log.h>
6868
+#elif defined(XP_OHOS)
69-
+# include <hilog/log.h>
69+
+int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
70+
+ __attribute__((__format__(os_log, 5, 6)));
7071
#endif
7172

7273
MOZ_BEGIN_EXTERN_C
@@ -75,7 +76,7 @@ index 0b7395177..e84d76aba 100644
7576
/* aMaxFrames */ 0);
7677
# endif
7778
+#elif defined(XP_OHOS)
78-
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert",
79+
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_Assert",
7980
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",
8081
+ aStr, aFilename, aLine);
8182
#else
@@ -90,23 +91,24 @@ index 0b7395177..e84d76aba 100644
9091
/* aMaxFrames */ 0);
9192
# endif
9293
+#elif defined(XP_OHOS)
93-
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
94+
+ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_CRASH",
9495
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
9596
+ aStr, aFilename, aLine);
9697
#else
9798
diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h
9899
index 3247b993c..c7039d5f8 100644
99100
--- a/mfbt/DbgMacro.h
100101
+++ b/mfbt/DbgMacro.h
101-
@@ -18,8 +18,10 @@
102+
@@ -18,8 +18,11 @@
102103
template <typename T>
103104
class nsTSubstring;
104105

105106
-#ifdef ANDROID
106107
+#if defined(ANDROID)
107108
# include <android/log.h>
108109
+#elif defined(XP_OHOS)
109-
+# include <hilog/log.h>
110+
+ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...)
111+
+ __attribute__((__format__(os_log, 5, 6)));
110112
#endif
111113

112114
namespace mozilla {
@@ -118,7 +120,7 @@ index 3247b993c..c7039d5f8 100644
118120
+#if defined(ANDROID)
119121
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str());
120122
+#elif defined(XP_OHOS)
121-
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str());
123+
+ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s\n", s.str().c_str());
122124
#else
123125
fputs(s.str().c_str(), stderr);
124126
#endif
@@ -139,13 +141,16 @@ index c3a2ca89e..3fea33f4b 100644
139141
static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) {
140142
// Avoid interleaving by writing to an on-stack buffer and then writing in one
141143
// go with fputs, as long as the output fits into the buffer.
142-
@@ -66,6 +68,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
144+
@@ -66,6 +68,13 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
143145
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
144146
__android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs);
145147
}
146148
+#elif defined(XP_OHOS)
147149
+MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
148-
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs);
150+
+ // OH_LOG_VPrint is available with API-level 18 (19?) or higher.
151+
+ char buffer[1024];
152+
+ VsprintfBuf(buffer, 1024, aFmt, aArgs);
153+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", buffer);
149154
+}
150155
#elif defined(FUZZING_SNAPSHOT)
151156
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
@@ -163,7 +168,7 @@ index c3a2ca89e..3fea33f4b 100644
163168
std::string line;
164169
while (std::getline(aStr, line)) {
165170
+# ifdef XP_OHOS
166-
+ printf_stderr("%{public}s\n", line.c_str());
171+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", line.c_str());
167172
+# else
168173
printf_stderr("%s\n", line.c_str());
169174
+# endif

mozjs-sys/mozjs/mfbt/Assertions.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)