-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Make struct passing work properly #3466
Conversation
Now with 100% more ABI compliant cfunctions.
|
Amazing! |
As always - awesome work @loladiro. |
two down, one to go. |
That's a ton of great work! |
With regards to tests, do you mean "more examples of structs to pass to C libraries"? If it would help I can cull things from HDF5 (although do you want dependencies like that?). |
There are also some simple structs in ODBC that might be good for testing. I've been tracking this issue to implement these structs in my package anyway. typedef struct tagDATE_STRUCT {
SQLSMALLINT year;
SQLUSMALLINT month;
SQLUSMALLINT day;
} DATE_STRUCT;
typedef struct tagTIME_STRUCT {
SQLUSMALLINT hour;
SQLUSMALLINT minute;
SQLUSMALLINT second;
} TIME_STRUCT;
typedef struct tagTIMESTAMP_STRUCT {
SQLSMALLINT year;
SQLUSMALLINT month;
SQLUSMALLINT day;
SQLUSMALLINT hour;
SQLUSMALLINT minute;
SQLUSMALLINT second;
SQLUINTEGER fraction;
} TIMESTAMP_STRUCT; |
More than the actual structs, I need examples of function signatures, where structs are being passed by value. |
Hmmm...yeah, ODBC wouldn't help much here. |
SDL.jl? |
I tried implementing win64, but LLVM seems to be somewhat broken in this case. |
Done! :) |
👍 Good stuff |
Hmm interestingly this seems broken on Linux 64bit, but not on Mac 64bit (the parallel tests don't work). @JeffBezanson or @vtjnash are you aware of any ABI differences between Mac and Linux on 64bit? |
Also adjust the tests for the fact that Complex is immutable
I was discussing that with Jeff offline. Using the C convention internally gets everything (cfunction with structs, and redistributable sys.so image) faster, then we can think about optimizing it more later. |
Fine with me. |
This completely fell through the cracks and should have been merged during the 0.3 cycle. See StackOverflow question about this: http://stackoverflow.com/questions/24870010/call-div-c-function-from-julia. I've encountered this occasionally myself – it would be really nice to be able to return structs. |
0.3.1 milestone? |
Maybe. It's technically a breaking change though. |
Ah in that case, 0.4. I was thinking of it as a purely-feature-adding thing. |
I could also really use this. I've been working on wrapping libav/ffmpeg, which has a kajillion structs. My options seem to have been to pass pointers to For now, I've gone with using immutables, as it has been the path of least resistance. But it feels rather sketchy to change immutable values (or even declare that a 100-member struct is immutable), so I'm looking forward to (I think I'll be able to publish a working version pretty soon.) |
This is unrelated to immutables or to using pointers to types as structs Once Keno finishes cleaning this up, or turns it over for someone else to finish, it could be merged. |
Okay, I misinterpreted. This is for passing structs directly, then? |
Correct, this is for correcting the calling-convention of passing structs by value. |
Passing pointers to types works the same (and was implemented before) immutable types. |
Okay, thanks. I'm probably doing something wrong, then. Sorry for the noise, will post on julia-dev or a separate issue if I have further problems. |
6c7c7e3
to
1a4c02f
Compare
What is the latest on this? |
Updated pr in #7906 |
This is a WIP on the long standing issue of passing Julia structs to C. I have implemented the x86_64 ABI and am working on the others. This is passing the tests included in Jameson's original pull request, though as the ABI is rather complicated, I would appreciate more tests to include.