792594a245a91ac18a88bfb8622412c5714c83f4
[platform/core/api/peripheral-io.git] / include / interface / peripheral_interface_common.h
1 /*
2  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __PERIPHERAL_INTERFACE_COMMON_H__
18 #define __PERIPHERAL_INTERFACE_COMMON_H__
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23
24 #include "peripheral_io.h"
25 #include "peripheral_handle.h"
26 #include "peripheral_log.h"
27
28 #define CHECK_ERROR(expr) \
29         do { \
30                 if (expr) { \
31                         if (errno == EAGAIN) \
32                                 return -EAGAIN; \
33                         char errmsg[255]; \
34                         strerror_r(errno, errmsg, sizeof(errmsg)); \
35                         _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
36                         return -EIO; \
37                 } \
38         } while (0)
39
40 typedef struct predefined_type {
41         char *type;
42         int len;
43 } predefined_type_s;
44
45 #endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/