RFR: 7903923: Derive C_* layouts directly from the Linker

Nizar Benalla nbenalla at openjdk.org
Mon Jan 6 11:56:48 UTC 2025


On Mon, 6 Jan 2025 11:37:54 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Depending on the platform, different `C_*`  correspond to different `JAVA_*` types. We can get those values directly from the linker.
>> 
>> This patch can allows us to have a common class for different platforms.
>> 
>> Please review, and thanks in advance!
>
> src/main/java/org/openjdk/jextract/impl/ToplevelBuilder.java line 80:
> 
>> 78:             """);
>> 79:         if (TypeImpl.IS_WINDOWS) {
>> 80:             first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get(\"int\");");
> 
> The canonical layout for this has name `long`. But the result is a `ValueLayout.OfInt` (because FFM uses `int` to model values of that type on Windows). In other words, the only thing that changes in Windows is the cast that should be to `OfInt`, not to `OfLong`.

Thanks for explaining, will fix it.

-------------

PR Review Comment: https://git.openjdk.org/jextract/pull/269#discussion_r1904063614


More information about the jextract-dev mailing list