Text file src/runtime/cgo/gcc_fatalf.c

     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  //go:build unix
     6  
     7  #include <stdarg.h>
     8  #ifdef __ANDROID__
     9  #include <android/log.h>
    10  #endif
    11  #include "libcgo.h"
    12  
    13  void
    14  fatalf(const char* format, ...)
    15  {
    16  	va_list ap;
    17  
    18  	fprintf(stderr, "runtime/cgo: ");
    19  	va_start(ap, format);
    20  	vfprintf(stderr, format, ap);
    21  	va_end(ap);
    22  	fprintf(stderr, "\n");
    23  
    24  #ifdef __ANDROID__
    25  	// When running from an Android .apk, /dev/stderr and /dev/stdout
    26  	// redirect to /dev/null. And when running a test binary
    27  	// via adb shell, it's easy to miss logcat. So write to both.
    28  	va_start(ap, format);
    29  	__android_log_vprint(ANDROID_LOG_FATAL, "runtime/cgo", format, ap);
    30  	va_end(ap);
    31  #endif
    32  
    33  	abort();
    34  }
    35  

View as plain text