summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/osal/inc/LV_Macros.h
blob: b8d7e85d5cf53054c226a1baa269832b228a0f69 (plain)
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
100
101
102
103
104
105
106
107
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*******************************************************************************
* @file        LV_Macros.h
* @par        NXP Software
* @brief    Macros definition for Smartphone team
*******************************************************************************/

#ifndef LV_MACROS_H
#define LV_MACROS_H

/*------------*/
/*    INCLUDES  */
/*------------*/
#include "M4OSA_Memory.h"
#include "M4OSA_Debug.h"

/******************************************************************************
*
* CHECK_PTR(fct, p, err, errValue)
* @note    This macro checks the value p. If it is NULL, it sets the variable err
*           to errValue and jumps to the label <fct>_cleanUp. A trace is displayed
*           signalling the error, the function name and the line number.
*
******************************************************************************/
#define CHECK_PTR(fct, p, err, errValue) \
{ \
    if(M4OSA_NULL == (p)) \
    { \
        (err) = (errValue) ; \
        M4OSA_TRACE1_1((M4OSA_Char*)"" #fct "(L%d): " #p " is NULL, returning " #errValue "",__LINE__) ; \
        goto fct##_cleanUp; \
    } \
}

/******************************************************************************
*
* CHECK_ERR(fct, err)
* @note    This macro checks the value err. If it is not NULL, a trace is displayed
*           signalling the error, the function name and the line number. The macro
*           jumps to the label <fct>_cleanUp.
*
******************************************************************************/
#define CHECK_ERR(fct, err) \
{ \
    if(M4NO_ERROR != (err)) \
    { \
        M4OSA_TRACE1_2((M4OSA_Char*)"!!! " #fct "(L%d): ERROR 0x%.8x returned",\
                                                               __LINE__,err) ; \
        goto fct##_cleanUp; \
    } \
}


/******************************************************************************
*
* CHECK_ERR(fct, err)
* @note    This macro compares a current state with a state value. If they are different,
*           err is set to M4ERR_STATE.
*           A trace is displayed signalling the error, the function name and the line number.
*           The macro jumps to the label <fct>_cleanUp.
*
******************************************************************************/
#define    CHECK_STATE(fct, stateValue, state) \
{ \
    if((stateValue) != (state)) \
    { \
        M4OSA_TRACE1_1("" #fct " called in bad state %d", state) ; \
        (err) = M4ERR_STATE ; \
        goto fct##_cleanUp; \
    } \
}

/******************************************************************************
*
* SAFE_FREE(p)
* @note    This macro checks the value of p is not NULL. If it is NULL, it does
*           nothing. Else, p is de allocated and set to NULL.
*
******************************************************************************/
#define SAFE_FREE(p) \
{ \
    if(M4OSA_NULL != (p)) \
    { \
        free((p)) ; \
        (p) = M4OSA_NULL ; \
    } \
}



#endif /*---  LV_MACROS_H ---*/