change Copyright headers, change line endings to Unix format
[platform/core/system/swap-probe.git] / include / osp_probe.h
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2011 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 #define GET_REAL_FUNC_OSP(FUNCNAME, LIBNAME, FUNCTIONPOINTER)   \
42         do {                                                                                                            \
43                 if(!FUNCTIONPOINTER) {                                                                  \
44                         probeBlockStart();                                                                      \
45                         if(lib_handle[LIBNAME] == NULL) {                                       \
46                                 lib_handle[LIBNAME] = dlopen(lib_string[LIBNAME], RTLD_LAZY);           \
47                                 if(lib_handle[LIBNAME] == NULL) {                               \
48                                         char perror_msg[PERROR_MSG_MAX];                        \
49                                         sprintf(perror_msg, "dlopen failed : %s", lib_string[LIBNAME]); \
50                                         perror(perror_msg);                                                     \
51                                         exit(0);                                                                        \
52                                 }                                                                                               \
53                         }                                                                                                       \
54                         void* funcp = dlsym(lib_handle[LIBNAME], #FUNCNAME);                    \
55                         if(funcp == NULL || dlerror() != NULL) {                        \
56                                 perror("dlsym failed : " #FUNCNAME);                    \
57                                 exit(0);                                                                                \
58                         }                                                                                                       \
59                         memcpy(&FUNCTIONPOINTER, &funcp, sizeof(void*));        \
60                         probeBlockEnd();                                                                        \
61                 }                                                                                                               \
62         } while(0)
63
64 #define PRE_PROBEBLOCK_OSP(FILTER)                                                                                              \
65         do {                                                                                                                                            \
66                 if((blockresult = preBlockBegin(CALLER_ADDRESS, FILTER, _sopt)) != 0) { \
67                         setProbePoint(&probeInfo);                                                                                      \
68                         preBlockEnd();                                                                                                          \
69                 }                                                                                                                                               \
70         } while(0)
71
72 extern int SceneManagerUsed;
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif