source: soft/giet_vm/libs/libsrl/srl_log.h @ 175

Last change on this file since 175 was 175, checked in by karaoui, 12 years ago

+ Adding the init attribute to the mwmr to specify the width of the mwmr channel
+ Fixing bugs in kernels_init

File size: 1.9 KB
Line 
1/*
2 * This file is part of DSX, development environment for static
3 * SoC applications.
4 *
5 * This file is distributed under the terms of the GNU General Public
6 * License.
7 *
8 * Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>
9 *     Laboratoire d'informatique de Paris 6 / ASIM, France
10 *
11 *  $Id$
12 */
13
14#ifndef SRL_LOG_H_
15#define SRL_LOG_H_
16
17/**
18 * @file
19 * @module{SRL}
20 * @short Debug messages
21 */
22
23#include "stdio.h"
24#include "giet_config.h"
25#include "srl_hw_helpers.h"
26
27/** @internal */
28enum __srl_verbosity {
29    VERB_NONE,
30    VERB_TRACE,
31    VERB_DEBUG,
32    VERB_MAX,
33};
34
35
36void _srl_log(const char *);
37void _srl_log_printf(const char *, ...);
38
39#define GET_VERB_(x,y) x##y
40#define GET_VERB(x) GET_VERB_(VERB_,x)
41
42/**
43   @this prints a message if the current verbosity is sufficient.
44
45   @param l Minimal verbosity of the message
46   @param c Message to print
47 */
48#define srl_log( l, c ) do {                                                                               \
49                if (GET_VERB(l) <= GET_VERB(CONFIG_SRL_VERBOSITY)) {               \
50            giet_tty_printf(c);                                             \
51                }                                                                                                                          \
52        } while (0)
53
54/**
55   @this prints a message if the current verbosity is sufficient.
56
57   @param l Minimal verbosity of the message
58   @param c Message to print, with a printf-like syntax
59 */
60#define srl_log_printf( l, ... ) do {                                   \
61                if (GET_VERB(l) <= GET_VERB(CONFIG_SRL_VERBOSITY)) {                \
62            giet_tty_printf(__VA_ARGS__);                                    \
63                }                                                                                                                           \
64        } while (0)
65
66/**
67   @this is the same as @ref #assert.
68    TODO change the location?
69 */
70#define srl_assert(expr)                                                                                                \
71    do {                                                                                                                                \
72        if ( ! (expr) ) {                                                                                               \
73            srl_log_printf(NONE, "assertion (%s) failed on %s:%d !\n",  \
74                                                   #expr, __FILE__, __LINE__ );                                 \
75            srl_abort();                                                                                                        \
76        }                                                                                                                               \
77    } while(0)
78
79#endif
Note: See TracBrowser for help on using the repository browser.