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/clImplCustomCode.c | |
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/clImplCustomCode.c')
-rw-r--r-- | resources/clImplCustomCode.c | 33 |
1 files changed, 33 insertions, 0 deletions
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; +} |