4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Sanghyun Lee <sanghyunnim.lee@samsung.com>
9 * Juyoung Kim <j0.kim@samsung.com>
10 * Vitaliy Cherepanov <v.cherepanov@samsung.com>
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)
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.
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
42 #define NO_RETURN_FORMAT "%s"
43 #define NO_RETURN_VALUE 0
44 #define APITYPE_INIT 0
45 #define APITYPE_CONTEXT 1
46 #define APITYPE_NO_CONTEXT 2
48 char contextValue[256];
50 #define PACK_GL_ADD(GL_api_type, GL_elapsed_time, GL_context_value) \
52 BUF_PTR = pack_int32(BUF_PTR, (uint32_t)GL_api_type); \
53 BUF_PTR = pack_int64(BUF_PTR, (uint64_t)GL_elapsed_time); \
54 BUF_PTR = pack_string(BUF_PTR, GL_context_value); \
58 #define BEFORE(FUNCNAME) \
59 DECLARE_VARIABLE_STANDARD_NORET; \
60 GLenum error = GL_NO_ERROR; \
61 static methodType FUNCNAME ## p = 0; \
63 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
64 uint64_t start_nsec = get_current_nsec(); \
67 if (lib_handle[LIBGLES20] == ((void *) 0)) { \
68 lib_handle[LIBGLES20] = dlopen(lib_string[LIBGLES20], RTLD_LAZY); \
69 if (lib_handle[LIBGLES20] == ((void *) 0)) { \
70 char perror_msg[128]; \
71 sprintf(perror_msg, "dlopen failed : %s", \
72 lib_string[LIBGLES20]); \
78 /* TODO: add library init event here */ \
80 tmpPtr = dlsym(lib_handle[LIBGLES20], #FUNCNAME); \
81 if (tmpPtr == NULL || dlerror() != NULL) { \
82 perror("dlsym failed : " #FUNCNAME); \
86 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
91 #define BEFORE_EGL(FUNCNAME) \
92 DECLARE_VARIABLE_STANDARD_NORET; \
93 GLenum error = GL_NO_ERROR; \
94 static methodType FUNCNAME ## p = 0; \
96 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
97 uint64_t start_nsec = get_current_nsec(); \
100 if (lib_handle[LIBEGL] == ((void *) 0)) { \
101 lib_handle[LIBEGL] = dlopen(lib_string[LIBEGL], RTLD_LAZY | RTLD_GLOBAL); \
102 if (lib_handle[LIBEGL] == ((void *) 0)) { \
103 char perror_msg[128]; \
104 sprintf(perror_msg, "dlopen failed : %s", \
105 lib_string[LIBEGL]); \
106 perror(perror_msg); \
111 tmpPtr = dlsym(lib_handle[LIBEGL], #FUNCNAME); \
112 if (tmpPtr == NULL || dlerror() != NULL) { \
113 perror("dlsym failed : " #FUNCNAME); \
117 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
122 #define BEFORE_OSP_UIFW(FUNCNAME) \
123 DECLARE_VARIABLE_STANDARD_NORET; \
124 GLenum error = GL_NO_ERROR; \
125 static methodType FUNCNAME ## p = 0; \
127 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
128 uint64_t start_nsec = get_current_nsec(); \
131 if (lib_handle[LIBOSP_UIFW] == ((void *) 0)) { \
132 lib_handle[LIBOSP_UIFW] = dlopen(lib_string[LIBOSP_UIFW], RTLD_LAZY); \
133 if (lib_handle[LIBOSP_UIFW] == ((void *) 0)) { \
134 char perror_msg[128]; \
135 sprintf(perror_msg, "dlopen failed : %s", \
136 lib_string[LIBOSP_UIFW]); \
137 perror(perror_msg); \
142 tmpPtr = dlsym(lib_handle[LIBOSP_UIFW], #FUNCNAME); \
143 if (tmpPtr == NULL || dlerror() != NULL) { \
144 perror("dlsym failed : " #FUNCNAME); \
148 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
153 #define AFTER(RET_VAL, APITYPE, CONTEXT_VAL, INPUTFORMAT, ...) \
154 POST_PACK_PROBEBLOCK_BEGIN(); \
155 PREPARE_LOCAL_BUF(); \
156 PACK_COMMON_BEGIN(MSG_PROBE_GL, vAPI_ID, INPUTFORMAT, __VA_ARGS__);\
157 PACK_COMMON_END(RET_VAL, error, blockresult); \
158 PACK_GL_ADD(APITYPE, get_current_nsec() - start_nsec, CONTEXT_VAL); \
160 POST_PACK_PROBEBLOCK_END()
162 #define AFTER_NO_PARAM(RETVAL, APITYPE, CONTEXTVALUE) \
163 AFTER(RETVAL, APITYPE, CONTEXTVALUE, "", 0)
165 #endif /* DA_GLES20_H_ */