tizen 2.3 release
[framework/system/swap-probe.git] / include / tizen_probe.h
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim <jaewon81.lim@samsung.com>
9  * Woojin Jung <woojin2.jung@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  *
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  *
29  */
30
31 #ifndef __BADA_PROBE_H__
32 #define __BADA_PROBE_H__
33
34 #include <string.h>
35 #include <dlfcn.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41
42 #define GET_REAL_FUNC_TIZEN(FUNCNAME, LIBNAME, FUNCTIONPOINTER)                                         \
43         do {                                                                                            \
44                 if(!FUNCTIONPOINTER) {                                                                  \
45                         probeBlockStart();                                                              \
46                         if(lib_handle[LIBNAME] == NULL) {                                               \
47                                 lib_handle[LIBNAME] = dlopen(lib_string[LIBNAME], RTLD_LAZY);           \
48                                 if(lib_handle[LIBNAME] == NULL) {                                       \
49                                         char perror_msg[PERROR_MSG_MAX];                                \
50                                         sprintf(perror_msg, "dlopen failed : %s", lib_string[LIBNAME]); \
51                                         perror(perror_msg);                                             \
52                                         exit(0);                                                        \
53                                 }                                                                       \
54                         }                                                                               \
55                         void* funcp = dlsym(lib_handle[LIBNAME], #FUNCNAME);                            \
56                         if(funcp == NULL || dlerror() != NULL) {                                        \
57                                 perror("dlsym failed : " #FUNCNAME);                                    \
58                                 exit(0);                                                                \
59                         }                                                                               \
60                         memcpy(&FUNCTIONPOINTER, &funcp, sizeof(void*));                                \
61                         probeBlockEnd();                                                                \
62                 }                                                                                       \
63         } while(0)
64
65 #define PRE_PROBEBLOCK_TIZEN(FILTER)                                                                                            \
66         do {                                                                                                                                            \
67                 if((blockresult = preBlockBegin(CALLER_ADDRESS, FILTER, _sopt)) != 0) { \
68                         setProbePoint(&probeInfo);                                      \
69                         preBlockEnd();                                                  \
70                 }                                                                       \
71         } while(0)
72
73 extern int SceneManagerUsed;
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #endif