hc
2024-08-16 a24a44ff9ca902811b99aa9663d697cf452e08ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/******************************************************************************
 *
 * Copyright 2016, Fuzhou Rockchip Electronics Co.Ltd . All rights reserved.
 * No part of this work may be reproduced, modified, distributed, transmitted,
 * transcribed, or translated into any language or computer format, in any form
 * or by any means without written permission of:
 * Fuzhou Rockchip Electronics Co.Ltd .
 *
 *
 *****************************************************************************/
/**
 *   @file dct_assert.h
 *
 *  This file defines the API for the assertion facility of the embedded lib.
 *
 *****************************************************************************/
/*****************************************************************************/
/**
 * @defgroup module_assert Assert macros
 *
 *
 * Example use of the assert system:
 *
 *
 * - In your source file just use the macro
 *
 * @code
 * void foo( uint8_t* pData, size_t size)
 * {
 *     DCT_ASSERT(pData != NULL);
 *     DCT_ASSERT(size > 0);
 * }
 * @endcode
 *
 * @{
 *
 *****************************************************************************/
#ifndef ASSERT_H_
#define ASSERT_H_
typedef char CHAR;
 
/**
 * @brief   The type of the assert handler. @see assert_handler
 *
 *****************************************************************************/
typedef void (*ASSERT_HANDLER)(void);
 
 
/**
 *          The assert handler is a function that is called in case an
 *          assertion failed. If no handler is registered, which is the
 *          default, exit() is called.
 *
 *****************************************************************************/
extern ASSERT_HANDLER   assert_handler;
 
/**
 *          Compile time assert. Use e.g. to check the size of certain data
 *           types. As this is evaluated at compile time, it will neither cause
 *           size nor speed overhead, and thus is does not need to be inside
 *           the NDEBUG.
 *
 *****************************************************************************/
/* we need several levels of indirection to make unique enum names working
 * we need unique enum names to be able to use DCT_ASSERT_STATIC more than
 * one time per compilation unit
 */
#define UNIQUE_ENUM_NAME(u)     assert_static__ ## u
#define GET_ENUM_NAME(x)        UNIQUE_ENUM_NAME(x)
#define DCT_ASSERT_STATIC(e)    enum { GET_ENUM_NAME(__LINE__) = 1/(e) }
 
#if defined(ENABLE_ASSERT) || !defined(NDEBUG)
/**
 *              Dump information on stderr and exit.
 *
 *  @param      file  Filename where assertion occured.
 *  @param      line  Linenumber where assertion occured.
 *
 *****************************************************************************/
#ifdef __cplusplus
extern "C"
#endif
void exit_(const char* file, int line);
 
 
/**
 *              The assert macro.
 *
 *  @param      exp Expression which assumed to be true.
 *
 *****************************************************************************/
#define DCT_ASSERT(exp) ((void)0)
#else
#define DCT_ASSERT(exp) ((void)0)
#endif
 
/* @} module_tracer*/
 
#endif /*ASSERT_H_*/