-
Notifications
You must be signed in to change notification settings - Fork 238
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 pd_this
on Windows
#2165
fix pd_this
on Windows
#2165
Conversation
aebaa9e
to
140a7b2
Compare
Just out of curiosity, I quickly checked on Linux: it does indeed export a symbol What do you (@umlaeute, @danomatika and @millerpuckette, in particular) think about this? (If anyone is interested in how thread-local storage actually works in Linux, I found this blog post very helpful: http://david-grs.github.io/tls_performance_overhead_cost_linux/). |
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.
looks good (after dropping the EXTERN
decorator from the C-file)
On Windows it is not possible to 'properly' export a thread local variable from a DLL. MinGW can do it, but the resulting symbol ('__emutls_v.pd_this') is not portable and certainly not understood by MSVC. The solution is to access 'pd_this' via a function call. For externals, 'pd_this' is now a macro for 'pd_getinstance()'. Internally, we directly use 'pd_this', but we don't try to export it. On other platforms, 'pd_this' is now properly marked as EXTERN.
140a7b2
to
c3497b7
Compare
Fixed! |
@millerpuckette This is needed for libpd. |
On Windows it is not possible to 'properly' export a thread local variable from a DLL. MinGW can do it, but the resulting symbol (
__emutls_v.pd_this
) is not portable and certainly not understood by MSVC. As a consequence, Windows externals built with-DPDINSTANCE
cannot really usepd_this
- unless both the external and the host is built with MinGW.The solution is to access
pd_this
via a function call, for this I've added a new API functionpd_getinstance()
. For externals,pd_this
is now a macro forpd_getinstance()
. Internally, we directly access 'pd_this', but we don't try to export it.On other platforms,
pd_this
is now properly markedEXTERN
.