diff options
author | Michael Bien <[email protected]> | 2011-07-18 19:06:59 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-07-18 19:06:59 +0200 |
commit | 140b7b5020f3b85e43fb0203ca041c176d9e730b (patch) | |
tree | 9b0d11c10526f924426f87f541b0bbbdaa9f618e /resources | |
parent | 6bd00879eec56c2753d84708f551557a2684904b (diff) |
custom impl for clGetExtensionFuncitonAddress binding to remove a few gluegen workarounds.
should be also a bit more gc friendly.
Diffstat (limited to 'resources')
-rw-r--r-- | resources/cl-impl.cfg | 8 | ||||
-rw-r--r-- | resources/clImplCustomCode.c | 33 |
2 files changed, 36 insertions, 5 deletions
diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg index 1f9240a2..977f430e 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -45,11 +45,6 @@ ProcAddressNameExpr $UpperCase(arg) #...or force all ForceProcAddressGen __ALL__ -Unignore clGetExtensionFunctionAddress -RenameJavaMethod clGetExtensionFunctionAddress clGetExtensionFunctionAddressImpl -AccessControl clGetExtensionFunctionAddressImpl PROTECTED -ArgumentIsString clGetExtensionFunctionAddressImpl 0 - #append to generated c files CustomCCode #include <CL/cl.h> CustomCCode #include <CL/cl_ext.h> @@ -79,6 +74,9 @@ ForceProcAddressGen clSetEventCallback Ignore clSetMemObjectDestructorCallback ForceProcAddressGen clSetMemObjectDestructorCallback +Ignore clGetExtensionFunctionAddress +ForceProcAddressGen clGetExtensionFunctionAddress + #take buffer capacity from input param 5 ReturnValueCapacity clEnqueueMapBuffer {5} diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index fba3cb3d..d1442f66 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -409,3 +409,36 @@ Java_com_jogamp_opencl_llb_impl_CLImpl_clSetMemObjectDestructorCallback0(JNIEnv return _res; } + +/* Java->C glue code: + * Java package: com.jogamp.opencl.llb.impl.CLImpl + * Java method: java.nio.ByteBuffer dispatch_clGetExtensionFunctionAddressImpl(java.lang.String func_name) + * C function: void * clGetExtensionFunctionAddress(const char * func_name); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl_dispatch_1clGetExtensionFunctionAddress1__Ljava_lang_String_2J(JNIEnv *env, jobject _unused, + jstring func_name, jlong procAddress) { + + typedef void * (*_local_ARG)(const char * func_name); + _local_ARG ptr_clGetExtensionFunctionAddress; + const char* _strchars_func_name = NULL; + void * _res; + + if (NULL != func_name) { + _strchars_func_name = (*env)->GetStringUTFChars(env, func_name, (jboolean*) NULL); + if (NULL == _strchars_func_name) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), "Failed to get UTF-8 chars for argument \"func_name\""); + return 0; + } + } + + ptr_clGetExtensionFunctionAddress = (_local_ARG) (intptr_t) procAddress; + _res = (* ptr_clGetExtensionFunctionAddress) ((char *) _strchars_func_name); + + if (NULL != func_name) { + (*env)->ReleaseStringUTFChars(env, func_name, _strchars_func_name); + } + if (NULL == _res) return 0; + + return (jlong)_res; +} |