11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1992, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes * (c) UNIX System Laboratories, Inc.
51539Srgrimes * All or some portions of this file are derived from material licensed
61539Srgrimes * to the University of California by American Telephone and Telegraph
71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81539Srgrimes * the permission of UNIX System Laboratories, Inc.
91539Srgrimes *
101539Srgrimes * Redistribution and use in source and binary forms, with or without
111539Srgrimes * modification, are permitted provided that the following conditions
121539Srgrimes * are met:
131539Srgrimes * 1. Redistributions of source code must retain the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer.
151539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161539Srgrimes *    notice, this list of conditions and the following disclaimer in the
171539Srgrimes *    documentation and/or other materials provided with the distribution.
18203964Simp * 3. Neither the name of the University nor the names of its contributors
191539Srgrimes *    may be used to endorse or promote products derived from this software
201539Srgrimes *    without specific prior written permission.
211539Srgrimes *
221539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321539Srgrimes * SUCH DAMAGE.
331539Srgrimes *
341539Srgrimes *	@(#)assert.h	8.2 (Berkeley) 1/21/94
3585421Sasmodai * $FreeBSD$
361539Srgrimes */
371539Srgrimes
3885605Smike#include <sys/cdefs.h>
3985605Smike
401539Srgrimes/*
411539Srgrimes * Unlike other ANSI header files, <assert.h> may usefully be included
421539Srgrimes * multiple times, with and without NDEBUG defined.
431539Srgrimes */
441539Srgrimes
451539Srgrimes#undef assert
461539Srgrimes#undef _assert
471539Srgrimes
481539Srgrimes#ifdef NDEBUG
491539Srgrimes#define	assert(e)	((void)0)
501539Srgrimes#define	_assert(e)	((void)0)
511539Srgrimes#else
521539Srgrimes#define	_assert(e)	assert(e)
5385605Smike
5485421Sasmodai#define	assert(e)	((e) ? (void)0 : __assert(__func__, __FILE__, \
5585605Smike			    __LINE__, #e))
5685605Smike#endif /* NDEBUG */
571539Srgrimes
58174133Sphk#ifndef _ASSERT_H_
59174133Sphk#define _ASSERT_H_
60228902Sed
61228955Sed/*
62228955Sed * Static assertions.  In principle we could define static_assert for
63228955Sed * C++ older than C++11, but this breaks if _Static_assert is
64228955Sed * implemented as a macro.
65228955Sed *
66228955Sed * C++ template parameters may contain commas, even if not enclosed in
67228955Sed * parentheses, causing the _Static_assert macro to be invoked with more
68228955Sed * than two parameters.
69228955Sed */
70228955Sed#if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus)
71228902Sed#define	static_assert	_Static_assert
72228902Sed#endif
73228902Sed
741539Srgrimes__BEGIN_DECLS
75217207Sedvoid __assert(const char *, const char *, int, const char *) __dead2;
761539Srgrimes__END_DECLS
77228902Sed
78174131Sphk#endif /* !_ASSERT_H_ */
79