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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdlib/] [assert.c] - Blame information for rev 1773

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

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
<<assert>>---Macro for Debugging Diagnostics
4
 
5
INDEX
6
        assert
7
 
8
ANSI_SYNOPSIS
9
        #include <assert.h>
10
        void assert(int <[expression]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <assert.h>
14
        assert(<[expression]>)
15
        int <[expression]>;
16
 
17
DESCRIPTION
18
        Use this macro to embed debuggging diagnostic statements in
19
        your programs.  The argument <[expression]> should be an
20
        expression which evaluates to true (nonzero) when your program
21
        is working as you intended.
22
 
23
        When <[expression]> evaluates to false (zero), <<assert>>
24
        calls <<abort>>, after first printing a message showing what
25
        failed and where:
26
 
27
. Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>
28
 
29
        The macro is defined to permit you to turn off all uses of
30
        <<assert>> at compile time by defining <<NDEBUG>> as a
31
        preprocessor variable.   If you do this, the <<assert>> macro
32
        expands to
33
 
34
. (void(0))
35
 
36
RETURNS
37
        <<assert>> does not return a value.
38
 
39
PORTABILITY
40
        The <<assert>> macro is required by ANSI, as is the behavior
41
        when <<NDEBUG>> is defined.
42
 
43
Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
44
<<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
45
*/
46
 
47
#include <assert.h>
48
#include <stdlib.h>
49
#include <stdio.h>
50
 
51
void
52
_DEFUN (__assert, (file, line, failedexpr),
53
        const char *file _AND
54
        int line _AND
55
        const char *failedexpr)
56
{
57
  (void)fiprintf(stderr,
58
        "assertion \"%s\" failed: file \"%s\", line %d\n",
59
        failedexpr, file, line);
60
  abort();
61
  /* NOTREACHED */
62
}

powered by: WebSVN 2.1.0

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