-
-
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
More Symbol Exports and C-API Example #4997
Conversation
Added some convenience functions to julia.h
|
These are already exported in my "moreExport" branch. But maybe they are not
|
Most of this is great. But, we don't really want to expose the |
@JeffBezanson: While it is certainly possible to call C functions only using ccall, I still think that it is great that we have the alternative way to define C functions and register them as Julia callable:
Is there some performance problem when using the JL_CALLABLE mechanism? |
@JeffBezanson: I see that my argument with ccall being limited to shared libraries is not the strongest one in practice. I have changed the example to use a ccall. This makes the example from my perspective a little bit more complex (two compilation units, how to define the path to the shared library) but it is ok. If you approve this I will update the embedding docu that Tim has already merged to master. |
Yes, it has several problems. With You can compile an executable so that it exports dynamic symbols that can be looked up by |
Do you mean it is possible to directly make a ccall to an executable? |
Ok I see that it is possible and so simple and great. I will update the example. |
I have squashed the commits |
fixed jl_call and removed the WIP to indicate that this is finished |
rebased |
Bump - probably needs another rebase? Would be nice to get this targeted for 0.3 if it's feasible... (I think we are starting to see more people who have an inverted/backend migration path) |
Yes, furthermore the embedding docu that is already in master has to be removed when this does not go in. I had rebased this after the static compilation got in. |
Yes this would be great for 0.3. It makes the interop story so much better. |
@ihnorton @JeffBezanson I have rebased this. |
What, if anything, remains to be done before merging this? cc: @JeffBezanson |
I have rebased this recently. So I am happy once this gets in. Probably the example should be automatically build. Currently its not. |
@@ -815,6 +815,10 @@ DLLEXPORT jl_array_t *jl_alloc_array_3d(jl_value_t *atype, size_t nr, size_t nc, | |||
DLLEXPORT void jl_array_sizehint(jl_array_t *a, size_t sz); | |||
DLLEXPORT void *jl_value_ptr(jl_value_t *a); | |||
DLLEXPORT void jl_cell_1d_push(jl_array_t *a, jl_value_t *item); | |||
STATIC_INLINE jl_value_t *jl_apply_array_type(jl_datatype_t *type, size_t dim) | |||
{ | |||
return jl_apply_type((jl_value_t*)jl_array_type, jl_tuple2(type, jl_box_long(dim))); |
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.
Here the result of jl_box_long
is not GC rooted while the new tuple is allocated.
Can this be tagged 0.3 please? The docu is already in since some time and this needs either be in for 0.3 or the docu has to removed. I am a little sorry that this has already confused some people and kind of feel responsible for this. |
Yes, we should really get this into 0.3. We've now advertised a bunch of nice C APIs that we haven't yet integrated. |
This is work in progress:
On linux, this requires #4955 to be merged.
I am pretty excited how easy the C API is to use.