diff options
author | alex <alex@FreeBSD.org> | 1997-11-25 01:29:16 +0000 |
---|---|---|
committer | alex <alex@FreeBSD.org> | 1997-11-25 01:29:16 +0000 |
commit | 2d792e656e2819795c575a1abeb8dc54e2357484 (patch) | |
tree | afcf53c94eef7b38ab83072ef9f8a80651b0230d /lib/libkse/thread | |
parent | 674aa81547dfa76c24a1a45b5acb9119cab75311 (diff) | |
download | FreeBSD-src-2d792e656e2819795c575a1abeb8dc54e2357484.zip FreeBSD-src-2d792e656e2819795c575a1abeb8dc54e2357484.tar.gz |
Modify the return values to comply with POSIX. Previously these
functions would return -1 and set errno to indicate the specific error.
POSIX requires that the functions return the error code as the return
value of the function instead.
Diffstat (limited to 'lib/libkse/thread')
-rw-r--r-- | lib/libkse/thread/thr_cond.c | 39 | ||||
-rw-r--r-- | lib/libkse/thread/thr_condattr_destroy.c | 3 | ||||
-rw-r--r-- | lib/libkse/thread/thr_condattr_init.c | 3 | ||||
-rw-r--r-- | lib/libkse/thread/thr_detach.c | 6 | ||||
-rw-r--r-- | lib/libkse/thread/thr_join.c | 9 | ||||
-rw-r--r-- | lib/libkse/thread/thr_mattr_init.c | 3 | ||||
-rw-r--r-- | lib/libkse/thread/thr_mutex.c | 48 | ||||
-rw-r--r-- | lib/libkse/thread/thr_mutexattr_destroy.c | 3 | ||||
-rw-r--r-- | lib/libkse/thread/thr_spec.c | 1 |
9 files changed, 38 insertions, 77 deletions
diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c index 1f95a2a..978ad04 100644 --- a/lib/libkse/thread/thr_cond.c +++ b/lib/libkse/thread/thr_cond.c @@ -44,8 +44,7 @@ pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) int rval = 0; if (cond == NULL) { - errno = EINVAL; - rval = -1; + rval = EINVAL; } else { /* * Check if a pointer to a condition variable attribute @@ -69,8 +68,7 @@ pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } @@ -78,8 +76,7 @@ pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) if (rval == 0) { if ((pcond = (pthread_cond_t) malloc(sizeof(struct pthread_cond))) == NULL) { - errno = ENOMEM; - rval = -1; + rval = ENOMEM; } else { /* * Initialise the condition variable @@ -102,8 +99,7 @@ pthread_cond_destroy(pthread_cond_t * cond) int rval = 0; if (cond == NULL || *cond == NULL) { - errno = EINVAL; - rval = -1; + rval = EINVAL; } else { /* Process according to condition variable type: */ switch ((*cond)->c_type) { @@ -115,8 +111,7 @@ pthread_cond_destroy(pthread_cond_t * cond) /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } @@ -140,8 +135,7 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) int status; if (cond == NULL || *cond == NULL) { - errno = EINVAL; - rval = -1; + rval = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -176,8 +170,7 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } @@ -197,8 +190,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, int status; if (cond == NULL || *cond == NULL) { - errno = EINVAL; - rval = -1; + rval = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -242,8 +234,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* Check if the wait timed out: */ else if (_thread_run->timeout) { /* Return a timeout error: */ - errno = ETIMEDOUT; - rval = -1; + rval = ETIMEDOUT; } } break; @@ -251,8 +242,7 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } @@ -272,8 +262,7 @@ pthread_cond_signal(pthread_cond_t * cond) pthread_t pthread; if (cond == NULL || *cond == NULL) { - errno = EINVAL; - rval = -1; + rval = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -292,8 +281,7 @@ pthread_cond_signal(pthread_cond_t * cond) /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } @@ -333,8 +321,7 @@ pthread_cond_broadcast(pthread_cond_t * cond) /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; break; } diff --git a/lib/libkse/thread/thr_condattr_destroy.c b/lib/libkse/thread/thr_condattr_destroy.c index b20f183..4179970 100644 --- a/lib/libkse/thread/thr_condattr_destroy.c +++ b/lib/libkse/thread/thr_condattr_destroy.c @@ -40,8 +40,7 @@ int pthread_condattr_destroy(pthread_condattr_t *attr) { int ret; if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { free(*attr); *attr = NULL; diff --git a/lib/libkse/thread/thr_condattr_init.c b/lib/libkse/thread/thr_condattr_init.c index f94e438..c87323d 100644 --- a/lib/libkse/thread/thr_condattr_init.c +++ b/lib/libkse/thread/thr_condattr_init.c @@ -45,8 +45,7 @@ pthread_condattr_init(pthread_condattr_t *attr) if ((pattr = (pthread_condattr_t) malloc(sizeof(struct pthread_cond_attr))) == NULL) { - errno = ENOMEM; - ret = -1; + ret = ENOMEM; } else { memcpy(pattr, &pthread_condattr_default, sizeof(struct pthread_cond_attr)); diff --git a/lib/libkse/thread/thr_detach.c b/lib/libkse/thread/thr_detach.c index 08cace4..c8f312c 100644 --- a/lib/libkse/thread/thr_detach.c +++ b/lib/libkse/thread/thr_detach.c @@ -49,8 +49,7 @@ pthread_detach(pthread_t * p_pthread) /* Check for invalid calling parameters: */ if (p_pthread == NULL || (pthread = *p_pthread) == NULL) { /* Return an invalid argument error: */ - errno = EINVAL; - rval = -1; + rval = EINVAL; } /* Check if the thread has not been detached: */ else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { @@ -70,8 +69,7 @@ pthread_detach(pthread_t * p_pthread) *p_pthread = NULL; } else { /* Return an error: */ - errno = ESRCH; - rval = -1; + rval = ESRCH; } /* Unblock signals: */ diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c index 161482e..63d0d58 100644 --- a/lib/libkse/thread/thr_join.c +++ b/lib/libkse/thread/thr_join.c @@ -67,14 +67,12 @@ pthread_join(pthread_t pthread, void **thread_return) if (pthread1 == NULL) { /* Return an error: */ - errno = ESRCH; - rval = -1; + rval = ESRCH; /* Check if this thread has been detached: */ } else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) { /* Return an error: */ - errno = ESRCH; - rval = -1; + rval = ESRCH; } /* Check if the thread is not dead: */ else if (pthread->state != PS_DEAD) { @@ -96,8 +94,7 @@ pthread_join(pthread_t pthread, void **thread_return) } } else { /* Return an error: */ - errno = ESRCH; - rval = -1; + rval = ESRCH; } } else { /* Check if the return value is required: */ diff --git a/lib/libkse/thread/thr_mattr_init.c b/lib/libkse/thread/thr_mattr_init.c index 323c982..73226a6 100644 --- a/lib/libkse/thread/thr_mattr_init.c +++ b/lib/libkse/thread/thr_mattr_init.c @@ -45,8 +45,7 @@ pthread_mutexattr_init(pthread_mutexattr_t *attr) if ((pattr = (pthread_mutexattr_t) malloc(sizeof(struct pthread_mutex_attr))) == NULL) { - errno = ENOMEM; - ret = -1; + ret = ENOMEM; } else { memcpy(pattr, &pthread_mutexattr_default, sizeof(struct pthread_mutex_attr)); diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c index 82a26e8..e6be6de 100644 --- a/lib/libkse/thread/thr_mutex.c +++ b/lib/libkse/thread/thr_mutex.c @@ -46,8 +46,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, int status; if (mutex == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Check if default mutex attributes: */ if (mutex_attr == NULL || *mutex_attr == NULL) { @@ -55,8 +54,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, type = MUTEX_TYPE_FAST; } else if ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX) { /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Use the requested mutex type: */ type = (*mutex_attr)->m_type; @@ -65,8 +63,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, /* Check no errors so far: */ if (ret == 0) { if ((pmutex = (pthread_mutex_t) malloc(sizeof(struct pthread_mutex))) == NULL) { - errno = ENOMEM; - ret = -1; + ret = ENOMEM; } else { /* Reset the mutex flags: */ pmutex->m_flags = 0; @@ -90,8 +87,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, /* Trap invalid mutex types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } if (ret == 0) { @@ -122,8 +118,7 @@ pthread_mutex_destroy(pthread_mutex_t * mutex) int status; if (mutex == NULL || *mutex == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -144,8 +139,7 @@ pthread_mutex_destroy(pthread_mutex_t * mutex) /* Trap undefined mutex types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } @@ -169,8 +163,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) int status; if (mutex == NULL || *mutex == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -185,8 +178,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) (*mutex)->m_owner = _thread_run; } else { /* Return a busy error: */ - errno = EBUSY; - ret = -1; + ret = EBUSY; } break; @@ -203,8 +195,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) (*mutex)->m_data.m_count++; } else { /* Return a busy error: */ - errno = EBUSY; - ret = -1; + ret = EBUSY; } } else { /* Lock the mutex for the running thread: */ @@ -215,8 +206,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) /* Trap invalid mutex types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } @@ -235,8 +225,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex) int status; if (mutex == NULL || *mutex == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -306,8 +295,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex) /* Trap invalid mutex types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } @@ -326,8 +314,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) int status; if (mutex == NULL || *mutex == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { /* Block signals: */ _thread_kern_sig_block(&status); @@ -339,8 +326,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) /* Check if the running thread is not the owner of the mutex: */ if ((*mutex)->m_owner != _thread_run) { /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; } /* * Get the next thread from the queue of threads waiting on @@ -357,8 +343,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) /* Check if the running thread is not the owner of the mutex: */ if ((*mutex)->m_owner != _thread_run) { /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; } /* Check if there are still counts: */ else if ((*mutex)->m_data.m_count) { @@ -378,8 +363,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) /* Trap invalid mutex types: */ default: /* Return an invalid argument error: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } diff --git a/lib/libkse/thread/thr_mutexattr_destroy.c b/lib/libkse/thread/thr_mutexattr_destroy.c index cf2e09f..5642cbe 100644 --- a/lib/libkse/thread/thr_mutexattr_destroy.c +++ b/lib/libkse/thread/thr_mutexattr_destroy.c @@ -40,8 +40,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { int ret; if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; + ret = EINVAL; } else { free(*attr); *attr = NULL; diff --git a/lib/libkse/thread/thr_spec.c b/lib/libkse/thread/thr_spec.c index 8d06c52..7ff9054 100644 --- a/lib/libkse/thread/thr_spec.c +++ b/lib/libkse/thread/thr_spec.c @@ -209,7 +209,6 @@ pthread_getspecific(pthread_key_t key) /* Check for errors: */ if (pthread == NULL) { /* Return an invalid argument error: */ - errno = EINVAL; data = NULL; } /* Check if there is specific data: */ |