Improve Windows support #368

Merged
jwharm merged 5 commits from upcall-w64 into main 2026-05-25 14:18:11 +02:00
Owner

This PR fixes issues that were discovered during a test on Windows.

All of the fixes involve long (and unsigned long) values, which are sized as 32-bit on (x86-64) Windows and 64-bit on (x86-64) Linux and macOS.
(See this wikipedia overview, specifically the difference between LLP64 and LP64, for details.) Java-GI uses 64-bit values (ValueLayout.JAVA_LONG) on Linux and macOS, and 32-bit values (ValueLayout.JAVA_INT) on Windows, whenever a long or unsigned long is encountered.

Most of this was already implemented previously, but it contained several bugs, that have now been fixed. Furthermore, callback functions with long/unsigned long parameters or return values now also work correctly (via a upcall_w64() function that is generated in addition to the already existing upcall()). This also works for method overrides.

On the Java side, all long and unsigned long parameter- and return-types are represented as int, which is the largest common denominator for all three supported platforms.

This PR shouldn't introduce any breaking changes in the API.

This PR fixes issues that were discovered during a test on Windows. All of the fixes involve `long` (and `unsigned long`) values, which are sized as 32-bit on (x86-64) Windows and 64-bit on (x86-64) Linux and macOS. (See [this wikipedia overview](https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models), specifically the difference between LLP64 and LP64, for details.) Java-GI uses 64-bit values (`ValueLayout.JAVA_LONG`) on Linux and macOS, and 32-bit values (`ValueLayout.JAVA_INT`) on Windows, whenever a `long` or `unsigned long` is encountered. Most of this was already implemented previously, but it contained several bugs, that have now been fixed. Furthermore, callback functions with `long`/`unsigned long` parameters or return values now also work correctly (via a `upcall_w64()` function that is generated in addition to the already existing `upcall()`). This also works for method overrides. On the Java side, all `long` and `unsigned long` parameter- and return-types are represented as `int`, which is the largest common denominator for all three supported platforms. This PR shouldn't introduce any breaking changes in the API.
jwharm merged commit 7e3c41c62a into main 2026-05-25 14:18:11 +02:00
jwharm deleted branch upcall-w64 2026-05-25 14:18:12 +02:00
Sign in to join this conversation.
No description provided.