Ticket #183: assert.h

File assert.h, 2.2 KB (added by shinji, 6 years ago)

assert.h from router build environment

Line 
1/* Copyright (C) 1991,1992,1994-1999,2000,2001 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
5   modify it under the terms of the GNU Lesser General Public
6   License as published by the Free Software Foundation; either
7   version 2.1 of the License, or (at your option) any later version.
8
9   The GNU C Library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with the GNU C Library; if not, write to the Free
16   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17   02111-1307 USA.  */
18
19/*
20 *  ISO C99 Standard: 7.2 Diagnostics   <assert.h>
21 */
22
23#ifndef __ASSERT_H
24#define __ASSERT_H
25#include <features.h>
26
27/* If NDEBUG is defined, do nothing.
28   If not, and EXPRESSION is zero, print an error message and abort.  */
29
30#ifdef  NDEBUG
31
32#define assert(expr)        ((void) 0)
33
34#else /* Not NDEBUG.  */
35
36__BEGIN_DECLS
37extern void __assert __P((const char *, const char *, int, const char *));
38__END_DECLS
39
40#define assert(expr)                                  \
41  ((void) ((expr) ||                                  \
42       (__assert (__STRING(expr),                     \
43               __FILE__, __LINE__, __ASSERT_FUNCTION), 0)))
44
45 
46/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
47   which contains the name of the function currently being defined.
48#  define __ASSERT_FUNCTION __PRETTY_FUNCTION__
49   This is broken in G++ before version 2.6.
50   C9x has a similar variable called __func__, but prefer the GCC one since
51   it demangles C++ function names.  */
52# ifdef __GNUC__
53#  if __GNUC__ > 2 || (__GNUC__ == 2 \
54               && __GNUC_MINOR__ >= (defined __cplusplus ? 6 : 4))
55#   define __ASSERT_FUNCTION    __PRETTY_FUNCTION__
56#  else
57#   define __ASSERT_FUNCTION    ((__const char *) 0)
58#  endif
59# else
60#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
61#   define __ASSERT_FUNCTION    __func__
62#  else
63#   define __ASSERT_FUNCTION    ((__const char *) 0)
64#  endif
65# endif
66
67
68#endif /* NDEBUG.  */
69
70#endif /* __ASSERT_H */