1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDLIB/ASSERT.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,63 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* FUNCTION
1.19 +* <<assert>>---Macro for Debugging Diagnostics
1.20 +* INDEX
1.21 +* assert
1.22 +* ANSI_SYNOPSIS
1.23 +* #include <assert.h>
1.24 +* void assert(int <[expression]>);
1.25 +* TRAD_SYNOPSIS
1.26 +* #include <assert.h>
1.27 +* assert(<[expression]>)
1.28 +* int <[expression]>;
1.29 +* Use this macro to embed debuggging diagnostic statements in
1.30 +* your programs. The argument <[expression]> should be an
1.31 +* expression which evaluates to true (nonzero) when your program
1.32 +* is working as you intended.
1.33 +* When <[expression]> evaluates to false (zero), <<assert>>
1.34 +* calls <<abort>>, after first printing a message showing what
1.35 +* failed and where:
1.36 +* . Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>
1.37 +* The macro is defined to permit you to turn off all uses of
1.38 +* <<assert>> at compile time by defining <<NDEBUG>> as a
1.39 +* preprocessor variable. If you do this, the <<assert>> macro
1.40 +* expands to
1.41 +* . (void(0))
1.42 +* RETURNS
1.43 +* <<assert>> does not return a value.
1.44 +* PORTABILITY
1.45 +* The <<assert>> macro is required by ANSI, as is the behavior
1.46 +* when <<NDEBUG>> is defined.
1.47 +* Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
1.48 +* <<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
1.49 +*
1.50 +*
1.51 +*/
1.52 +
1.53 +
1.54 +
1.55 +#include <assert.h>
1.56 +#include <stdlib.h>
1.57 +#include <stdio.h>
1.58 +
1.59 +EXPORT_C void __assert (const char *file, int line, const char *failedexpr)
1.60 +{
1.61 + (void)fprintf(stderr,
1.62 + "assertion \"%s\" failed: file \"%s\", line %d\n",
1.63 + failedexpr, file, line);
1.64 + abort();
1.65 + /* NOTREACHED */
1.66 +}