1 /* pthread.cc: posix pthread interface for Cygwin
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2011 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_spin_init (pthread_spinlock_t *spinlock, int pshared)
98 return pthread_spinlock::init (spinlock, pshared);
102 /* Synchronisation */
104 pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
106 return pthread_cond::init (cond, attr);
111 pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
113 return pthread_rwlock::init (rwlock, attr);
119 pthread_cancel (pthread_t thread)
121 return pthread::cancel (thread);
125 pthread_setcancelstate (int state, int *oldstate)
127 return pthread::self ()->setcancelstate (state, oldstate);
131 pthread_setcanceltype (int type, int *oldtype)
133 return pthread::self ()->setcanceltype (type, oldtype);
137 pthread_testcancel ()
139 pthread::self ()->testcancel ();
143 _pthread_cleanup_push (__pthread_cleanup_handler *handler)
145 pthread::self ()->push_cleanup_handler (handler);
149 _pthread_cleanup_pop (int execute)
151 pthread::self ()->pop_cleanup_handler (execute);
156 sem_init (sem_t * sem, int pshared, unsigned int value)
158 return semaphore::init (sem, pshared, value);
162 sem_destroy (sem_t * sem)
164 return semaphore::destroy (sem);
168 sem_wait (sem_t * sem)
170 return semaphore::wait (sem);
174 sem_trywait (sem_t * sem)
176 return semaphore::trywait (sem);
180 sem_timedwait (sem_t * sem, const struct timespec *abstime)
182 return semaphore::timedwait (sem, abstime);
186 sem_post (sem_t * sem)
188 return semaphore::post (sem);
192 sem_getvalue (sem_t * sem, int *sval)
194 return semaphore::getvalue (sem, sval);