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_INTERFACE_UTILS_H 17 #define DISPLAY_INTERFACE_UTILS_H 18 19 #include "hilog/log.h" 20 21 #define DISPLAY_CHECK(val, ...) \ 22 do { \ 23 if (val) { \ 24 HDF_LOGE("%{public}d@%{public}s: check failed", __LINE__, __func__); \ 25 __VA_ARGS__; \ 26 } \ 27 } while (0) 28 29 #define DISPLAY_CHK_RETURN(val, ret, ...) \ 30 do { \ 31 if (val) { \ 32 __VA_ARGS__; \ 33 return (ret); \ 34 } \ 35 } while (0) 36 37 #define DISPLAY_CHK_CONDITION(ret, cond, func, ...) \ 38 do { \ 39 if (cond == ret) { \ 40 ret = func; \ 41 if (cond != ret) { \ 42 __VA_ARGS__; \ 43 } \ 44 } \ 45 } while (0) 46 47 #define DISPLAY_CHK_BREAK(val, ...) \ 48 if (val) { \ 49 __VA_ARGS__; \ 50 break; \ 51 } \ 52 53 #endif // DISPLAY_INTERFACE_UTILS_H 54