File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
modules/core/src/opencl/runtime Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,24 @@ static void* WinGetProcAddress(const char* name)
134
134
#include < dlfcn.h>
135
135
#include < stdio.h>
136
136
137
+ static void *GetHandle (const char *file)
138
+ {
139
+ void *handle;
140
+
141
+ handle = dlopen (file, RTLD_LAZY | RTLD_GLOBAL);
142
+ if (!handle)
143
+ return NULL ;
144
+
145
+ if (dlsym (handle, OPENCL_FUNC_TO_CHECK_1_1) == NULL )
146
+ {
147
+ fprintf (stderr, ERROR_MSG_INVALID_VERSION);
148
+ dlclose (handle);
149
+ return NULL ;
150
+ }
151
+
152
+ return handle;
153
+ }
154
+
137
155
static void * GetProcAddress (const char * name)
138
156
{
139
157
static bool initialized = false ;
@@ -143,20 +161,18 @@ static void* GetProcAddress(const char* name)
143
161
cv::AutoLock lock (cv::getInitializationMutex ());
144
162
if (!initialized)
145
163
{
146
- const char * path = " libOpenCL.so" ;
147
164
const char * envPath = getenv (" OPENCV_OPENCL_RUNTIME" );
148
165
if (envPath)
149
- path = envPath;
150
- handle = dlopen (path, RTLD_LAZY | RTLD_GLOBAL);
151
- if (handle == NULL )
152
166
{
153
- if (envPath)
167
+ handle = GetHandle (envPath);
168
+ if (!handle)
154
169
fprintf (stderr, ERROR_MSG_CANT_LOAD);
155
170
}
156
- else if ( dlsym (handle, OPENCL_FUNC_TO_CHECK_1_1) == NULL )
171
+ else
157
172
{
158
- fprintf (stderr, ERROR_MSG_INVALID_VERSION);
159
- handle = NULL ;
173
+ handle = GetHandle (" libOpenCL.so" );
174
+ if (!handle)
175
+ handle = GetHandle (" libOpenCL.so.1" );
160
176
}
161
177
initialized = true ;
162
178
}
You can’t perform that action at this time.
0 commit comments