RFR: 7903485 Windows.h fails to extract on jextract/panama [v2]
Jorn Vernee
jvernee at openjdk.org
Mon Jun 12 12:41:17 UTC 2023
On Mon, 12 Jun 2023 09:56:40 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/main/java/org/openjdk/jextract/impl/UnsupportedLayouts.java line 44:
>>
>>> 42: public static final MemoryLayout __INT128 = makeUnsupportedLayout(16, "__int128");
>>> 43:
>>> 44: public static final MemoryLayout LONG_DOUBLE = makeUnsupportedLayout(IS_WINDOWS ? 8 : 16, "long double");
>>
>> We could use the `ValueLayout.JAVA_DOUBLE` layout in `Type.java` for the `long double` type (we are already selecting the layout based on the platform for `long` there as well). If we do that `long double` would just work on Windows.
>>
>> FWIW, I gave this a try, and it looks like we'd just have to skip `LibUnsupportedTest::testIgnoredMethods` on Windows in that case. Windows.h still extracts successfully as well:
>>
>>
>> diff --git a/src/main/java/org/openjdk/jextract/Type.java b/src/main/java/org/openjdk/jextract/Type.java
>> index 65e0fed..291ec0c 100644
>> --- a/src/main/java/org/openjdk/jextract/Type.java
>> +++ b/src/main/java/org/openjdk/jextract/Type.java
>> @@ -137,7 +137,9 @@ public interface Type {
>> /**
>> * {@code long double} type.
>> */
>> - LongDouble("long double", UnsupportedLayouts.LONG_DOUBLE),
>> + LongDouble("long double", TypeImpl.IS_WINDOWS ?
>> + ValueLayout.JAVA_DOUBLE :
>> + UnsupportedLayouts.LONG_DOUBLE),
>> /**
>> * {@code float128} type.
>> */
>> diff --git a/src/main/java/org/openjdk/jextract/impl/UnsupportedLayouts.java b/src/main/java/org/openjdk/jextract/impl/UnsupportedLayouts.java
>> index a6b1aec..0797368 100644
>> --- a/src/main/java/org/openjdk/jextract/impl/UnsupportedLayouts.java
>> +++ b/src/main/java/org/openjdk/jextract/impl/UnsupportedLayouts.java
>> @@ -37,11 +37,9 @@ import java.nio.ByteOrder;
>> public final class UnsupportedLayouts {
>> private UnsupportedLayouts() {}
>>
>> - private static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");
>> -
>> public static final MemoryLayout __INT128 = makeUnsupportedLayout(16, "__int128");
>>
>> - public static final MemoryLayout LONG_DOUBLE = makeUnsupportedLayout(IS_WINDOWS ? 8 : 16, "long double");
>> + public static final MemoryLayout LONG_DOUBLE = makeUnsupportedLayout(16, "long double");
>>
>> public static final MemoryLayout _FLOAT128 = makeUnsupportedLayout(16, "_float128");
>>
>> diff --git a/test/jtreg/generator/test8257892/LibUnsupportedTest.java b/test/jtreg/generator/test8257892/LibUnsupportedTest....
>
> I can do that if that's preferred. (it's mostly a choice on whether we want the set of supported types to be stable across platforms or not).
I'm not sure I see the value in being consistent across platforms, tbh. Given also that the jextract output is already platform specific. And, after all, if we did support 128 bit `long double` in the linker, there would still be a difference between the platforms because they use different layouts for that type.
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/122#discussion_r1226604156
More information about the jextract-dev
mailing list