9e596fea2bf31d02662cffd48687158952a79ca7
[platform/core/appfw/app-core.git] / src / base / appcore_base_private.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
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 #pragma once
18
19 #define LOG_TAG "APP_CORE_BASE"
20
21 #include <stdio.h>
22 #include <stdbool.h>
23 #include <dlog.h>
24
25 #ifndef EXPORT_API
26 #  define EXPORT_API __attribute__ ((visibility("default")))
27 #endif
28
29 #ifndef _DLOG_H_
30 #  define _ERR(fmt, arg...) \
31         do { fprintf(stderr, "appcore: "fmt"\n", ##arg); } while (0)
32
33 #  define _INFO(fmt, arg...) \
34         do { fprintf(stdout, fmt"\n", ##arg); } while (0)
35
36 #  define _DBG(fmt, arg...) \
37         do { \
38                 if (getenv("APPCORE_DEBUG")) { \
39                         fprintf(stdout, fmt"\n", ##arg); \
40                 } \
41         } while (0)
42 #else
43 #  define _ERR(fmt, arg...) \
44         do { \
45                 fprintf(stderr, "appcore: "fmt"\n", ##arg); \
46                 LOGE(fmt, ##arg); \
47         } while (0)
48 #  define _INFO(...) LOGI(__VA_ARGS__)
49 #  define _DBG(...) LOGD(__VA_ARGS__)
50 #endif
51
52 #define _warn_if(expr, fmt, arg...) do { \
53                 if (expr) { \
54                         _ERR(fmt, ##arg); \
55                 } \
56         } while (0)
57
58 #define _ret_if(expr) do { \
59                 if (expr) { \
60                         return; \
61                 } \
62         } while (0)
63
64 #define _retv_if(expr, val) do { \
65                 if (expr) { \
66                         return (val); \
67                 } \
68         } while (0)
69
70 #define _retm_if(expr, fmt, arg...) do { \
71                 if (expr) { \
72                         _ERR(fmt, ##arg); \
73                         return; \
74                 } \
75         } while (0)
76
77 #define _retvm_if(expr, val, fmt, arg...) do { \
78                 if (expr) { \
79                         _ERR(fmt, ##arg); \
80                         return (val); \
81                 } \
82         } while (0)
83
84
85 extern void aul_finalize();
86