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 clrjit exports on non-Windows platforms. #38254

Merged
merged 3 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SOURCES UnmanagedCallersOnlyDll.cpp )

# add the executable
add_library (UnmanagedCallersOnlyDll SHARED ${SOURCES})
target_link_libraries(UnmanagedCallersOnlyDll ${LINK_LIBRARIES_ADDITIONAL})
target_link_libraries(UnmanagedCallersOnlyDll ${LINK_LIBRARIES_ADDITIONAL})

# add the install targets
install (TARGETS UnmanagedCallersOnlyDll DESTINATION bin)
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,33 @@ namespace
int Result;
};

void ProxyCall(ProxyCallContext* cxt)
void* ProxyCall(void* cxtRaw)
{
auto cxt = (ProxyCallContext*)cxtRaw;
cxt->Result = CallManagedProc(cxt->CallbackProc, cxt->N);
return NULL;
}
}

extern "C" DLL_EXPORT int STDMETHODCALLTYPE CallManagedProcOnNewThread(CALLBACKPROC pCallbackProc, int n)
{
ProxyCallContext cxt{ pCallbackProc, n, 0 };

#ifdef _WIN32
std::thread newThreadToRuntime{ ProxyCall, &cxt };

// Wait for new thread to complete
newThreadToRuntime.join();

#else // _WIN32
pthread_t newThreadToRuntime;
int ret = pthread_create(&newThreadToRuntime, NULL, ProxyCall, &cxt);
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved

// Wait for new thread to complete
pthread_join(newThreadToRuntime, NULL);

#endif // _WIN32

return cxt.Result;
}

Expand Down