7 void* (*thread_function)(void*);
10 pthread_mutex_t init_lock;
11 pthread_cond_t init_cond;
16 fake_thread_proxy (LPVOID parameter)
18 real_thread_info_t* rti = (real_thread_info_t*) parameter;
20 fprintf (stderr, "WINDOWS THREAD, @ pthread = %p\n", pthread_self());
22 pthread_mutex_lock (&rti->init_lock);
23 rti->thread_id = pthread_self();
24 pthread_cond_signal (&rti->init_cond);
25 pthread_mutex_unlock (&rti->init_lock);
28 if (pthread_attr_get_schedparam (&rti->attr)) {
29 pthread_set_schedparam (pthread_self(), policy, sched_param);
32 /* XXX no way to use pthread API to set contention scope,
33 because that has to be done before a thread is created.
34 But ... its only meaningful for an M:N thread implemenation
35 so its not important for the only platform where
36 this code matters (Linux running Wine) because Linux
37 uses a 1:1 thread design.
40 return (DWORD) rti->thread_function (rti->thread_arg);
44 wine_pthread_create (pthread_t* thread_id, const pthread_attr_t* attr, void *(*function)(void*), void* arg)
49 fprintf (stderr, "****** Lets make a windows pthread\n");
51 real_thread_info_t* rti = (real_thread_info_t*) malloc (sizeof (real_thread_info_t));
53 rti->thread_function = function;
54 rti->thread_arg = arg;
59 fprintf (stderr, "\tset up the locks\n");
61 pthread_mutex_init (&rti->init_lock, NULL);
62 pthread_cond_init (&rti->init_cond, NULL);
64 pthread_mutex_lock (&rti->init_lock);
66 fprintf (stderr, "\tget the stacksize\n");
69 if (pthread_attr_getstacksize (attr, &stack_size) != 0) {
76 fprintf (stderr, "\tget that sucker started in the proxy, stacksize = %u\n", stack_size);
78 if (CreateThread (0, stack_size, fake_thread_proxy, rti, 0, &tid) == NULL) {
82 pthread_cond_wait (&rti->init_cond, &rti->init_lock);
83 pthread_mutex_unlock (&rti->init_lock);
84 fprintf (stderr, "\tlet it run\n");
86 *thread_id = rti->thread_id;