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

`mi_heap_visit_blocks` callback is missing explicit calling convention #84

Closed
seanmiddleditch opened this issue Jul 7, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@seanmiddleditch
Copy link

commented Jul 7, 2019

The callback mi_block_visit_fun is missing a calling convention specification (e.g. __cdecl or the like), which can cause linkage problems when mixing a mimalloc library compiled with one ABI but linked into a target that uses a different default ABI (e.g. using the /Gv switch that can be common in performance-oriented codebases).

Its standard practice in Windows code to always tag a calling convention on callback function declarations to avoid this issue. Windows headers use the CALLBACK macro for this purpose though specifying a new macro for mimalloc's purpose would suffice too so the code remains portable.

The idea is that this function can be declared in mimalloc.h using this specifier and then any user code that is defining a callback for mi_heap_visit_blocks would use the same specifier macro for the callback declaration, guaranteeing compatibility even if the default calling conventions differ.

@daanx

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2019

Thanks for spotting this. I will add this.

@daanx

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2019

Fixed in the latest dev branch

@daanx daanx closed this Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.