summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-01-17 07:55:20 +0100
committerThomas Martitz <kugel@rockbox.org>2012-01-21 18:39:19 +0100
commit5b4a6c4267074c40655213e443ab4997530a4a98 (patch)
treeddcaa5d0971a61aaa4856943e00c50e5096c1698 /firmware/target
parentcf333a61c7861361b4025cb0f67c8f75b0b07eef (diff)
Hosted: Merge debugf() implementations. Cleanup debug.h.
Fixes debug build for ypr0. Change-Id: I9c0eff651dcf268a3fafed1a71fcc47f3e323d36
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/hosted/debug-hosted.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/firmware/target/hosted/debug-hosted.c b/firmware/target/hosted/debug-hosted.c
new file mode 100644
index 0000000000..35c487958b
--- /dev/null
+++ b/firmware/target/hosted/debug-hosted.c
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (c) 2002 Daniel Stenberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef WIN32
+static unsigned old_cp;
+
+void debug_exit(void)
+{
+ /* Reset console output codepage */
+ SetConsoleOutputCP(old_cp);
+}
+
+void debug_init(void)
+{
+ old_cp = GetConsoleOutputCP();
+ /* Set console output codepage to UTF8. Only works
+ * correctly when the console uses a truetype font. */
+ SetConsoleOutputCP(65001);
+ atexit(debug_exit);
+}
+#else
+void debug_init(void)
+{
+ /* nothing to be done */
+}
+#endif
+
+void debugf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+}
+
+void ldebugf(const char* file, int line, const char *fmt, ...)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ fprintf( stderr, "%s:%d ", file, line );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+}