forked from wavewave/nix-build-ghc-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrts_android_log_write.patch
42 lines (39 loc) · 1.36 KB
/
rts_android_log_write.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff -rupN a/rts/RtsMessages.c b/rts/RtsMessages.c
--- a/rts/RtsMessages.c 2014-12-23 02:31:10.000000000 +0000
+++ b/rts/RtsMessages.c 2015-10-11 22:25:49.802309919 +0000
@@ -19,6 +19,11 @@
#include <windows.h>
#endif
+#ifdef __ANDROID__
+#include <dlfcn.h>
+#include <android/log.h>
+#endif
+
/* -----------------------------------------------------------------------------
General message generation functions
@@ -163,6 +168,26 @@ rtsFatalInternalErrorFn(const char *s, v
fflush(stderr);
}
+#ifdef __ANDROID__
+ {
+ /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
+ void* handle = dlopen("liblog.so", RTLD_GLOBAL | RTLD_NOW);
+ int (*__android_log_write)(int, const char*, const char*) = dlsym(handle, "__android_log_write");
+ // if (prog_argv != NULL && prog_name != NULL) {
+ // char* s1;
+ // sprintf(s1, "%s: internal error: ", prog_name);
+ // __android_log_write( ANDROID_LOG_ERROR, "ghc-rts", s1);
+ // } else {
+ // char* s1;
+ // sprintf(s1, "internal error: ");
+ // __android_log_write( ANDROID_LOG_ERROR, "ghc-rts", s1);
+ // }
+ char* s2;
+ vsprintf(s2, s, ap);
+ __android_log_write( ANDROID_LOG_ERROR, "ghc-rts", s2);
+ }
+#endif // __ANDROID__
+
#ifdef TRACING
if (RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG) endEventLogging();
#endif