Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2007-06-27 16:44:41 +0400
committerEric Blake <eblake@redhat.com>2007-06-27 16:44:41 +0400
commit3473e6bd7b268deb4314659009512d846a75b368 (patch)
tree6ad0d0da98788ea8cab097e3ff0f908233da5161 /newlib/libc/include
parent26e8e4befff225f93ed71f0f3182647cea975ecc (diff)
Support __func__ in assert, as required by C99.
* libc/stdlib/assert.c (__assert_func): New function. (__assert): Use __assert_func. * libc/include/assert.h (assert) [!NDEBUG]: Use __assert_func when possible.
Diffstat (limited to 'newlib/libc/include')
-rw-r--r--newlib/libc/include/assert.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/newlib/libc/include/assert.h b/newlib/libc/include/assert.h
index b681a8518..ed14928ba 100644
--- a/newlib/libc/include/assert.h
+++ b/newlib/libc/include/assert.h
@@ -11,18 +11,31 @@ extern "C" {
#undef assert
#ifdef NDEBUG /* required by ANSI standard */
-#define assert(p) ((void)0)
+# define assert(__e) ((void)0)
#else
-
-#ifdef __STDC__
-#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
-#else /* PCC */
-#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, "e"))
-#endif
-
-#endif /* NDEBUG */
-
-void _EXFUN(__assert,(const char *, int, const char *));
+# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
+ __ASSERT_FUNC, #__e))
+
+# ifndef __ASSERT_FUNC
+ /* Use g++'s demangled names in C++. */
+# if defined __cplusplus && defined __GNUC__
+# define __ASSERT_FUNC __PRETTY_FUNCTION__
+
+ /* C99 requires the use of __func__, gcc also supports it. */
+# elif defined __GNUC__ || __STDC_VERSION__ >= 199901L
+# define __ASSERT_FUNC __func__
+
+ /* failed to detect __func__ support. */
+# else
+# define __ASSERT_FUNC ((char *) 0)
+# endif
+# endif /* !__ASSERT_FUNC */
+#endif /* !NDEBUG */
+
+void _EXFUN(__assert, (const char *, int, const char *)
+ _ATTRIBUTE ((__noreturn__)));
+void _EXFUN(__assert_func, (const char *, int, const char *, const char *)
+ _ATTRIBUTE ((__noreturn__)));
#ifdef __cplusplus
}