aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/cgo/gcc_android.c26
-rw-r--r--src/runtime/cgo/gcc_fatalf.c17
2 files changed, 14 insertions, 29 deletions
diff --git a/src/runtime/cgo/gcc_android.c b/src/runtime/cgo/gcc_android.c
index 7ea213599d..1373feb47a 100644
--- a/src/runtime/cgo/gcc_android.c
+++ b/src/runtime/cgo/gcc_android.c
@@ -2,36 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include <stdarg.h>
-#include <android/log.h>
#include <pthread.h>
#include <dlfcn.h>
#include "libcgo.h"
-void
-fatalf(const char* format, ...)
-{
- va_list ap;
-
- // Write to both stderr and logcat.
- //
- // When running from an .apk, /dev/stderr and /dev/stdout
- // redirect to /dev/null. And when running a test binary
- // via adb shell, it's easy to miss logcat.
-
- fprintf(stderr, "runtime/cgo: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-
- va_start(ap, format);
- __android_log_vprint(ANDROID_LOG_FATAL, "runtime/cgo", format, ap);
- va_end(ap);
-
- abort();
-}
-
// Truncated to a different magic value on 32-bit; that's ok.
#define magic1 (0x23581321345589ULL)
diff --git a/src/runtime/cgo/gcc_fatalf.c b/src/runtime/cgo/gcc_fatalf.c
index 8d46e9187d..2754414fc1 100644
--- a/src/runtime/cgo/gcc_fatalf.c
+++ b/src/runtime/cgo/gcc_fatalf.c
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build unix && !android
+//go:build unix
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
#include "libcgo.h"
void
@@ -19,5 +20,15 @@ fatalf(const char* format, ...)
vfprintf(stderr, format, ap);
va_end(ap);
fprintf(stderr, "\n");
+
+#ifdef __ANDROID__
+ // When running from an Android .apk, /dev/stderr and /dev/stdout
+ // redirect to /dev/null. And when running a test binary
+ // via adb shell, it's easy to miss logcat. So write to both.
+ va_start(ap, format);
+ __android_log_vprint(ANDROID_LOG_FATAL, "runtime/cgo", format, ap);
+ va_end(ap);
+#endif
+
abort();
}