Skip to content
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

Fix exported names from gc.c to have jl_gc_ prefix #11741

Merged
merged 4 commits into from
Jun 20, 2015

Conversation

ScottPJones
Copy link
Contributor

Changed exported names in gc.c to have the jl_gc_ prefix to prevent name collisions when julia is linked with other code.

gc_wb* -> jl_gc_wb*
gc_queue_root -> jl_gc_queue_root
allocobj -> jl_gc_allocobj
alloc_[0-4]w -> jl_gc_alloc_*w
diff_gc_total_bytes -> jl_gc_diff_total_bytes
sync_gc_total_bytes -> jl_gc_sync_total_bytes

@yuyichao
Copy link
Contributor

yuyichao% git grep gc_wb doc | wc -l
4

@tkelman tkelman added breaking This change will break code embedding Embedding Julia using the C API labels Jun 18, 2015
@ScottPJones
Copy link
Contributor Author

@yuyichao You were the one that pointed to the gc_wb functions 😀 Please tell me what else you've seen that I need to change!

@yuyichao
Copy link
Contributor

You were the one that pointed to the gc_wb functions

And I said that it is in the embedding doc #11363 (comment).

Just do a git grep on the function you changes and make sure to change it everywhere, not limited to c code. (especially the doc)

@@ -785,21 +785,21 @@ static inline int maybe_collect(void)

// preserved values

DLLEXPORT int jl_gc_n_preserved_values(void)
int jl_gc_n_preserved_values(void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were the ones I asked about originally, that were exported, but not used anywhere in Base or registered packages. I wasn't aware of the embedded document when I started... these functions aren't described there, do they need to be exported?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I think they are potentially useful and shouldn't cause any issues to be exported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll put the DLLEXPORTs back on thos... I just don't like having unused stuff cluttering up an API...

@ScottPJones
Copy link
Contributor Author

And as you are there, there's also gc_wb and friends

Ah, sorry, I missed the later comment you made - I was just going by the above comment!
I wasn't using git grep, I was using my editor's file search/replace function... missed the .rst file extension... I've gone back and looked at absolutely every file in the repository... I did catch all occurrences now. I even found something that hadn't been updated in the documentation...
jl_gc_enable()/jl_gc_disable() are now jl_gc_enable(1)/jl_gc_enable(0).


#endif

DLLEXPORT void *jl_gc_managed_malloc(size_t sz);
DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isaligned, jl_value_t* owner);
void *jl_gc_managed_malloc(size_t sz);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still has DLLEXPORT at the implementation in gc.c, at least with MSVC the linkage needs to be consistent. I'd err on the side of leaving this exported, since someone saw the need to put DLLEXPORT on it in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed, just waiting for Base.runtests() to complete again!

@ScottPJones
Copy link
Contributor Author

The change to jl_gc_enable was one of @JeffBezanson's, 8ff36e1
I guess he forgot to update the documentation

@JeffBezanson
Copy link
Member

This is great, thanks for taking care of it.

@ScottPJones
Copy link
Contributor Author

I may have to pull out the update for jl_gc_enable to another PR though, since this one is a breaking change for embedders, apparently, 😞 so who knows when it might ever get merged!

@@ -196,8 +196,8 @@ There are some functions to control the GC. In normal use cases, these should no

========================= ==============================================================================
``void jl_gc_collect()`` Force a GC run
``void jl_gc_disable()`` Disable the GC
``void jl_gc_enable()`` Enable the GC
``void jl_gc_enable(0)`` Disable the GC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right! Will fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needs fixing?

@JeffBezanson
Copy link
Member

I'm not too worried about that. I would merge this.

@waTeim
Copy link
Contributor

waTeim commented Jun 18, 2015

I am in the clear on this one anyway (whew!). Are there others?

@ScottPJones
Copy link
Contributor Author

@waTeim The initial message gives the full list that I changed.
The idea was actually to make life easier for people embedding, or linking in large C libraries!

@ScottPJones
Copy link
Contributor Author

OK, I've fixed my stupid mistake correcting the documentation of jl_gc_enable!

@ScottPJones
Copy link
Contributor Author

I found these also, that weren't from gc.c (which is what this PR was about cleaning up):
What should be done with them? Thanks!
show_execution_point
_resetstkoflw
___chkstk_ms
__chkstk
_chkstk
_alloca

@pao
Copy link
Member

pao commented Jun 18, 2015

I think some (all?) of those are entry points for LLVM so we can't rename them, see #9339 (comment). But @vtjnash would know for sure.

@ScottPJones
Copy link
Contributor Author

@pao Yes, I noticed them afterwards in a bunch of ../dep/llvm* files...
This is another place where a little internal documentation would go a long way!
It does look like show_execution_point should be prefixed with jl_ as well...

@ScottPJones
Copy link
Contributor Author

Or is show_execution_point some special name also? For a debugger? (again, internal documentation saves time)

@vtjnash
Copy link
Member

vtjnash commented Jun 18, 2015

git blame says it was added by @timholy in #7464, but doesn't appear to get used?

the _ prefix on those other variables indicates that they come from the compiler

@ScottPJones
Copy link
Contributor Author

@vtjnash About the _ indicating they came from the compiler... that's just a convention... which I was aware of, however, which compiler? Julia is a compiler... A little internal documentation can go a long way... (just saying that those names are required by LLVM).

@ScottPJones
Copy link
Contributor Author

All I can find (in all of the JuliaLang/julia repository) is the definition, and the setup of the name for LLVM.

/j/julia/src/julia.h: void show_execution_point(char *filename, int lno);
/j/julia/src/codegen.cpp: static Function *show_execution_point_func;
/j/julia/src/codegen.cpp:     show_execution_point_func =
/j/julia/src/codegen.cpp:                          "show_execution_point", m);
/j/julia/src/codegen.cpp:     add_named_global(show_execution_point_func, (void*)*show_execution_point);
/j/julia/src/debuginfo.cpp: void show_execution_point(char *filename, int lno)

@vtjnash
Copy link
Member

vtjnash commented Jun 18, 2015

however, which compiler? Julia is a compiler...

julia's compiler uses jl_ as it's prefix, as you noted at the top

@ScottPJones
Copy link
Contributor Author

Unfortunately, as I've shown in this PR, not consistently, which is why I was asking about those in the first place!

@ScottPJones
Copy link
Contributor Author

There are also many many "internal" functions, that don't follow the jl_ convention, and I think those should also be fixed, but I think just dealing with the exported ones, which can break things, was enough for a little programming while watching the TV! 😀

``void jl_gc_collect()`` Force a GC run
``void jl_gc_disable()`` Disable the GC
``void jl_gc_enable()`` Enable the GC
``void jl_gc_collect()`` Force a GC run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rst might be picky about the spacing here, need to check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a full install build, and the documentation looked fine to me... did you see a problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as the table looks right in the html-rendered version then should be fine

@tkelman tkelman removed the breaking This change will break code label Jun 18, 2015
@Keno
Copy link
Member

Keno commented Jun 18, 2015

Since it's breaking, this probably deserves a NEWS entry. Other than that this looks fine to me.

@ScottPJones
Copy link
Contributor Author

OK, very good point! Will do.

@JeffBezanson
Copy link
Member

👍 LGTM.

@ScottPJones
Copy link
Contributor Author

I've updated NEWS.md, but I noticed something else while updating it,
@JeffBezanson: there's no mention of the recent Union()-> Union{} change.
Shouldn't that also be in NEWS.md? Thanks!

@ScottPJones
Copy link
Contributor Author

@tkelman OK, changed to a sublist!

@tkelman
Copy link
Contributor

tkelman commented Jun 19, 2015

Thanks, that looks better, but there's still an unaddressed comment, and needs a rebase probably due to your other news update

@ScottPJones
Copy link
Contributor Author

What unaddressed comment? Am I missing something?

@tkelman
Copy link
Contributor

tkelman commented Jun 19, 2015

#11741 (comment) - may have gotten lost in a rebase?

@yuyichao
Copy link
Contributor

I've also had a similar comment. In additional to the void return type being wrong, (0) and (1) are not valid signature either. Probably should merge the two lines.

@ScottPJones
Copy link
Contributor Author

Yep, I lost that change, because I edited in directly on GitHub, and then when I next pushed...

@ScottPJones
Copy link
Contributor Author

@yuyichao What's wrong with the (0) and (1)? That seemed to be the best way to describe it... it takes an int, 0 to disable, 1 (or non-zero) to enable.
@tkelman I put back my documentation change, squashed out the typo fixes

@yuyichao
Copy link
Contributor

(0) and (1) themselves are fine, but not with return types, because it's invalid code.

The functions in the doc is either shown by how they are used, or by their signature e.g. this

@ScottPJones
Copy link
Contributor Author

@yuyichao, let me know if you think the way I changed the documentation seems OK to you, thanks!

@yuyichao
Copy link
Contributor

I personally prefer listing the signature but this is also good for me.

@ScottPJones
Copy link
Contributor Author

The signature didn't give what the int return value meant, so I thought this way might be more informative, that's all.

@JeffBezanson
Copy link
Member

All looks good to me.

@ScottPJones
Copy link
Contributor Author

Anybody willing to merge this? (I'd love to pare down my plethora of outstanding PRs before Wednesday! 😀)

JeffBezanson added a commit that referenced this pull request Jun 20, 2015
Fix exported names from gc.c to have jl_gc_ prefix
@JeffBezanson JeffBezanson merged commit c6ceac2 into JuliaLang:master Jun 20, 2015
@ScottPJones
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedding Embedding Julia using the C API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants