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