Greetings,
I have a proprietary library that has both Windows and Linux ports. The Windows DLL has problems running on Wine, so I have created a builtin version of this DLL in Wine. This has worked fine, except for one function that basically creates a new thread and fires back events to the calling Window application. I believe I have traced this down to the Linux version of the library creating the new thread with pthread_create.
Windows.exe
Call_dll_to_spawn_thread_and_register_callback(MyCallbackfunc);
Windows DLL implemented in wine:
void * NewThread(void *p)
{
MyParams *params = (MyParams *)p;
for (i = 0; i < 500000; i++)
p->Callback();
}
void Call_dll_to_spawn_thread_and_register_callback(void (*callback)())
{
MyParams *params = (MyParams *)malloc(sizeof(MyParams));
params->Callback = callback;
pthread_create(&MyThread, NULL, NewThread, (void *)params);
}
If instead of using pthread_create I use CreateThread, I never have a problem. I notice no other wine DLLs are using pthread_create and I have seen hints that this might not work. If so, how do I use the Linux library. (Call_dll_to_spawn_thread_and_register_callback is just simulating what the Linux library would do)
Do I create a separate thread using CreateThread to communicate back to the Window application, so that Call_dll_to_spawn_thread_and_register_callback effectively creates two threads, one using CreateThread (Wine DLL), one using pthread_create (Linux Library) and then do synchronization between the two?
Any help, suggestion, ideas, questions would be greatly appreciated.
Phil