[BACK]Return to assert.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / include

Annotation of src/include/assert.h, Revision 1.21

1.21    ! joerg       1: /*     $NetBSD: assert.h,v 1.20 2008/11/02 14:27:44 christos Exp $     */
1.6       cgd         2:
1.5       cgd         3: /*-
                      4:  * Copyright (c) 1992, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  * (c) UNIX System Laboratories, Inc.
                      7:  * All or some portions of this file are derived from material licensed
                      8:  * to the University of California by American Telephone and Telegraph
                      9:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
                     10:  * the permission of UNIX System Laboratories, Inc.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
1.15      agc        20:  * 3. Neither the name of the University nor the names of its contributors
1.5       cgd        21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
1.6       cgd        36:  *     @(#)assert.h    8.2 (Berkeley) 1/21/94
1.5       cgd        37:  */
                     38:
                     39: /*
                     40:  * Unlike other ANSI header files, <assert.h> may usefully be included
                     41:  * multiple times, with and without NDEBUG defined.
                     42:  */
                     43:
1.12      kleink     44: #include <sys/cdefs.h>
1.13      bjh21      45: #include <sys/featuretest.h>
1.20      christos   46: #include <sys/null.h>
1.12      kleink     47:
1.5       cgd        48: #undef assert
                     49:
                     50: #ifdef NDEBUG
1.17      kleink     51: # ifndef __lint__
1.12      kleink     52: #  define assert(e)    (__static_cast(void,0))
1.17      kleink     53: # else /* !__lint__ */
1.7       christos   54: #  define assert(e)
1.17      kleink     55: # endif /* __lint__ */
1.7       christos   56: #else /* !NDEBUG */
1.9       kleink     57: # if __STDC__
1.10      kleink     58: #  define assert(e)                                                    \
1.12      kleink     59:        ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__,   \
                     60:                                                  __assert_function__, #e))
1.7       christos   61: # else /* PCC */
1.10      kleink     62: #  define assert(e)                                                    \
1.12      kleink     63:        ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__,   \
                     64:                                                  __assert_function__, "e"))
1.9       kleink     65: # endif /* !__STDC__ */
1.7       christos   66: #endif /* NDEBUG */
1.13      bjh21      67:
1.8       lukem      68: #undef _DIAGASSERT
                     69: #if !defined(_DIAGNOSTIC)
1.17      kleink     70: # if !defined(__lint__)
1.12      kleink     71: #  define _DIAGASSERT(e) (__static_cast(void,0))
1.17      kleink     72: # else /* !__lint__ */
1.8       lukem      73: #  define _DIAGASSERT(e)
1.17      kleink     74: # endif /* __lint__ */
1.8       lukem      75: #else /* _DIAGNOSTIC */
1.9       kleink     76: # if __STDC__
1.10      kleink     77: #  define _DIAGASSERT(e)                                               \
1.12      kleink     78:        ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \
                     79:                                                      __assert_function__, #e))
1.8       lukem      80: # else /* !__STDC__ */
1.10      kleink     81: #  define _DIAGASSERT(e)                                               \
1.12      kleink     82:        ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \
                     83:                                                      __assert_function__, "e"))
1.8       lukem      84: # endif
                     85: #endif /* _DIAGNOSTIC */
                     86:
                     87:
1.19      gmcgarry   88: #if defined(__lint__)
                     89: #define        __assert_function__     (__static_cast(const void *,0))
                     90: #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
1.10      kleink     91: #define        __assert_function__     __func__
                     92: #elif __GNUC_PREREQ__(2, 6)
                     93: #define        __assert_function__     __PRETTY_FUNCTION__
                     94: #else
1.12      kleink     95: #define        __assert_function__     (__static_cast(const void *,0))
1.10      kleink     96: #endif
                     97:
1.11      christos   98: #ifndef __ASSERT_DECLARED
                     99: #define __ASSERT_DECLARED
1.5       cgd       100: __BEGIN_DECLS
1.21    ! joerg     101: __dead void __assert(const char *, int, const char *);
        !           102: __dead void __assert13(const char *, int, const char *, const char *);
1.18      perry     103: void __diagassert(const char *, int, const char *);
                    104: void __diagassert13(const char *, int, const char *, const char *);
1.5       cgd       105: __END_DECLS
1.11      christos  106: #endif /* __ASSERT_DECLARED */

CVSweb <webmaster@jp.NetBSD.org>