SFBAssert.h

Go to the documentation of this file.
00001 /*                                              -*- mode:C++; fill-column:100 -*-
00002   SFBAssert.h - Names for SFB assertions
00003   Copyright (C) 2008 The Regents of the University of New Mexico.  All rights reserved.
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this library; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00018   USA
00019 */
00020 
00027 #ifndef SFBASSERT_H_
00028 #define SFBASSERT_H_
00029 
00030 #include "SFBErrors.h"  /* For E_ error codes */
00031 
00032 #ifndef API_UNPROTECTED
00033 
00047 #define API_BUG(code) do { _apiError_(code,__FILE__,__LINE__); } while (0)
00048 
00049 
00064 #define API_ASSERT(condition,code) do { if (!(condition)) API_BUG(code); } while (0)
00065 
00066 #else
00067 
00068 #define API_BUG(code) 0 /* ignored */ 
00069 #define API_ASSERT(condition,code) /* ignored */
00070 
00071 #endif
00072 
00093 #define POISON(code0_6) API_BUG(BLINK_MAP(1,0,code0_6))
00094 
00097 #define API_ASSERT_MAX_CODE(value,maxval,code) API_ASSERT(((u32)(value))<(maxval),code)
00098 
00100 #define API_ASSERT_MAX(value,maxval) API_ASSERT_MAX_CODE(value,maxval,E_API_MAX_RANGE)
00101 
00103 #define API_ASSERT_TRUE(value) API_ASSERT((value)!=0,E_API_TRUE)
00104 
00106 #define API_ASSERT_FALSE(value) API_ASSERT((value)==0,E_API_FALSE)
00107 
00109 #define API_ASSERT_NONZERO(value) API_ASSERT((value)!=0,E_API_NONZERO)
00110 
00112 #define API_ASSERT_NONNULL(value) API_ASSERT((value)!=0,E_API_NULL_POINTER)
00113 
00115 #define API_ASSERT_NULL(value) API_ASSERT((value)==0,E_API_NONNULL_POINTER)
00116 
00118 #define API_ASSERT_ZERO(value) API_ASSERT((value)==0,E_API_ZERO)
00119 
00121 #define API_ASSERT_EQUAL(target,value) API_ASSERT((value)==(target),E_API_EQUAL)
00122 
00124 #define API_ASSERT_NOT_EQUAL(target,value) API_ASSERT((value)!=(target),E_API_NOT_EQUAL)
00125 
00127 #define API_ASSERT_LESS(target,value) API_ASSERT((target)<(value),E_API_LESS)
00128 
00130 #define API_ASSERT_LESS_EQUAL(target,value) API_ASSERT((target)<=(value),E_API_LESS_EQUAL)
00131 
00133 #define API_ASSERT_GREATER(target,value) API_ASSERT((target)>(value),E_API_GREATER)
00134 
00136 #define API_ASSERT_GREATER_EQUAL(target,value) API_ASSERT((target)>=(value),E_API_GREATER_EQUAL)
00137 
00139 #define API_ASSERT_VALID_PIN(u32Pin) API_ASSERT_MAX_CODE(u32Pin,VIRTUAL_PIN_COUNT,E_API_BAD_PIN)
00140 
00145 #define API_ASSERT_VALID_FACE(u32Face) API_ASSERT_MAX_CODE(u32Face,FACE_COUNT,E_API_BAD_FACE)
00146 
00152 #define API_ASSERT_VALID_EXTENDED_FACE(u32Face) API_ASSERT_MAX_CODE(u32Face,MAX_FACE_INDEX,E_API_BAD_FACE)
00153 
00155 #define API_ASSERT_HALFWORD_ALIGNED(uptraddress) API_ASSERT((((uptr)(uptraddress))&1)==0,E_API_HALFWORD_ALIGNED)
00156 
00158 #define API_ASSERT_WORD_ALIGNED(uptraddress) API_ASSERT((((uptr)(uptraddress))&3)==0,E_API_WORD_ALIGNED)
00159 
00161 #define API_ASSERT_DOUBLEWORD_ALIGNED(uptraddress) API_ASSERT((((uptr)(uptraddress))&7)==0,E_API_DOUBLEWORD_ALIGNED)
00162 
00163 #endif /*SFBASSERT_H_*/

Generated on Fri Apr 22 06:54:11 2011 for SFB by doxygen 1.5.9