From da4690501068ea2f70f76bf62995633f5efcfda4 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 6 Jan 1999 20:02:14 +0000 Subject: [PATCH] add RUNTIME_CHECK --- lib/isc/error.c | 7 ++++++- lib/isc/include/isc/error.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/isc/error.c b/lib/isc/error.c index ede5066227..925e3c45e2 100644 --- a/lib/isc/error.c +++ b/lib/isc/error.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998 Internet Software Consortium. + * Copyright (C) 1998, 1999 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -64,6 +64,11 @@ isc_error_fatal(char *file, int line, char *format, ...) { abort(); } +void +isc_error_runtimecheck(char *file, int line, char *expression) { + (fatal_callback)(file, line, "RUNTIME_CHECK(%s) failed.", expression); +} + static void default_unexpected_callback(char *file, int line, char *format, va_list args) { fprintf(stderr, "%s:%d: ", file, line); diff --git a/lib/isc/include/isc/error.h b/lib/isc/include/isc/error.h index dfda22b3bb..8e4975ba75 100644 --- a/lib/isc/include/isc/error.h +++ b/lib/isc/include/isc/error.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998 Internet Software Consortium. + * Copyright (C) 1998, 1999 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,8 +26,12 @@ void isc_error_setunexpected(isc_errorcallback_t); void isc_error_setfatal(isc_errorcallback_t); void isc_error_unexpected(char *, int, char *, ...); void isc_error_fatal(char *, int, char *, ...); +void isc_error_runtimecheck(char *, int, char *); #define UNEXPECTED_ERROR isc_error_unexpected #define FATAL_ERROR isc_error_fatal +#define RUNTIME_CHECK(cond) \ + ((void) ((cond) || \ + ((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0))) #endif /* ISC_ERROR_H */