assert.h revision 1.12
11.12Skleink/* $NetBSD: assert.h,v 1.12 2001/05/06 15:31:09 kleink Exp $ */ 21.6Scgd 31.5Scgd/*- 41.5Scgd * Copyright (c) 1992, 1993 51.5Scgd * The Regents of the University of California. All rights reserved. 61.5Scgd * (c) UNIX System Laboratories, Inc. 71.5Scgd * All or some portions of this file are derived from material licensed 81.5Scgd * to the University of California by American Telephone and Telegraph 91.5Scgd * Co. or Unix System Laboratories, Inc. and are reproduced herein with 101.5Scgd * the permission of UNIX System Laboratories, Inc. 111.5Scgd * 121.5Scgd * Redistribution and use in source and binary forms, with or without 131.5Scgd * modification, are permitted provided that the following conditions 141.5Scgd * are met: 151.5Scgd * 1. Redistributions of source code must retain the above copyright 161.5Scgd * notice, this list of conditions and the following disclaimer. 171.5Scgd * 2. Redistributions in binary form must reproduce the above copyright 181.5Scgd * notice, this list of conditions and the following disclaimer in the 191.5Scgd * documentation and/or other materials provided with the distribution. 201.5Scgd * 3. All advertising materials mentioning features or use of this software 211.5Scgd * must display the following acknowledgement: 221.5Scgd * This product includes software developed by the University of 231.5Scgd * California, Berkeley and its contributors. 241.5Scgd * 4. Neither the name of the University nor the names of its contributors 251.5Scgd * may be used to endorse or promote products derived from this software 261.5Scgd * without specific prior written permission. 271.5Scgd * 281.5Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.5Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.5Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.5Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.5Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.5Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.5Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.5Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.5Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.5Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.5Scgd * SUCH DAMAGE. 391.5Scgd * 401.6Scgd * @(#)assert.h 8.2 (Berkeley) 1/21/94 411.5Scgd */ 421.5Scgd 431.5Scgd/* 441.5Scgd * Unlike other ANSI header files, <assert.h> may usefully be included 451.5Scgd * multiple times, with and without NDEBUG defined. 461.5Scgd */ 471.5Scgd 481.12Skleink#include <sys/cdefs.h> 491.12Skleink 501.5Scgd#undef assert 511.5Scgd#undef _assert 521.5Scgd 531.5Scgd#ifdef NDEBUG 541.7Schristos# ifndef lint 551.12Skleink# define assert(e) (__static_cast(void,0)) 561.12Skleink# define _assert(e) (__static_cast(void,0)) 571.7Schristos# else /* !lint */ 581.7Schristos# define assert(e) 591.7Schristos# define _assert(e) 601.7Schristos# endif /* lint */ 611.7Schristos#else /* !NDEBUG */ 621.7Schristos# define _assert(e) assert(e) 631.9Skleink# if __STDC__ 641.10Skleink# define assert(e) \ 651.12Skleink ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__, \ 661.12Skleink __assert_function__, #e)) 671.7Schristos# else /* PCC */ 681.10Skleink# define assert(e) \ 691.12Skleink ((e) ? __static_cast(void,0) : __assert13(__FILE__, __LINE__, \ 701.12Skleink __assert_function__, "e")) 711.9Skleink# endif /* !__STDC__ */ 721.7Schristos#endif /* NDEBUG */ 731.5Scgd 741.8Slukem#undef _DIAGASSERT 751.8Slukem#if !defined(_DIAGNOSTIC) 761.8Slukem# if !defined(lint) 771.12Skleink# define _DIAGASSERT(e) (__static_cast(void,0)) 781.8Slukem# else /* !lint */ 791.8Slukem# define _DIAGASSERT(e) 801.8Slukem# endif /* lint */ 811.8Slukem#else /* _DIAGNOSTIC */ 821.9Skleink# if __STDC__ 831.10Skleink# define _DIAGASSERT(e) \ 841.12Skleink ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \ 851.12Skleink __assert_function__, #e)) 861.8Slukem# else /* !__STDC__ */ 871.10Skleink# define _DIAGASSERT(e) \ 881.12Skleink ((e) ? __static_cast(void,0) : __diagassert13(__FILE__, __LINE__, \ 891.12Skleink __assert_function__, "e")) 901.8Slukem# endif 911.8Slukem#endif /* _DIAGNOSTIC */ 921.8Slukem 931.8Slukem 941.10Skleink#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 951.10Skleink#define __assert_function__ __func__ 961.10Skleink#elif __GNUC_PREREQ__(2, 6) 971.10Skleink#define __assert_function__ __PRETTY_FUNCTION__ 981.10Skleink#else 991.12Skleink#define __assert_function__ (__static_cast(const void *,0)) 1001.10Skleink#endif 1011.10Skleink 1021.11Schristos#ifndef __ASSERT_DECLARED 1031.11Schristos#define __ASSERT_DECLARED 1041.5Scgd__BEGIN_DECLS 1051.5Scgdvoid __assert __P((const char *, int, const char *)); 1061.10Skleinkvoid __assert13 __P((const char *, int, const char *, const char *)); 1071.8Slukemvoid __diagassert __P((const char *, int, const char *)); 1081.10Skleinkvoid __diagassert13 __P((const char *, int, const char *, const char *)); 1091.5Scgd__END_DECLS 1101.11Schristos#endif /* __ASSERT_DECLARED */ 111