7 void* (*thread_function)(void*);
10 pthread_mutex_t init_lock;
11 pthread_cond_t init_cond;
16 fake_thread_proxy (LPVOID parameter)
19 real_thread_info_t* rti = (real_thread_info_t*) parameter;
21 pthread_mutex_lock (&rti->init_lock);
22 rti->thread_id = pthread_self();
23 pthread_cond_signal (&rti->init_cond);
24 pthread_mutex_unlock (&rti->init_lock);
27 if (pthread_attr_get_schedparam (&rti->attr)) {
28 pthread_set_schedparam (pthread_self(), policy, sched_param);
31 /* XXX no way to use pthread API to set contention scope,
32 because that has to be done before a thread is created.
33 But ... its only meaningful for an M:N thread implemenation
34 so its not important for the only platform where
35 this code matters (Linux running Wine) because Linux
36 uses a 1:1 thread design.
39 retval = (DWORD) rti->thread_function (rti->thread_arg);
46 wine_pthread_create (pthread_t* thread_id, const pthread_attr_t* attr, void *(*function)(void*), void* arg)
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 pthread_mutex_init (&rti->init_lock, NULL);
60 pthread_cond_init (&rti->init_cond, NULL);
62 pthread_mutex_lock (&rti->init_lock);
65 if (pthread_attr_getstacksize (attr, &stack_size) != 0) {
72 if (CreateThread (0, stack_size, fake_thread_proxy, rti, 0, &tid) == NULL) {
76 pthread_cond_wait (&rti->init_cond, &rti->init_lock);
77 pthread_mutex_unlock (&rti->init_lock);
79 *thread_id = rti->thread_id;