lib: __assert_fail: Update to standard.
* lib/mes/__assert_fail.c (__assert_fail): Add file, line, function parameters. * include/assert.h (assert): Update caller. (__assert_fail): Update prototype. * include/mes/lib.h (__assert_fail): Likewise. * lib/mes/assert_msg.c (assert_msg): Likewise. Include assert.h.
This commit is contained in:
parent
84fd995f43
commit
25e0c4d119
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -27,8 +27,9 @@
|
||||||
#undef __MES_ASSERT_H
|
#undef __MES_ASSERT_H
|
||||||
#include_next <assert.h>
|
#include_next <assert.h>
|
||||||
#else // ! SYSTEM_LIBC
|
#else // ! SYSTEM_LIBC
|
||||||
#define assert(x) ((x) ? (void)0 : __assert_fail (#x))
|
#define assert(x) ((x) ? (void)0 : __assert_fail (#x, 0, 0, 0))
|
||||||
void __assert_fail (char *s);
|
void __assert_fail (char const *s, char const *file, unsigned line,
|
||||||
|
char const *function);
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_ASSERT_H
|
#endif // __MES_ASSERT_H
|
||||||
|
|
|
@ -67,7 +67,8 @@ extern void (*__call_at_exit) (void);
|
||||||
#define __FILEDES_MAX 512
|
#define __FILEDES_MAX 512
|
||||||
|
|
||||||
#if !SYSTEM_LIBC
|
#if !SYSTEM_LIBC
|
||||||
void __assert_fail (char *s);
|
void __assert_fail (char const *s, char const *file, unsigned line,
|
||||||
|
char const *function);
|
||||||
ssize_t __buffered_read (int filedes, void *buffer, size_t size);
|
ssize_t __buffered_read (int filedes, void *buffer, size_t size);
|
||||||
size_t __buffered_read_clear (int filedes);
|
size_t __buffered_read_clear (int filedes);
|
||||||
void _exit (int code);
|
void _exit (int code);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -19,14 +19,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
__assert_fail (char *s)
|
__assert_fail (char const *msg, char const *file, unsigned line,
|
||||||
|
char const *function)
|
||||||
{
|
{
|
||||||
|
if (file && file[0])
|
||||||
|
{
|
||||||
|
eputs (file);
|
||||||
|
eputs (":");
|
||||||
|
}
|
||||||
|
if (line)
|
||||||
|
{
|
||||||
|
eputs (itoa (line));
|
||||||
|
eputs (":");
|
||||||
|
}
|
||||||
|
if (function && function[0])
|
||||||
|
{
|
||||||
|
eputs (function);
|
||||||
|
eputs (":");
|
||||||
|
}
|
||||||
eputs ("assert fail: ");
|
eputs ("assert fail: ");
|
||||||
eputs (s);
|
eputs (msg);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
char *fail = s;
|
char *fail = 0;
|
||||||
fail = 0;
|
|
||||||
fail[0] = 0;
|
fail[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
* Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
||||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -20,11 +20,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
assert_msg (int bool, char *msg)
|
assert_msg (int bool, char *msg)
|
||||||
{
|
{
|
||||||
if (bool == 0)
|
if (bool == 0)
|
||||||
__assert_fail (msg);
|
__assert_fail (msg, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue