mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
2002-09-21 Robert Collins <rbtcollins@hotmail.com>
* pthread.cc: Use class::call for converted pthread and semaphore calls. * thread.cc: Convert various __pthread_call and __sem_call to pthread::call and sem::call throughout. * pthread.h (__pthread_cancel): Convert to pthread::cancel. (__pthread_join): Convert to pthread::join. (__pthread_detach): Convert to pthread::detach. (__pthread_create): Convert to pthread::create. (__pthread_once): Convert to pthread::once. (__pthread_atfork): Convert to pthread::atfork. (__pthread_suspend): Convert to pthread::suspend. (__pthread_continue): Convert to pthread::resume. (__sem_init): Convert to semaphore::init. (__sem_destroy): Convert to semaphore::destroy. (__sem_wait): Convert to semaphore::wait. (__sem_trywait): Convert to semaphore::trywait. (__sem_post): Convert to semaphore::post.
This commit is contained in:
parent
af428c1ef4
commit
01f58e415c
@ -1,3 +1,23 @@
|
||||
2002-09-21 Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
* pthread.cc: Use class::call for converted pthread and semaphore
|
||||
calls.
|
||||
* thread.cc: Convert various __pthread_call and __sem_call to
|
||||
pthread::call and sem::call throughout.
|
||||
* pthread.h (__pthread_cancel): Convert to pthread::cancel.
|
||||
(__pthread_join): Convert to pthread::join.
|
||||
(__pthread_detach): Convert to pthread::detach.
|
||||
(__pthread_create): Convert to pthread::create.
|
||||
(__pthread_once): Convert to pthread::once.
|
||||
(__pthread_atfork): Convert to pthread::atfork.
|
||||
(__pthread_suspend): Convert to pthread::suspend.
|
||||
(__pthread_continue): Convert to pthread::resume.
|
||||
(__sem_init): Convert to semaphore::init.
|
||||
(__sem_destroy): Convert to semaphore::destroy.
|
||||
(__sem_wait): Convert to semaphore::wait.
|
||||
(__sem_trywait): Convert to semaphore::trywait.
|
||||
(__sem_post): Convert to semaphore::post.
|
||||
|
||||
2002-09-21 Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
* thread.cc: Finish the removal of the separate pthread_key
|
||||
|
@ -21,19 +21,19 @@ int
|
||||
pthread_create (pthread_t * thread, const pthread_attr_t * attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
{
|
||||
return __pthread_create (thread, attr, start_routine, arg);
|
||||
return pthread::create (thread, attr, start_routine, arg);
|
||||
}
|
||||
|
||||
int
|
||||
pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
|
||||
{
|
||||
return __pthread_once (once_control, init_routine);
|
||||
return pthread::once (once_control, init_routine);
|
||||
}
|
||||
|
||||
int
|
||||
pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
|
||||
{
|
||||
return __pthread_atfork(prepare, parent, child);
|
||||
return pthread::atfork(prepare, parent, child);
|
||||
}
|
||||
|
||||
int
|
||||
@ -147,13 +147,13 @@ pthread_exit (void *value_ptr)
|
||||
int
|
||||
pthread_join (pthread_t thread, void **return_val)
|
||||
{
|
||||
return __pthread_join (&thread, (void **) return_val);
|
||||
return pthread::join (&thread, (void **) return_val);
|
||||
}
|
||||
|
||||
int
|
||||
pthread_detach (pthread_t thread)
|
||||
{
|
||||
return __pthread_detach (&thread);
|
||||
return pthread::detach (&thread);
|
||||
}
|
||||
|
||||
|
||||
@ -161,14 +161,14 @@ pthread_detach (pthread_t thread)
|
||||
int
|
||||
pthread_suspend (pthread_t thread)
|
||||
{
|
||||
return __pthread_suspend (&thread);
|
||||
return pthread::suspend (&thread);
|
||||
}
|
||||
|
||||
/* same */
|
||||
int
|
||||
pthread_continue (pthread_t thread)
|
||||
{
|
||||
return __pthread_continue (&thread);
|
||||
return pthread::resume (&thread);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
@ -425,7 +425,7 @@ pthread_setschedparam (pthread_t thread, int policy,
|
||||
int
|
||||
pthread_cancel (pthread_t thread)
|
||||
{
|
||||
return __pthread_cancel (thread);
|
||||
return pthread::cancel (thread);
|
||||
}
|
||||
|
||||
int
|
||||
@ -462,31 +462,31 @@ _pthread_cleanup_pop (int execute)
|
||||
int
|
||||
sem_init (sem_t * sem, int pshared, unsigned int value)
|
||||
{
|
||||
return __sem_init (sem, pshared, value);
|
||||
return semaphore::init (sem, pshared, value);
|
||||
}
|
||||
|
||||
int
|
||||
sem_destroy (sem_t * sem)
|
||||
{
|
||||
return __sem_destroy (sem);
|
||||
return semaphore::destroy (sem);
|
||||
}
|
||||
|
||||
int
|
||||
sem_wait (sem_t * sem)
|
||||
{
|
||||
return __sem_wait (sem);
|
||||
return semaphore::wait (sem);
|
||||
}
|
||||
|
||||
int
|
||||
sem_trywait (sem_t * sem)
|
||||
{
|
||||
return __sem_trywait (sem);
|
||||
return semaphore::trywait (sem);
|
||||
}
|
||||
|
||||
int
|
||||
sem_post (sem_t * sem)
|
||||
{
|
||||
return __sem_post (sem);
|
||||
return semaphore::post (sem);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1398,7 +1398,7 @@ pthread::getsequence_np ()
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_create (pthread_t *thread, const pthread_attr_t *attr,
|
||||
pthread::create (pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
{
|
||||
DECLARE_TLS_STORAGE;
|
||||
@ -1407,7 +1407,7 @@ __pthread_create (pthread_t *thread, const pthread_attr_t *attr,
|
||||
|
||||
*thread = new pthread ();
|
||||
(*thread)->create (start_routine, attr ? *attr : NULL, arg);
|
||||
if (!pthread::isGoodObject (thread))
|
||||
if (!isGoodObject (thread))
|
||||
{
|
||||
delete (*thread);
|
||||
*thread = NULL;
|
||||
@ -1418,7 +1418,7 @@ __pthread_create (pthread_t *thread, const pthread_attr_t *attr,
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
||||
pthread::once (pthread_once_t *once_control, void (*init_routine) (void))
|
||||
{
|
||||
// already done ?
|
||||
if (once_control->state)
|
||||
@ -1442,9 +1442,9 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_cancel (pthread_t thread)
|
||||
pthread::cancel (pthread_t thread)
|
||||
{
|
||||
if (!pthread::isGoodObject (&thread))
|
||||
if (!isGoodObject (&thread))
|
||||
return ESRCH;
|
||||
|
||||
return thread->cancel ();
|
||||
@ -1510,7 +1510,7 @@ pthread::atforkchild (void)
|
||||
*parent and child calls are called in FI-FC order.
|
||||
*/
|
||||
int
|
||||
__pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void))
|
||||
pthread::atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void))
|
||||
{
|
||||
callback *prepcb = NULL, *parentcb = NULL, *childcb = NULL;
|
||||
if (prepare)
|
||||
@ -1726,16 +1726,16 @@ __pthread_attr_destroy (pthread_attr_t *attr)
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_join (pthread_t *thread, void **return_val)
|
||||
pthread::join (pthread_t *thread, void **return_val)
|
||||
{
|
||||
pthread_t joiner = pthread::self ();
|
||||
pthread_t joiner = self ();
|
||||
|
||||
// Initialize return val with NULL
|
||||
if (return_val)
|
||||
*return_val = NULL;
|
||||
|
||||
/*FIXME: wait on the thread cancellation event as well - we are a cancellation point*/
|
||||
if (!pthread::isGoodObject (thread))
|
||||
if (!isGoodObject (thread))
|
||||
return ESRCH;
|
||||
|
||||
if (__pthread_equal (thread,&joiner))
|
||||
@ -1766,9 +1766,9 @@ __pthread_join (pthread_t *thread, void **return_val)
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_detach (pthread_t *thread)
|
||||
pthread::detach (pthread_t *thread)
|
||||
{
|
||||
if (!pthread::isGoodObject (thread))
|
||||
if (!isGoodObject (thread))
|
||||
return ESRCH;
|
||||
|
||||
(*thread)->mutex.Lock ();
|
||||
@ -1797,9 +1797,9 @@ __pthread_detach (pthread_t *thread)
|
||||
}
|
||||
|
||||
int
|
||||
__pthread_suspend (pthread_t *thread)
|
||||
pthread::suspend (pthread_t *thread)
|
||||
{
|
||||
if (!pthread::isGoodObject (thread))
|
||||
if (!isGoodObject (thread))
|
||||
return ESRCH;
|
||||
|
||||
if ((*thread)->suspended == false)
|
||||
@ -1813,9 +1813,9 @@ __pthread_suspend (pthread_t *thread)
|
||||
|
||||
|
||||
int
|
||||
__pthread_continue (pthread_t *thread)
|
||||
pthread::resume (pthread_t *thread)
|
||||
{
|
||||
if (!pthread::isGoodObject (thread))
|
||||
if (!isGoodObject (thread))
|
||||
return ESRCH;
|
||||
|
||||
if ((*thread)->suspended == true)
|
||||
@ -2456,10 +2456,10 @@ semaphore::isGoodObject (sem_t const * sem)
|
||||
}
|
||||
|
||||
int
|
||||
__sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||
semaphore::init (sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
/*opengroup calls this undefined */
|
||||
if (semaphore::isGoodObject (sem))
|
||||
if (isGoodObject (sem))
|
||||
return EBUSY;
|
||||
|
||||
if (value > SEM_VALUE_MAX)
|
||||
@ -2467,7 +2467,7 @@ __sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||
|
||||
*sem = new semaphore (pshared, value);
|
||||
|
||||
if (!semaphore::isGoodObject (sem))
|
||||
if (!isGoodObject (sem))
|
||||
{
|
||||
delete (*sem);
|
||||
*sem = NULL;
|
||||
@ -2477,9 +2477,9 @@ __sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||
}
|
||||
|
||||
int
|
||||
__sem_destroy (sem_t *sem)
|
||||
semaphore::destroy (sem_t *sem)
|
||||
{
|
||||
if (!semaphore::isGoodObject (sem))
|
||||
if (!isGoodObject (sem))
|
||||
return EINVAL;
|
||||
|
||||
/*FIXME - new feature - test for busy against threads... */
|
||||
@ -2490,9 +2490,9 @@ __sem_destroy (sem_t *sem)
|
||||
}
|
||||
|
||||
int
|
||||
__sem_wait (sem_t *sem)
|
||||
semaphore::wait (sem_t *sem)
|
||||
{
|
||||
if (!semaphore::isGoodObject (sem))
|
||||
if (!isGoodObject (sem))
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
@ -2503,9 +2503,9 @@ __sem_wait (sem_t *sem)
|
||||
}
|
||||
|
||||
int
|
||||
__sem_trywait (sem_t *sem)
|
||||
semaphore::trywait (sem_t *sem)
|
||||
{
|
||||
if (!semaphore::isGoodObject (sem))
|
||||
if (!isGoodObject (sem))
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
@ -2515,9 +2515,9 @@ __sem_trywait (sem_t *sem)
|
||||
}
|
||||
|
||||
int
|
||||
__sem_post (sem_t *sem)
|
||||
semaphore::post (sem_t *sem)
|
||||
{
|
||||
if (!semaphore::isGoodObject (sem))
|
||||
if (!isGoodObject (sem))
|
||||
return EINVAL;
|
||||
|
||||
(*sem)->Post ();
|
||||
|
@ -336,9 +336,21 @@ public:
|
||||
static void atforkparent();
|
||||
static void atforkchild();
|
||||
|
||||
/* API calls */
|
||||
static int cancel (pthread_t);
|
||||
static int join (pthread_t * thread, void **return_val);
|
||||
static int detach (pthread_t * thread);
|
||||
static int create (pthread_t * thread, const pthread_attr_t * attr,
|
||||
void *(*start_routine) (void *), void *arg);
|
||||
static int once (pthread_once_t *, void (*)(void));
|
||||
static int atfork(void (*)(void), void (*)(void), void (*)(void));
|
||||
static int suspend (pthread_t * thread);
|
||||
static int resume (pthread_t * thread);
|
||||
|
||||
virtual void exit (void *value_ptr);
|
||||
|
||||
virtual int cancel ();
|
||||
|
||||
virtual void testcancel ();
|
||||
static void static_cancel_self ();
|
||||
|
||||
@ -358,9 +370,6 @@ private:
|
||||
__pthread_cleanup_handler *cleanup_stack;
|
||||
pthread_mutex mutex;
|
||||
|
||||
friend int __pthread_join (pthread_t * thread, void **return_val);
|
||||
friend int __pthread_detach (pthread_t * thread);
|
||||
|
||||
void pop_all_cleanup_handlers (void);
|
||||
void precreate (pthread_attr *);
|
||||
void postcreate ();
|
||||
@ -439,6 +448,13 @@ class semaphore:public verifyable_object
|
||||
{
|
||||
public:
|
||||
static bool isGoodObject(sem_t const *);
|
||||
/* API calls */
|
||||
static int init (sem_t * sem, int pshared, unsigned int value);
|
||||
static int destroy (sem_t * sem);
|
||||
static int wait (sem_t * sem);
|
||||
static int trywait (sem_t * sem);
|
||||
static int post (sem_t * sem);
|
||||
|
||||
HANDLE win32_obj_id;
|
||||
class semaphore * next;
|
||||
int shared;
|
||||
@ -496,21 +512,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/* Cancellation */
|
||||
int __pthread_cancel (pthread_t thread);
|
||||
|
||||
/* Thread Exit */
|
||||
int __pthread_join (pthread_t * thread, void **return_val);
|
||||
int __pthread_detach (pthread_t * thread);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/* ThreadCreation */
|
||||
int __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
|
||||
void *(*start_routine) (void *), void *arg);
|
||||
int __pthread_once (pthread_once_t *, void (*)(void));
|
||||
int __pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
|
||||
|
||||
int __pthread_attr_init (pthread_attr_t * attr);
|
||||
int __pthread_attr_destroy (pthread_attr_t * attr);
|
||||
int __pthread_attr_setdetachstate (pthread_attr_t *, int);
|
||||
@ -531,10 +534,6 @@ int __pthread_attr_setschedpolicy (pthread_attr_t *, int);
|
||||
int __pthread_attr_setscope (pthread_attr_t *, int);
|
||||
int __pthread_attr_setstackaddr (pthread_attr_t *, void *);
|
||||
|
||||
/* Thread suspend */
|
||||
int __pthread_suspend (pthread_t * thread);
|
||||
int __pthread_continue (pthread_t * thread);
|
||||
|
||||
/* Thread SpecificData */
|
||||
int __pthread_key_create (pthread_key_t * key, void (*destructor) (void *));
|
||||
int __pthread_key_delete (pthread_key_t key);
|
||||
@ -593,16 +592,7 @@ int __pthread_getschedparam (pthread_t thread, int *policy,
|
||||
int __pthread_setschedparam (pthread_t thread, int policy,
|
||||
const struct sched_param *param);
|
||||
|
||||
/* cancelability states */
|
||||
|
||||
/* Semaphores */
|
||||
int __sem_init (sem_t * sem, int pshared, unsigned int value);
|
||||
int __sem_destroy (sem_t * sem);
|
||||
int __sem_wait (sem_t * sem);
|
||||
int __sem_trywait (sem_t * sem);
|
||||
int __sem_post (sem_t * sem);
|
||||
};
|
||||
|
||||
#endif // MT_SAFE
|
||||
|
||||
#endif // _CYGNUS_THREADS_
|
||||
|
Loading…
x
Reference in New Issue
Block a user