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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [assert.c] - Blame information for rev 179

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

Line No. Rev Author Line
1 148 jeremybenn
/*
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
DESCRIPTION
13
        Use this macro to embed debuggging diagnostic statements in
14
        your programs.  The argument <[expression]> should be an
15
        expression which evaluates to true (nonzero) when your program
16
        is working as you intended.
17
 
18
        When <[expression]> evaluates to false (zero), <<assert>>
19
        calls <<abort>>, after first printing a message showing what
20
        failed and where:
21
 
22
. Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>, function: <[func]>
23
 
24
        If the name of the current function is not known (for example,
25
        when using a C89 compiler that does not understand __func__),
26
        the function location is omitted.
27
 
28
        The macro is defined to permit you to turn off all uses of
29
        <<assert>> at compile time by defining <<NDEBUG>> as a
30
        preprocessor variable.   If you do this, the <<assert>> macro
31
        expands to
32
 
33
. (void(0))
34
 
35
RETURNS
36
        <<assert>> does not return a value.
37
 
38
PORTABILITY
39
        The <<assert>> macro is required by ANSI, as is the behavior
40
        when <<NDEBUG>> is defined.
41
 
42
Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
43
<<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
44
*/
45
 
46
#include <assert.h>
47
#include <stdlib.h>
48
#include <stdio.h>
49
 
50
/* func can be NULL, in which case no function information is given.  */
51
void
52
_DEFUN (__assert_func, (file, line, func, failedexpr),
53
        const char *file _AND
54
        int line _AND
55
        const char *func _AND
56
        const char *failedexpr)
57
{
58
  fiprintf(stderr,
59
           "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
60
           failedexpr, file, line,
61
           func ? ", function: " : "", func ? func : "");
62
  abort();
63
  /* NOTREACHED */
64
}
65
 
66
void
67
_DEFUN (__assert, (file, line, failedexpr),
68
        const char *file _AND
69
        int line _AND
70
        const char *failedexpr)
71
{
72
   __assert_func (file, line, NULL, failedexpr);
73
  /* NOTREACHED */
74
}

powered by: WebSVN 2.1.0

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