1 /* 2 * Copyright (c) 2021 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 LE_UTILS_ 17 #define LE_UTILS_ 18 #include <memory.h> 19 #include <stdint.h> 20 #include <stdio.h> 21 22 #include "init_log.h" 23 #include "list.h" 24 #include "securec.h" 25 26 #define LE_TEST_FLAGS(flags, flag) (((flags) & (flag)) == (flag)) 27 #define LE_SET_FLAGS(flags, flag) ((flags) |= (flag)) 28 #define LE_CLEAR_FLAGS(flags, flag) ((flags) &= ~(flag)) 29 30 #define LE_LOG_FILE "loopevent.log" 31 #define LE_LABEL "LoopEvent" 32 #define LE_LOGI(fmt, ...) STARTUP_LOGI(LE_LOG_FILE, LE_LABEL, fmt, ##__VA_ARGS__) 33 #define LE_LOGE(fmt, ...) STARTUP_LOGE(LE_LOG_FILE, LE_LABEL, fmt, ##__VA_ARGS__) 34 #define LE_LOGV(fmt, ...) STARTUP_LOGV(LE_LOG_FILE, LE_LABEL, fmt, ##__VA_ARGS__) 35 36 #define LE_CHECK(ret, exper, ...) \ 37 if (!(ret)) { \ 38 LE_LOGE(__VA_ARGS__); \ 39 exper; \ 40 } 41 #define LE_ONLY_CHECK(ret, exper, ...) \ 42 if (!(ret)) { \ 43 exper; \ 44 } 45 46 void SetNoBlock(int fd); 47 #endif