1 #include <CL/cl.h> 2 #include <CL/cl_gl.h> 3 #include <CL/cl_egl.h> 4 #include <CL/cl_ext.h> 5 #include <dlfcn.h> 6 7 8 void* libHandle = nullptr; 9 10 #define FUNC_TYPES(rettype, fname, fargs, callArgs) \ 11 typedef rettype (* fname ## _t) fargs; 12 13 #define FUNC_SYM(rettype, fname, fargs, callArgs) \ 14 rettype fname fargs { \ 15 if (!libHandle) \ 16 libHandle = dlopen( "libOpenCL.so", RTLD_NOW | RTLD_GLOBAL ); \ 17 \ 18 static fname ## _t func = nullptr; \ 19 if (!func) \ 20 func = reinterpret_cast< fname ## _t >(dlsym(libHandle, #fname)); \ 21 \ 22 return func callArgs; \ 23 \ 24 } 25 26 #define CL_MACRO FUNC_TYPES 27 #include "apis.h" 28 #undef CL_MACRO 29 30 #define CL_MACRO FUNC_SYM 31 #include "apis.h" 32 #undef CL_MACRO 33