From c150be9eb7e0d69def245d877bd66f6df87f58a1 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 21 Aug 2012 23:08:30 -0400 Subject: Get Dimension working on Android. --- libdimension/error.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'libdimension/error.c') diff --git a/libdimension/error.c b/libdimension/error.c index 371c7cd..9fb116a 100644 --- a/libdimension/error.c +++ b/libdimension/error.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes * + * Copyright (C) 2009-2012 Tavian Barnes * * * * This file is part of The Dimension Library. * * * @@ -28,13 +28,18 @@ #include #include #include +#include + +/** Android log tag. */ +#define TAG "libdimension" /** Report internal errors in this file. */ -#define DMNSN_LOCAL_ERROR(str) \ - do { \ - fprintf(stderr, "Dimension ERROR: %s, %s:%u: %s\n", \ - DMNSN_FUNC, __FILE__, __LINE__, (str)); \ - abort(); \ +#define DMNSN_LOCAL_ERROR(str) \ + do { \ + __android_log_print(ANDROID_LOG_ERROR, TAG, \ + "Dimension ERROR: %s, %s:%u: %s\n", \ + DMNSN_FUNC, __FILE__, __LINE__, (str)); \ + abort(); \ } while (0) /** dmnsn_local_lock_mutex implementation. */ @@ -89,18 +94,19 @@ dmnsn_report_error(bool die, const char *func, const char *file, dmnsn_local_unlock_mutex(&dmnsn_always_die_mutex); /* Print the diagnostic string */ - fprintf(stderr, "Dimension %s: %s, %s:%u: %s\n", - die ? "ERROR" : "WARNING", func, file, line, str); + __android_log_print(ANDROID_LOG_ERROR, TAG, + "Dimension %s: %s, %s:%u: %s\n", + die ? "ERROR" : "WARNING", func, file, line, str); /* Print the value of errno */ if (err != 0) { - fprintf(stderr, "Last error: %d", err); + __android_log_print(ANDROID_LOG_ERROR, TAG, "Last error: %d", err); #if DMNSN_SYS_ERRLIST if (err >= 0 && err < sys_nerr) { - fprintf(stderr, " (%s)", sys_errlist[err]); + __android_log_print(ANDROID_LOG_ERROR, TAG, " (%s)", sys_errlist[err]); } #endif - fprintf(stderr, "\n"); + __android_log_print(ANDROID_LOG_ERROR, TAG, "\n"); } /* Print a stack trace to standard error */ -- cgit v1.2.3