RFR: 7903239: ofAddress factory of function pointer type is wrong for struct returns [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Aug 3 21:12:25 UTC 2022
On Tue, 2 Aug 2022 18:01:38 GMT, Marko <duke at openjdk.org> wrote:
>> When generating the lambda inside the `ofAddress` factory, it is missing the `SegmentAllocator` needed when the function returns a struct. This is [implemented for regular functions](https://github.com/openjdk/jextract/blob/0582eaf1b4cdba95f0ee8c2480767433bb647d0d/src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java#L122-L127), but not for function pointers.
>
> Marko has updated the pull request incrementally with one additional commit since the last revision:
>
> add proper tests
test/jtreg/generator/test7903239/Test7903239.java line 51:
> 49: var foo = test7903239_h.foo$SEGMENT();
> 50:
> 51: var barA = Foo.a(foo, session).apply();
I think the limitation of the strategy are clearer in this example :-)
The allocator is decided once and for all when the functional interface instance is obtained. Any other call to `apply` will use the same segment allocator specified on creation. To solve this, I believe the only way is to use the default method setup I described earlier. But the patch is good enough as is for now.
test/jtreg/generator/test7903239/libTest7903239.c line 2:
> 1: /*
> 2: * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
If the test is new, should it have 2022 in the copyright year? (also in c file)
-------------
PR: https://git.openjdk.org/jextract/pull/58
More information about the jextract-dev
mailing list