Tue Sep 25 21:25:00 2001 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (pthread_cond::BroadCast): Use address with verifyable_object_isvalid(). (pthread_cond::Signal): Ditto. (__pthread_create): Ditto. (__pthread_cleanup): Ditto. (__pthread_attr_init): Ditto. (__pthread_attr_getinheritsched): Ditto. (__pthread_attr_getschedparam): Ditto. (__pthread_attr_getschedpolicy): Ditto. (__pthread_attr_getscope): Ditto. (__pthread_attr_setdetachstate): Ditto. (__pthread_attr_getdetachstate): Ditto. (__pthread_attr_setinheritsched): Ditto. (__pthread_attr_setschedparam): Ditto. (__pthread_attr_setschedpolicy): Ditto. (__pthread_attr_setscope): Ditto. (__pthread_attr_setstacksize): Ditto. (__pthread_attr_getstacksize): Ditto. (__pthread_attr_destroy): Ditto. (__pthread_join): Ditto. (__pthread_detach): Ditto. (__pthread_suspend): Ditto. (__pthread_continue): Ditto. (__pthread_getschedparam): Ditto. (__pthread_getsequence_np): Ditto. (__pthread_key_create): Ditto. (__pthread_key_delete): Ditto. (__pthread_setschedparam): Ditto. (__pthread_setspecific): Ditto. (__pthread_getspecific): Ditto. (__pthread_cond_destroy): Ditto. (__pthread_cond_init): Ditto. (__pthread_cond_broadcast): Ditto. (__pthread_cond_signal): Ditto. (__pthread_cond_timedwait): Ditto. (__pthread_cond_wait): Ditto. (__pthread_condattr_init): Ditto. (__pthread_condattr_getpshared): Ditto. (__pthread_condattr_setpshared): Ditto. (__pthread_condattr_destroy): Ditto. (__pthread_kill): Ditto. (__pthread_mutex_init): Ditto. (__pthread_mutex_getprioceiling): Ditto. (__pthread_mutex_lock): Ditto. (__pthread_mutex_trylock): Ditto. (__pthread_mutex_unlock): Ditto. (__pthread_mutex_destroy): Ditto. (__pthread_mutex_setprioceiling): Ditto. (__pthread_mutexattr_getprotocol): Ditto. (__pthread_mutexattr_getpshared): Ditto. (__pthread_mutexattr_gettype): Ditto. (__pthread_mutexattr_init): Ditto. (__pthread_mutexattr_destroy): Ditto. (__pthread_mutexattr_setprotocol): Ditto. (__pthread_mutexattr_setprioceiling): Ditto. (__pthread_mutexattr_getprioceiling): Ditto. (__pthread_mutexattr_setpshared): Ditto. (__pthread_mutexattr_settype): Ditto. (__sem_init): Ditto. (__sem_destroy): Ditto. (__sem_wait): Ditto. (__sem_trywait): Ditto. (__sem_post): Ditto. (verifyable_object_isvalid): Recieve a pointer to a pointer for verification. (__pthread_mutexattr_getprotocol): Fix typo in magic number. (__pthread_mutexattr_getpshared): Ditto. (__pthread_mutexattr_gettype): Ditto. * thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a pointer for verification. * include/pthread.h: Fix typo for __cleanup_routine_type typedef. (Contrib from Net).
This commit is contained in:
parent
79776fc2cc
commit
c918cf9421
|
@ -1,3 +1,75 @@
|
||||||
|
Tue Sep 25 21:25:00 2001 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* thread.cc (pthread_cond::BroadCast): Use address with verifyable_object_isvalid().
|
||||||
|
(pthread_cond::Signal): Ditto.
|
||||||
|
(__pthread_create): Ditto.
|
||||||
|
(__pthread_cleanup): Ditto.
|
||||||
|
(__pthread_attr_init): Ditto.
|
||||||
|
(__pthread_attr_getinheritsched): Ditto.
|
||||||
|
(__pthread_attr_getschedparam): Ditto.
|
||||||
|
(__pthread_attr_getschedpolicy): Ditto.
|
||||||
|
(__pthread_attr_getscope): Ditto.
|
||||||
|
(__pthread_attr_setdetachstate): Ditto.
|
||||||
|
(__pthread_attr_getdetachstate): Ditto.
|
||||||
|
(__pthread_attr_setinheritsched): Ditto.
|
||||||
|
(__pthread_attr_setschedparam): Ditto.
|
||||||
|
(__pthread_attr_setschedpolicy): Ditto.
|
||||||
|
(__pthread_attr_setscope): Ditto.
|
||||||
|
(__pthread_attr_setstacksize): Ditto.
|
||||||
|
(__pthread_attr_getstacksize): Ditto.
|
||||||
|
(__pthread_attr_destroy): Ditto.
|
||||||
|
(__pthread_join): Ditto.
|
||||||
|
(__pthread_detach): Ditto.
|
||||||
|
(__pthread_suspend): Ditto.
|
||||||
|
(__pthread_continue): Ditto.
|
||||||
|
(__pthread_getschedparam): Ditto.
|
||||||
|
(__pthread_getsequence_np): Ditto.
|
||||||
|
(__pthread_key_create): Ditto.
|
||||||
|
(__pthread_key_delete): Ditto.
|
||||||
|
(__pthread_setschedparam): Ditto.
|
||||||
|
(__pthread_setspecific): Ditto.
|
||||||
|
(__pthread_getspecific): Ditto.
|
||||||
|
(__pthread_cond_destroy): Ditto.
|
||||||
|
(__pthread_cond_init): Ditto.
|
||||||
|
(__pthread_cond_broadcast): Ditto.
|
||||||
|
(__pthread_cond_signal): Ditto.
|
||||||
|
(__pthread_cond_timedwait): Ditto.
|
||||||
|
(__pthread_cond_wait): Ditto.
|
||||||
|
(__pthread_condattr_init): Ditto.
|
||||||
|
(__pthread_condattr_getpshared): Ditto.
|
||||||
|
(__pthread_condattr_setpshared): Ditto.
|
||||||
|
(__pthread_condattr_destroy): Ditto.
|
||||||
|
(__pthread_kill): Ditto.
|
||||||
|
(__pthread_mutex_init): Ditto.
|
||||||
|
(__pthread_mutex_getprioceiling): Ditto.
|
||||||
|
(__pthread_mutex_lock): Ditto.
|
||||||
|
(__pthread_mutex_trylock): Ditto.
|
||||||
|
(__pthread_mutex_unlock): Ditto.
|
||||||
|
(__pthread_mutex_destroy): Ditto.
|
||||||
|
(__pthread_mutex_setprioceiling): Ditto.
|
||||||
|
(__pthread_mutexattr_getprotocol): Ditto.
|
||||||
|
(__pthread_mutexattr_getpshared): Ditto.
|
||||||
|
(__pthread_mutexattr_gettype): Ditto.
|
||||||
|
(__pthread_mutexattr_init): Ditto.
|
||||||
|
(__pthread_mutexattr_destroy): Ditto.
|
||||||
|
(__pthread_mutexattr_setprotocol): Ditto.
|
||||||
|
(__pthread_mutexattr_setprioceiling): Ditto.
|
||||||
|
(__pthread_mutexattr_getprioceiling): Ditto.
|
||||||
|
(__pthread_mutexattr_setpshared): Ditto.
|
||||||
|
(__pthread_mutexattr_settype): Ditto.
|
||||||
|
(__sem_init): Ditto.
|
||||||
|
(__sem_destroy): Ditto.
|
||||||
|
(__sem_wait): Ditto.
|
||||||
|
(__sem_trywait): Ditto.
|
||||||
|
(__sem_post): Ditto.
|
||||||
|
(verifyable_object_isvalid): Recieve a pointer to a pointer for verification.
|
||||||
|
(__pthread_mutexattr_getprotocol): Fix typo in magic number.
|
||||||
|
(__pthread_mutexattr_getpshared): Ditto.
|
||||||
|
(__pthread_mutexattr_gettype): Ditto.
|
||||||
|
* thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a
|
||||||
|
pointer for verification.
|
||||||
|
* include/pthread.h: Fix typo for __cleanup_routine_type typedef. (Contrib from Net).
|
||||||
|
|
||||||
Tue Sep 25 02:09:42 2001 Christopher Faylor <cgf@redhat.com>
|
Tue Sep 25 02:09:42 2001 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* select.cc (fhandler_tty_common::ready_for_read): Rewrite to correctly
|
* select.cc (fhandler_tty_common::ready_for_read): Rewrite to correctly
|
||||||
|
|
|
@ -101,7 +101,7 @@ int pthread_cancel (pthread_t);
|
||||||
void pthread_cleanup_push (void (*routine)(void*), void *arg);
|
void pthread_cleanup_push (void (*routine)(void*), void *arg);
|
||||||
void pthread_cleanup_pop (int execute);
|
void pthread_cleanup_pop (int execute);
|
||||||
*/
|
*/
|
||||||
typedef void __cleanup_routine_type (void *);
|
typedef void (*__cleanup_routine_type) (void *);
|
||||||
|
|
||||||
#define pthread_cleanup_push(fn, arg) { __cleanup_routine_type __cleanup_routine=fn; \
|
#define pthread_cleanup_push(fn, arg) { __cleanup_routine_type __cleanup_routine=fn; \
|
||||||
void *__cleanup_param=arg;
|
void *__cleanup_param=arg;
|
||||||
|
|
|
@ -462,7 +462,7 @@ pthread_cond::BroadCast ()
|
||||||
if (pthread_mutex_lock (&cond_access))
|
if (pthread_mutex_lock (&cond_access))
|
||||||
system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
|
system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
|
||||||
int count = waiting;
|
int count = waiting;
|
||||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (&mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
{
|
{
|
||||||
if (pthread_mutex_unlock (&cond_access))
|
if (pthread_mutex_unlock (&cond_access))
|
||||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
|
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
|
||||||
|
@ -483,7 +483,7 @@ pthread_cond::Signal ()
|
||||||
{
|
{
|
||||||
if (pthread_mutex_lock (&cond_access))
|
if (pthread_mutex_lock (&cond_access))
|
||||||
system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
|
system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
|
||||||
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (&mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
{
|
{
|
||||||
if (pthread_mutex_unlock (&cond_access))
|
if (pthread_mutex_unlock (&cond_access))
|
||||||
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
|
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
|
||||||
|
@ -812,13 +812,16 @@ check_valid_pointer (void *pointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
verifyable_object_isvalid (verifyable_object *object, long magic)
|
verifyable_object_isvalid (void const * objectptr, long magic)
|
||||||
{
|
{
|
||||||
if (!object || object == PTHREAD_MUTEX_INITIALIZER)
|
verifyable_object **object = (verifyable_object **)objectptr;
|
||||||
return 0;
|
|
||||||
if (check_valid_pointer (object))
|
if (check_valid_pointer (object))
|
||||||
return 0;
|
return 0;
|
||||||
if (object->magic != magic)
|
if (!*object || *object == PTHREAD_MUTEX_INITIALIZER)
|
||||||
|
return 0;
|
||||||
|
if (check_valid_pointer (*object))
|
||||||
|
return 0;
|
||||||
|
if ((*object)->magic != magic)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -882,12 +885,12 @@ 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)
|
void *(*start_routine) (void *), void *arg)
|
||||||
{
|
{
|
||||||
if (attr && !verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (attr && !verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
*thread = new pthread ();
|
*thread = new pthread ();
|
||||||
(*thread)->create (start_routine, attr ? *attr : NULL, arg);
|
(*thread)->create (start_routine, attr ? *attr : NULL, arg);
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*thread);
|
delete (*thread);
|
||||||
*thread = NULL;
|
*thread = NULL;
|
||||||
|
@ -931,7 +934,7 @@ __pthread_cleanup (pthread_t thread)
|
||||||
int
|
int
|
||||||
__pthread_cancel (pthread_t thread)
|
__pthread_cancel (pthread_t thread)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (&thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
if (thread->cancelstate == PTHREAD_CANCEL_ENABLE)
|
if (thread->cancelstate == PTHREAD_CANCEL_ENABLE)
|
||||||
{
|
{
|
||||||
|
@ -1283,7 +1286,7 @@ int
|
||||||
__pthread_attr_init (pthread_attr_t *attr)
|
__pthread_attr_init (pthread_attr_t *attr)
|
||||||
{
|
{
|
||||||
*attr = new pthread_attr;
|
*attr = new pthread_attr;
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*attr);
|
delete (*attr);
|
||||||
*attr = NULL;
|
*attr = NULL;
|
||||||
|
@ -1296,7 +1299,7 @@ int
|
||||||
__pthread_attr_getinheritsched (const pthread_attr_t *attr,
|
__pthread_attr_getinheritsched (const pthread_attr_t *attr,
|
||||||
int *inheritsched)
|
int *inheritsched)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*inheritsched = (*attr)->inheritsched;
|
*inheritsched = (*attr)->inheritsched;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1306,7 +1309,7 @@ int
|
||||||
__pthread_attr_getschedparam (const pthread_attr_t *attr,
|
__pthread_attr_getschedparam (const pthread_attr_t *attr,
|
||||||
struct sched_param *param)
|
struct sched_param *param)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*param = (*attr)->schedparam;
|
*param = (*attr)->schedparam;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1319,7 +1322,7 @@ __pthread_attr_getschedparam (const pthread_attr_t *attr,
|
||||||
int
|
int
|
||||||
__pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy)
|
__pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*policy = SCHED_FIFO;
|
*policy = SCHED_FIFO;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1329,7 +1332,7 @@ __pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy)
|
||||||
int
|
int
|
||||||
__pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope)
|
__pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*contentionscope = (*attr)->contentionscope;
|
*contentionscope = (*attr)->contentionscope;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1338,7 +1341,7 @@ __pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope)
|
||||||
int
|
int
|
||||||
__pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
|
__pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (detachstate < 0 || detachstate > 1)
|
if (detachstate < 0 || detachstate > 1)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -1349,7 +1352,7 @@ __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
|
||||||
int
|
int
|
||||||
__pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
|
__pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*detachstate = (*attr)->joinable;
|
*detachstate = (*attr)->joinable;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1358,7 +1361,7 @@ __pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
|
||||||
int
|
int
|
||||||
__pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched)
|
__pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (inheritsched != PTHREAD_INHERIT_SCHED
|
if (inheritsched != PTHREAD_INHERIT_SCHED
|
||||||
&& inheritsched != PTHREAD_EXPLICIT_SCHED)
|
&& inheritsched != PTHREAD_EXPLICIT_SCHED)
|
||||||
|
@ -1371,7 +1374,7 @@ int
|
||||||
__pthread_attr_setschedparam (pthread_attr_t *attr,
|
__pthread_attr_setschedparam (pthread_attr_t *attr,
|
||||||
const struct sched_param *param)
|
const struct sched_param *param)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (!valid_sched_parameters (param))
|
if (!valid_sched_parameters (param))
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
@ -1383,7 +1386,7 @@ __pthread_attr_setschedparam (pthread_attr_t *attr,
|
||||||
int
|
int
|
||||||
__pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy)
|
__pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (policy != SCHED_FIFO)
|
if (policy != SCHED_FIFO)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
@ -1393,7 +1396,7 @@ __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy)
|
||||||
int
|
int
|
||||||
__pthread_attr_setscope (pthread_attr_t *attr, int contentionscope)
|
__pthread_attr_setscope (pthread_attr_t *attr, int contentionscope)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (contentionscope != PTHREAD_SCOPE_SYSTEM
|
if (contentionscope != PTHREAD_SCOPE_SYSTEM
|
||||||
&& contentionscope != PTHREAD_SCOPE_PROCESS)
|
&& contentionscope != PTHREAD_SCOPE_PROCESS)
|
||||||
|
@ -1409,7 +1412,7 @@ __pthread_attr_setscope (pthread_attr_t *attr, int contentionscope)
|
||||||
int
|
int
|
||||||
__pthread_attr_setstacksize (pthread_attr_t *attr, size_t size)
|
__pthread_attr_setstacksize (pthread_attr_t *attr, size_t size)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
(*attr)->stacksize = size;
|
(*attr)->stacksize = size;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1418,7 +1421,7 @@ __pthread_attr_setstacksize (pthread_attr_t *attr, size_t size)
|
||||||
int
|
int
|
||||||
__pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *size)
|
__pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *size)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*size = (*attr)->stacksize;
|
*size = (*attr)->stacksize;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1427,7 +1430,7 @@ __pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *size)
|
||||||
int
|
int
|
||||||
__pthread_attr_destroy (pthread_attr_t *attr)
|
__pthread_attr_destroy (pthread_attr_t *attr)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_ATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
delete (*attr);
|
delete (*attr);
|
||||||
*attr = NULL;
|
*attr = NULL;
|
||||||
|
@ -1452,7 +1455,7 @@ int
|
||||||
__pthread_join (pthread_t *thread, void **return_val)
|
__pthread_join (pthread_t *thread, void **return_val)
|
||||||
{
|
{
|
||||||
/*FIXME: wait on the thread cancellation event as well - we are a cancellation point*/
|
/*FIXME: wait on the thread cancellation event as well - we are a cancellation point*/
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
|
|
||||||
if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED)
|
if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED)
|
||||||
|
@ -1477,7 +1480,7 @@ __pthread_join (pthread_t *thread, void **return_val)
|
||||||
int
|
int
|
||||||
__pthread_detach (pthread_t *thread)
|
__pthread_detach (pthread_t *thread)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
|
|
||||||
if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED)
|
if ((*thread)->attr.joinable == PTHREAD_CREATE_DETACHED)
|
||||||
|
@ -1493,7 +1496,7 @@ __pthread_detach (pthread_t *thread)
|
||||||
int
|
int
|
||||||
__pthread_suspend (pthread_t *thread)
|
__pthread_suspend (pthread_t *thread)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
|
|
||||||
if ((*thread)->suspended == false)
|
if ((*thread)->suspended == false)
|
||||||
|
@ -1509,7 +1512,7 @@ __pthread_suspend (pthread_t *thread)
|
||||||
int
|
int
|
||||||
__pthread_continue (pthread_t *thread)
|
__pthread_continue (pthread_t *thread)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
|
|
||||||
if ((*thread)->suspended == true)
|
if ((*thread)->suspended == true)
|
||||||
|
@ -1533,7 +1536,7 @@ int
|
||||||
__pthread_getschedparam (pthread_t thread, int *policy,
|
__pthread_getschedparam (pthread_t thread, int *policy,
|
||||||
struct sched_param *param)
|
struct sched_param *param)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (&thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
*policy = SCHED_FIFO;
|
*policy = SCHED_FIFO;
|
||||||
/*we don't return the current effective priority, we return the current requested
|
/*we don't return the current effective priority, we return the current requested
|
||||||
|
@ -1546,7 +1549,7 @@ __pthread_getschedparam (pthread_t thread, int *policy,
|
||||||
unsigned long
|
unsigned long
|
||||||
__pthread_getsequence_np (pthread_t *thread)
|
__pthread_getsequence_np (pthread_t *thread)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return (*thread)->GetThreadId ();
|
return (*thread)->GetThreadId ();
|
||||||
}
|
}
|
||||||
|
@ -1558,12 +1561,12 @@ __pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
|
||||||
/*The opengroup docs don't define if we should check this or not,
|
/*The opengroup docs don't define if we should check this or not,
|
||||||
*but creation is relatively rare..
|
*but creation is relatively rare..
|
||||||
*/
|
*/
|
||||||
if (verifyable_object_isvalid (*key, PTHREAD_KEY_MAGIC))
|
if (verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC))
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
|
||||||
*key = new pthread_key (destructor);
|
*key = new pthread_key (destructor);
|
||||||
|
|
||||||
if (!verifyable_object_isvalid (*key, PTHREAD_KEY_MAGIC))
|
if (!verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*key);
|
delete (*key);
|
||||||
*key = NULL;
|
*key = NULL;
|
||||||
|
@ -1575,7 +1578,7 @@ __pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
|
||||||
int
|
int
|
||||||
__pthread_key_delete (pthread_key_t key)
|
__pthread_key_delete (pthread_key_t key)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC))
|
if (!verifyable_object_isvalid (&key, PTHREAD_KEY_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
delete (key);
|
delete (key);
|
||||||
|
@ -1599,7 +1602,7 @@ int
|
||||||
__pthread_setschedparam (pthread_t thread, int policy,
|
__pthread_setschedparam (pthread_t thread, int policy,
|
||||||
const struct sched_param *param)
|
const struct sched_param *param)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (&thread, PTHREAD_MAGIC))
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
if (policy != SCHED_FIFO)
|
if (policy != SCHED_FIFO)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
@ -1616,7 +1619,7 @@ __pthread_setschedparam (pthread_t thread, int policy,
|
||||||
int
|
int
|
||||||
__pthread_setspecific (pthread_key_t key, const void *value)
|
__pthread_setspecific (pthread_key_t key, const void *value)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC))
|
if (!verifyable_object_isvalid (&key, PTHREAD_KEY_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
(key)->set (value);
|
(key)->set (value);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1625,7 +1628,7 @@ __pthread_setspecific (pthread_key_t key, const void *value)
|
||||||
void *
|
void *
|
||||||
__pthread_getspecific (pthread_key_t key)
|
__pthread_getspecific (pthread_key_t key)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (key, PTHREAD_KEY_MAGIC))
|
if (!verifyable_object_isvalid (&key, PTHREAD_KEY_MAGIC))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (key)->get ();
|
return (key)->get ();
|
||||||
|
@ -1637,7 +1640,7 @@ __pthread_getspecific (pthread_key_t key)
|
||||||
int
|
int
|
||||||
__pthread_cond_destroy (pthread_cond_t *cond)
|
__pthread_cond_destroy (pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
/*reads are atomic */
|
/*reads are atomic */
|
||||||
|
@ -1653,15 +1656,15 @@ __pthread_cond_destroy (pthread_cond_t *cond)
|
||||||
int
|
int
|
||||||
__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
|
__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
|
||||||
{
|
{
|
||||||
if (attr && !verifyable_object_isvalid (*attr, PTHREAD_CONDATTR_MAGIC))
|
if (attr && !verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
|
||||||
*cond = new pthread_cond (attr ? (*attr) : NULL);
|
*cond = new pthread_cond (attr ? (*attr) : NULL);
|
||||||
|
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*cond);
|
delete (*cond);
|
||||||
*cond = NULL;
|
*cond = NULL;
|
||||||
|
@ -1674,7 +1677,7 @@ __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
|
||||||
int
|
int
|
||||||
__pthread_cond_broadcast (pthread_cond_t *cond)
|
__pthread_cond_broadcast (pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
(*cond)->BroadCast ();
|
(*cond)->BroadCast ();
|
||||||
|
@ -1685,7 +1688,7 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
|
||||||
int
|
int
|
||||||
__pthread_cond_signal (pthread_cond_t *cond)
|
__pthread_cond_signal (pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
(*cond)->Signal ();
|
(*cond)->Signal ();
|
||||||
|
@ -1707,9 +1710,9 @@ __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||||
__pthread_mutex_init (mutex, NULL);
|
__pthread_mutex_init (mutex, NULL);
|
||||||
themutex = mutex;
|
themutex = mutex;
|
||||||
|
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
struct timeb currSysTime;
|
struct timeb currSysTime;
|
||||||
long waitlength;
|
long waitlength;
|
||||||
|
@ -1757,9 +1760,9 @@ __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
__pthread_mutex_init (mutex, NULL);
|
__pthread_mutex_init (mutex, NULL);
|
||||||
themutex = mutex;
|
themutex = mutex;
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
|
if (!verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (pthread_mutex_lock (&(*cond)->cond_access))
|
if (pthread_mutex_lock (&(*cond)->cond_access))
|
||||||
|
@ -1794,7 +1797,7 @@ int
|
||||||
__pthread_condattr_init (pthread_condattr_t *condattr)
|
__pthread_condattr_init (pthread_condattr_t *condattr)
|
||||||
{
|
{
|
||||||
*condattr = new pthread_condattr;
|
*condattr = new pthread_condattr;
|
||||||
if (!verifyable_object_isvalid (*condattr, PTHREAD_CONDATTR_MAGIC))
|
if (!verifyable_object_isvalid (condattr, PTHREAD_CONDATTR_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*condattr);
|
delete (*condattr);
|
||||||
*condattr = NULL;
|
*condattr = NULL;
|
||||||
|
@ -1806,7 +1809,7 @@ __pthread_condattr_init (pthread_condattr_t *condattr)
|
||||||
int
|
int
|
||||||
__pthread_condattr_getpshared (const pthread_condattr_t *attr, int *pshared)
|
__pthread_condattr_getpshared (const pthread_condattr_t *attr, int *pshared)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_CONDATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*pshared = (*attr)->shared;
|
*pshared = (*attr)->shared;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1815,7 +1818,7 @@ __pthread_condattr_getpshared (const pthread_condattr_t *attr, int *pshared)
|
||||||
int
|
int
|
||||||
__pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
|
__pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_CONDATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if ((pshared < 0) || (pshared > 1))
|
if ((pshared < 0) || (pshared > 1))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -1829,7 +1832,7 @@ __pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
|
||||||
int
|
int
|
||||||
__pthread_condattr_destroy (pthread_condattr_t *condattr)
|
__pthread_condattr_destroy (pthread_condattr_t *condattr)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*condattr, PTHREAD_CONDATTR_MAGIC))
|
if (!verifyable_object_isvalid (condattr, PTHREAD_CONDATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
delete (*condattr);
|
delete (*condattr);
|
||||||
*condattr = NULL;
|
*condattr = NULL;
|
||||||
|
@ -1843,7 +1846,7 @@ __pthread_kill (pthread_t thread, int sig)
|
||||||
// lock myself, for the use of thread2signal
|
// lock myself, for the use of thread2signal
|
||||||
// two different kills might clash: FIXME
|
// two different kills might clash: FIXME
|
||||||
|
|
||||||
if (!verifyable_object_isvalid (thread, PTHREAD_MAGIC))
|
if (!verifyable_object_isvalid (&thread, PTHREAD_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (thread->sigs)
|
if (thread->sigs)
|
||||||
|
@ -1901,14 +1904,14 @@ int
|
||||||
__pthread_mutex_init (pthread_mutex_t *mutex,
|
__pthread_mutex_init (pthread_mutex_t *mutex,
|
||||||
const pthread_mutexattr_t *attr)
|
const pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
if (attr && !verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (attr && !verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if (verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
|
if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
|
||||||
*mutex = new pthread_mutex (attr ? (*attr) : NULL);
|
*mutex = new pthread_mutex (attr ? (*attr) : NULL);
|
||||||
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*mutex);
|
delete (*mutex);
|
||||||
*mutex = NULL;
|
*mutex = NULL;
|
||||||
|
@ -1924,7 +1927,7 @@ __pthread_mutex_getprioceiling (const pthread_mutex_t *mutex,
|
||||||
pthread_mutex_t *themutex=(pthread_mutex_t *) mutex;
|
pthread_mutex_t *themutex=(pthread_mutex_t *) mutex;
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
__pthread_mutex_init ((pthread_mutex_t *) mutex, NULL);
|
__pthread_mutex_init ((pthread_mutex_t *) mutex, NULL);
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/*We don't define _POSIX_THREAD_PRIO_PROTECT because we do't currently support
|
/*We don't define _POSIX_THREAD_PRIO_PROTECT because we do't currently support
|
||||||
*mutex priorities.
|
*mutex priorities.
|
||||||
|
@ -1941,10 +1944,14 @@ int
|
||||||
__pthread_mutex_lock (pthread_mutex_t *mutex)
|
__pthread_mutex_lock (pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
pthread_mutex_t *themutex = mutex;
|
pthread_mutex_t *themutex = mutex;
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
__pthread_mutex_init (mutex, NULL);
|
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
|
{
|
||||||
|
int rv = __pthread_mutex_init (mutex, NULL);
|
||||||
|
if (rv)
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
(*themutex)->Lock ();
|
(*themutex)->Lock ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1955,7 +1962,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
|
||||||
pthread_mutex_t *themutex = mutex;
|
pthread_mutex_t *themutex = mutex;
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
__pthread_mutex_init (mutex, NULL);
|
__pthread_mutex_init (mutex, NULL);
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if ((*themutex)->TryLock ())
|
if ((*themutex)->TryLock ())
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
@ -1967,7 +1974,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
__pthread_mutex_init (mutex, NULL);
|
__pthread_mutex_init (mutex, NULL);
|
||||||
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
(*mutex)->UnLock ();
|
(*mutex)->UnLock ();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1978,7 +1985,7 @@ __pthread_mutex_destroy (pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
if (check_valid_pointer (mutex) && (*mutex == PTHREAD_MUTEX_INITIALIZER))
|
if (check_valid_pointer (mutex) && (*mutex == PTHREAD_MUTEX_INITIALIZER))
|
||||||
return 0;
|
return 0;
|
||||||
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
/*reading a word is atomic */
|
/*reading a word is atomic */
|
||||||
|
@ -1997,7 +2004,7 @@ __pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prioceiling,
|
||||||
pthread_mutex_t *themutex = mutex;
|
pthread_mutex_t *themutex = mutex;
|
||||||
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
|
||||||
__pthread_mutex_init (mutex, NULL);
|
__pthread_mutex_init (mutex, NULL);
|
||||||
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -2008,7 +2015,7 @@ int
|
||||||
__pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr,
|
__pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr,
|
||||||
int *protocol)
|
int *protocol)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -2017,7 +2024,7 @@ int
|
||||||
__pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
|
__pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
|
||||||
int *pshared)
|
int *pshared)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*pshared = (*attr)->pshared;
|
*pshared = (*attr)->pshared;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2030,7 +2037,7 @@ __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
|
__pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEX_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
*type = (*attr)->mutextype;
|
*type = (*attr)->mutextype;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2044,11 +2051,11 @@ __pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_init (pthread_mutexattr_t *attr)
|
__pthread_mutexattr_init (pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
if (verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
|
||||||
*attr = new pthread_mutexattr ();
|
*attr = new pthread_mutexattr ();
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*attr);
|
delete (*attr);
|
||||||
*attr = NULL;
|
*attr = NULL;
|
||||||
|
@ -2060,7 +2067,7 @@ __pthread_mutexattr_init (pthread_mutexattr_t *attr)
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
|
__pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
delete (*attr);
|
delete (*attr);
|
||||||
*attr = NULL;
|
*attr = NULL;
|
||||||
|
@ -2072,7 +2079,7 @@ __pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int protocol)
|
__pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int protocol)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -2082,7 +2089,7 @@ int
|
||||||
__pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr,
|
__pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr,
|
||||||
int prioceiling)
|
int prioceiling)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -2091,7 +2098,7 @@ int
|
||||||
__pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr,
|
__pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr,
|
||||||
int *prioceiling)
|
int *prioceiling)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return ENOSYS;
|
return ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -2099,7 +2106,7 @@ __pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr,
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
|
__pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/*we don't use pshared for anything as yet. We need to test PROCESS_SHARED
|
/*we don't use pshared for anything as yet. We need to test PROCESS_SHARED
|
||||||
*functionality
|
*functionality
|
||||||
|
@ -2114,7 +2121,7 @@ __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type)
|
__pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
|
if (!verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (type != PTHREAD_MUTEX_RECURSIVE)
|
if (type != PTHREAD_MUTEX_RECURSIVE)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -2127,7 +2134,7 @@ int
|
||||||
__sem_init (sem_t *sem, int pshared, unsigned int value)
|
__sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||||
{
|
{
|
||||||
/*opengroup calls this undefined */
|
/*opengroup calls this undefined */
|
||||||
if (verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
|
||||||
if (value > SEM_VALUE_MAX)
|
if (value > SEM_VALUE_MAX)
|
||||||
|
@ -2135,7 +2142,7 @@ __sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||||
|
|
||||||
*sem = new semaphore (pshared, value);
|
*sem = new semaphore (pshared, value);
|
||||||
|
|
||||||
if (!verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (!verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
{
|
{
|
||||||
delete (*sem);
|
delete (*sem);
|
||||||
*sem = NULL;
|
*sem = NULL;
|
||||||
|
@ -2147,7 +2154,7 @@ __sem_init (sem_t *sem, int pshared, unsigned int value)
|
||||||
int
|
int
|
||||||
__sem_destroy (sem_t *sem)
|
__sem_destroy (sem_t *sem)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (!verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
/*FIXME - new feature - test for busy against threads... */
|
/*FIXME - new feature - test for busy against threads... */
|
||||||
|
@ -2160,7 +2167,7 @@ __sem_destroy (sem_t *sem)
|
||||||
int
|
int
|
||||||
__sem_wait (sem_t *sem)
|
__sem_wait (sem_t *sem)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (!verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
(*sem)->Wait ();
|
(*sem)->Wait ();
|
||||||
|
@ -2170,7 +2177,7 @@ __sem_wait (sem_t *sem)
|
||||||
int
|
int
|
||||||
__sem_trywait (sem_t *sem)
|
__sem_trywait (sem_t *sem)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (!verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
return (*sem)->TryWait ();
|
return (*sem)->TryWait ();
|
||||||
|
@ -2179,7 +2186,7 @@ __sem_trywait (sem_t *sem)
|
||||||
int
|
int
|
||||||
__sem_post (sem_t *sem)
|
__sem_post (sem_t *sem)
|
||||||
{
|
{
|
||||||
if (!verifyable_object_isvalid (*sem, SEM_MAGIC))
|
if (!verifyable_object_isvalid (sem, SEM_MAGIC))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
(*sem)->Post ();
|
(*sem)->Post ();
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
~verifyable_object ();
|
~verifyable_object ();
|
||||||
};
|
};
|
||||||
|
|
||||||
int verifyable_object_isvalid (verifyable_object *, long);
|
int verifyable_object_isvalid (void const *, long);
|
||||||
|
|
||||||
class pthread_key:public verifyable_object
|
class pthread_key:public verifyable_object
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue