--- OpenCL/OpenCL.xs 2012/04/19 13:18:31 1.27 +++ OpenCL/OpenCL.xs 2012/04/19 14:36:46 1.31 @@ -2,6 +2,10 @@ #include "perl.h" #include "XSUB.h" +#ifdef I_DLFCN + #include +#endif + #ifdef __APPLE__ #include #else @@ -33,6 +37,22 @@ /*****************************************************************************/ +// name must include a leading underscore +static void * +getsym (const char *name) +{ + #if defined I_DLFCN && defined RTLD_DEFAULT + #if !DLSYM_NEEDS_UNDERSCORE + ++name; // skip _ + #endif + return dlsym (RTLD_DEFAULT, name); + #else + return 0; + #endif +} + +/*****************************************************************************/ + /* up to two temporary buffers */ static void * tmpbuf (size_t size) @@ -146,7 +166,7 @@ if (SvROK (sv) && SvTYPE (SvRV (sv)) == SVt_PVAV) { AV *av = (AV *)SvRV (sv); - int i, len = av_len (av); + int i, len = av_len (av) + 1; cl_context_properties *p = tmpbuf (sizeof (cl_context_properties) * (len + extracount + 1)); cl_context_properties *l = p; @@ -158,14 +178,15 @@ for (i = 0; i < len; i += 2) { - cl_context_properties t = SvIV (*av_fetch (av, i, 0)); + cl_context_properties t = SvIV (*av_fetch (av, i , 0)); + SV *p_sv = *av_fetch (av, i + 1, 0); cl_context_properties v; switch (t) { default: /* unknown property, treat as int */ - v = SvIV (*av_fetch (av, i, 0)); + v = SvIV (p_sv); break; } @@ -1245,7 +1266,7 @@ PPCODE: cl_gl_object_type type; cl_GLuint name; - NEED_SUCCESS (clGetGLObjectInfo, (self, &type, &name)); + NEED_SUCCESS (GetGLObjectInfo, (self, &type, &name)); EXTEND (SP, 2); PUSHs (sv_2mortal (newSVuv (type))); PUSHs (sv_2mortal (newSVuv (name))); @@ -1300,7 +1321,7 @@ target (OpenCL::Image self) PPCODE: cl_GLenum value [1]; - NEED_SUCCESS (GetGlTextureInfo, (self, CL_GL_TEXTURE_TARGET, sizeof (value), value, 0)); + NEED_SUCCESS (GetGLTextureInfo, (self, CL_GL_TEXTURE_TARGET, sizeof (value), value, 0)); EXTEND (SP, 1); const int i = 0; PUSHs (sv_2mortal (newSVuv (value [i]))); @@ -1309,7 +1330,7 @@ gl_mipmap_level (OpenCL::Image self) PPCODE: cl_GLint value [1]; - NEED_SUCCESS (GetGlTextureInfo, (self, CL_GL_MIPMAP_LEVEL, sizeof (value), value, 0)); + NEED_SUCCESS (GetGLTextureInfo, (self, CL_GL_MIPMAP_LEVEL, sizeof (value), value, 0)); EXTEND (SP, 1); const int i = 0; PUSHs (sv_2mortal (newSViv (value [i])));