smart-green-house/project_ZigBee/Components/hal/include/hal_assert.h

111 lines
5.2 KiB
C

/**************************************************************************************************
Filename: hal_assert.h
Revised: $Date: 2009-02-16 18:03:22 -0800 (Mon, 16 Feb 2009) $
Revision: $Revision: 19172 $
Description: Describe the purpose and contents of the file.
Copyright 2006-2007 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef HAL_ASSERT_H
#define HAL_ASSERT_H
/* ------------------------------------------------------------------------------------------------
* Macros
* ------------------------------------------------------------------------------------------------
*/
/*
* HAL_ASSERT( expression ) - The given expression must evaluate as "true" or else the assert
* handler is called. From here, the call stack feature of the debugger can pinpoint where
* the problem occurred.
*
* HAL_ASSERT_FORCED( ) - If asserts are in use, immediately calls the assert handler.
*
* HAL_ASSERT_STATEMENT( statement ) - Inserts the given C statement but only when asserts
* are in use. This macros allows debug code that is not part of an expression.
*
* HAL_ASSERT_DECLARATION( declaration ) - Inserts the given C declaration but only when asserts
* are in use. This macros allows debug code that is not part of an expression.
*
* Asserts can be disabled for optimum performance and minimum code size (ideal for
* finalized, debugged production code). To disable, define the preprocessor
* symbol HALNODEBUG at the project level.
*/
#ifdef HALNODEBUG
#define HAL_ASSERT(expr)
#define HAL_ASSERT_FORCED()
#define HAL_ASSERT_STATEMENT(statement)
#define HAL_ASSERT_DECLARATION(declaration)
#else
#define HAL_ASSERT(expr) st( if (!( expr )) halAssertHandler(); )
#define HAL_ASSERT_FORCED() halAssertHandler()
#define HAL_ASSERT_STATEMENT(statement) st( statement )
#define HAL_ASSERT_DECLARATION(declaration) declaration
#endif
/*
* This macro compares the size of the first parameter to the integer value
* of the second parameter. If they do not match, a compile time error for
* negative array size occurs (even gnu chokes on negative array size).
*
* This compare is done by creating a typedef for an array. No variables are
* created and no memory is consumed with this check. The created type is
* used for checking only and is not for use by any other code. The value
* of 10 in this macro is arbitrary, it just needs to be a value larger
* than one to result in a positive number for the array size.
*/
#define HAL_ASSERT_SIZE(x,y) typedef char x ## _assert_size_t[-1+10*(sizeof(x) == (y))]
/* ------------------------------------------------------------------------------------------------
* Prototypes
* ------------------------------------------------------------------------------------------------
*/
void halAssertHandler(void);
/**************************************************************************************************
*/
/**************************************************************************************************
* FUNCTIONS - API
**************************************************************************************************/
extern void halAssertHazardLights(void);
#endif