1/* $NetBSD: assert.h,v 1.3 2021/08/14 16:14:55 christos Exp $ */ 2 3/* Generic assert.h */ 4/* $OpenLDAP$ */ 5/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 1998-2021 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18 19#ifndef _AC_ASSERT_H 20#define _AC_ASSERT_H 21 22#undef assert 23 24#ifdef LDAP_DEBUG 25 26#if defined( HAVE_ASSERT_H ) || defined( STDC_HEADERS ) 27 28#undef NDEBUG 29#include <assert.h> 30 31#else /* !(HAVE_ASSERT_H || STDC_HEADERS) */ 32 33#define LDAP_NEED_ASSERT 1 34 35/* 36 * no assert()... must be a very old compiler. 37 * create a replacement and hope it works 38 */ 39 40LBER_F (void) ber_pvt_assert LDAP_P(( const char *file, int line, 41 const char *test )); 42 43/* Can't use LDAP_STRING(test), that'd expand to "test" */ 44#if defined(__STDC__) || defined(__cplusplus) 45#define assert(test) \ 46 ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, #test ) ) 47#else 48#define assert(test) \ 49 ((test) ? (void)0 : ber_pvt_assert( __FILE__, __LINE__, "test" ) ) 50#endif 51 52#endif /* (HAVE_ASSERT_H || STDC_HEADERS) */ 53 54#else /* !LDAP_DEBUG */ 55/* no asserts */ 56#define assert(test) ((void)0) 57#endif /* LDAP_DEBUG */ 58 59#endif /* _AC_ASSERT_H */ 60