ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.xs
(Generate patch)

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.31 by root, Thu Apr 19 14:36:46 2012 UTC vs.
Revision 1.32 by root, Thu Apr 19 19:36:24 2012 UTC

36typedef SV *FUTURE; 36typedef SV *FUTURE;
37 37
38/*****************************************************************************/ 38/*****************************************************************************/
39 39
40// name must include a leading underscore 40// name must include a leading underscore
41// all of this horrors would be unneceesary if somebody wrote a proper OpenGL module
42// for perl. doh.
41static void * 43static void *
42getsym (const char *name) 44glsym (const char *name)
43{ 45{
46 void *fun = 0;
47
44 #if defined I_DLFCN && defined RTLD_DEFAULT 48 #if defined I_DLFCN && defined RTLD_DEFAULT
45 #if !DLSYM_NEEDS_UNDERSCORE 49 fun = dlsym (RTLD_DEFAULT, name + 1);
46 ++name; // skip _
47 #endif
48 return dlsym (RTLD_DEFAULT, name); 50 if (!fun) fun = dlsym (RTLD_DEFAULT, name);
49 #else 51
50 return 0; 52 if (!fun)
53 {
54 static void *libgl;
55 static const char *glso[] = {
56 "libGL.so.1",
57 "libGL.so.3",
58 "libGL.so.4.0",
59 "libGL.so",
60 "/usr/lib/libGL.so",
61 "/usr/X11R6/lib/libGL.1.dylib"
62 };
63 int i;
64
65 for (i = 0; !libgl && i < sizeof (glso) / sizeof (glso [0]); ++i)
66 {
67 libgl = dlopen (glso [i], RTLD_LAZY);
68 if (libgl)
69 break;
70 }
71
72 if (libgl)
73 {
74 fun = dlsym (libgl, name + 1);
75 if (!fun) fun = dlsym (libgl, name);
76 }
77 }
51 #endif 78 #endif
79
80 return fun;
52} 81}
53 82
54/*****************************************************************************/ 83/*****************************************************************************/
55 84
56/* up to two temporary buffers */ 85/* up to two temporary buffers */
178 207
179 for (i = 0; i < len; i += 2) 208 for (i = 0; i < len; i += 2)
180 { 209 {
181 cl_context_properties t = SvIV (*av_fetch (av, i , 0)); 210 cl_context_properties t = SvIV (*av_fetch (av, i , 0));
182 SV *p_sv = *av_fetch (av, i + 1, 0); 211 SV *p_sv = *av_fetch (av, i + 1, 0);
183 cl_context_properties v; 212 cl_context_properties v = SvIV (p_sv); // code below can override
184 213
185 switch (t) 214 switch (t)
186 { 215 {
216 case CL_GLX_DISPLAY_KHR:
217 if (!SvOK (p_sv))
218 {
219 void *func = glsym ("_glXGetCurrentDisplay");
220 if (func)
221 v = (cl_context_properties)((void *(*)(void))func)();
222 }
223 break;
224
225 case CL_GL_CONTEXT_KHR:
226 if (!SvOK (p_sv))
227 {
228 void *func = glsym ("_glXGetCurrentContext");
229 if (func)
230 v = (cl_context_properties)((void *(*)(void))func)();
231 }
232 break;
233
187 default: 234 default:
188 /* unknown property, treat as int */ 235 /* unknown property, treat as int */
189 v = SvIV (p_sv);
190 break; 236 break;
191 } 237 }
192 238
193 *l++ = t; 239 *l++ = t;
194 *l++ = v; 240 *l++ = v;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines