spacing changes.

This commit is contained in:
Christopher Faylor 2001-04-23 02:56:19 +00:00
parent c02e9189cf
commit 3c76c0760f

View File

@ -304,7 +304,8 @@ MTinterface::Init (int forked)
/* possible the atfork lists should be inited here as well */ /* possible the atfork lists should be inited here as well */
for (int i =0;i<256;i++)pshared_mutexs[i]=NULL; for (int i = 0; i < 256; i++)
pshared_mutexs[i] = NULL;
#if 0 #if 0
item->function = NULL; item->function = NULL;
@ -357,7 +358,7 @@ pthread::create (void *(*func) (void *), pthread_attr * newattr,
if (attr.inheritsched == PTHREAD_EXPLICIT_SCHED) if (attr.inheritsched == PTHREAD_EXPLICIT_SCHED)
{ {
/* FIXME: set the scheduling settings for the new thread */ /* FIXME: set the scheduling settings for the new thread */
/* sched_thread_setparam(win32_obj_id, attr.schedparam); */ /* sched_thread_setparam (win32_obj_id, attr.schedparam); */
} }
ResumeThread (win32_obj_id); ResumeThread (win32_obj_id);
} }
@ -391,7 +392,7 @@ pthread_cond::pthread_cond (pthread_condattr * attr):verifyable_object (PTHREAD_
this->win32_obj_id =::CreateEvent (&sec_none_nih, false, /* auto signal reset - which I think is pthreads like ? */ this->win32_obj_id =::CreateEvent (&sec_none_nih, false, /* auto signal reset - which I think is pthreads like ? */
false, /* start non signaled */ false, /* start non signaled */
NULL /* no name */ ); NULL /* no name */);
if (!this->win32_obj_id) if (!this->win32_obj_id)
magic = 0; magic = 0;
@ -432,8 +433,8 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
{ {
// FIXME: race condition (potentially drop events // FIXME: race condition (potentially drop events
// Possible solution (single process only) - place this in a critical section. // Possible solution (single process only) - place this in a critical section.
ReleaseMutex(mutex->win32_obj_id); ReleaseMutex (mutex->win32_obj_id);
rv = WaitForSingleObject(win32_obj_id, dwMilliseconds); rv = WaitForSingleObject (win32_obj_id, dwMilliseconds);
} }
else else
rv = SignalObjectAndWait (mutex->win32_obj_id, win32_obj_id, dwMilliseconds, rv = SignalObjectAndWait (mutex->win32_obj_id, win32_obj_id, dwMilliseconds,
@ -468,7 +469,7 @@ pthread_key::~pthread_key ()
if (pthread_key_destructor * dest = MT_INTERFACE->destructors.Remove (this)) if (pthread_key_destructor * dest = MT_INTERFACE->destructors.Remove (this))
delete dest; delete dest;
TlsFree (dwTlsIndex); TlsFree (dwTlsIndex);
}; }
int int
pthread_key::set (const void *value) pthread_key::set (const void *value)
@ -521,23 +522,23 @@ pthread_mutex::pthread_mutex (unsigned short id):verifyable_object (PTHREAD_MUTE
if (MT_INTERFACE->pshared_mutexs[id]) if (MT_INTERFACE->pshared_mutexs[id])
return; return;
char stringbuf[29]; char stringbuf[29];
snprintf(stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f); snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
system_printf("name of mutex to transparently open %s\n",stringbuf); system_printf ("name of mutex to transparently open %s\n",stringbuf);
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf); this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
if (win32_obj_id==0 || (win32_obj_id && GetLastError() != ERROR_ALREADY_EXISTS)) if (win32_obj_id==0 || (win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS))
{ {
// the mutex has been deleted or we couldn't get access. // the mutex has been deleted or we couldn't get access.
// the error_already_exists test is because we are only opening an // the error_already_exists test is because we are only opening an
// existint mutex here // existint mutex here
system_printf("couldn't get pshared mutex %x, %d\n",win32_obj_id, GetLastError()); system_printf ("couldn't get pshared mutex %x, %d\n",win32_obj_id, GetLastError ());
CloseHandle(win32_obj_id); CloseHandle (win32_obj_id);
magic=0; magic = 0;
win32_obj_id=NULL; win32_obj_id = NULL;
return; return;
} }
pshared = PTHREAD_PROCESS_SHARED; pshared = PTHREAD_PROCESS_SHARED;
MT_INTERFACE->pshared_mutexs[id]=this; MT_INTERFACE->pshared_mutexs[id] = this;
} }
pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):verifyable_object (PTHREAD_MUTEX_MAGIC) pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):verifyable_object (PTHREAD_MUTEX_MAGIC)
@ -549,27 +550,27 @@ pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):
// This does open a D.O.S. - the name is guessable (if you are willing to run // This does open a D.O.S. - the name is guessable (if you are willing to run
// thru all possible address values :] // thru all possible address values :]
char stringbuf[29]; char stringbuf[29];
unsigned short id=1; unsigned short id = 1;
while (id < 256) while (id < 256)
{ {
snprintf(stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f); snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
system_printf("name of mutex to create %s\n",stringbuf); system_printf ("name of mutex to create %s\n",stringbuf);
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf); this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
if (this->win32_obj_id && GetLastError() != ERROR_ALREADY_EXISTS) if (this->win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS)
{ {
MT_INTERFACE->pshared_mutexs[id]=this; MT_INTERFACE->pshared_mutexs[id] = this;
pshared_mutex *pmutex=(pshared_mutex *)(mutex); pshared_mutex *pmutex=(pshared_mutex *)(mutex);
pmutex->id=id; pmutex->id = id;
pmutex->flags=SYS_BASE; pmutex->flags = SYS_BASE;
pshared=PTHREAD_PROCESS_SHARED; pshared = PTHREAD_PROCESS_SHARED;
condwaits = 0; condwaits = 0;
return; return;
} }
id++; id++;
CloseHandle(win32_obj_id); CloseHandle (win32_obj_id);
} }
magic=0; magic = 0;
win32_obj_id=NULL; win32_obj_id = NULL;
} }
else else
{ {
@ -604,7 +605,7 @@ pthread_mutex::~pthread_mutex ()
{ {
if (win32_obj_id) if (win32_obj_id)
CloseHandle (win32_obj_id); CloseHandle (win32_obj_id);
win32_obj_id=NULL; win32_obj_id = NULL;
} }
int int
@ -626,12 +627,12 @@ pthread_mutex::UnLock ()
} }
pthread_mutex ** pthread_mutex **
__pthread_mutex_getpshared(pthread_mutex_t *mutex) __pthread_mutex_getpshared (pthread_mutex_t *mutex)
{ {
if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) != SYS_BASE ) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) != SYS_BASE)
return (pthread_mutex **)mutex; return (pthread_mutex **) mutex;
pshared_mutex *pmutex=(pshared_mutex *)(mutex); pshared_mutex *pmutex=(pshared_mutex *)(mutex);
if ((MT_INTERFACE->pshared_mutexs[pmutex->id]) != NULL ) if ((MT_INTERFACE->pshared_mutexs[pmutex->id]) != NULL)
return &(MT_INTERFACE->pshared_mutexs[pmutex->id]); return &(MT_INTERFACE->pshared_mutexs[pmutex->id]);
/* attempt to get the existing mutex */ /* attempt to get the existing mutex */
pthread_mutex * newmutex; pthread_mutex * newmutex;
@ -639,7 +640,7 @@ __pthread_mutex_getpshared(pthread_mutex_t *mutex)
if (!verifyable_object_isvalid (newmutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (newmutex, PTHREAD_MUTEX_MAGIC))
{ {
delete (newmutex); delete (newmutex);
MT_INTERFACE->pshared_mutexs[pmutex->id]=NULL; MT_INTERFACE->pshared_mutexs[pmutex->id] = NULL;
return &(MT_INTERFACE->pshared_mutexs[0]); return &(MT_INTERFACE->pshared_mutexs[0]);
} }
return &(MT_INTERFACE->pshared_mutexs[pmutex->id]); return &(MT_INTERFACE->pshared_mutexs[pmutex->id]);
@ -652,7 +653,7 @@ pshared (PTHREAD_PROCESS_PRIVATE), mutextype (PTHREAD_MUTEX_DEFAULT)
pthread_mutexattr::~pthread_mutexattr () pthread_mutexattr::~pthread_mutexattr ()
{ {
}; }
semaphore::semaphore (int pshared, unsigned int value):verifyable_object (SEM_MAGIC) semaphore::semaphore (int pshared, unsigned int value):verifyable_object (SEM_MAGIC)
{ {
@ -782,7 +783,7 @@ thread_init_wrapper (void *_arg)
#if 0 #if 0
// ??? This code only runs if the thread exits by returning. // ??? This code only runs if the thread exits by returning.
// it's all now in __pthread_exit(); // it's all now in __pthread_exit ();
#endif #endif
/* never reached */ /* never reached */
return 0; return 0;
@ -803,7 +804,7 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
*thread = NULL; *thread = NULL;
return EAGAIN; return EAGAIN;
} }
InterlockedIncrement(&MT_INTERFACE->threadcount); InterlockedIncrement (&MT_INTERFACE->threadcount);
return 0; return 0;
} }
@ -816,7 +817,7 @@ __pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
/* but a cancellation handler is not the right thing. We need this in the thread /* but a cancellation handler is not the right thing. We need this in the thread
* cleanup routine. Assumption: a thread can only be in one pthread_once routine * cleanup routine. Assumption: a thread can only be in one pthread_once routine
* at a time. Stote a mutex_t * in the pthread_structure. if that's non null unlock * at a time. Stote a mutex_t * in the pthread_structure. if that's non null unlock
* on pthread_exit(); * on pthread_exit ();
*/ */
if (once_control->state == 0) if (once_control->state == 0)
{ {
@ -846,7 +847,7 @@ __pthread_cancel (pthread_t thread)
if (thread->cancelstate == PTHREAD_CANCEL_ENABLE) if (thread->cancelstate == PTHREAD_CANCEL_ENABLE)
{ {
#if 0 #if 0
/* once all the functions call testcancel(), we will do this */ /* once all the functions call testcancel (), we will do this */
if (thread->canceltype == PTHREAD_CANCEL_DEFERRED) if (thread->canceltype == PTHREAD_CANCEL_DEFERRED)
{ {
} }
@ -865,176 +866,176 @@ __pthread_cancel (pthread_t thread)
return ESRCH; return ESRCH;
/* /*
we return ESRCH until all the required functions call testcancel(); we return ESRCH until all the required functions call testcancel ();
this will give applications predictable behaviour. this will give applications predictable behaviour.
the required function list is: * indicates done, X indicates not present in cygwin. the required function list is: * indicates done, X indicates not present in cygwin.
aio_suspend() aio_suspend ()
*close() *close ()
*creat() *creat ()
fcntl() fcntl ()
fsync() fsync ()
getmsg() getmsg ()
getpmsg() getpmsg ()
lockf() lockf ()
mq_receive() mq_receive ()
mq_send() mq_send ()
msgrcv() msgrcv ()
msgsnd() msgsnd ()
msync() msync ()
nanosleep() nanosleep ()
open() open ()
pause() pause ()
poll() poll ()
pread() pread ()
pthread_cond_timedwait() pthread_cond_timedwait ()
pthread_cond_wait() pthread_cond_wait ()
*pthread_join() *pthread_join ()
pthread_testcancel() pthread_testcancel ()
putmsg() putmsg ()
putpmsg() putpmsg ()
pwrite() pwrite ()
read() read ()
readv() readv ()
select() select ()
sem_wait() sem_wait ()
sigpause() sigpause ()
sigsuspend() sigsuspend ()
sigtimedwait() sigtimedwait ()
sigwait() sigwait ()
sigwaitinfo() sigwaitinfo ()
*sleep() *sleep ()
system() system ()
tcdrain() tcdrain ()
*usleep() *usleep ()
wait() wait ()
wait3() wait3()
waitid() waitid ()
waitpid() waitpid ()
write() write ()
writev() writev ()
the optional list is: the optional list is:
catclose() catclose ()
catgets() catgets ()
catopen() catopen ()
closedir() closedir ()
closelog() closelog ()
ctermid() ctermid ()
dbm_close() dbm_close ()
dbm_delete() dbm_delete ()
dbm_fetch() dbm_fetch ()
dbm_nextkey() dbm_nextkey ()
dbm_open() dbm_open ()
dbm_store() dbm_store ()
dlclose() dlclose ()
dlopen() dlopen ()
endgrent() endgrent ()
endpwent() endpwent ()
endutxent() endutxent ()
fclose() fclose ()
fcntl() fcntl ()
fflush() fflush ()
fgetc() fgetc ()
fgetpos() fgetpos ()
fgets() fgets ()
fgetwc() fgetwc ()
fgetws() fgetws ()
fopen() fopen ()
fprintf() fprintf ()
fputc() fputc ()
fputs() fputs ()
fputwc() fputwc ()
fputws() fputws ()
fread() fread ()
freopen() freopen ()
fscanf() fscanf ()
fseek() fseek ()
fseeko() fseeko ()
fsetpos() fsetpos ()
ftell() ftell ()
ftello() ftello ()
ftw() ftw ()
fwprintf() fwprintf ()
fwrite() fwrite ()
fwscanf() fwscanf ()
getc() getc ()
getc_unlocked() getc_unlocked ()
getchar() getchar ()
getchar_unlocked() getchar_unlocked ()
getcwd() getcwd ()
getdate() getdate ()
getgrent() getgrent ()
getgrgid() getgrgid ()
getgrgid_r() getgrgid_r ()
getgrnam() getgrnam ()
getgrnam_r() getgrnam_r ()
getlogin() getlogin ()
getlogin_r() getlogin_r ()
getpwent() getpwent ()
* getpwnam() * getpwnam ()
* getpwnam_r() * getpwnam_r ()
* getpwuid() * getpwuid ()
* getpwuid_r() * getpwuid_r ()
gets() gets ()
getutxent() getutxent ()
getutxid() getutxid ()
getutxline() getutxline ()
getw() getw ()
getwc() getwc ()
getwchar() getwchar ()
getwd() getwd ()
glob() glob ()
iconv_close() iconv_close ()
iconv_open() iconv_open ()
ioctl() ioctl ()
lseek() lseek ()
mkstemp() mkstemp ()
nftw() nftw ()
opendir() opendir ()
openlog() openlog ()
pclose() pclose ()
perror() perror ()
popen() popen ()
printf() printf ()
putc() putc ()
putc_unlocked() putc_unlocked ()
putchar() putchar ()
putchar_unlocked() putchar_unlocked ()
puts() puts ()
pututxline() pututxline ()
putw() putw ()
putwc() putwc ()
putwchar() putwchar ()
readdir() readdir ()
readdir_r() readdir_r ()
remove() remove ()
rename() rename ()
rewind() rewind ()
rewinddir() rewinddir ()
scanf() scanf ()
seekdir() seekdir ()
semop() semop ()
setgrent() setgrent ()
setpwent() setpwent ()
setutxent() setutxent ()
strerror() strerror ()
syslog() syslog ()
tmpfile() tmpfile ()
tmpnam() tmpnam ()
ttyname() ttyname ()
ttyname_r() ttyname_r ()
ungetc() ungetc ()
ungetwc() ungetwc ()
unlink() unlink ()
vfprintf() vfprintf ()
vfwprintf() vfwprintf ()
vprintf() vprintf ()
vwprintf() vwprintf ()
wprintf() wprintf ()
wscanf() wscanf ()
Note, that for fcntl(), for any value of the cmd argument. Note, that for fcntl (), for any value of the cmd argument.
And we must not introduce cancellation points anywhere else that's part of the posix or And we must not introduce cancellation points anywhere else that's part of the posix or
opengroup specs. opengroup specs.
@ -1094,35 +1095,35 @@ __pthread_testcancel (void)
* If yes, we're safe, if no, we're not. * If yes, we're safe, if no, we're not.
*/ */
void void
__pthread_atforkprepare(void) __pthread_atforkprepare (void)
{ {
callback *cb=MT_INTERFACE->pthread_prepare; callback *cb = MT_INTERFACE->pthread_prepare;
while (cb) while (cb)
{ {
cb->cb(); cb->cb ();
cb=cb->next; cb = cb->next;
} }
} }
void void
__pthread_atforkparent(void) __pthread_atforkparent (void)
{ {
callback *cb=MT_INTERFACE->pthread_parent; callback *cb = MT_INTERFACE->pthread_parent;
while (cb) while (cb)
{ {
cb->cb(); cb->cb ();
cb=cb->next; cb = cb->next;
} }
} }
void void
__pthread_atforkchild(void) __pthread_atforkchild (void)
{ {
callback *cb=MT_INTERFACE->pthread_child; callback *cb = MT_INTERFACE->pthread_child;
while (cb) while (cb)
{ {
cb->cb(); cb->cb ();
cb=cb->next; cb = cb->next;
} }
} }
@ -1135,9 +1136,9 @@ __pthread_atforkchild(void)
* parent and child calls are called in FI-FC order. * parent and child calls are called in FI-FC order.
*/ */
int 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; callback * prepcb = NULL, * parentcb = NULL, * childcb = NULL;
if (prepare) if (prepare)
{ {
prepcb = new callback; prepcb = new callback;
@ -1170,7 +1171,7 @@ __pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void
if (prepcb) if (prepcb)
{ {
prepcb->cb = prepare; prepcb->cb = prepare;
prepcb->next=(callback *)InterlockedExchangePointer((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb); prepcb->next=(callback *)InterlockedExchangePointer ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
} }
if (parentcb) if (parentcb)
{ {
@ -1179,7 +1180,7 @@ __pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void
while (*t) while (*t)
t = &(*t)->next; t = &(*t)->next;
/* t = pointer to last next in the list */ /* t = pointer to last next in the list */
parentcb->next=(callback *)InterlockedExchangePointer((LONG *)t, (long int) parentcb); parentcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) parentcb);
} }
if (childcb) if (childcb)
{ {
@ -1188,7 +1189,7 @@ __pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void
while (*t) while (*t)
t = &(*t)->next; t = &(*t)->next;
/* t = pointer to last next in the list */ /* t = pointer to last next in the list */
childcb->next=(callback *)InterlockedExchangePointer((LONG *)t, (long int) childcb); childcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) childcb);
} }
return 0; return 0;
} }
@ -1356,7 +1357,7 @@ __pthread_exit (void *value_ptr)
MT_INTERFACE->destructors.IterateNull (); MT_INTERFACE->destructors.IterateNull ();
thread->return_ptr = value_ptr; thread->return_ptr = value_ptr;
if (InterlockedDecrement(&MT_INTERFACE->threadcount) == 0) if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0)
exit (0); exit (0);
else else
ExitThread (0); ExitThread (0);
@ -1383,7 +1384,7 @@ __pthread_join (pthread_t * thread, void **return_val)
*return_val = (*thread)->return_ptr; *return_val = (*thread)->return_ptr;
} /* End if */ } /* End if */
pthread_testcancel(); pthread_testcancel ();
return 0; return 0;
} }
@ -1616,12 +1617,12 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
int rv; int rv;
if (!abstime) if (!abstime)
return EINVAL; return EINVAL;
pthread_mutex **themutex=NULL; pthread_mutex **themutex = NULL;
if (*mutex == PTHREAD_MUTEX_INITIALIZER) if (*mutex == PTHREAD_MUTEX_INITIALIZER)
__pthread_mutex_init (mutex, NULL); __pthread_mutex_init (mutex, NULL);
if (( ((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE )) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared(mutex); themutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
@ -1648,12 +1649,12 @@ int
__pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex) __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
{ {
int rv; int rv;
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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE )) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared(mutex); themutex = __pthread_mutex_getpshared (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))
@ -1786,7 +1787,7 @@ 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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE )) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex // a pshared mutex
return EBUSY; return EBUSY;
if (attr && !verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC)) if (attr && !verifyable_object_isvalid (*attr, PTHREAD_MUTEXATTR_MAGIC))
@ -1798,7 +1799,7 @@ __pthread_mutex_init (pthread_mutex_t * mutex,
if (attr && (*attr)->pshared == PTHREAD_PROCESS_SHARED) if (attr && (*attr)->pshared == PTHREAD_PROCESS_SHARED)
{ {
pthread_mutex_t throwaway = new pthread_mutex (mutex, (*attr)); pthread_mutex_t throwaway = new pthread_mutex (mutex, (*attr));
mutex = __pthread_mutex_getpshared((pthread_mutex_t *)mutex); mutex = __pthread_mutex_getpshared ((pthread_mutex_t *) mutex);
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
{ {
@ -1822,12 +1823,12 @@ int
__pthread_mutex_getprioceiling (const pthread_mutex_t * mutex, __pthread_mutex_getprioceiling (const pthread_mutex_t * mutex,
int *prioceiling) int *prioceiling)
{ {
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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE )) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared((pthread_mutex_t *)mutex); themutex = __pthread_mutex_getpshared ((pthread_mutex_t *) mutex);
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
@ -1844,12 +1845,12 @@ __pthread_mutex_getprioceiling (const pthread_mutex_t * mutex,
int 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 (*mutex == PTHREAD_MUTEX_INITIALIZER)
__pthread_mutex_init (mutex, NULL); __pthread_mutex_init (mutex, NULL);
if (( ((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE ) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE)
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared(mutex); themutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
(*themutex)->Lock (); (*themutex)->Lock ();
@ -1859,12 +1860,12 @@ __pthread_mutex_lock (pthread_mutex_t * mutex)
int int
__pthread_mutex_trylock (pthread_mutex_t * mutex) __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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE ) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE)
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared(mutex); themutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
if ((*themutex)->TryLock () == WAIT_TIMEOUT) if ((*themutex)->TryLock () == WAIT_TIMEOUT)
@ -1877,9 +1878,9 @@ __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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE ) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE)
// a pshared mutex // a pshared mutex
mutex = __pthread_mutex_getpshared(mutex); mutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
(*mutex)->UnLock (); (*mutex)->UnLock ();
@ -1891,9 +1892,9 @@ __pthread_mutex_destroy (pthread_mutex_t * mutex)
{ {
if (*mutex == PTHREAD_MUTEX_INITIALIZER) if (*mutex == PTHREAD_MUTEX_INITIALIZER)
return 0; return 0;
if (( ((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE ) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE) == SYS_BASE)
// a pshared mutex // a pshared mutex
mutex = __pthread_mutex_getpshared(mutex); mutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
@ -1910,12 +1911,12 @@ int
__pthread_mutex_setprioceiling (pthread_mutex_t * mutex, int prioceiling, __pthread_mutex_setprioceiling (pthread_mutex_t * mutex, int prioceiling,
int *old_ceiling) int *old_ceiling)
{ {
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 (( ((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE )) if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
// a pshared mutex // a pshared mutex
themutex = __pthread_mutex_getpshared(mutex); themutex = __pthread_mutex_getpshared (mutex);
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC)) if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
return EINVAL; return EINVAL;
return ENOSYS; return ENOSYS;