1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-01 08:27:59 +00:00

Enable static initialisation of mutexes and condition variables.

This commit is contained in:
John Birrell 1998-04-04 11:33:01 +00:00
parent 5a2f1fed77
commit 883674371e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35027
6 changed files with 96 additions and 24 deletions

View File

@ -134,9 +134,15 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -189,9 +195,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);

View File

@ -162,9 +162,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -224,9 +230,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);

View File

@ -134,9 +134,15 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -189,9 +195,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);

View File

@ -162,9 +162,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -224,9 +230,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);

View File

@ -134,9 +134,15 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -189,9 +195,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
if (cond == NULL || *cond == NULL) {
if (cond == NULL)
rval = EINVAL;
} else {
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
else if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);

View File

@ -162,9 +162,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@ -224,9 +230,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
int ret = 0;
int status;
if (mutex == NULL || *mutex == NULL) {
if (mutex == NULL)
ret = EINVAL;
} else {
/*
* If the mutex is statically initialized, perform the dynamic
* initialization:
*/
else if (*mutex != NULL ||
(ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);