From 176a4ebc288252d77958393580892be80cdbe3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 30 Jun 2004 02:39:29 +0000 Subject: [PATCH] Added a proper assert() implementation, removed the old one. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8242 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/Jamfile | 1 + src/kernel/libroot/posix/assert.c | 35 ++++++++++++++++++++++++ src/kernel/libroot/posix/stdlib/Jamfile | 2 -- src/kernel/libroot/posix/stdlib/assert.c | 15 ---------- 4 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 src/kernel/libroot/posix/assert.c delete mode 100644 src/kernel/libroot/posix/stdlib/assert.c diff --git a/src/kernel/libroot/posix/Jamfile b/src/kernel/libroot/posix/Jamfile index 21c89eb733..09a3dca0cf 100644 --- a/src/kernel/libroot/posix/Jamfile +++ b/src/kernel/libroot/posix/Jamfile @@ -3,6 +3,7 @@ SubDir OBOS_TOP src kernel libroot posix ; UsePrivateHeaders [ FDirName syslog_daemon ] ; KernelMergeObject posix_main.o : + <$(SOURCE_GRIST)>assert.c <$(SOURCE_GRIST)>dlfcn.c <$(SOURCE_GRIST)>errno.c <$(SOURCE_GRIST)>fnmatch.c diff --git a/src/kernel/libroot/posix/assert.c b/src/kernel/libroot/posix/assert.c new file mode 100644 index 0000000000..abefb7333d --- /dev/null +++ b/src/kernel/libroot/posix/assert.c @@ -0,0 +1,35 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#undef NDEBUG + // just in case + +#include + +#include +#include +#include + + +extern char *__progname; + + +void +__assert_fail(const char *assertion, const char *file, + unsigned int line, const char *function) +{ + fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function, assertion); + debugger(assertion); +} + + +void +__assert_perror_fail(int error, const char *file, + unsigned int line, const char *function) +{ + fprintf(stderr, "%s: %s:%d:%s: %s\n", __progname, file, line, function, strerror(error)); + debugger(strerror(error)); +} diff --git a/src/kernel/libroot/posix/stdlib/Jamfile b/src/kernel/libroot/posix/stdlib/Jamfile index 9f2fe1e9f8..662f12b9cf 100644 --- a/src/kernel/libroot/posix/stdlib/Jamfile +++ b/src/kernel/libroot/posix/stdlib/Jamfile @@ -2,7 +2,6 @@ SubDir OBOS_TOP src kernel libroot posix stdlib ; KernelMergeObject posix_stdlib.o : <$(SOURCE_GRIST)>abs.c - <$(SOURCE_GRIST)>assert.c <$(SOURCE_GRIST)>atof.c <$(SOURCE_GRIST)>atoi.c <$(SOURCE_GRIST)>bsearch.c @@ -28,7 +27,6 @@ KernelMergeObject posix_stdlib.o : MergeObjectFromObjects kernel_posix_stdlib.o : <$(SOURCE_GRIST)>abs.o - <$(SOURCE_GRIST)>assert.o <$(SOURCE_GRIST)>atoi.o <$(SOURCE_GRIST)>bsearch.o <$(SOURCE_GRIST)>merge.o diff --git a/src/kernel/libroot/posix/stdlib/assert.c b/src/kernel/libroot/posix/stdlib/assert.c deleted file mode 100644 index 76cfb4a5de..0000000000 --- a/src/kernel/libroot/posix/stdlib/assert.c +++ /dev/null @@ -1,15 +0,0 @@ -/* -** Copyright 2002, Travis Geiselbrecht. All rights reserved. -** Copyright 2002, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ - -#include - -void -_assert(char const *s1, int l, char const *s2) -{ - (void)(s1); - (void)(l); - (void)(s2); -}