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

@seanmiddleditch
Copy link

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
Copy link
Collaborator

daanx commented Jul 8, 2019

Thanks for spotting this. I will add this.

@daanx
Copy link
Collaborator

daanx commented Jul 8, 2019

Fixed in the latest dev branch

@daanx daanx closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants