1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 14:30:43 -08:00
emacs/mps/code/assert.c
Richard Brooksby 3d5e2ca85f Adding hopenames back into the master sources, so that they can be included in the union sources along with the id keywords.
This was achieved by partially undoing changelist 24817, including an accidental corruption of eventgen.pl.

Copied from Perforce
 Change: 24877
 ServerID: perforce.ravenbrook.com
2001-12-06 18:14:02 +00:00

72 lines
1.5 KiB
C

/* impl.c.assert: ASSERTION IMPLEMENTATION
*
* $Id$
* $HopeName: MMsrc!assert.c(trunk.12) $
* Copyright (c) 2001 Ravenbrook Limited.
*
* This source provides the AssertFail function which is
* invoked by the assertion macros (see impl.h.assert).
* It also provides for user-installed assertion failure handlers.
*/
#include "check.h"
#include "mpm.h"
SRCID(assert, "$Id$");
/* CheckLevel -- Control check level
*
* This controls the behaviour of Check methods unless MPS_HOT_RED
* is defined, when it is effectively stuck at "CheckNONE".
*/
unsigned CheckLevel = CheckSHALLOW;
static void AssertLib(const char *cond, const char *id,
const char *file, unsigned line)
{
WriteF(mps_lib_stderr,
"\n"
"MPS ASSERTION FAILURE\n"
"\n"
"Id: $S\n", id,
"File: $S\n", file,
"Line: $U\n", (WriteFU)line,
"Condition: $S\n", cond,
"\n",
NULL);
mps_lib_abort();
}
static AssertHandler handler = &AssertLib;
AssertHandler AssertDefault(void)
{
return &AssertLib;
}
AssertHandler AssertInstall(AssertHandler new)
{
AssertHandler prev = handler;
handler = new;
return prev;
}
/* AssertFail -- fail an assertion
*
* This function is called when an ASSERT macro fails a test. It
* calls the installed assertion handler, if it is not NULL. If
* handler returns the progam continues.
*/
void AssertFail1(const char *s)
{
if (handler != NULL)
(*handler)(s, "", "", 0);
}