spacing changes.
This commit is contained in:
parent
c02e9189cf
commit
3c76c0760f
@ -14,7 +14,7 @@ details. */
|
|||||||
|
|
||||||
Win32 puts some contraints on what can and cannot be implemented. Where possible
|
Win32 puts some contraints on what can and cannot be implemented. Where possible
|
||||||
we work around those contrainsts. Where we cannot work around the constraints we
|
we work around those contrainsts. Where we cannot work around the constraints we
|
||||||
either pretend to be conformant, or return an error code.
|
either pretend to be conformant, or return an error code.
|
||||||
|
|
||||||
Some caveats: PROCESS_SHARED objects while they pretend to be process shared,
|
Some caveats: PROCESS_SHARED objects while they pretend to be process shared,
|
||||||
may not actually work. Some test cases are needed to determine win32's behaviour.
|
may not actually work. Some test cases are needed to determine win32's behaviour.
|
||||||
@ -47,7 +47,7 @@ details. */
|
|||||||
|
|
||||||
extern int threadsafe;
|
extern int threadsafe;
|
||||||
|
|
||||||
/* pthread_key_destructor_list class: to-be threadsafe single linked list
|
/* pthread_key_destructor_list class: to-be threadsafe single linked list
|
||||||
* FIXME: Put me in a dedicated file, or a least a tools area !
|
* FIXME: Put me in a dedicated file, or a least a tools area !
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -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)
|
||||||
@ -486,7 +487,7 @@ pthread_key::get ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define SYS_BASE (unsigned char) 0xC0
|
#define SYS_BASE (unsigned char) 0xC0
|
||||||
// Note: the order is important. This is an overloaded pthread_mutex_t from
|
// Note: the order is important. This is an overloaded pthread_mutex_t from
|
||||||
// userland
|
// userland
|
||||||
typedef struct _pshared_mutex {
|
typedef struct _pshared_mutex {
|
||||||
unsigned char id;
|
unsigned char id;
|
||||||
@ -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
|
||||||
{
|
{
|
||||||
@ -593,7 +594,7 @@ pthread_mutex::pthread_mutex (pthread_mutexattr * attr):verifyable_object (PTHRE
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
|
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
|
||||||
|
|
||||||
if (!win32_obj_id)
|
if (!win32_obj_id)
|
||||||
magic = 0;
|
magic = 0;
|
||||||
condwaits = 0;
|
condwaits = 0;
|
||||||
@ -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,9 +640,9 @@ __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;
|
||||||
}
|
}
|
||||||
@ -815,8 +816,8 @@ __pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
|
|||||||
/* Here we must set a cancellation handler to unlock the mutex if needed */
|
/* Here we must set a cancellation handler to unlock the mutex if needed */
|
||||||
/* 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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -860,181 +861,181 @@ __pthread_cancel (pthread_t thread)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* return 0;
|
/* return 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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.
|
||||||
@ -1077,52 +1078,52 @@ __pthread_testcancel (void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Races in pthread_atfork:
|
* Races in pthread_atfork:
|
||||||
* We are race safe in that any additions to the lists are made via
|
* We are race safe in that any additions to the lists are made via
|
||||||
* InterlockedExchangePointer.
|
* InterlockedExchangePointer.
|
||||||
* However, if the user application doesn't perform syncronisation of some sort
|
* However, if the user application doesn't perform syncronisation of some sort
|
||||||
* It's not guaranteed that a near simultaneous call to pthread_atfork and fork
|
* It's not guaranteed that a near simultaneous call to pthread_atfork and fork
|
||||||
* will result in the new atfork handlers being calls.
|
* will result in the new atfork handlers being calls.
|
||||||
* More rigorous internal syncronisation isn't needed as the user program isn't
|
* More rigorous internal syncronisation isn't needed as the user program isn't
|
||||||
* guaranteeing their own state.
|
* guaranteeing their own state.
|
||||||
*
|
*
|
||||||
* as far as multiple calls to pthread_atfork, the worst case is simultaneous calls
|
* as far as multiple calls to pthread_atfork, the worst case is simultaneous calls
|
||||||
* will result in an indeterminate order for parent and child calls (what gets inserted
|
* will result in an indeterminate order for parent and child calls (what gets inserted
|
||||||
* first isn't guaranteed.)
|
* first isn't guaranteed.)
|
||||||
*
|
*
|
||||||
* There is one potential race... Does the result of InterlockedExchangePointer
|
* There is one potential race... Does the result of InterlockedExchangePointer
|
||||||
* get committed to the return location _before_ any context switches can occur?
|
* get committed to the return location _before_ any context switches can occur?
|
||||||
* 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
|
|
||||||
__pthread_atforkparent(void)
|
|
||||||
{
|
|
||||||
callback *cb=MT_INTERFACE->pthread_parent;
|
|
||||||
while (cb)
|
|
||||||
{
|
|
||||||
cb->cb();
|
|
||||||
cb=cb->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__pthread_atforkchild(void)
|
__pthread_atforkparent (void)
|
||||||
{
|
{
|
||||||
callback *cb=MT_INTERFACE->pthread_child;
|
callback *cb = MT_INTERFACE->pthread_parent;
|
||||||
while (cb)
|
while (cb)
|
||||||
{
|
{
|
||||||
cb->cb();
|
cb->cb ();
|
||||||
cb=cb->next;
|
cb = cb->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__pthread_atforkchild (void)
|
||||||
|
{
|
||||||
|
callback *cb = MT_INTERFACE->pthread_child;
|
||||||
|
while (cb)
|
||||||
|
{
|
||||||
|
cb->cb ();
|
||||||
|
cb = cb->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,14 +1131,14 @@ __pthread_atforkchild(void)
|
|||||||
*/
|
*/
|
||||||
#define InterlockedExchangePointer InterlockedExchange
|
#define InterlockedExchangePointer InterlockedExchange
|
||||||
|
|
||||||
/* Register a set of functions to run before and after fork.
|
/* Register a set of functions to run before and after fork.
|
||||||
* prepare calls are called in LI-FC order.
|
* prepare calls are called in LI-FC order.
|
||||||
* 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;
|
||||||
}
|
}
|
||||||
@ -1228,7 +1229,7 @@ __pthread_attr_getschedparam (const pthread_attr_t * attr,
|
|||||||
|
|
||||||
/* From a pure code point of view, this should call a helper in sched.cc,
|
/* From a pure code point of view, this should call a helper in sched.cc,
|
||||||
* to allow for someone adding scheduler policy changes to win32 in the future.
|
* to allow for someone adding scheduler policy changes to win32 in the future.
|
||||||
* However that's extremely unlikely, so short and sweet will do us
|
* However that's extremely unlikely, so short and sweet will do us
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
__pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
|
__pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
|
||||||
@ -1312,7 +1313,7 @@ __pthread_attr_setscope (pthread_attr_t * attr, int contentionscope)
|
|||||||
if (contentionscope != PTHREAD_SCOPE_SYSTEM
|
if (contentionscope != PTHREAD_SCOPE_SYSTEM
|
||||||
&& contentionscope != PTHREAD_SCOPE_PROCESS)
|
&& contentionscope != PTHREAD_SCOPE_PROCESS)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/* In future, we may be able to support system scope by escalating the thread
|
/* In future, we may be able to support system scope by escalating the thread
|
||||||
* priority to exceed the priority class. For now we only support PROCESS scope. */
|
* priority to exceed the priority class. For now we only support PROCESS scope. */
|
||||||
if (contentionscope != PTHREAD_SCOPE_PROCESS)
|
if (contentionscope != PTHREAD_SCOPE_PROCESS)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -1470,7 +1471,7 @@ int
|
|||||||
__pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
|
__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;
|
||||||
@ -1496,7 +1497,7 @@ __pthread_key_delete (pthread_key_t key)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* provided for source level compatability.
|
/* provided for source level compatability.
|
||||||
* See http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_getconcurrency.html
|
* See http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_getconcurrency.html
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -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,8 +1799,8 @@ __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))
|
||||||
{
|
{
|
||||||
delete throwaway;
|
delete throwaway;
|
||||||
@ -1822,19 +1823,19 @@ 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
|
||||||
* mutex priorities.
|
* mutex priorities.
|
||||||
*
|
*
|
||||||
* We can support mutex priorities in the future though:
|
* We can support mutex priorities in the future though:
|
||||||
* Store a priority with each mutex.
|
* Store a priority with each mutex.
|
||||||
* When the mutex is optained, set the thread priority as appropriate
|
* When the mutex is optained, set the thread priority as appropriate
|
||||||
* When the mutex is released, reset the thre priority.
|
* When the mutex is released, reset the thre priority.
|
||||||
*/
|
*/
|
||||||
@ -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,18 +1911,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Win32 doesn't support mutex priorities - see __pthread_mutex_getprioceiling
|
/* Win32 doesn't support mutex priorities - see __pthread_mutex_getprioceiling
|
||||||
* for more detail */
|
* for more detail */
|
||||||
int
|
int
|
||||||
__pthread_mutexattr_getprotocol (const pthread_mutexattr_t * attr,
|
__pthread_mutexattr_getprotocol (const pthread_mutexattr_t * attr,
|
||||||
@ -1942,8 +1943,8 @@ __pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Win32 mutex's are equivalent to posix RECURSIVE mutexs.
|
/* Win32 mutex's are equivalent to posix RECURSIVE mutexs.
|
||||||
* We need to put glue in place to support other types of mutex's. We map
|
* We need to put glue in place to support other types of mutex's. We map
|
||||||
* PTHREAD_MUTEX_DEFAULT to PTHREAD_MUTEX_RECURSIVE and return EINVAL for other types.
|
* PTHREAD_MUTEX_DEFAULT to PTHREAD_MUTEX_RECURSIVE and return EINVAL for other types.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -2020,8 +2021,8 @@ __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
|
||||||
*/
|
*/
|
||||||
if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
|
if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user