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