From cf22ba44ce7a99a2cd2cb4c65fb0c67ebe8b4f25 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sun, 19 Apr 2020 15:57:06 +0200 Subject: [PATCH] mescc: Mes C Library: Add assert_msg. * lib/mes/assert_msg.c: New file. --- build-aux/configure-lib.sh | 1 + include/mes/mes.h | 1 + lib/mes/assert_msg.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 lib/mes/assert_msg.c diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index c28b339c..e4b8943d 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -113,6 +113,7 @@ if test $mes_libc = mes; then lib/ctype/isdigit.c lib/ctype/isspace.c lib/ctype/isxdigit.c +lib/mes/assert_msg.c lib/posix/write.c lib/stdlib/atoi.c " diff --git a/include/mes/mes.h b/include/mes/mes.h index 422be601..ea49256a 100644 --- a/include/mes/mes.h +++ b/include/mes/mes.h @@ -105,6 +105,7 @@ int unreadchar (); long length__ (SCM x); size_t bytes_cells (size_t length); void assert_max_string (size_t i, char const *msg, char *string); +void assert_msg (int check, char *msg); #include "mes/builtins.h" #include "mes/constants.h" diff --git a/lib/mes/assert_msg.c b/lib/mes/assert_msg.c new file mode 100644 index 00000000..191aa87c --- /dev/null +++ b/lib/mes/assert_msg.c @@ -0,0 +1,30 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2019 Jeremiah Orians + * Copyright © 2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +void +assert_msg (int bool, char *msg) +{ + if (bool == 0) + __assert_fail (msg); +}