github.com/aloncn/graphics-go@v0.0.1/src/runtime/cgo/gcc_android.c (about)

     1  // Copyright 2014 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build cgo
     6  
     7  #include <stdarg.h>
     8  #include <android/log.h>
     9  #include "libcgo.h"
    10  
    11  void
    12  fatalf(const char* format, ...)
    13  {
    14  	va_list ap;
    15  
    16  	// Write to both stderr and logcat.
    17  	//
    18  	// When running from an .apk, /dev/stderr and /dev/stdout
    19  	// redirect to /dev/null. And when running a test binary
    20  	// via adb shell, it's easy to miss logcat.
    21  
    22  	fprintf(stderr, "runtime/cgo: ");
    23  	va_start(ap, format);
    24  	vfprintf(stderr, format, ap);
    25  	va_end(ap);
    26  	fprintf(stderr, "\n");
    27  
    28  	va_start(ap, format);
    29  	__android_log_vprint(ANDROID_LOG_FATAL, "runtime/cgo", format, ap);
    30  	va_end(ap);
    31  
    32  	abort();
    33  }