summaryrefslogtreecommitdiff
path: root/include/assert.h
diff options
context:
space:
mode:
authorkleink <kleink@NetBSD.org>2000-12-19 14:32:59 +0000
committerkleink <kleink@NetBSD.org>2000-12-19 14:32:59 +0000
commitf02540ff10b332b8ef5ad9e89ded894e39d68bec (patch)
tree775e107e82bd688c68133f74df9dd03a49eb1db5 /include/assert.h
parentd615c85a36834952f43c49ca587cb3d530cd8189 (diff)
C99: Print the name of the function enclosing the assertion, if possible.
Diffstat (limited to 'include/assert.h')
-rw-r--r--include/assert.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/include/assert.h b/include/assert.h
index 125b21a034b..f8c6e7bd2d6 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -1,4 +1,4 @@
-/* $NetBSD: assert.h,v 1.9 2000/08/07 16:21:32 kleink Exp $ */
+/* $NetBSD: assert.h,v 1.10 2000/12/19 14:32:59 kleink Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -59,9 +59,13 @@
#else /* !NDEBUG */
# define _assert(e) assert(e)
# if __STDC__
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
+# define assert(e) \
+ ((e) ? (void)0 : __assert13(__FILE__, __LINE__, \
+ __assert_function__, #e))
# else /* PCC */
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, "e"))
+# define assert(e) \
+ ((e) ? (void)0 : __assert13(__FILE__, __LINE__, \
+ __assert_function__, "e"))
# endif /* !__STDC__ */
#endif /* NDEBUG */
@@ -74,16 +78,30 @@
# endif /* lint */
#else /* _DIAGNOSTIC */
# if __STDC__
-# define _DIAGASSERT(e) ((e) ? (void)0 : __diagassert(__FILE__, __LINE__, #e))
+# define _DIAGASSERT(e) \
+ ((e) ? (void)0 : __diagassert13(__FILE__, __LINE__, \
+ __assert_function__, #e))
# else /* !__STDC__ */
-# define _DIAGASSERT(e) ((e) ? (void)0 : __diagassert(__FILE__, __LINE__, "e"))
+# define _DIAGASSERT(e) \
+ ((e) ? (void)0 : __diagassert13(__FILE__, __LINE__, \
+ __assert_function__, "e"))
# endif
#endif /* _DIAGNOSTIC */
#include <sys/cdefs.h>
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define __assert_function__ __func__
+#elif __GNUC_PREREQ__(2, 6)
+#define __assert_function__ __PRETTY_FUNCTION__
+#else
+#define __assert_function__ ((const void *)0)
+#endif
+
__BEGIN_DECLS
void __assert __P((const char *, int, const char *));
+void __assert13 __P((const char *, int, const char *, const char *));
void __diagassert __P((const char *, int, const char *));
+void __diagassert13 __P((const char *, int, const char *, const char *));
__END_DECLS