Subversion Repositories shark

Rev

Rev 1618 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
 
22
/*
23
 * Copyright (C) 1999 Massimiliano Giorgi
24
 *
25
 * This program is free software; you can redistribute it and/or modify
26
 * it under the terms of the GNU General Public License as published by
27
 * the Free Software Foundation; either version 2 of the License, or
28
 * (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38
 *
39
 */
40
 
41
/*
79 pj 42
 * CVS :        $Id: assert.h,v 1.2 2003-03-13 13:36:27 pj Exp $
2 pj 43
 *
44
 * File:        $File$
79 pj 45
 * Revision:    $Revision: 1.2 $
46
 * Last update: $Date: 2003-03-13 13:36:27 $
2 pj 47
 */
48
 
49
#ifndef _KERNEL_ASSERT_H
50
#define _KERNEL_ASSERT_H
51
 
1621 fabio 52
#include <arch/sys/cdefs.h>
79 pj 53
 
54
__BEGIN_DECLS
55
 
2 pj 56
/**/
57
 
58
#ifdef NDEBUG
59
 
60
#define assertk(test) {}
61
 
62
#else
63
 
64
void _failed_assertk(char *test,char *filename, int line);
65
 
66
#define assertk(test) \
67
  { if (!(test)) _failed_assertk(#test,__FILE__,__LINE__); }
68
 
69
#endif
70
 
71
/**/
72
 
73
#ifdef _PARANOIA
74
 
75
void _failed_magic_assert(char *filename, int line, char *fmt, ...)
76
        __attribute__ ((format (printf, 3, 4)));
77
 
78
#define magic_assert(value, magic, format, args...)               \
79
  {                                                               \
80
    if ((value)!=(magic))                                         \
81
      _failed_magic_assert(__FILE__,__LINE__,format, ##args); \
82
  }
83
 
84
#define magic_assert_ext(value, magic, fun, format, args...)      \
85
  {                                                               \
86
    if ((value)!=(magic)) {                                       \
87
      fun();                                                      \
88
      _failed_magic_assert(__FILE__,__LINE__,format, ##args); \
89
    }                                                             \
90
  }
91
 
92
#else
93
 
94
#define magic_assert(value, magic, format, args...) {}
95
#define magic_assert_ext(value, magic, fun, format, args...) {}
96
 
97
#endif
98
 
99
/**/
79 pj 100
__END_DECLS
2 pj 101
#endif