summaryrefslogtreecommitdiff
path: root/libpthread/pthread.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-01-06 08:56:53 +0000
committerEric Andersen <andersen@codepoet.org>2002-01-06 08:56:53 +0000
commit799217d26e5aa1a4eecfc94550736440c27f737b (patch)
tree581def60b67ebf1b2f56e82513872a584f5d695d /libpthread/pthread.c
parente077f341ca5758360b4c050c493a1d81b06c72a0 (diff)
Fix formatting. Stub out pthread_join and pthread_exit for now.
-Erik
Diffstat (limited to 'libpthread/pthread.c')
-rw-r--r--libpthread/pthread.c65
1 files changed, 40 insertions, 25 deletions
diff --git a/libpthread/pthread.c b/libpthread/pthread.c
index 1b0773c2c..d3eb13961 100644
--- a/libpthread/pthread.c
+++ b/libpthread/pthread.c
@@ -46,9 +46,9 @@ int pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutex
int pthread_mutex_lock (pthread_mutex_t *mutex)
{
while (mutex->__m_lock.__spinlock == 0) {
- usleep(10000);
- }
- --(mutex->__m_lock.__spinlock);
+ usleep(10000);
+ }
+ --(mutex->__m_lock.__spinlock);
return 0;
}
@@ -60,11 +60,11 @@ int pthread_mutex_unlock (pthread_mutex_t *mutex)
int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
{
- ++(mutex->__m_lock.__spinlock);
- while (cond->__c_lock.__spinlock == 0) {
- usleep(10000);
- }
- --(cond->__c_lock.__spinlock);
+ ++(mutex->__m_lock.__spinlock);
+ while (cond->__c_lock.__spinlock == 0) {
+ usleep(10000);
+ }
+ --(cond->__c_lock.__spinlock);
return 0;
}
@@ -82,25 +82,40 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr)
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void* (*fn)(void *), void *data)
{
- long retval;
- void **newstack;
+ long retval;
+ void **newstack;
int (*clonefunc)(void *) = (int (*)(void *))(fn);
- newstack = (void **) malloc(STACKSIZE);
- if (!newstack)
- return -1;
- newstack = (void **) (STACKSIZE + (char *) newstack);
- *--newstack = data;
- retval = clone(clonefunc, newstack,
+ newstack = (void **) malloc(STACKSIZE);
+ if (!newstack)
+ return -1;
+ newstack = (void **) (STACKSIZE + (char *) newstack);
+ *--newstack = data;
+ retval = clone(clonefunc, newstack,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD, data);
- if (retval < 0) {
- errno = -retval;
- *thread = 0;
- retval = -1;
- } else {
- *thread = retval;
- retval = 0;
- }
- return retval;
+ if (retval < 0) {
+ errno = -retval;
+ *thread = 0;
+ retval = -1;
+ } else {
+ *thread = retval;
+ retval = 0;
+ }
+ return retval;
+}
+
+int pthread_join (pthread_t thread, void **thread_return)
+{
+ int retval;
+ /* Fixme -- wait for thread and get its return value */
+ retval = EXIT_SUCCESS;
+ if (thread_return)
+ *thread_return = retval;
+ _exit(retval);
}
+link_warning(pthread_join, "pthread_join is a stub and does not behave properly");
+void pthread_exit (void *retval)
+{
+ _exit(retval);
+}