/*
    Copyright 2000 (c) by Authors,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public 
    Licence. A full copy of the GNU GPL is provided in the file COPYING 
    found in the development root of Topsy.
*/
/*
	
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Topsy/Attic/Assert.h,v $
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $  by: $Author: baderma $
 
*/
#ifndef __ASSERT_H__
#define __ASSERT_H__

#include "Threads.h"


#define CHECK_REQUIRE		1
#define CHECK_ENSURE		1
#define CHECK_ASSERT		1

void error_assertion (char *type, char *threadName,
                      const char * fileName, int lineNumber, const char *cond);


#if CHECK_REQUIRE != 0
// use for precondition
#define REQUIRE(cond) \
	((void) ((cond) ||  \
	(error_assertion("REQUIRE", getCurrentThreadName(),  \
				__FILE__, __LINE__, #cond), 0) ))
#else
#define REQUIRE(cond)
#endif

#if CHECK_ENSURE != 0
// use for postcondition
#define ENSURE(cond) \
	((void) ((cond) ||  \
	(error_assertion("ENSURE", getCurrentThreadName(),  \
				__FILE__, __LINE__, #cond), 0) ))
#else
#define ENSURE(cond)
#endif

#if CHECK_ASSERT != 0
// everything else :-)
#define ASSERT(cond) \
	((void) ((cond) ||  \
	(error_assertion("ASSERT", getCurrentThreadName(),  \
				__FILE__, __LINE__, #cond), 0) ))

#define ASSERT_REDEF(cond) ASSERT(cond)
/* for c comaptibility */
#else
#define ASSERT(cond)
#define ASSERT_REDEF(cond)
#endif

#endif
