- rename log functions to stop conflicts under win32 (wingdi)
git-svn-id: svn://svn.berlios.de/openocd/trunk@523 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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]));
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -26,25 +26,25 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -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 <name>\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 <name>\n");
|
||||
OUTPUT("--command | -c\trun <command>\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 <name>\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 <name>\n");
|
||||
LOG_OUTPUT("--command | -c\trun <command>\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +140,6 @@ void usleep(int us);
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
|
||||
#undef ERROR
|
||||
|
||||
#if IS_MINGW == 1
|
||||
static __inline unsigned char inb(unsigned short int port)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user