14dfc7d99Sopenharmony_ci/*
24dfc7d99Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
34dfc7d99Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44dfc7d99Sopenharmony_ci * you may not use this file except in compliance with the License.
54dfc7d99Sopenharmony_ci * You may obtain a copy of the License at
64dfc7d99Sopenharmony_ci *
74dfc7d99Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84dfc7d99Sopenharmony_ci *
94dfc7d99Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104dfc7d99Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114dfc7d99Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124dfc7d99Sopenharmony_ci * See the License for the specific language governing permissions and
134dfc7d99Sopenharmony_ci * limitations under the License.
144dfc7d99Sopenharmony_ci */
154dfc7d99Sopenharmony_ci
164dfc7d99Sopenharmony_ci#ifndef RESSCHED_COMMON_INCLUDE_IPC_UTIL_H
174dfc7d99Sopenharmony_ci#define RESSCHED_COMMON_INCLUDE_IPC_UTIL_H
184dfc7d99Sopenharmony_ci
194dfc7d99Sopenharmony_ci#include "res_sched_log.h"
204dfc7d99Sopenharmony_ci
214dfc7d99Sopenharmony_cinamespace OHOS {
224dfc7d99Sopenharmony_cinamespace ResourceSchedule {
234dfc7d99Sopenharmony_ci
244dfc7d99Sopenharmony_ci#define READ_PARCEL(parcel, type, out, errReturn, className)                    \
254dfc7d99Sopenharmony_ci    do {                                                                        \
264dfc7d99Sopenharmony_ci        if (!(parcel).Read##type(out)) {                                        \
274dfc7d99Sopenharmony_ci            RESSCHED_LOGE(""#className"::%{public}s read"#out" failed", __func__); \
284dfc7d99Sopenharmony_ci            return errReturn;                                                   \
294dfc7d99Sopenharmony_ci        }                                                                       \
304dfc7d99Sopenharmony_ci    } while (0)                                                                 \
314dfc7d99Sopenharmony_ci
324dfc7d99Sopenharmony_ci#define WRITE_PARCEL(parcel, type, in, errReturn, className)                    \
334dfc7d99Sopenharmony_ci    do {                                                                        \
344dfc7d99Sopenharmony_ci        if (!(parcel).Write##type(in)) {                                        \
354dfc7d99Sopenharmony_ci            RESSCHED_LOGE(""#className"::%{public}s write"#in" failed", __func__); \
364dfc7d99Sopenharmony_ci            return errReturn;                                                   \
374dfc7d99Sopenharmony_ci        }                                                                       \
384dfc7d99Sopenharmony_ci    } while (0)
394dfc7d99Sopenharmony_ci
404dfc7d99Sopenharmony_ci} // namespace ResourceSchedule
414dfc7d99Sopenharmony_ci} // namespace OHOS
424dfc7d99Sopenharmony_ci
434dfc7d99Sopenharmony_ci#endif // RESSCHED_COMMON_INCLUDE_IPC_UTIL_H
44