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