#define posix_check_cmd(cmd) posix_check_err (cmd, #cmd)
+typedef struct
+{
+ GRealThread thread;
+
+ pthread_t system_thread;
+} GThreadPosix;
+
void
g_system_thread_free (GRealThread *thread)
{
- g_slice_free (GRealThread, thread);
+ GThreadPosix *pt = (GThreadPosix *) thread;
+
+ g_slice_free (GThreadPosix, pt);
}
GRealThread *
gboolean joinable,
GError **error)
{
- GRealThread *thread;
+ GThreadPosix *thread;
pthread_attr_t attr;
gint ret;
- thread = g_slice_new0 (GRealThread);
+ thread = g_slice_new0 (GThreadPosix);
posix_check_cmd (pthread_attr_init (&attr));
posix_check_cmd (pthread_attr_setdetachstate (&attr,
joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
- ret = pthread_create ((pthread_t *) &(thread->system_thread), &attr, (void* (*)(void*))thread_func, thread);
+ ret = pthread_create (&thread->system_thread, &attr, (void* (*)(void*))thread_func, thread);
posix_check_cmd (pthread_attr_destroy (&attr));
{
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
"Error creating thread: %s", g_strerror (ret));
- g_slice_free (GRealThread, thread);
+ g_slice_free (GThreadPosix, thread);
return NULL;
}
posix_check_err (ret, "pthread_create");
- return thread;
+ return (GRealThread *) thread;
}
/**
void
g_system_thread_wait (GRealThread *thread)
{
+ GThreadPosix *pt = (GThreadPosix *) thread;
gpointer ignore;
- posix_check_cmd (pthread_join (*(pthread_t*)&(thread->system_thread), &ignore));
+ posix_check_cmd (pthread_join (pt->system_thread, &ignore));
}
void