OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [isoinfra/] [v2_0/] [include/] [assert.h] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_ISO_ASSERT_H
2
#define CYGONCE_ISO_ASSERT_H
3
/*========================================================================
4
//
5
//      assert.h
6
//
7
//      ISO C assertions
8
//
9
//========================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):     jlarmour
46
// Contributors:
47
// Date:          2000-04-14
48
// Purpose:       This file provides the assert functions required by
49
//                ISO C and POSIX 1003.1.
50
// Description:   The real contents of this file get set from the
51
//                configuration (set by the implementation)
52
// Usage:         #include <assert.h>
53
//
54
//####DESCRIPTIONEND####
55
//
56
//======================================================================
57
*/
58
 
59
/* CONFIGURATION */
60
 
61
#include <pkgconf/isoinfra.h>          /* Configuration header */
62
#include <pkgconf/infra.h>             /* CYGDBG_USE_ASSERTS */
63
 
64
/* INCLUDES */
65
 
66
#ifdef CYGBLD_ISO_ASSERT_HEADER
67
# include CYGBLD_ISO_ASSERT_HEADER
68
#else
69
 
70
# ifdef NDEBUG
71
#  define assert( __bool ) ((void)0)
72
# else /* if NDEBUG is NOT defined */
73
 
74
/* First preference is to be standards compliant */
75
 
76
#if defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_EXIT)
77
 
78
# include <stdio.h>
79
# include <stdlib.h>
80
 
81
# define assert( __bool )                                                 \
82
    do {                                                                  \
83
        if (0 == (__bool)) {                                              \
84
            fprintf( stderr, "User assertion failed: \"%s\", at %s:%d\n", \
85
                         #__bool, __FILE__, __LINE__);                    \
86
            abort();                                                      \
87
        }                                                                 \
88
    } while(0)
89
 
90
 
91
/* Second preference is to use the common infra assertion support */
92
 
93
#elif defined(CYGDBG_USE_ASSERTS)
94
 
95
# include <cyg/infra/cyg_ass.h>
96
 
97
# define assert( __bool ) \
98
        CYG_MACRO_START   \
99
        CYG_ASSERT( __bool, "User assertion failed: \""  #__bool "\"" ); \
100
        CYG_MACRO_END
101
#else /* Fallback */
102
 
103
# include <cyg/infra/diag.h>
104
 
105
# define assert( __bool )                                                 \
106
    do {                                                                  \
107
        if (0 == (__bool)) {                                              \
108
            diag_printf( "User assertion failed: \"%s\", at %s:%d\n",     \
109
                         #__bool, __FILE__, __LINE__);                    \
110
        for (;;);                                                         \
111
        }                                                                 \
112
    } while(0)
113
 
114
#endif
115
 
116
# endif /* NDEBUG not defined */
117
#endif
118
 
119
#endif /* CYGONCE_ISO_ASSERT_H multiple inclusion protection */
120
 
121
/* EOF assert.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.