From 30ad5a705dad5ac4ccae99cbd00c1a05863de4de Mon Sep 17 00:00:00 2001 From: "\"Steven J. Hill\"" Date: Tue, 4 Oct 2005 00:05:37 +0000 Subject: Neaten up the libpthread directory. --- libpthread/README.NPTL | 307 --------------------------- libpthread/linuxthreads/pthread.c-OLDEXAMPLE | 121 +++++++++++ libpthread/pthread.c | 121 ----------- 3 files changed, 121 insertions(+), 428 deletions(-) delete mode 100644 libpthread/README.NPTL create mode 100644 libpthread/linuxthreads/pthread.c-OLDEXAMPLE delete mode 100644 libpthread/pthread.c (limited to 'libpthread') diff --git a/libpthread/README.NPTL b/libpthread/README.NPTL deleted file mode 100644 index 7e50984cb..000000000 --- a/libpthread/README.NPTL +++ /dev/null @@ -1,307 +0,0 @@ -The base NPTL code for uClibc is from the glibc project located at -. The starting version was the HEAD of -the glibc CVS repository dated 2005-05-06. Important changes from -glibc will continue to be brought in as necessary until the version -for uClibc is standing on its own. All of the files were originally -brought over verbatim with no modifications. Obviously, these will -undergo any necessary changes needed for integration into uClibc. -Additionally (or subtractingly), the files and directories below -were removed and not imported. - --- Steven J. Hill on 2005-05-06 - - -nptl/Makeconfig -nptl/configure -nptl/shlib-versions -nptl/sysdeps/generic -nptl/sysdeps/ia64 -nptl/sysdeps/pthread/Makefile -nptl/sysdeps/pthread/Subdirs -nptl/sysdeps/pthread/allocalim.h -nptl/sysdeps/pthread/configure -nptl/sysdeps/pthread/configure.in -nptl/sysdeps/pthread/createthread.c -nptl/sysdeps/pthread/flockfile.c -nptl/sysdeps/pthread/ftrylockfile.c -nptl/sysdeps/pthread/funlockfile.c -nptl/sysdeps/pthread/librt-cancellation.c -nptl/sysdeps/pthread/list.h -nptl/sysdeps/pthread/malloc-machine.h -nptl/sysdeps/pthread/posix-timer.h -nptl/sysdeps/pthread/pt-initfini.c -nptl/sysdeps/pthread/pt-longjmp.c -nptl/sysdeps/pthread/pthread-functions.h -nptl/sysdeps/pthread/pthread.h -nptl/sysdeps/pthread/pthread_barrier_wait.c -nptl/sysdeps/pthread/pthread_cond_broadcast.c -nptl/sysdeps/pthread/pthread_cond_signal.c -nptl/sysdeps/pthread/pthread_cond_timedwait.c -nptl/sysdeps/pthread/pthread_cond_wait.c -nptl/sysdeps/pthread/pthread_getcpuclockid.c -nptl/sysdeps/pthread/pthread_once.c -nptl/sysdeps/pthread/pthread_rwlock_rdlock.c -nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c -nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c -nptl/sysdeps/pthread/pthread_rwlock_unlock.c -nptl/sysdeps/pthread/pthread_rwlock_wrlock.c -nptl/sysdeps/pthread/pthread_sigmask.c -nptl/sysdeps/pthread/pthread_spin_destroy.c -nptl/sysdeps/pthread/pthread_spin_init.c -nptl/sysdeps/pthread/pthread_spin_unlock.c -nptl/sysdeps/pthread/rt-unwind-resume.c -nptl/sysdeps/pthread/setxid.h -nptl/sysdeps/pthread/sigaction.c -nptl/sysdeps/pthread/sigfillset.c -nptl/sysdeps/pthread/sigprocmask.c -nptl/sysdeps/pthread/tcb-offsets.h -nptl/sysdeps/pthread/timer_create.c -nptl/sysdeps/pthread/timer_delete.c -nptl/sysdeps/pthread/timer_getoverr.c -nptl/sysdeps/pthread/timer_gettime.c -nptl/sysdeps/pthread/timer_routines.c -nptl/sysdeps/pthread/timer_settime.c -nptl/sysdeps/pthread/tst-mqueue8x.c -nptl/sysdeps/pthread/tst-timer.c -nptl/sysdeps/pthread/unwind-forcedunwind.c -nptl/sysdeps/pthread/unwind-resume.c -nptl/sysdeps/s390 -nptl/sysdeps/unix -nptl/tst-_res1.c -nptl/tst-_res1mod1.c -nptl/tst-_res1mod2.c -nptl/tst-align.c -nptl/tst-align2.c -nptl/tst-atfork1.c -nptl/tst-atfork2.c -nptl/tst-atfork2mod.c -nptl/tst-attr1.c -nptl/tst-attr2.c -nptl/tst-attr3.c -nptl/tst-backtrace1.c -nptl/tst-barrier1.c -nptl/tst-barrier2.c -nptl/tst-barrier3.c -nptl/tst-barrier4.c -nptl/tst-basic1.c -nptl/tst-basic2.c -nptl/tst-basic3.c -nptl/tst-basic4.c -nptl/tst-basic5.c -nptl/tst-basic6.c -nptl/tst-cancel-wrappers.sh -nptl/tst-cancel1.c -nptl/tst-cancel10.c -nptl/tst-cancel11.c -nptl/tst-cancel12.c -nptl/tst-cancel13.c -nptl/tst-cancel14.c -nptl/tst-cancel15.c -nptl/tst-cancel16.c -nptl/tst-cancel17.c -nptl/tst-cancel18.c -nptl/tst-cancel19.c -nptl/tst-cancel2.c -nptl/tst-cancel20.c -nptl/tst-cancel21.c -nptl/tst-cancel22.c -nptl/tst-cancel23.c -nptl/tst-cancel3.c -nptl/tst-cancel4.c -nptl/tst-cancel5.c -nptl/tst-cancel6.c -nptl/tst-cancel7.c -nptl/tst-cancel8.c -nptl/tst-cancel9.c -nptl/tst-cancelx1.c -nptl/tst-cancelx10.c -nptl/tst-cancelx11.c -nptl/tst-cancelx12.c -nptl/tst-cancelx13.c -nptl/tst-cancelx14.c -nptl/tst-cancelx15.c -nptl/tst-cancelx16.c -nptl/tst-cancelx17.c -nptl/tst-cancelx18.c -nptl/tst-cancelx2.c -nptl/tst-cancelx20.c -nptl/tst-cancelx21.c -nptl/tst-cancelx3.c -nptl/tst-cancelx4.c -nptl/tst-cancelx5.c -nptl/tst-cancelx6.c -nptl/tst-cancelx7.c -nptl/tst-cancelx8.c -nptl/tst-cancelx9.c -nptl/tst-cleanup0.c -nptl/tst-cleanup0.expect -nptl/tst-cleanup1.c -nptl/tst-cleanup2.c -nptl/tst-cleanup3.c -nptl/tst-cleanup4.c -nptl/tst-cleanup4aux.c -nptl/tst-cleanupx0.c -nptl/tst-cleanupx0.expect -nptl/tst-cleanupx1.c -nptl/tst-cleanupx2.c -nptl/tst-cleanupx3.c -nptl/tst-cleanupx4.c -nptl/tst-clock1.c -nptl/tst-clock2.c -nptl/tst-cond1.c -nptl/tst-cond10.c -nptl/tst-cond11.c -nptl/tst-cond12.c -nptl/tst-cond13.c -nptl/tst-cond14.c -nptl/tst-cond15.c -nptl/tst-cond16.c -nptl/tst-cond17.c -nptl/tst-cond18.c -nptl/tst-cond19.c -nptl/tst-cond2.c -nptl/tst-cond20.c -nptl/tst-cond21.c -nptl/tst-cond3.c -nptl/tst-cond4.c -nptl/tst-cond5.c -nptl/tst-cond6.c -nptl/tst-cond7.c -nptl/tst-cond8.c -nptl/tst-cond9.c -nptl/tst-context1.c -nptl/tst-detach1.c -nptl/tst-dlsym1.c -nptl/tst-eintr1.c -nptl/tst-eintr2.c -nptl/tst-eintr3.c -nptl/tst-eintr4.c -nptl/tst-eintr5.c -nptl/tst-exec1.c -nptl/tst-exec2.c -nptl/tst-exec3.c -nptl/tst-exec4.c -nptl/tst-execstack-mod.c -nptl/tst-execstack.c -nptl/tst-exit1.c -nptl/tst-exit2.c -nptl/tst-exit3.c -nptl/tst-fini1.c -nptl/tst-fini1mod.c -nptl/tst-flock1.c -nptl/tst-flock2.c -nptl/tst-fork1.c -nptl/tst-fork2.c -nptl/tst-fork3.c -nptl/tst-fork4.c -nptl/tst-getpid1.c -nptl/tst-getpid2.c -nptl/tst-join1.c -nptl/tst-join2.c -nptl/tst-join3.c -nptl/tst-join4.c -nptl/tst-join5.c -nptl/tst-key1.c -nptl/tst-key2.c -nptl/tst-key3.c -nptl/tst-key4.c -nptl/tst-kill1.c -nptl/tst-kill2.c -nptl/tst-kill3.c -nptl/tst-kill4.c -nptl/tst-kill5.c -nptl/tst-kill6.c -nptl/tst-locale1.c -nptl/tst-locale2.c -nptl/tst-mutex1.c -nptl/tst-mutex2.c -nptl/tst-mutex3.c -nptl/tst-mutex4.c -nptl/tst-mutex5.c -nptl/tst-mutex5a.c -nptl/tst-mutex6.c -nptl/tst-mutex7.c -nptl/tst-mutex7a.c -nptl/tst-mutex8.c -nptl/tst-mutex9.c -nptl/tst-oddstacklimit.c -nptl/tst-once1.c -nptl/tst-once2.c -nptl/tst-once3.c -nptl/tst-once4.c -nptl/tst-oncex3.c -nptl/tst-oncex4.c -nptl/tst-popen1.c -nptl/tst-raise1.c -nptl/tst-rwlock1.c -nptl/tst-rwlock10.c -nptl/tst-rwlock11.c -nptl/tst-rwlock12.c -nptl/tst-rwlock13.c -nptl/tst-rwlock14.c -nptl/tst-rwlock2.c -nptl/tst-rwlock3.c -nptl/tst-rwlock4.c -nptl/tst-rwlock5.c -nptl/tst-rwlock6.c -nptl/tst-rwlock7.c -nptl/tst-rwlock8.c -nptl/tst-rwlock9.c -nptl/tst-sched1.c -nptl/tst-sem1.c -nptl/tst-sem2.c -nptl/tst-sem3.c -nptl/tst-sem4.c -nptl/tst-sem5.c -nptl/tst-sem6.c -nptl/tst-sem7.c -nptl/tst-sem8.c -nptl/tst-sem9.c -nptl/tst-setuid1-static.c -nptl/tst-setuid1.c -nptl/tst-signal1.c -nptl/tst-signal2.c -nptl/tst-signal3.c -nptl/tst-signal4.c -nptl/tst-signal5.c -nptl/tst-signal6.c -nptl/tst-spin1.c -nptl/tst-spin2.c -nptl/tst-spin3.c -nptl/tst-stack1.c -nptl/tst-stack2.c -nptl/tst-stack3.c -nptl/tst-stdio1.c -nptl/tst-stdio2.c -nptl/tst-sysconf.c -nptl/tst-tls1.c -nptl/tst-tls2.c -nptl/tst-tls3.c -nptl/tst-tls3mod.c -nptl/tst-tls4.c -nptl/tst-tls4moda.c -nptl/tst-tls4modb.c -nptl/tst-tls5.c -nptl/tst-tls5.h -nptl/tst-tls5mod.c -nptl/tst-tls5moda.c -nptl/tst-tls5modb.c -nptl/tst-tls5modc.c -nptl/tst-tls5modd.c -nptl/tst-tls5mode.c -nptl/tst-tls5modf.c -nptl/tst-tls6.sh -nptl/tst-tsd1.c -nptl/tst-tsd2.c -nptl/tst-tsd3.c -nptl/tst-tsd4.c -nptl/tst-tsd5.c -nptl/tst-umask1.c -nptl/tst-unload.c -nptl/tst-vfork1.c -nptl/tst-vfork1x.c -nptl/tst-vfork2.c -nptl/tst-vfork2x.c -nptl/version.c -nptl_db/ChangeLog -nptl_db/shlib-versions diff --git a/libpthread/linuxthreads/pthread.c-OLDEXAMPLE b/libpthread/linuxthreads/pthread.c-OLDEXAMPLE new file mode 100644 index 000000000..88b163087 --- /dev/null +++ b/libpthread/linuxthreads/pthread.c-OLDEXAMPLE @@ -0,0 +1,121 @@ +/* vi: set sw=4 ts=4: */ +/* + * A _very_ simple clone based pthread-like implementation + * + * Copyright (C) 2001,2002 by Erik Andersen + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License + * for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include + +#define STACKSIZE 8096 + +#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ +#define CLONE_VM 0x00000100 /* set if VM shared between processes */ +#define CLONE_FS 0x00000200 /* set if fs info shared between proces ses */ +#define CLONE_FILES 0x00000400 /* set if open files shared between pro cesses */ +#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */ + + + +/* Lame home-grown clone based threading */ +int pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutex_attr) +{ + mutex->__m_lock.__spinlock = 1; + return 0; +} + +int pthread_mutex_lock (pthread_mutex_t *mutex) +{ + while (mutex->__m_lock.__spinlock == 0) { + usleep(10000); + } + --(mutex->__m_lock.__spinlock); + return 0; +} + +int pthread_mutex_unlock (pthread_mutex_t *mutex) +{ + ++(mutex->__m_lock.__spinlock); + return 0; +} + +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); + return 0; +} + +int pthread_cond_signal(pthread_cond_t *cond) +{ + ++(cond->__c_lock.__spinlock); + return 0; +} + +int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr) +{ + cond->__c_lock.__spinlock = 1; + return 0; +} + +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void* (*fn)(void *), void *data) +{ + 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, + 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; +} + +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) + (int)*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(*(int *)retval); +} diff --git a/libpthread/pthread.c b/libpthread/pthread.c deleted file mode 100644 index 88b163087..000000000 --- a/libpthread/pthread.c +++ /dev/null @@ -1,121 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * A _very_ simple clone based pthread-like implementation - * - * Copyright (C) 2001,2002 by Erik Andersen - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License - * for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#define STACKSIZE 8096 - -#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ -#define CLONE_VM 0x00000100 /* set if VM shared between processes */ -#define CLONE_FS 0x00000200 /* set if fs info shared between proces ses */ -#define CLONE_FILES 0x00000400 /* set if open files shared between pro cesses */ -#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */ - - - -/* Lame home-grown clone based threading */ -int pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutex_attr) -{ - mutex->__m_lock.__spinlock = 1; - return 0; -} - -int pthread_mutex_lock (pthread_mutex_t *mutex) -{ - while (mutex->__m_lock.__spinlock == 0) { - usleep(10000); - } - --(mutex->__m_lock.__spinlock); - return 0; -} - -int pthread_mutex_unlock (pthread_mutex_t *mutex) -{ - ++(mutex->__m_lock.__spinlock); - return 0; -} - -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); - return 0; -} - -int pthread_cond_signal(pthread_cond_t *cond) -{ - ++(cond->__c_lock.__spinlock); - return 0; -} - -int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr) -{ - cond->__c_lock.__spinlock = 1; - return 0; -} - -int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void* (*fn)(void *), void *data) -{ - 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, - 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; -} - -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) - (int)*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(*(int *)retval); -} -- cgit v1.2.3