1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef DISPLAY_COMMAND_DATA_UTILS_H
17#define DISPLAY_COMMAND_DATA_UTILS_H
18
19#include "hilog/log.h"
20
21#undef LOG_TAG
22#define LOG_TAG "DISP_PACK"
23#undef LOG_DOMAIN
24#define LOG_DOMAIN 0xD002515
25
26#define DISPLAY_CHECK(val, ...)           \
27    do {                                  \
28        if (val) {                        \
29            HDF_LOGE("%{public}d@%{public}s: check failed", __LINE__, __func__); \
30            __VA_ARGS__;                  \
31        }                                 \
32    } while (0)
33
34#define DISPLAY_CHK_RETURN(val, ret, ...) \
35    do {                                  \
36        if (val) {                        \
37            __VA_ARGS__;                  \
38            return (ret);                 \
39        }                                 \
40    } while (0)
41
42#define DISPLAY_CHK_CONDITION(ret, cond, func, ...)         \
43    do {                                                    \
44        if (cond == ret) {                                  \
45            ret = func;                                     \
46            if (cond != ret) {                              \
47                __VA_ARGS__;                                \
48            }                                               \
49        }                                                   \
50    } while (0)
51
52#endif // DISPLAY_COMMAND_DATA_UTILS_H
53