From 028339e2648008dc11ca159349e2d1b51b458d17 Mon Sep 17 00:00:00 2001
From: Petr Rockai <me@mornfall.net>
Date: Sat, 19 Oct 2019 23:05:15 +0000
Subject: [PATCH] libc: Improve presentation of assertion failures in
 counterexample traces.

---
 dios/include/assert.h      | 11 +++++------
 dios/libc/_PDCLIB/assert.c |  7 ++++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dios/include/assert.h b/dios/include/assert.h
index 55c33dd87..d0f4dbc3f 100644
--- a/dios/include/assert.h
+++ b/dios/include/assert.h
@@ -13,17 +13,16 @@
 #undef _assert
 
 #ifdef NDEBUG
-# define	assert(e)	((void)0)
-# define	_assert(e)	((void)0)
+# define assert(e)  ((void)0)
+# define _assert(e) ((void)0)
 #else
-# define	_assert(e)	assert(e)
-# define	assert(e)	((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __func__))
+# define _assert(e) assert(e)
+# define assert(e)  ( (e) ? (void) 0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__) )
 #endif
 
 #ifndef _ASSERT_H_
 #define _ASSERT_H_
 __BEGIN_DECLS
-void __assert_fail( const char *__assertion, const char *__file, unsigned int __line, const char *__function )
-    _PDCLIB_nothrow;
+void __assert_fail( const char *, const char *, unsigned, const char * ) __nothrow;
 __END_DECLS
 #endif
diff --git a/dios/libc/_PDCLIB/assert.c b/dios/libc/_PDCLIB/assert.c
index b487eed22..aacd4fc02 100644
--- a/dios/libc/_PDCLIB/assert.c
+++ b/dios/libc/_PDCLIB/assert.c
@@ -15,10 +15,11 @@
 
 #include <_PDCLIB/cdefs.h>
 
-void __assert_fail( const char *__assertion, const char *__file, unsigned int __line, const char *__function )
+void __assert_fail( const char *stmt, const char *file, unsigned line, const char *fun )
 {
-    __dios_trace_f( "Assertion failed: %s, file %s, line %u.", __assertion, __file, __line );
-    __dios_fault( _VM_F_Assert, NULL );
+    char buffer[ 200 ];
+    snprintf( buffer, 200, "%s:%u: %s: assertion '%s' failed", file, line, fun, stmt );
+    __dios_fault( _VM_F_Assert, buffer );
 }
 
 #endif
-- 
GitLab