From d47e1b8f362379d8a2307f49e2b42115a3f40524 Mon Sep 17 00:00:00 2001 From: ntfreak Date: Tue, 25 Mar 2008 15:45:17 +0000 Subject: - rename log functions to stop conflicts under win32 (wingdi) git-svn-id: svn://svn.berlios.de/openocd/trunk@523 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/binarybuffer.c | 2 +- src/helper/command.c | 2 +- src/helper/configuration.c | 2 +- src/helper/fileio.c | 10 +++---- src/helper/log.c | 10 +++---- src/helper/log.h | 65 +++++++++++++++++++++++----------------------- src/helper/options.c | 18 ++++++------- src/helper/replacements.h | 2 -- 8 files changed, 54 insertions(+), 57 deletions(-) (limited to 'src/helper') diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index ddfcced0..03e2b7e3 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -78,7 +78,7 @@ u32 buf_get_u32(u8* buffer, unsigned int first, unsigned int num) if (!buffer) { - ERROR("buffer not initialized"); + LOG_ERROR("buffer not initialized"); return 0; } diff --git a/src/helper/command.c b/src/helper/command.c index 8d5a77ea..7d24d81d 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -372,7 +372,7 @@ int command_run_line(command_context_t *context, char *line) if (*line && (line[0] == '#')) return ERROR_OK; - DEBUG("%s", line); + LOG_DEBUG("%s", line); nwords = parse_line(line, words, sizeof(words) / sizeof(words[0])); diff --git a/src/helper/configuration.c b/src/helper/configuration.c index d7255606..fb5b797e 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -84,7 +84,7 @@ FILE *open_file_from_path (char *file, char *mode) } if (fp) - DEBUG("opened %s", full_path); + LOG_DEBUG("opened %s", full_path); return fp; } diff --git a/src/helper/fileio.c b/src/helper/fileio.c index eaf8e0db..9edf764b 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -62,7 +62,7 @@ int fileio_open_local(fileio_t *fileio) strcpy(access, "a+"); break; default: - ERROR("BUG: access neither read, write nor readwrite"); + LOG_ERROR("BUG: access neither read, write nor readwrite"); return ERROR_INVALID_ARGUMENTS; } @@ -76,7 +76,7 @@ int fileio_open_local(fileio_t *fileio) if (!(fileio->file = open_file_from_path (fileio->url, access))) { - ERROR("couldn't open %s", fileio->url); + LOG_ERROR("couldn't open %s", fileio->url); return ERROR_FILEIO_OPERATION_FAILED; } @@ -127,11 +127,11 @@ int fileio_close_local(fileio_t *fileio) { if (retval == EBADF) { - ERROR("BUG: fileio_local->file not a valid file descriptor"); + LOG_ERROR("BUG: fileio_local->file not a valid file descriptor"); } else { - ERROR("couldn't close %s: %s", fileio->url, strerror(errno)); + LOG_ERROR("couldn't close %s: %s", fileio->url, strerror(errno)); } return ERROR_FILEIO_OPERATION_FAILED; @@ -157,7 +157,7 @@ int fileio_seek(fileio_t *fileio, u32 position) int retval; if ((retval = fseek(fileio->file, position, SEEK_SET)) != 0) { - ERROR("couldn't seek file %s: %s", fileio->url, strerror(errno)); + LOG_ERROR("couldn't seek file %s: %s", fileio->url, strerror(errno)); return ERROR_FILEIO_OPERATION_FAILED; } diff --git a/src/helper/log.c b/src/helper/log.c index 2e985d03..d0f0e3dd 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -61,7 +61,7 @@ static int count = 0; */ static void log_puts(enum log_levels level, const char *file, int line, const char *function, const char *string) { - if (level == LOG_OUTPUT) + if (level == LOG_LVL_OUTPUT) { /* do not prepend any headers, just print out what we were given and return */ fputs(string, log_output); @@ -75,7 +75,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch if (strchr(string, '\n')!=NULL) { - if (debug_level >= LOG_DEBUG) + if (debug_level >= LOG_LVL_DEBUG) { /* print with count and time information */ int t=(int)(timeval_ms()-start); @@ -94,8 +94,8 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch fflush(log_output); - /* Never forward LOG_DEBUG, too verbose and they can be found in the log if need be */ - if (level <= LOG_INFO) + /* Never forward LOG_LVL_DEBUG, too verbose and they can be found in the log if need be */ + if (level <= LOG_LVL_INFO) { log_callback_t *cb, *next; cb = log_callbacks; @@ -205,7 +205,7 @@ int log_init(struct command_context_s *cmd_ctx) { /* set defaults for daemon configuration, if not set by cmdline or cfgfile */ if (debug_level == -1) - debug_level = LOG_INFO; + debug_level = LOG_LVL_INFO; if (log_output == NULL) { diff --git a/src/helper/log.h b/src/helper/log.h index 601b7527..9929d420 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -26,25 +26,25 @@ #include /* logging priorities - * LOG_SILENT - turn off all output. In lieu of try+catch this can be used as a - * feeble ersatz. - * LOG_USER - user messages. Could be anything from information - * to progress messags. These messages do not represent - * incorrect or unexpected behaviour, just normal execution. - * LOG_ERROR - fatal errors, that are likely to cause program abort - * LOG_WARNING - non-fatal errors, that may be resolved later - * LOG_INFO - state information, etc. - * LOG_DEBUG - debug statements, execution trace + * LOG_LVL_SILENT - turn off all output. In lieu of try+catch this can be used as a + * feeble ersatz. + * LOG_LVL_USER - user messages. Could be anything from information + * to progress messags. These messages do not represent + * incorrect or unexpected behaviour, just normal execution. + * LOG_LVL_ERROR - fatal errors, that are likely to cause program abort + * LOG_LVL_WARNING - non-fatal errors, that may be resolved later + * LOG_LVL_INFO - state information, etc. + * LOG_LVL_DEBUG - debug statements, execution trace */ enum log_levels { - LOG_SILENT = -3, - LOG_OUTPUT = -2, - LOG_USER = -1, - LOG_ERROR = 0, - LOG_WARNING = 1, - LOG_INFO = 2, - LOG_DEBUG = 3 + LOG_LVL_SILENT = -3, + LOG_LVL_OUTPUT = -2, + LOG_LVL_USER = -1, + LOG_LVL_ERROR = 0, + LOG_LVL_WARNING = 1, + LOG_LVL_INFO = 2, + LOG_LVL_DEBUG = 3 }; extern void log_printf(enum log_levels level, const char *file, int line, @@ -79,30 +79,29 @@ extern int debug_level; * Matters on feeble CPUs for DEBUG/INFO statements that are involved frequently */ -#define DEBUG(expr ...) \ - log_printf_lf (LOG_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_DEBUG(expr ...) \ + log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) -#define INFO(expr ...) \ - log_printf_lf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_INFO(expr ...) \ + log_printf_lf (LOG_LVL_INFO, __FILE__, __LINE__, __FUNCTION__, expr) -#define INFO_N(expr ...) \ - log_printf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_INFO_N(expr ...) \ + log_printf (LOG_LVL_INFO, __FILE__, __LINE__, __FUNCTION__, expr) -#define WARNING(expr ...) \ - log_printf_lf (LOG_WARNING, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_WARNING(expr ...) \ + log_printf_lf (LOG_LVL_WARNING, __FILE__, __LINE__, __FUNCTION__, expr) -#define ERROR(expr ...) \ - log_printf_lf (LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_ERROR(expr ...) \ + log_printf_lf (LOG_LVL_ERROR, __FILE__, __LINE__, __FUNCTION__, expr) -#define USER(expr ...) \ - log_printf_lf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_USER(expr ...) \ + log_printf_lf (LOG_LVL_USER, __FILE__, __LINE__, __FUNCTION__, expr) -#define USER_N(expr ...) \ - log_printf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr) - -#define OUTPUT(expr ...) \ - log_printf (LOG_OUTPUT, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_USER_N(expr ...) \ + log_printf (LOG_LVL_USER, __FILE__, __LINE__, __FUNCTION__, expr) +#define LOG_OUTPUT(expr ...) \ + log_printf (LOG_LVL_OUTPUT, __FILE__, __LINE__, __FUNCTION__, expr) /* general failures * error codes < 100 diff --git a/src/helper/options.c b/src/helper/options.c index 23b0a637..5ad09fbd 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -47,7 +47,7 @@ static struct option long_options[] = int configuration_output_handler(struct command_context_s *context, char* line) { - INFO_N(line); + LOG_INFO_N(line); return ERROR_OK; } @@ -111,14 +111,14 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[] if (help_flag) { - OUTPUT("Open On-Chip Debugger\n(c) 2005-2008 by Dominic Rath\n\n"); - OUTPUT("--help | -h\tdisplay this help\n"); - OUTPUT("--version | -v\tdisplay OpenOCD version\n"); - OUTPUT("--file | -f\tuse configuration file \n"); - OUTPUT("--search | -s\tdir to search for config files and scripts\n"); - OUTPUT("--debug | -d\tset debug level <0-3>\n"); - OUTPUT("--log_output | -l\tredirect log output to file \n"); - OUTPUT("--command | -c\trun \n"); + LOG_OUTPUT("Open On-Chip Debugger\n(c) 2005-2008 by Dominic Rath\n\n"); + LOG_OUTPUT("--help | -h\tdisplay this help\n"); + LOG_OUTPUT("--version | -v\tdisplay OpenOCD version\n"); + LOG_OUTPUT("--file | -f\tuse configuration file \n"); + LOG_OUTPUT("--search | -s\tdir to search for config files and scripts\n"); + LOG_OUTPUT("--debug | -d\tset debug level <0-3>\n"); + LOG_OUTPUT("--log_output | -l\tredirect log output to file \n"); + LOG_OUTPUT("--command | -c\trun \n"); exit(-1); } diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 79a7a1bd..4df76012 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -140,8 +140,6 @@ void usleep(int us); #include #include -#undef ERROR - #if IS_MINGW == 1 static __inline unsigned char inb(unsigned short int port) { -- cgit v1.2.3