From 26459f7e8f30a34b66b08098fc25350a6427447f Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Mon, 8 May 2017 18:10:13 +0300 Subject: [PATCH] fix(dyncall): invalid handling of 64-bit integers on 32-bit architectures --- doc/notes/3.1.2.md | 1 + modules/core/src/main/c/system/org_lwjgl_system_Callback.c | 4 ++-- .../src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/notes/3.1.2.md b/doc/notes/3.1.2.md index 0c040e463a..f3e6ca2fa6 100644 --- a/doc/notes/3.1.2.md +++ b/doc/notes/3.1.2.md @@ -42,6 +42,7 @@ This build includes the following changes: - OpenAL: Removed buffer auto-sizing from `alcCaptureSamples`. The number of samples must now be specified explicitly, similar to `alcRenderSamplesSOFT`. - Vulkan: Function addresses are now retrieved only once, using the optimal method for each function type. * This avoids warnings on pedantic validation layers. +- Fixed callback invocation bugs on 32-bit architectures. ### Breaking Changes diff --git a/modules/core/src/main/c/system/org_lwjgl_system_Callback.c b/modules/core/src/main/c/system/org_lwjgl_system_Callback.c index dbdb3523e5..69e21c61dd 100644 --- a/modules/core/src/main/c/system/org_lwjgl_system_Callback.c +++ b/modules/core/src/main/c/system/org_lwjgl_system_Callback.c @@ -49,7 +49,7 @@ static char cbHandlerV(DCCallback *cb, DCArgs *args, DCValue *result, void *user (*env)->CallVoidMethod(env, (jobject)userdata, javaCallbackV, - args + (jlong)(intptr_t)args ); // Check for exception @@ -69,7 +69,7 @@ static char cbHandlerV(DCCallback *cb, DCArgs *args, DCValue *result, void *user *(Type*)result = (Type)(*env)->Call##JavaType##Method(env, \ (jobject)userdata, \ javaCallback##Name, \ - args \ + (jlong)(intptr_t)args \ ); \ \ if ( (*env)->ExceptionCheck(env) && async ) \ diff --git a/modules/generator/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt b/modules/generator/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt index 3b4d2bb932..376cc29b4c 100644 --- a/modules/generator/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt +++ b/modules/generator/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt @@ -46,8 +46,10 @@ class CallbackFunction( private val NativeType.argType get() = if (this is PointerType || mapping === PrimitiveMapping.POINTER) "Pointer" - else if (mapping == PrimitiveMapping.BOOLEAN) + else if (mapping === PrimitiveMapping.BOOLEAN) "Bool" + else if (mapping === PrimitiveMapping.LONG) + "LongLong" else (mapping as PrimitiveMapping).javaMethodName.upperCaseFirst