This is an automated email from the git hooks/post-receive script. tpot-guest pushed a commit to annotated tag upstream/1.0.10 in repository jffi-next.
commit 941b9e14db0f8b514224de7843171e9480d12f12 Author: Wayne Meissner <[email protected]> Date: Tue Apr 26 19:33:21 2011 +1000 Add fast paths for numeric functions with up to three array arguments. --- jni/jffi/FastNumericInvoker.c | 686 ++++++++++++++++++++++++++++++++++++++-- src/com/kenai/jffi/Foreign.java | 129 +++++++- 2 files changed, 796 insertions(+), 19 deletions(-) diff --git a/jni/jffi/FastNumericInvoker.c b/jni/jffi/FastNumericInvoker.c index f7a100a..8902f51 100644 --- a/jni/jffi/FastNumericInvoker.c +++ b/jni/jffi/FastNumericInvoker.c @@ -39,6 +39,8 @@ #include "jffi.h" #include "Exception.h" #include "Function.h" +#include "CallContext.h" +#include "Array.h" #include "LastError.h" #include "com_kenai_jffi_Foreign.h" @@ -46,6 +48,60 @@ /* for return values <= sizeof(long), need to use an ffi_sarg sized return value */ #define RETVAL(retval, rtype) ((rtype)->size > sizeof(ffi_sarg) ? (retval).j : (retval).sarg) +#if defined(__i386__) && 1 +# define INT_BYPASS_FFI +#endif + +#if defined(__x86_64__) && 1 +# define INT_BYPASS_FFI +# define LONG_BYPASS_FFI +#endif + +#define MAX_STACK_ARRAY (1024) + + +#define OBJIDX(flags) ((flags & com_kenai_jffi_ObjectBuffer_INDEX_MASK) >> com_kenai_jffi_ObjectBuffer_INDEX_SHIFT) +#define OBJTYPE(flags) ((flags) & com_kenai_jffi_ObjectBuffer_TYPE_MASK) + +#define IS_ARRAY(flags) \ + ((OBJTYPE(flags) & ~com_kenai_jffi_ObjectBuffer_PRIM_MASK) == com_kenai_jffi_ObjectBuffer_ARRAY) + +#define IS_BUFFER(flags) \ + ((OBJTYPE(flags) & ~com_kenai_jffi_ObjectBuffer_PRIM_MASK) == com_kenai_jffi_ObjectBuffer_BUFFER) + + +typedef struct Pinned { + jobject object; + int offset; + int length; + int flags; +} Pinned; + +typedef struct ObjectParam { + jobject object; + int offset; + int length; + int flags; +} ObjectParam; + + +static void call1(CallContext* ctx, void* function, FFIValue* retval, + jlong n1); +static void call2(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2); +static void call3(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3); +static void call4(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3, jlong n4); +static void call5(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5); +static void call6(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6); +static bool pin_arrays(JNIEnv* env, Pinned* pinned, int pinnedCount, + Array* arrays, int *arrayCount, jlong* v); +static bool object_to_ptr(JNIEnv* env, jobject obj, int off, int len, int f, void** pptr, + Array* arrays, int* arrayCount, Pinned* pinned, int* pinnedCount); + /* * Class: com_kenai_jffi_Foreign * Method: invokeVrL @@ -56,8 +112,21 @@ Java_com_kenai_jffi_Foreign_invokeVrN(JNIEnv* env, jobject self, jlong ctxAddres { Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; + + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval.j = ((jlong (*)(void)) ctx->function)(); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval.sarg = ((jint (*)(void)) ctx->function)(); +#endif + } else { + ffi_call0(ctx, ctx->function, &retval); + } - ffi_call0(ctx, ctx->function, &retval); SAVE_ERRNO(ctx); return RETVAL(retval, ctx->cif.rtype); @@ -74,9 +143,8 @@ Java_com_kenai_jffi_Foreign_invokeNrN(JNIEnv* env, jobject self, jlong ctxAddres Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call1(ctx, ctx->function, &retval, arg1); - SAVE_ERRNO(ctx); - + call1((CallContext *) ctx, ctx->function, &retval, arg1); + return RETVAL(retval, ctx->cif.rtype); } @@ -91,9 +159,8 @@ Java_com_kenai_jffi_Foreign_invokeNNrN(JNIEnv* env, jobject self, jlong ctxAddre Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call2(ctx, ctx->function, &retval, arg1, arg2); - SAVE_ERRNO(ctx); - + call2((CallContext *) ctx, ctx->function, &retval, arg1, arg2); + return RETVAL(retval, ctx->cif.rtype); } @@ -109,9 +176,8 @@ Java_com_kenai_jffi_Foreign_invokeNNNrN(JNIEnv* env, jobject self, jlong ctxAddr Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call3(ctx, ctx->function, &retval, arg1, arg2, arg3); - SAVE_ERRNO(ctx); - + call3((CallContext *) ctx, ctx->function, &retval, arg1, arg2, arg3); + return RETVAL(retval, ctx->cif.rtype); } @@ -122,9 +188,8 @@ Java_com_kenai_jffi_Foreign_invokeNNNNrN(JNIEnv* env, jobject self, jlong ctxAdd Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call4(ctx, ctx->function, &retval, arg1, arg2, arg3, arg4); - SAVE_ERRNO(ctx); - + call4((CallContext *) ctx, ctx->function, &retval, arg1, arg2, arg3, arg4); + return RETVAL(retval, ctx->cif.rtype); } @@ -135,9 +200,8 @@ Java_com_kenai_jffi_Foreign_invokeNNNNNrN(JNIEnv* env, jobject self, jlong ctxAd Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call5(ctx, ctx->function, &retval, arg1, arg2, arg3, arg4, arg5); - SAVE_ERRNO(ctx); - + call5((CallContext *) ctx, ctx->function, &retval, arg1, arg2, arg3, arg4, arg5); + return RETVAL(retval, ctx->cif.rtype); } @@ -148,8 +212,594 @@ Java_com_kenai_jffi_Foreign_invokeNNNNNNrN(JNIEnv* env, jobject self, jlong ctxA Function* ctx = (Function *) j2p(ctxAddress); FFIValue retval; - ffi_call6(ctx, ctx->function, &retval, arg1, arg2, arg3, arg4, arg5, arg6); + call6((CallContext *) ctx, ctx->function, &retval, arg1, arg2, arg3, arg4, arg5, arg6); + + return RETVAL(retval, ctx->cif.rtype); +} + +static void +call1(CallContext* ctx, void* function, FFIValue* retval, jlong n1) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong)) function)(n1); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint)) function)(*(jint *) &n1); +#endif + + } else { + ffi_call1(ctx, function, retval, n1); + } + SAVE_ERRNO(ctx); +} - return RETVAL(retval, ctx->cif.rtype); +static void +call2(CallContext* ctx, void* function, FFIValue* retval, jlong n1, jlong n2) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong, jlong)) function)(n1, n2); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint, jint)) function)( + *(jint *) &n1, *(jint *) &n2); +#endif + + } else { + ffi_call2(ctx, function, retval, n1, n2); + } + + SAVE_ERRNO(ctx); +} + +static void +call3(CallContext* ctx, void* function, FFIValue* retval, jlong n1, jlong n2, jlong n3) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong, jlong, jlong)) function)(n1, n2, n3); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint, jint, jint)) function)( + *(jint *) &n1, *(jint *) &n2, *(jint *) &n3); +#endif + + } else { + ffi_call3(ctx, function, retval, n1, n2, n3); + } + + SAVE_ERRNO(ctx); +} + + + +static void +call4(CallContext* ctx, void* function, FFIValue* retval, jlong n1, jlong n2, jlong n3, jlong n4) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong, jlong, jlong, jlong)) function)(n1, n2, n3, n4); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint, jint, jint, jint)) function)( + *(jint *) &n1, *(jint *) &n2, *(jint *) &n3, *(jint *) &n4); +#endif + + } else { + ffi_call4(ctx, function, retval, n1, n2, n3, n4); + } + + SAVE_ERRNO(ctx); +} + + +static void +call5(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong, jlong, jlong, jlong, jlong)) function)(n1, n2, n3, n4, n5); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint, jint, jint, jint, jint)) function)( + *(jint *) &n1, *(jint *) &n2, *(jint *) &n3, + *(jint *) &n4, *(jint *) &n5); +#endif + + } else { + ffi_call5(ctx, function, retval, n1, n2, n3, n4, n5); + } + + SAVE_ERRNO(ctx); +} + +static void +call6(CallContext* ctx, void* function, FFIValue* retval, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6) +{ + if (0) { +#if defined(LONG_BYPASS_FFI) && defined(__x86_64__) + } else if (likely(ctx->isFastLong)) { + retval->j = ((jlong (*)(jlong, jlong, jlong, jlong, jlong, jlong)) function)( + n1, n2, n3, n4, n5, n6); +#endif + +#if defined(INT_BYPASS_FFI) && defined(__i386__) + } else if (likely(ctx->isFastInt)) { + retval->sarg = ((jint (*)(jint, jint, jint, jint, jint, jint)) function)( + *(jint *) &n1, *(jint *) &n2, *(jint *) &n3, + *(jint *) &n4, *(jint *) &n5, *(jint *) &n6); +#endif + + } else { + ffi_call6(ctx, function, retval, n1, n2, n3, n4, n5, n6); + } + + SAVE_ERRNO(ctx); +} + +static bool +pin_arrays(JNIEnv* env, Pinned* pinned, int pinnedCount, + Array* arrays, int *arrayCount, jlong* v) +{ + int aryIdx; + for (aryIdx = 0; aryIdx < pinnedCount; aryIdx++) { + Pinned* p = &pinned[aryIdx]; + Array* ary = &arrays[*arrayCount]; + + void* addr = jffi_getArrayCritical(env, p->object, p->offset, p->length, p->flags, ary); + if (unlikely(addr == NULL)) { + return false; + } + + v[OBJIDX(p->flags)] = p2j(addr); + (*arrayCount)++; + } + + return true; +} + +static bool +object_to_ptr(JNIEnv* env, jobject obj, int off, int len, int f, void** pptr, + Array* arrays, int* arrayCount, Pinned* pinned, int* pinnedCount) +{ + if (unlikely(obj == NULL)) { + throwException(env, NullPointer, "null object for parameter %d", OBJIDX(f)); + return false; + + } else if (unlikely(IS_PINNED_ARRAY(f))) { + Pinned* p = &pinned[(*pinnedCount)++]; + p->object = obj; + p->offset = off; + p->length = len; + p->flags = f; + + } else if (IS_ARRAY(f)) { + *pptr = jffi_getArrayHeap(env, obj, off, len, f, &arrays[*arrayCount]); + if (unlikely(*pptr == NULL)) { + return false; + } + (*arrayCount)++; + + } else if (IS_BUFFER((f))) { + caddr_t addr = (caddr_t) (*env)->GetDirectBufferAddress(env, obj); + if (unlikely(addr == NULL)) { + throwException(env, NullPointer, + "could not get direct buffer address for parameter %d", OBJIDX(f)); + return false; + } + *pptr = addr + off; + + } else { + throwException(env, IllegalArgument, "unsupported object type for parameter %d: %#x", OBJIDX(f), f); + return false; + } + + return true; +} + +static void +free_arrays(JNIEnv* env, Array* arrays, int arrayCount) +{ + int aryIdx; + for (aryIdx = arrayCount; aryIdx >= 0; aryIdx--) { + if (arrays[aryIdx].release != NULL) { + (*arrays[aryIdx].release)(env, &arrays[aryIdx]); + } + } +} + +#define N1 n1 +#define N2 N1, n2 +#define N3 N2, n3 +#define N4 N3, n4 +#define N5 N4, n5 +#define N6 N5, n6 + +#define INIT(n) \ + const int MAX_PARAM_INDEX = (n) - 1; \ + CallContext* ctx = (CallContext *) j2p(ctxAddress); \ + Array arrays[(n)]; \ + Pinned pinned[(n)]; \ + int arrayCount = 0, pinnedCount = 0; \ + FFIValue retval; \ + jlong v[] = { N##n } + +#define FREE_ARRAYS(env, arrays, arrayCount) do { \ + int aryIdx; \ + for (aryIdx = arrayCount; aryIdx >= 0; aryIdx--) { \ + if (arrays[aryIdx].release != NULL) (*arrays[aryIdx].release)(env, &arrays[aryIdx]); \ + } \ +} while(0) + +#define END \ + error: \ + RELEASE_ARRAYS(env, arrays, arrayCount); \ + return RETVAL(retval, ctx->cif.rtype) + +#define ADDOBJ(obj, off, len, flags) do { \ + int idx = OBJIDX(flags); \ + if (unlikely(idx < 0 || idx > MAX_PARAM_INDEX)) { \ + throwException(env, OutOfBounds, "invalid object parameter index %d (expected 0..%d)", \ + idx, MAX_PARAM_INDEX); \ + goto error; \ + } \ + if (likely(IS_UNPINNED_ARRAY(flags) && len < MAX_STACK_ARRAY)) { \ + void* ptr = alloca(jffi_arraySize((len) + 1, (flags))); \ + if (unlikely(jffi_getArrayBuffer(env, obj, off, len, flags, &arrays[arrayCount], ptr) == NULL)) { \ + goto error; \ + } \ + v[idx] = p2j(ptr); \ + arrayCount++; \ + } else if (!object_to_ptr(env, obj, off, len, flags, (void **) ARGPTR(&v[idx], ctx->cif.arg_types[idx]), arrays, &arrayCount, pinned, &pinnedCount)) { \ + goto error; \ + } \ +} while (0) + +#define PIN_ARRAYS do { \ + if (unlikely(pinnedCount > 0)) { \ + if (!pin_arrays(env, pinned, pinnedCount, arrays, &arrayCount, v)) goto error; \ + } \ +} while(0) + +#define CALL(n, args...) \ + PIN_ARRAYS; \ + call##n(ctx, j2p(function), &retval, args); \ + END + +#define CALL1 CALL(1, v[0]) +#define CALL2 CALL(2, v[0], v[1]) +#define CALL3 CALL(3, v[0], v[1], v[2]) +#define CALL4 CALL(4, v[0], v[1], v[2], v[3]) +#define CALL5 CALL(5, v[0], v[1], v[2], v[3], v[4]) +#define CALL6 CALL(6, v[0], v[1], v[2], v[3], v[4], v[5]) + +#if defined(__OPTIMIZE_SIZE__) || 1 + +#define OBJPARAM1 \ + ObjectParam objects[] = { \ + { o1, o1off, o1len, o1flags } \ + } + +#define OBJPARAM2 \ + ObjectParam objects[] = { \ + { o1, o1off, o1len, o1flags }, \ + { o2, o2off, o2len, o2flags } \ + } + +#define OBJPARAM3 \ + ObjectParam objects[] = { \ + { o1, o1off, o1len, o1flags }, \ + { o2, o2off, o2len, o2flags }, \ + { o3, o3off, o3len, o3flags } \ + } + +#define INVOKE(n, o) \ + OBJPARAM##o; \ + return invoke##n(env, ctxAddress, function, N##n, objects, o); + + +#define IMPL(n) \ + INIT(n); \ + int objIdx; \ + for (objIdx = 0; objIdx < nobjects; objIdx++) { \ + ADDOBJ(objects[objIdx].object, objects[objIdx].offset, objects[objIdx].length, \ + objects[objIdx].flags); \ + } \ + CALL##n; + +static jlong +invoke1(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, + ObjectParam* objects, int nobjects) +{ + IMPL(1); +} + +static jlong +invoke2(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, jlong n2, + ObjectParam* objects, int nobjects) +{ + IMPL(2); +} + +static jlong +invoke3(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, + ObjectParam* objects, int nobjects) +{ + IMPL(3); +} + +static jlong +invoke4(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, + ObjectParam* objects, int nobjects) +{ + IMPL(4); +} + +static jlong +invoke5(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, + ObjectParam* objects, int nobjects) +{ + IMPL(5); +} + +static jlong +invoke6(JNIEnv* env, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6, + ObjectParam* objects, int nobjects) +{ + IMPL(6); +} + +#else + +#define ADDOBJ1 \ + ADDOBJ(o1, o1off, o1len, o1flags) + +#define ADDOBJ2 \ + ADDOBJ1; ADDOBJ(o2, o2off, o2len, o2flags) + +#define ADDOBJ3 \ + ADDOBJ2; ADDOBJ(o3, o3off, o3len, o3flags) + + +# define INVOKE(n, o) \ + INIT(n); \ + ADDOBJ##o; \ + CALL##n + +#endif + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNO1rN + * Signature: (JJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN1O1rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(1, 1); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNO1rN + * Signature: (JJJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN2O1rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(2, 1); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNO2rN + * Signature: (JJJJLjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN2O2rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len) +{ + INVOKE(2, 2); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNO1rN + * Signature: (JJJJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN3O1rN(JNIEnv* env, jobject self, + jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(3, 1); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNO2rN + * Signature: (JJJJJLjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN3O2rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len) +{ + INVOKE(3, 2); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNO3rN + * Signature: (JJLjava/lang/Object;IIILjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN3O3rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len, + jobject o3, jint o3flags, jint o3off, jint o3len) +{ + INVOKE(3, 3); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNO1rN + * Signature: (JJJJJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN4O1rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(4, 1); } + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNO2rN + * Signature: (JJJJJJLjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN4O2rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len) +{ + INVOKE(4, 2); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNO3rN + * Signature: (JJJJJJLjava/lang/Object;IIILjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN4O3rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len, + jobject o3, jint o3flags, jint o3off, jint o3len) +{ + INVOKE(4, 3); +} + + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNO1rN + * Signature: (JJJJJJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN5O1rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(5, 1); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNO2rN + * Signature: (JJJJJJJLjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN5O2rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len) +{ + INVOKE(5, 2); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNO3rN + * Signature: (JJJJJJJLjava/lang/Object;IIILjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN5O3rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len, + jobject o3, jint o3flags, jint o3off, jint o3len) +{ + INVOKE(5, 3); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNNO1rN + * Signature: (JJJJJJJJLjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN6O1rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6, + jobject o1, jint o1flags, jint o1off, jint o1len) +{ + INVOKE(6, 1); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNNO2rN + * Signature: (JJJJJJJJLjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN6O2rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len) +{ + INVOKE(6, 2); +} + +/* + * Class: com_kenai_jffi_Foreign + * Method: invokeNNNNNNO3rN + * Signature: (JJJJJJJJLjava/lang/Object;IIILjava/lang/Object;IIILjava/lang/Object;III)J + */ +JNIEXPORT jlong JNICALL +Java_com_kenai_jffi_Foreign_invokeN6O3rN(JNIEnv* env, jobject self, jlong ctxAddress, jlong function, + jlong n1, jlong n2, jlong n3, jlong n4, jlong n5, jlong n6, + jobject o1, jint o1flags, jint o1off, jint o1len, + jobject o2, jint o2flags, jint o2off, jint o2len, + jobject o3, jint o3flags, jint o3off, jint o3len) +{ + INVOKE(6, 3); +} + diff --git a/src/com/kenai/jffi/Foreign.java b/src/com/kenai/jffi/Foreign.java index 5f8b243..7cf1c00 100644 --- a/src/com/kenai/jffi/Foreign.java +++ b/src/com/kenai/jffi/Foreign.java @@ -830,9 +830,136 @@ final class Foreign { final native long invokeNNNNNNrN(long function, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6); /** + * Invokes a function with one numeric argument, and returns a numeric value. + * + * @param callContext The FFI call context describing the function to invoke. + * @param functionAddress The native function to invoke. + * @param arg1 An array, to be passed as a pointer for the first numeric parameter. + * @param off1 The offset from the start of the array. + * @param len1 The length of the array to use. + * @param flags1 Array flags (direction, type). + */ + final native long invokeN1O1rN(long callContext, long functionAddress, + long n1, + Object o1, int o1flags, int o1off, int o1len); + + /** + * Invokes a function with two numeric arguments, and returns a numeric value. + * + * @param callContext The FFI call context describing the function to invoke. + * @param functionAddress The native function to invoke. + * @param n1 The first numeric argument. + * @param idx1 The index of the first numeric argument; + * @param o1 An Object (array or buffer), to be passed as a pointer. + * @param o1off The offset from the start of the array or buffer. + * @param o1len The length of the array to use. + * @param o1flags Object flags (direction, type, idx). + * @return A numeric value. + */ + final native long invokeN2O1rN(long callContext, long functionAddress, + long n1, long n2, + Object o1, int o1flags, int o1off, int o1len); + + /** + * Invokes a function with two numeric arguments, and returns a numeric value. + * + * @param callContext The FFI call context describing the function to invoke. + * @param functionAddress The native function to invoke. + * @param o1 An Object (array or buffer), to be passed as a pointer. + * @param o1off The offset from the start of the array or buffer. + * @param o1len The length of the array to use. + * @param o1flags Object flags (direction, type, idx). + * @param o2 An Object (array or buffer), to be passed as a pointer. + * @param o2off The offset from the start of the array or buffer. + * @param o2len The length of the array to use. + * @param o2flags Object flags (direction, type, idx). + * @return A numeric value. + */ + final native long invokeN2O2rN(long callContext, long functionAddress, + long n1, long n2, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len); + + /** + * Invokes a function with three numeric arguments, and returns a numeric value. + * + * @param callContext The FFI call context describing the function to invoke. + * @param functionAddress The native function to invoke. + * @param n1 a long. + * @param idx1 The parameter index of n1. + * @param n2 a long. + * @param idx2 The parameter index of n2. + * @param o1 An Object (array or buffer), to be passed as a pointer. + * @param o1off The offset from the start of the array or buffer. + * @param o1len The length of the array to use. + * @param o1flags Object flags (direction, type, parameter index). + * @return A numeric value. + */ + final native long invokeN3O1rN(long callContext, long functionAddress, + long n1, long n2, long n3, + Object o1, int o1flags, int o1off, int o1len); + + final native long invokeN3O2rN(long callContext, long functionAddress, + long n1, long n2, long n3, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len); + + final native long invokeN3O3rN(long callContext, long functionAddress, + long n1, long n2, long n3, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len, + Object o3, int o3flags, int o3off, int o3len); + + final native long invokeN4O1rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, + Object o1, int o1flags, int o1off, int o1len); + + final native long invokeN4O2rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len); + + final native long invokeN4O3rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len, + Object o3, int o3flags, int o3off, int o3len); + + final native long invokeN5O1rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, + Object o1, int o1off, int o1len, int o1flags); + + final native long invokeN5O2rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len); + + final native long invokeN5O3rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len, + Object o3, int o3flags, int o3off, int o3len); + + final native long invokeN6O1rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, long n6, + Object o1, int o1flags, int o1off, int o1len); + + final native long invokeN6O2rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, long n6, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len); + + final native long invokeN6O3rN(long callContext, long functionAddress, + long n1, long n2, long n3, long n4, long n5, long n6, + Object o1, int o1flags, int o1off, int o1len, + Object o2, int o2flags, int o2off, int o2len, + Object o3, int o3flags, int o3off, int o3len); + + + /** * Invokes a function that returns a 32 bit integer. * @param function The address of the function context structure from {@link #newFunction}. - * @param buffer A byte array containing the aguments to the function. + * @param buffer A byte array containing the arguments to the function. * @return A 32 bit integer value. */ final native int invokeArrayReturnInt(long function, byte[] buffer); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

