1 /* pthread.cc: posix pthread interface for Cygwin
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007 Red Hat, Inc.
5 Originally written by Marco Fuykschot <marco@ddi.nl>
7 This file is part of Cygwin.
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
20 pthread_create (pthread_t *thread, const pthread_attr_t *attr,
21 void *(*start_routine) (void *), void *arg)
23 return pthread::create (thread, attr, start_routine, arg);
27 pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
29 return pthread::once (once_control, init_routine);
33 pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void))
35 return pthread::atfork (prepare, parent, child);
40 pthread_exit (void *value_ptr)
42 return pthread::self ()->exit (value_ptr);
46 pthread_join (pthread_t thread, void **return_val)
48 return pthread::join (&thread, (void **) return_val);
52 pthread_detach (pthread_t thread)
54 return pthread::detach (&thread);
58 /* This isn't a posix call... should we keep it? */
60 pthread_suspend (pthread_t thread)
62 return pthread::suspend (&thread);
67 pthread_continue (pthread_t thread)
69 return pthread::resume (&thread);
73 pthread_getsequence_np (pthread_t * thread)
75 if (!pthread::is_good_object (thread))
77 return (*thread)->getsequence_np ();
82 pthread_t pthread_self ()
84 return pthread::self ();
89 pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
91 return pthread_mutex::init (mutex, attr, NULL);
96 pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
98 return pthread_cond::init (cond, attr);
103 pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
105 return pthread_rwlock::init (rwlock, attr);
111 pthread_cancel (pthread_t thread)
113 return pthread::cancel (thread);
117 pthread_setcancelstate (int state, int *oldstate)
119 return pthread::self ()->setcancelstate (state, oldstate);
123 pthread_setcanceltype (int type, int *oldtype)
125 return pthread::self ()->setcanceltype (type, oldtype);
129 pthread_testcancel ()
131 pthread::self ()->testcancel ();
135 _pthread_cleanup_push (__pthread_cleanup_handler *handler)
137 pthread::self ()->push_cleanup_handler (handler);
141 _pthread_cleanup_pop (int execute)
143 pthread::self ()->pop_cleanup_handler (execute);
148 sem_init (sem_t * sem, int pshared, unsigned int value)
150 return semaphore::init (sem, pshared, value);
154 sem_destroy (sem_t * sem)
156 return semaphore::destroy (sem);
160 sem_wait (sem_t * sem)
162 return semaphore::wait (sem);
166 sem_trywait (sem_t * sem)
168 return semaphore::trywait (sem);
172 sem_timedwait (sem_t * sem, const struct timespec *abstime)
174 return semaphore::timedwait (sem, abstime);
178 sem_post (sem_t * sem)
180 return semaphore::post (sem);
184 sem_getvalue (sem_t * sem, int *sval)
186 return semaphore::getvalue (sem, sval);