diff --git a/src/plugins/e-acsl/share/e-acsl/e_acsl_printf.h b/src/plugins/e-acsl/share/e-acsl/e_acsl_printf.h index 8eafd66f8c0cc990d9a1de021445b642aeb7cd83..d51f2524de3585134c52f56cceca44aeee74ab1d 100644 --- a/src/plugins/e-acsl/share/e-acsl/e_acsl_printf.h +++ b/src/plugins/e-acsl/share/e-acsl/e_acsl_printf.h @@ -33,6 +33,12 @@ #include <stddef.h> #include <stdint.h> #include <unistd.h> +#include <limits.h> + +// For PATH_MAX in Linux +#ifdef __linux__ + #include <linux/limits.h> +#endif static void printf(char *fmt, ...); @@ -262,11 +268,6 @@ static void eprintf(char *fmt, ...) { } static void vabort(char *fmt, ...) { - char *mtstr = "E_ACSL ERROR:"; - char extfmt [strlen(mtstr) + strlen(fmt) + 1] ; - sprintf(extfmt,"%s%s",mtstr,fmt); - fmt = extfmt; - va_list va; va_start(va,fmt); _format(NULL,_charc_stderr,fmt,va); @@ -289,3 +290,25 @@ static void sprintf(char* s,char *fmt, ...) { putcp(&s,0); va_end(va); } + +#define assert(expr) \ + ((expr) ? (void)(0) : vabort("%s at %s:%d\n", \ + #expr, __FILE__,__LINE__)) + +static void vassert_fail(int expr, int line, char *file, char *fmt, ...) { + if (!expr) { + char *afmt = "%s at %s:%d\n"; + char buf [strlen(fmt) + strlen(afmt) + PATH_MAX + 11]; + sprintf(buf, afmt, fmt, file, line); + fmt = buf; + + va_list va; + va_start(va,fmt); + _format(NULL,_charc_stderr,fmt,va); + va_end(va); + abort(); + } +} + +#define vassert(expr, fmt, ...) \ + vassert_fail(expr, __LINE__, __FILE__, fmt, __VA_ARGS__) diff --git a/src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c b/src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c index 3075c22ff861a61073fb5e64aec54514da07064d..f6c6062282af3e8c97cbdf75957e38b738f92347 100644 --- a/src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c +++ b/src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <stdbool.h> -#include <assert.h> #include "e_acsl_mmodel_api.h" #include "e_acsl_mmodel.h" #include "../e_acsl_printf.h"