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