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#ifndef LE_DOMAIN
31#define LE_DOMAIN (BASE_DOMAIN + 4)
32#endif
33#define LE_LABEL "LoopEvent"
34#define LE_LOGI(fmt, ...) STARTUP_LOGI(LE_DOMAIN, LE_LABEL, fmt, ##__VA_ARGS__)
35#define LE_LOGE(fmt, ...) STARTUP_LOGE(LE_DOMAIN, LE_LABEL, fmt, ##__VA_ARGS__)
36#define LE_LOGV(fmt, ...) STARTUP_LOGV(LE_DOMAIN, LE_LABEL, fmt, ##__VA_ARGS__)
37#define LE_LOGW(fmt, ...) STARTUP_LOGW(LE_DOMAIN, LE_LABEL, fmt, ##__VA_ARGS__)
38
39#define LE_CHECK(ret, exper, ...)                                                                                      \
40    if (!(ret)) {                                                                                                      \
41        LE_LOGE(__VA_ARGS__);                                                                                          \
42        exper;                                                                                                         \
43    }
44#define LE_ONLY_CHECK(ret, exper, ...)                                                                                 \
45    if (!(ret)) {                                                                                                      \
46        exper;                                                                                                         \
47    }
48
49void SetNoBlock(int fd);
50#endif