1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
*
* This software may be freely used, copied, modified, and distributed
* provided that the above copyright notice is preserved in all copies of the
* software.
*/
/* -*-C-*-
*
* $Revision$
* $Date$
*
*
* logging.h - methods for logging warnings, errors and trace info
*/
#ifndef angel_logging_h
#define angel_logging_h
#include <stdarg.h>
/*
* __rt_warning
* ------------
* Provides a standard method of generating run-time system
* warnings. The actual action taken by this code can be board or
* target application specific, e.g. internal logging, debug message,
* etc.
*/
extern void __rt_warning(char *format, ...);
/*---------------------------------------------------------------------------*/
/*
* __rt_error
* ----------
* Raise an internal Angel error. The parameters are passed directly
* to "__rt_warning" for display, and the code then raises a debugger
* event and stops the target processing.
*/
extern void __rt_error(char *format, ...);
/*
* Some macros for debugging and warning messages
*/
typedef enum WarnLevel {
WL_TRACE,
WL_WARN,
WL_ERROR
} WarnLevel;
void va_warn(WarnLevel level, char *format, va_list args);
#ifdef _WINGDI_
/* stupidity in MSVC <wingdi.h> (in <windows.h> in <winsock.h>) */
# undef ERROR
#endif
#ifndef ERROR
# define ERROR_FORMAT "Error \"%s\" in %s at line %d\n"
# define ERROR(e) __rt_error(ERROR_FORMAT, (e), __FILE__, __LINE__)
#endif
#ifndef ASSERT
# ifdef ASSERTIONS_ENABLED
# define ASSERT(x, y) ((x) ? (void)(0) : ERROR((y)))
# else
# define ASSERT(x, y) ((void)(0))
# endif
#endif
#ifndef WARN
# ifdef ASSERTIONS_ENABLED
# define WARN_FORMAT "Warning \"%s\" in %s at line %d\n"
# define WARN(w) __rt_warning(WARN_FORMAT, (w), __FILE__, __LINE__)
# else
# define WARN(w) ((void)(0))
# endif
#endif
#ifdef NO_INFO_MESSAGES
# define __rt_info (void)
# ifndef INFO
# define INFO(w)
# endif
#else
# define __rt_info __rt_warning
# ifndef INFO
# ifdef DEBUG
# define INFO(w) __rt_warning("%s\n", (w))
# else
# define INFO(w) ((void)(0))
# endif
# endif
#endif
#if defined(DEBUG) && !defined(NO_IDLE_CHITCHAT)
# ifndef DO_TRACE
# define DO_TRACE (1)
# endif
#endif
#ifdef DO_TRACE
extern void __rt_trace(char *format, ...);
#endif
#ifndef TRACE
# ifdef DO_TRACE
# define TRACE(w) __rt_trace("%s ", (w))
# else
# define TRACE(w) ((void)(0))
# endif
#endif
#endif /* ndef angel_logging_h */
/* EOF logging.h */
|