diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-17 07:55:20 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-21 18:39:19 +0100 |
commit | 5b4a6c4267074c40655213e443ab4997530a4a98 (patch) | |
tree | ddcaa5d0971a61aaa4856943e00c50e5096c1698 /firmware/target/hosted | |
parent | cf333a61c7861361b4025cb0f67c8f75b0b07eef (diff) | |
download | rockbox-5b4a6c4267074c40655213e443ab4997530a4a98.tar.gz rockbox-5b4a6c4267074c40655213e443ab4997530a4a98.zip |
Hosted: Merge debugf() implementations. Cleanup debug.h.
Fixes debug build for ypr0.
Change-Id: I9c0eff651dcf268a3fafed1a71fcc47f3e323d36
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/debug-hosted.c | 65 |
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2002 Daniel Stenberg | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdarg.h> | ||
23 | #include <stdio.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | #ifdef WIN32 | ||
27 | static unsigned old_cp; | ||
28 | |||
29 | void debug_exit(void) | ||
30 | { | ||
31 | /* Reset console output codepage */ | ||
32 | SetConsoleOutputCP(old_cp); | ||
33 | } | ||
34 | |||
35 | void debug_init(void) | ||
36 | { | ||
37 | old_cp = GetConsoleOutputCP(); | ||
38 | /* Set console output codepage to UTF8. Only works | ||
39 | * correctly when the console uses a truetype font. */ | ||
40 | SetConsoleOutputCP(65001); | ||
41 | atexit(debug_exit); | ||
42 | } | ||
43 | #else | ||
44 | void debug_init(void) | ||
45 | { | ||
46 | /* nothing to be done */ | ||
47 | } | ||
48 | #endif | ||
49 | |||
50 | void debugf(const char *fmt, ...) | ||
51 | { | ||
52 | va_list ap; | ||
53 | va_start( ap, fmt ); | ||
54 | vfprintf( stderr, fmt, ap ); | ||
55 | va_end( ap ); | ||
56 | } | ||
57 | |||
58 | void ldebugf(const char* file, int line, const char *fmt, ...) | ||
59 | { | ||
60 | va_list ap; | ||
61 | va_start( ap, fmt ); | ||
62 | fprintf( stderr, "%s:%d ", file, line ); | ||
63 | vfprintf( stderr, fmt, ap ); | ||
64 | va_end( ap ); | ||
65 | } | ||