-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate data only array members if they are of fixed size #1388
Conversation
integration_tests/CMakeLists.txt
Outdated
@@ -351,7 +351,8 @@ RUN(NAME structs_11 LABELS cpython llvm c) | |||
RUN(NAME structs_12 LABELS cpython llvm c) | |||
RUN(NAME structs_13 LABELS llvm c | |||
EXTRAFILES structs_13b.c) | |||
RUN(NAME structs_14 LABELS cpython llvm c) | |||
RUN(NAME structs_14 LABELS llvm c | |||
EXTRAFILES structs_14b.c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to do a separate test, since we lost CPython test here. We want to ideally test everything via CPython, but at least what we were testing before.
integration_tests/structs_14b.c
Outdated
sum_buffer += data[i]; | ||
} | ||
return sum_buffer; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not enough. I think we need to pass the whole structure into C, then in C recreate the same structure using char[64]
style, and then access the members and check that everything works. That would be robust.
The current test could still pass even with our pointer setup (yes, the memory would not be initialized properly, but one could get "lucky").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which one do you want to pass to C, buffer_struct
(not decorated with @ccall
/@ccallable
) or buffer_struct_clink
(decorated with @ccall
/@ccallable
)? I guess buffer_struct_clink
should be passed to C for testing as its the one with BindC
ABI, correct? If you want to pass both, then LLVM backend will also need to be updated to always (irrespective of the ABI) represent fixed sized array members as data only pointers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added test as per my understanding of the requirement. Please let me know if they look good or if you want any change in it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good, although it's not immediately obvious to me from the test that it does the right thing. Let's add the C Struct test as I indicated in the comment, then I think it will be 100% clear that it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good to merge! Thanks for fixing this.
…d sized array members of BindC structs
407c7f7
to
08f4940
Compare
cc: @certik
Closes #1387