summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libpthread
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/libpthread')
-rw-r--r--mdk-stage1/dietlibc/libpthread/CHANGES51
-rw-r--r--mdk-stage1/dietlibc/libpthread/Makefile140
-rw-r--r--mdk-stage1/dietlibc/libpthread/README36
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_atfork.c77
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getdetachstate.c14
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getinheritsched.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getschedparam.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getschedpolicy.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getscope.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getstackaddr.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_getstacksize.c14
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_init.c18
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setdetachstate.c17
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setinheritsched.c17
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setschedparam.c22
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setschedpolicy.c24
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setscope.c17
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setstackaddr.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_attr_setstacksize.c16
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cancel.c33
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cleanup_pop.c27
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cleanup_push.c23
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_broadcast.c26
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_destroy.c19
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_init.c15
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_signal.c26
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_timedwait.c74
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_cond_wait.c59
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_condattr.c15
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_create.c81
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_detach.c29
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_equal.c3
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_errno.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_exit.c17
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c16
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fgetc.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_flockfile.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_fputc.c9
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c5
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c22
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_getspecific.c20
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_internal.c359
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_join.c39
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_key.c48
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_key_create.c36
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_key_delete.c20
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutex_destroy.c15
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutex_init.c18
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutex_lock.c32
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutex_trylock.c33
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutex_unlock.c31
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutexattr_getkind_np.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutexattr_init.c15
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_mutexattr_setkind_np.c17
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_once.c9
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_self.c4
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_setcancelstate.c24
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_setcanceltype.c24
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c21
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_setspecific.c20
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sigmask.c8
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_spinlock.c34
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_alloc.c36
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_close.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_create.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_fcntl.c11
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_fsync.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_logging.c33
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_nanosleep.c11
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_open.c13
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_pause.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_read.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_sigsuspend.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_tcdrain.c12
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_waitpid.c12
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_sys_write.c10
-rw-r--r--mdk-stage1/dietlibc/libpthread/pthread_testcancel.c16
-rw-r--r--mdk-stage1/dietlibc/libpthread/test.c72
-rw-r--r--mdk-stage1/dietlibc/libpthread/thread_internal.h134
80 files changed, 0 insertions, 2330 deletions
diff --git a/mdk-stage1/dietlibc/libpthread/CHANGES b/mdk-stage1/dietlibc/libpthread/CHANGES
deleted file mode 100644
index 63376623b..000000000
--- a/mdk-stage1/dietlibc/libpthread/CHANGES
+++ /dev/null
@@ -1,51 +0,0 @@
-This is the pthread implementation of dietlibc.
-Written from scratch by Olaf Dreesen.
-
-Mon Aug 6 15:46:39 MEST 2001
-
- Ups... did the wrong error handling... the error is returned not put to
- errno...
- probably thread_key is not SMP save...
-
-Thu Apr 12 16:47:12 MEST 2001
-
- added conditional variables...
- except pthread_cond_timedwait all should work man-page like
- pthread_cond_timedwait dosen't handle cancel request according to man-page
-
- added thread specific key handling (all according to man-page)
-
-Fri Mar 30 18:47:37 MEST 2001
-
- uff found some logic errors and fixed them.
- pthread_create had a problem with user provided stacks.
-
-
-Fri Mar 23 14:09:54 MET 2001
-
- arg.. the kernel-header are so inconsistent...
- on x86 it works on arm and sparc not due to MISSING defines, miss-places
- includes and __KERNEL__ checks....
- the best in this category is that the kernel-header are changed that the
- buggy (g)libc haven't to change... (f..k glibc, the headers HAVE to be
- CONSISTENT)
- a public defined symbol on arch X have to be in Y to unless marked...
- that is mainly speaking SCHED.H ! arg....
-
-
-Wed Mar 14 04:28:45 MET 2001
-
- I have implemented the "Manager Thread" so that nested thread creation
- works. really ugly stuff... don't look at it unless you're sitting on solid
- ground.
-
-
-Mon Mar 12 16:16:00 CET 2001
-
- first of all:
- I strongly suggest NOT to use it yet, it's very, very, ... very
- experimental. I guess you got the point. there is still much debug code,
- incomplete functions and unusable states....
-
- I'm still working on the final alpha...
-
diff --git a/mdk-stage1/dietlibc/libpthread/Makefile b/mdk-stage1/dietlibc/libpthread/Makefile
deleted file mode 100644
index f2ab8d8dc..000000000
--- a/mdk-stage1/dietlibc/libpthread/Makefile
+++ /dev/null
@@ -1,140 +0,0 @@
-all: libpthread.a
-
-ARCH=$(shell uname -m | sed 's/i[4-9]86/i386/')
-
-CFLAGS=-pipe
-CROSS=
-
-CC=gcc
-
-VPATH=../$(ARCH)/
-
-PTHREAD_OBJS = \
- __testandset.o \
- \
- pthread_internal.o \
- pthread_key.o \
- \
- pthread_once.o pthread_spinlock.o \
- \
- pthread_create.o pthread_detach.o \
- pthread_join.o pthread_self.o \
- pthread_exit.o pthread_equal.o \
- \
- pthread_cleanup_push.o \
- pthread_cleanup_pop.o \
- \
- pthread_attr_getdetachstate.o \
- pthread_attr_getinheritsched.o \
- pthread_attr_getschedparam.o \
- pthread_attr_getschedpolicy.o \
- pthread_attr_getscope.o \
- pthread_attr_getstackaddr.o \
- pthread_attr_getstacksize.o \
- pthread_attr_init.o \
- pthread_attr_setdetachstate.o \
- pthread_attr_setinheritsched.o \
- pthread_attr_setschedparam.o \
- pthread_attr_setschedpolicy.o \
- pthread_attr_setscope.o \
- pthread_attr_setstackaddr.o \
- pthread_attr_setstacksize.o \
- \
- pthread_cancel.o pthread_setcancelstate.o \
- pthread_setcanceltype.o pthread_testcancel.o \
- \
- pthread_mutex_init.o \
- pthread_mutex_destroy.o \
- pthread_mutex_lock.o \
- pthread_mutex_trylock.o \
- pthread_mutex_unlock.o \
- \
- pthread_mutexattr_getkind_np.o \
- pthread_mutexattr_init.o \
- pthread_mutexattr_setkind_np.o \
- \
- pthread_condattr.o \
- pthread_cond_broadcast.o \
- pthread_cond_destroy.o \
- pthread_cond_init.o \
- pthread_cond_signal.o \
- pthread_cond_timedwait.o \
- pthread_cond_wait.o \
- \
- pthread_key_create.o \
- pthread_key_delete.o \
- pthread_getspecific.o \
- pthread_setspecific.o \
- \
- pthread_atfork.o \
- pthread_sys_alloc.o \
- pthread_sys_close.o \
- pthread_sys_create.o \
- pthread_sys_fcntl.o \
- pthread_sys_fsync.o \
- pthread_sys_fdatasync.o \
- pthread_sys_nanosleep.o \
- pthread_sys_logging.o \
- pthread_sys_open.o \
- pthread_sys_pause.o \
- pthread_sys_read.o \
- pthread_sys_sigsuspend.o \
- pthread_sys_tcdrain.o \
- pthread_sys_waitpid.o \
- pthread_sys_write.o
-
-%.o : %.c
- $(CC) $(CFLAGS) -c -o $@ $?
-
-include ../$(ARCH)/Makefile.add
-
-ifeq ($(CFLAGS),-pipe)
-CFLAGS+=-O -fomit-frame-pointer
-endif
-
-#CFLAGS = -g
-CFLAGS += -Wall
-
-CFLAGS += -I.. -I../include -Wall
-
-PWD=$(shell pwd)
-
-.SUFFIXES:
-.SUFFIXES: .S .c
-
-% :: %,v
-
-%.o: %.S
- $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $<
-
-%.o: %.c
- $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $<
-# $(CROSS)strip -x -R .comment -R .note $@
-
-libpthread.a: $(PTHREAD_OBJS)
- ar cr $@ $^
-
-libpthread.so: libpthread.a
- $(CROSS)ld -whole-archive -shared -o $@ $^
-
-
-clean:
- $(RM) *.o *.a *.so *.out *~
-
-exports: libpthread.a
- nm -g libpthread.a | grep -w T | awk '{ print $$3 }' | sort -u > exports
-
-.PHONY: test.out
-
-test.out: test.o libpthread.a $(LIBS)
- $(CROSS)$(CC) -g $(CFLAGS) -nostdlib ../bin-$(ARCH)/start.o -o $@ $^ ../bin-$(ARCH)/dietlibc.a -lgcc
-
-
-.PHONY: sparc ppc mips arm alpha i386
-
-sparc ppc alpha i386:
- $(MAKE) ARCH=$@ CROSS=$@-linux- all t libdietc.so
-
-mips arm:
- $(MAKE) ARCH=$@ CROSS=$@-linux-gnu- all t libdietc.so
-
diff --git a/mdk-stage1/dietlibc/libpthread/README b/mdk-stage1/dietlibc/libpthread/README
deleted file mode 100644
index ee85a572d..000000000
--- a/mdk-stage1/dietlibc/libpthread/README
+++ /dev/null
@@ -1,36 +0,0 @@
-LIBPTHREAD
-
- This is the pthread implementation of dietlibc.
- Written from scratch by Olaf Dreesen.
-
-1. STATUS: near complete and should work (or not... I had a lot of heisen-bugs...)
- On non i386 archs the kernel header have major differences...
- NO workaround yet for this problems...
-
-It's like linuxthreads a clone base thread implementation.
-
-I have implemented a "Manager Thread" with all the pain it involves...
-Nested thread creation is now working fine...
-
-
-2. HOW-TO make this lib:
-
- it is a standard dietlibc helper lib...
-
-
-3. NOTES
-
-NON STANDARD SIGNAL HANDLING for the threads:
-
- SIGHUP the targeted thread is canceled
- depends on the cancel type of the thread.
-
- ASYNCHRONOUS: the signal handler will KILL the thread immediately.
-
- DEFERRED: the signal handler mark its thread as canceled.
- (only for the sig-handler to do some sane stuff...)
-
- SIGTERM the thread is KILLED
- if the thread signaled is the main thread, then ALL child-threads
- will get a SIGHUP and after some micros a SIGTERM....
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_atfork.c b/mdk-stage1/dietlibc/libpthread/pthread_atfork.c
deleted file mode 100644
index 70ca9f162..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_atfork.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-#define PTHREAD_NUM_ATFORK 4
-
-static struct _pthread_fastlock __atfork_struct_lock;
-static struct {
- int used;
- void (*prepare)(void);
- void (*parent)(void);
- void (*child)(void);
-} pthread_atfork_buf[PTHREAD_NUM_ATFORK];
-
-int pthread_atfork(void (*prepare)(void),
- void (*parent)(void),
- void (*child)(void))
-{
- int i,ret=-1;
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&__atfork_struct_lock);
-
- for (i=0;i<PTHREAD_NUM_ATFORK; ++i) {
- if (!(pthread_atfork_buf[i].used)) {
- pthread_atfork_buf[i].prepare=prepare;
- pthread_atfork_buf[i].parent=parent;
- pthread_atfork_buf[i].child=child;
- ret=0;
- break;
- }
- }
-
- __pthread_unlock(&__atfork_struct_lock);
- __NO_ASYNC_CANCEL_END;
-
- if (ret) ret=ENOMEM;
- return ret;
-}
-
-pid_t fork(void)
-{
- pid_t pid;
- int i=PTHREAD_NUM_ATFORK;
-
- __NO_ASYNC_CANCEL_BEGIN;
-
- __TEST_CANCEL();
- __pthread_lock(&__atfork_struct_lock);
-
- while (i) {
- if (pthread_atfork_buf[--i].used)
- if (pthread_atfork_buf[i].prepare)
- pthread_atfork_buf[i].prepare();
- }
-
- pid=__libc_fork();
-
- if (pid>0) { /* parent */
- for (i=0;i<PTHREAD_NUM_ATFORK;++i)
- if (pthread_atfork_buf[i].used)
- if (pthread_atfork_buf[i].parent)
- pthread_atfork_buf[i].parent();
- } else if (pid==0) { /* child */
- for (i=0;i<PTHREAD_NUM_ATFORK;++i)
- if (pthread_atfork_buf[i].used)
- if (pthread_atfork_buf[i].child)
- pthread_atfork_buf[i].child();
- }
-
- __pthread_unlock(&__atfork_struct_lock);
- __NO_ASYNC_CANCEL_END;
-
- return pid;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getdetachstate.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getdetachstate.c
deleted file mode 100644
index ccdfc0e47..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getdetachstate.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
-{
- __THREAD_INIT();
-
- *detachstate=attr->__detachstate;
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getinheritsched.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getinheritsched.c
deleted file mode 100644
index 314fd8ade..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getinheritsched.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
-{
- __THREAD_INIT();
-
- *inherit = attr->__inheritsched;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedparam.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedparam.c
deleted file mode 100644
index f0a9a07d1..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedparam.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
-{
- __THREAD_INIT();
-
- param->sched_priority=attr->__schedparam.sched_priority;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedpolicy.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedpolicy.c
deleted file mode 100644
index 53f1bed8c..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getschedpolicy.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
-{
- __THREAD_INIT();
-
- *policy = attr->__schedpolicy;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getscope.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getscope.c
deleted file mode 100644
index 99a33110d..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getscope.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
-{
- __THREAD_INIT();
-
- *scope=PTHREAD_SCOPE_SYSTEM;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getstackaddr.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getstackaddr.c
deleted file mode 100644
index d71421901..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getstackaddr.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stack)
-{
- __THREAD_INIT();
-
- *stack=attr->__stackaddr;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_getstacksize.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_getstacksize.c
deleted file mode 100644
index 4785979a0..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_getstacksize.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize)
-{
- __THREAD_INIT();
-
- *stacksize=attr->__stacksize;
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_init.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_init.c
deleted file mode 100644
index fbcefa3bd..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_init.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_init(pthread_attr_t *attr)
-{
- __THREAD_INIT();
-
- memset(attr,0,sizeof(pthread_attr_t));
- attr->__stacksize=PTHREAD_STACK_SIZE;
- return 0;
-}
-
-int pthread_attr_destroy(pthread_attr_t *attr) __attribute__((alias("pthread_attr_init")));
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setdetachstate.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setdetachstate.c
deleted file mode 100644
index f5eab5816..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setdetachstate.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
-{
- __THREAD_INIT();
-
- if ((detachstate == PTHREAD_CREATE_JOINABLE) ||
- (detachstate == PTHREAD_CREATE_DETACHED)) {
- attr->__detachstate=detachstate;
- return 0;
- }
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setinheritsched.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setinheritsched.c
deleted file mode 100644
index 0b7a691e7..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setinheritsched.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
-{
- __THREAD_INIT();
-
- if ((inherit==PTHREAD_INHERIT_SCHED) ||
- (inherit==PTHREAD_EXPLICIT_SCHED)) {
- attr->__inheritsched=inherit;
- return 0;
- }
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedparam.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedparam.c
deleted file mode 100644
index a3e5a9b4a..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedparam.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
-{
- __THREAD_INIT();
-
- if ((attr->__schedpolicy == SCHED_OTHER) && (param->sched_priority == 0)) {
- attr->__schedparam.sched_priority=0;
- return 0;
- }
- if (((attr->__schedpolicy == SCHED_RR) || (attr->__schedpolicy == SCHED_FIFO))
- && ((param->sched_priority > 0) && (param->sched_priority < 100))) {
- attr->__schedparam.sched_priority=param->sched_priority;
- return 0;
- }
- return EINVAL;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedpolicy.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedpolicy.c
deleted file mode 100644
index 227d3f7ad..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setschedpolicy.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
-{
- __THREAD_INIT();
-
- if (policy==SCHED_OTHER) {
- attr->__schedpolicy=policy;
- return 0;
- }
- if ((policy==SCHED_FIFO) || (policy==SCHED_RR)) {
- if (geteuid()==0) {
- attr->__schedpolicy=policy;
- return 0;
- }
- return ENOTSUP;
- }
- else
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setscope.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setscope.c
deleted file mode 100644
index 9be11ca2d..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setscope.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setscope(pthread_attr_t *attr, int scope)
-{
- __THREAD_INIT();
-
- if (scope==PTHREAD_SCOPE_SYSTEM) return 0;
-
- if (scope==PTHREAD_SCOPE_PROCESS)
- return ENOTSUP;
- else
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setstackaddr.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setstackaddr.c
deleted file mode 100644
index 4b320cd9d..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setstackaddr.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack)
-{
- __THREAD_INIT();
-
- attr->__stackaddr=stack;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_attr_setstacksize.c b/mdk-stage1/dietlibc/libpthread/pthread_attr_setstacksize.c
deleted file mode 100644
index 1a0aae929..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_attr_setstacksize.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
-{
- __THREAD_INIT();
-
- if (stacksize>=PTHREAD_STACK_SIZE) {
- attr->__stacksize=stacksize;
- return 0;
- }
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cancel.c b/mdk-stage1/dietlibc/libpthread/pthread_cancel.c
deleted file mode 100644
index c0ae60349..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cancel.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cancel(pthread_t th)
-{
- pthread_t j;
- _pthread_descr thread;
-
- __THREAD_INIT();
-
- j=__find_thread_id(th);
-
- if (j==-1) {
- return ESRCH;
- }
- thread = __get_thread_struct(j);
-
- if (thread==0) {
- return ESRCH;
- }
-
- if (thread->cancelstate!=PTHREAD_CANCEL_DISABLE) {
- thread->canceled=1;
- if (thread->canceltype!=PTHREAD_CANCEL_DEFERRED) {
- kill(thread->pid,SIGHUP);
- }
- }
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cleanup_pop.c b/mdk-stage1/dietlibc/libpthread/pthread_cleanup_pop.c
deleted file mode 100644
index 641bb6083..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cleanup_pop.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-void pthread_cleanup_pop(int execute)
-{
- _pthread_descr this;
- struct thread_cleanup_t tmp;
- int i=PTHREAD_MAX_CLEANUP;
-
- __THREAD_INIT();
-
- this = __thread_self();
-
- while(i>0) {
- if (this->cleanup_stack[--i].func) {
- tmp.func=this->cleanup_stack[i].func;
- tmp.arg=this->cleanup_stack[i].arg;
- this->cleanup_stack[i].func=0;
- break;
- }
- }
-
- if (execute) tmp.func(tmp.arg);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cleanup_push.c b/mdk-stage1/dietlibc/libpthread/pthread_cleanup_push.c
deleted file mode 100644
index cd2aabf71..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cleanup_push.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-void pthread_cleanup_push(void (*func)(void*), void *arg)
-{
- _pthread_descr this;
- int i;
-
- __THREAD_INIT();
-
- this = __thread_self();
-
- for (i=0; i<PTHREAD_MAX_CLEANUP; ++i) {
- if (this->cleanup_stack[i].func==0) {
- this->cleanup_stack[i].func=func;
- this->cleanup_stack[i].arg=arg;
- break;
- }
- }
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_broadcast.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_broadcast.c
deleted file mode 100644
index 776e0adfc..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_broadcast.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_broadcast(pthread_cond_t *cond)
-{
- _pthread_descr tmp;
-
- __THREAD_INIT();
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
-
- for (tmp=cond->wait_chain;tmp;tmp=tmp->waitnext) {
- tmp->waitnext=0;
- tmp->waiting=0;
- }
- cond->wait_chain=0;
-
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_STOP;
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_destroy.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_destroy.c
deleted file mode 100644
index b553b41df..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_destroy.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_destroy(pthread_cond_t *cond)
-{
- __THREAD_INIT();
-
- if (cond->wait_chain) {
- return EBUSY;
- }
-
- memset(cond,0,sizeof(pthread_cond_t));
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_init.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_init.c
deleted file mode 100644
index 76dd5cb97..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_init.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cond_attr)
-{
- __THREAD_INIT();
-
- memset(cond,0,sizeof(pthread_cond_t));
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_signal.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_signal.c
deleted file mode 100644
index 02a3c028e..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_signal.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_signal(pthread_cond_t *cond)
-{
- _pthread_descr tmp=0;
-
- __THREAD_INIT();
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
- if ((tmp=cond->wait_chain)) cond->wait_chain=tmp->waitnext;
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_STOP;
-
- if (tmp) {
- tmp->waitnext=0;
- tmp->waiting=0;
- }
-
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_timedwait.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_timedwait.c
deleted file mode 100644
index 71d80bdb5..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_timedwait.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
- const struct timespec *abstime)
-{
- _pthread_descr tmp;
- _pthread_descr this;
- int ret=0;
-
- __THREAD_INIT();
-
- this=__thread_self();
-
- /* put in wait-chain */
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
- this->waiting=1;
- if (cond->wait_chain) {
- for(tmp=cond->wait_chain;tmp->waitnext;tmp=tmp->waitnext);
- tmp->waitnext=this;
- } else cond->wait_chain=this;
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_STOP;
-
- /* Aeh yeah / wait till cond-signal OR timeout */
- pthread_mutex_unlock(mutex);
- while (this->waiting) {
- struct timeval tv;
- gettimeofday(&tv,0);
- if ((abstime->tv_sec <= tv.tv_sec) && (abstime->tv_nsec <= (tv.tv_usec*1000))) {
- ret = 1;
- break;
- }
- __thread_wait_some_time();
- if (this->canceled) break; /* a cancel */
- }
- pthread_mutex_lock(mutex);
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
- if (this->waiting) { /* still waiting -> TIMEOUT or SIGNAL */
- _pthread_descr prev;
- /* remove from wait-chain */
- prev=cond->wait_chain;
- if ((prev=cond->wait_chain)==this) {
- cond->wait_chain=this->waitnext;
- } else {
- for (tmp=prev->waitnext;tmp;prev=tmp,tmp=prev->waitnext) {
- if (tmp==this) {
- prev->waitnext=this->waitnext;
- break;
- }
- }
- }
- this->waiting=0;
- this->waitnext=0;
- }
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_END;
-
- if (ret) return ETIMEDOUT;
-
- {
- register int err = (*__errno_location());
- if (err==EINTR) return err;
- }
- return 0;
-}
-
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_cond_wait.c b/mdk-stage1/dietlibc/libpthread/pthread_cond_wait.c
deleted file mode 100644
index 8db49e840..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_cond_wait.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
- _pthread_descr tmp;
- _pthread_descr this;
-
- __THREAD_INIT();
-
- this=__thread_self();
-
- /* put in wait-chain */
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
- this->waiting=1;
- if (cond->wait_chain) {
- for(tmp=cond->wait_chain;tmp->waitnext;tmp=tmp->waitnext);
- tmp->waitnext=this;
- } else cond->wait_chain=this;
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_STOP;
-
- /* Aeh yeah / wait till signal */
- pthread_mutex_unlock(mutex);
- while (this->waiting) {
- __thread_wait_some_time();
- if (this->canceled) break; /* we got a cancel signal */
- }
- pthread_mutex_lock(mutex);
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&(cond->lock));
- if (this->waiting) { /* still waiting -> SIGNAL */
- _pthread_descr prev;
- /* remove from wait-chain */
- prev=cond->wait_chain;
- if ((prev=cond->wait_chain)==this) {
- cond->wait_chain=this->waitnext;
- } else {
- for (tmp=prev->waitnext;tmp;prev=tmp,tmp=prev->waitnext) {
- if (tmp==this) {
- prev->waitnext=this->waitnext;
- break;
- }
- }
- }
- this->waiting=0;
- this->waitnext=0;
- }
- __pthread_unlock(&(cond->lock));
- __NO_ASYNC_CANCEL_END;
- return 0;
-}
-
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_condattr.c b/mdk-stage1/dietlibc/libpthread/pthread_condattr.c
deleted file mode 100644
index c537890ba..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_condattr.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <pthread.h>
-
-int pthread_condattr_init(pthread_condattr_t *attr)
-{
- return 0;
-}
-
-int pthread_condattr_destroy(pthread_condattr_t *attr)
-__attribute__((alias("pthread_condattr_init")));
-
-int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared)
-__attribute__((alias("pthread_condattr_init")));
-
-int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
-__attribute__((alias("pthread_condattr_init")));
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_create.c b/mdk-stage1/dietlibc/libpthread/pthread_create.c
deleted file mode 100644
index 714c2bf4b..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_create.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_create (pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine) (void *), void *arg)
-{
- int ret=0;
- _pthread_descr td;
- pthread_attr_t default_attr;
-
- __THREAD_INIT();
-
- if (start_routine==0) {
- return EINVAL;
- }
-
- td = __thread_get_free();
-
- if (td) {
- td->go.__spinlock=PTHREAD_SPIN_LOCKED;
- if (!(attr)) {
- pthread_attr_init(&default_attr);
- attr=&default_attr;
- }
-
- if ((td->policy!=SCHED_OTHER)&&(td->priority==0)) {
- return EINVAL;
- }
-
- if (attr->__inheritsched==PTHREAD_INHERIT_SCHED) {
- _pthread_descr this = __thread_self();
- td->policy = this->policy;
- td->priority = this->priority;
- } else {
- td->policy = attr->__schedpolicy;
- td->priority = attr->__schedparam.sched_priority;
- }
-
- td->func = start_routine;
- td->arg = arg;
-
- td->detached = attr->__detachstate;
-
- td->stack_size = attr->__stacksize;
-
- if (!(attr->__stackaddr)) {
- char *stack=(char*)malloc(td->stack_size);
- if (!(stack)) {
- return EINVAL;
- }
- td->stack_begin = stack;
-#ifdef __parisc__
- td->stack_addr = stack;
-#else
- td->stack_addr = stack+td->stack_size;
-#endif
- } else {
- td->stack_begin = 0;
- td->stack_addr = attr->__stackaddr;
- }
-
- ret = signal_manager_thread(td);
-
- if (ret>1)
- *thread=ret;
- else {
- ++td->exited; /* mark as exited */
- __thread_cleanup(td);
- if (ret<0) return (*(__errno_location()));
- return EAGAIN;
- }
- }
- else
- return EAGAIN;
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_detach.c b/mdk-stage1/dietlibc/libpthread/pthread_detach.c
deleted file mode 100644
index 2f72b97a7..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_detach.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_detach(pthread_t th)
-{
- pthread_t j;
- _pthread_descr thread;
-
- __THREAD_INIT();
-
- j=__find_thread_id(th);
-
- if (j==-1) {
- return ESRCH;
- }
- thread = __get_thread_struct(j);
-
- if (thread->detached) {
- return EINVAL;
- }
-
- if (!thread->joined) {
- thread->detached=1;
- }
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_equal.c b/mdk-stage1/dietlibc/libpthread/pthread_equal.c
deleted file mode 100644
index d054d86ed..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_equal.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <pthread.h>
-
-int pthread_equal(pthread_t thread1, pthread_t thread2) { return (thread1==thread2); }
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_errno.c b/mdk-stage1/dietlibc/libpthread/pthread_errno.c
deleted file mode 100644
index d035544ad..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_errno.c
+++ /dev/null
@@ -1,5 +0,0 @@
-int errno;
-
-#include "dietwarning.h"
-
-link_warning("errno","\e[1;33;41m>>> your multithreaded code uses errno! <<<\e[0m");
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_exit.c b/mdk-stage1/dietlibc/libpthread/pthread_exit.c
deleted file mode 100644
index 41eac0a33..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_exit.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-void pthread_exit(void *retval)
-{
- _pthread_descr this;
-
- __THREAD_INIT();
-
- this = __thread_self();
- this->retval = retval;
-
- longjmp(this->jmp_exit,1);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c b/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c
deleted file mode 100644
index d73c84220..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_fdglue2.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "dietstdio.h"
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
-
-extern int __stdio_atexit;
-extern FILE* __stdio_init_file_nothreads(int fd,int closeonerror);
-
-FILE* __stdio_init_file(int fd,int closeonerror) {
- FILE *tmp=__stdio_init_file_nothreads(fd,closeonerror);
- if (tmp) pthread_mutex_init(&tmp->m,0);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c b/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c
deleted file mode 100644
index 34e79e0fe..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_fgetc.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "dietstdio.h"
-#include <unistd.h>
-
-int fgetc(FILE *stream) {
- int tmp;
- pthread_mutex_lock(&stream->m);
- tmp=fgetc_unlocked(stream);
- pthread_mutex_unlock(&stream->m);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c b/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c
deleted file mode 100644
index 72131ffb1..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_flockfile.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "dietstdio.h"
-
-void flockfile(FILE* f) {
- pthread_mutex_lock(&f->m);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_fputc.c b/mdk-stage1/dietlibc/libpthread/pthread_fputc.c
deleted file mode 100644
index 82344b107..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_fputc.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <dietstdio.h>
-
-int fputc(int c, FILE *stream) {
- int tmp;
- pthread_mutex_lock(&stream->m);
- tmp=fputc_unlocked(c,stream);
- pthread_mutex_unlock(&stream->m);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c b/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c
deleted file mode 100644
index beae058af..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_funlockfile.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "dietstdio.h"
-
-void funlockfile(FILE* f) {
- pthread_mutex_unlock(&f->m);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c b/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c
deleted file mode 100644
index aaaba4458..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_getschedparam.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_getschedparam(pthread_t target_thread, int *policy, struct sched_param *param)
-{
- int p;
- __THREAD_INIT();
-
- if (__find_thread_id(target_thread)<0) {
- return ESRCH;
- }
-
- if (((p=sched_getscheduler(target_thread))==-1)||
- (sched_getparam(target_thread,param) ==-1)) {
- return (*(__errno_location()));
- }
- *policy=p;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_getspecific.c b/mdk-stage1/dietlibc/libpthread/pthread_getspecific.c
deleted file mode 100644
index c2f84c814..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_getspecific.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-extern struct _thread_key __thread_keys[PTHREAD_KEYS_MAX];
-const void *pthread_getspecific(pthread_key_t key)
-{
- int id;
- __THREAD_INIT();
-
- id=__find_thread_id(getpid());
-
- if ((key<PTHREAD_KEYS_MAX) && (__thread_keys[key].used)) {
- return __thread_keys[key].tkd[id];
- }
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_internal.c b/mdk-stage1/dietlibc/libpthread/pthread_internal.c
deleted file mode 100644
index 7bb4e16cb..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_internal.c
+++ /dev/null
@@ -1,359 +0,0 @@
-#include <signal.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <sched.h>
-#include <sys/resource.h>
-
-#include <stdio.h>
-#include "thread_internal.h"
-
-static struct _pthread_fastlock __thread_struct_lock = {PTHREAD_SPIN_UNLOCKED};
-static struct _pthread_descr_struct threads[PTHREAD_THREADS_MAX];
-static int _max_used_thread_id=1;
-pthread_once_t __thread_inited;
-
-static struct _pthread_fastlock __manager_thread_signal_lock = {PTHREAD_SPIN_UNLOCKED};
-static struct _pthread_fastlock __manager_thread_data_lock = {PTHREAD_SPIN_LOCKED};
-static struct _pthread_fastlock __manager_thread_data_go_lock = {PTHREAD_SPIN_LOCKED};
-
-//#define DEBUG
-
-/* find thread */
-int __find_thread_id(int pid)
-{
- register int i;
- for (i=0; i<_max_used_thread_id; i++)
- if (threads[i].pid==pid)
- return i;
- return -1;
-}
-
-/* get thread */
-_pthread_descr __get_thread_struct(int id)
-{
- return threads+id;
-}
-
-/* thread errno location */
-int *__errno_location(void)
-{
- int id=0;
- if (__thread_inited) id=__find_thread_id(getpid());
- if (id<0)
- return 0;
- else
- return &threads[id].errno;
-}
-
-/* thread self */
-_pthread_descr __thread_self()
-{
- register int i=__find_thread_id(getpid());
- if (i<0)
- return 0;
- else
- return threads+i;
-}
-
-/* allocate a thread slot */
-_pthread_descr __thread_get_free()
-{
- _pthread_descr ret=0;
- int i;
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&__thread_struct_lock);
-
- for (i=0; i<PTHREAD_THREADS_MAX; i++) {
- if (threads[i].pid==0) {
- ret = threads+i;
- /* clear struct */
- memset(ret,0,sizeof(struct _pthread_descr_struct));
- ret->pid=1; /* mark as taken */
- if (i>=_max_used_thread_id) _max_used_thread_id=i+1;
- break;
- }
- }
-
- __pthread_unlock(&__thread_struct_lock);
- __NO_ASYNC_CANCEL_END;
- return ret;
-}
-
-/* sleep a little (reschedule for this time) */
-void __thread_wait_some_time()
-{
- struct timespec reg;
- reg.tv_sec=0;
- reg.tv_nsec=SPIN_SLEEP_DURATION;
- __libc_nanosleep(&reg,0);
-}
-
-/* cleanup/join a thread */
-int __thread_join(_pthread_descr th, void**return_value)
-{
- /* mark thread th as joined */
- if (__testandset(&(th->joined))) return EINVAL;
- /* wait for thread to exit */
- while(!th->exited) __thread_wait_some_time();
- /* put return value to caller */
- if (return_value) *return_value=th->retval;
- /* cleanup thread */
- if (th->stack_begin) free(th->stack_begin);
- th->joined=0;
- th->pid=0;
- return 0;
-}
-
-/* SIGHUP handler (thread cancel) PTHREAD_CANCEL_ASYNCHRONOUS */
-static void __thread_cancel_handler(int sig)
-{
- _pthread_descr this;
- this = __thread_self();
- this->canceled=1;
- if (this->canceltype==PTHREAD_CANCEL_ASYNCHRONOUS)
- pthread_exit(PTHREAD_CANCELED);
- signal( SIGHUP, __thread_cancel_handler );
-}
-
-/* kill ALL threads / other then prime task and manager thread */
-static void __kill_all_threads()
-{
- int i;
-
- for (i=2; i<_max_used_thread_id; i++) {
- if (threads[i].pid>1) {
-#ifdef DEBUG
- printf("CANCEL ! %d\n",threads[i].pid);
-#endif
- threads[i].canceled=1;
- kill(threads[i].pid, SIGHUP); /* cancel thread */
- }
- }
-
- __thread_wait_some_time();
-
- for (i=2; i<_max_used_thread_id; i++) {
- if (threads[i].pid>1) {
-#ifdef DEBUG
- printf("KILL ! %d\n",threads[i].pid);
-#endif
- kill(threads[i].pid, SIGTERM); /* KILL thread */
- }
- }
-}
-
-__attribute__((weak)) volatile void __thread_start__key(int id);
-__attribute__((weak)) volatile void __thread_start__key(int id) { return; }
-__attribute__((weak,alias("__thread_start__key"))) volatile void __thread_exit__key(int id);
-
-/* support for manager */
-static void *__mthread_starter(void *arg)
-{
- _pthread_descr td = (_pthread_descr)arg;
- int i = td->stack_size-4096;
-
- /* just to be sure */
- td->pid=getpid();
-
- /* signal handling for a thread */
- signal(SIGTERM, _exit);
- signal(SIGCHLD, SIG_DFL);
- signal(SIGHUP, __thread_cancel_handler );
-
- /* limit stack so that we NEVER have to worry */
- setrlimit(RLIMIT_STACK, (struct rlimit *)(&i));
-
- /* set scheduler */
- if (td->policy!=SCHED_OTHER) {
- struct sched_param sp;
- sp.sched_priority=td->priority;
- sched_setscheduler(td->pid,td->policy, &sp);
- }
-
- /* thread_key glue */
- __thread_start__key(td-threads);
-
-#ifdef DEBUG
- printf("in starter %d, parameter %8p\n", td->pid, td->func);
-#endif
- do {
- __thread_wait_some_time();
- if (td->canceled) return (void*)42;
- } while (__pthread_trylock(&td->go));
-
-#ifdef DEBUG
- printf("post starter %d, parameter %8p\n", td->pid, td->func);
-#endif
-
- if (!td->canceled) {
- if (!(setjmp(td->jmp_exit))) {
- td->retval=td->func(td->arg);
-#ifdef DEBUG
- } else {
- printf("pthread_exit called in %d\n", td->pid);
-#endif
- }
- }
- pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0);
-
- /* thread_key glue */
- __thread_exit__key(td-threads);
-
-#ifdef DEBUG
- printf("end starter %d, retval %8p\n", td->pid, td->retval);
-#endif
-
- /* execute all functions on the cleanup-stack */
- for (i=PTHREAD_MAX_CLEANUP;i;) {
- if (td->cleanup_stack[--i].func) {
- td->cleanup_stack[i].func(td->cleanup_stack[i].arg);
- }
- }
-
- return 0;
-}
-
-
-/* manager thread and signal handler */
-static char __manager_thread_stack[12*1024];
-static volatile _pthread_descr __manager_thread_data;
-static void __manager_SIGCHLD(int sig)
-{
- int pid, status, i;
-
- while(1) {
- pid = __libc_waitpid (-1, &status, WNOHANG);
- if (pid <= 0) break;
-
- for (i=0; i<_max_used_thread_id; i++) {
- if (threads[i].pid==pid) {
- ++threads[i].exited;
- if (threads[i].detached) {
- threads[i].joined=0;
- __thread_cleanup(threads+i);
- }
- break;
- }
- }
- }
-}
-
-static void __manager_SIGTERM(int sig)
-{
- __kill_all_threads();
- _exit(0);
-}
-
-static void* __manager_thread(void *arg)
-{
- struct sigaction sig_action_chld;
- sig_action_chld.sa_handler = __manager_SIGCHLD;
- sigemptyset(&sig_action_chld.sa_mask);
- sig_action_chld.sa_flags = SA_RESTART;
-
- sigaction(SIGCHLD, &sig_action_chld, 0);
- signal(SIGTERM, __manager_SIGTERM);
- signal(SIGHUP, SIG_IGN);
-
- __pthread_unlock(&__manager_thread_data_go_lock); /* release init */
- while(1) {
- do {
- __thread_wait_some_time();
- if (getppid()<2) __manager_SIGTERM(0);
- } while (__pthread_trylock(&__manager_thread_data_lock));
-
- __manager_thread_data->pid =
- __clone(__mthread_starter,
- __manager_thread_data->stack_addr,
- CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD,
- __manager_thread_data);
- __thread_wait_some_time();
- __thread_wait_some_time();
- __pthread_unlock(&__manager_thread_data->go);
-#ifdef DEBUG
- printf("manager new thread %d\n",__manager_thread_data->pid);
-#endif
- __pthread_unlock(&__manager_thread_data_go_lock); /* release sender */
- }
- return 0;
-}
-
-/* pthread_create bottom half */
-int signal_manager_thread(_pthread_descr td)
-{
- __NO_ASYNC_CANCEL_BEGIN;
-
- __pthread_lock(&__manager_thread_signal_lock); /* lock */
-
- __manager_thread_data = td;
- __thread_wait_some_time();
- __pthread_unlock(&__manager_thread_data_lock); /* signal manager to start */
- __thread_wait_some_time();
- __pthread_lock(&__manager_thread_data_go_lock); /* wait for manager */
-
- __pthread_unlock(&__manager_thread_signal_lock); /* unlock */
-
- __NO_ASYNC_CANCEL_END;
-
- return td->pid;
-}
-
-
-/* thread stop */
-static void __thread_main_exit()
-{
- if (getpid()!=threads[0].pid) {
-#ifdef DEBUG
- printf("A THREAD ? %d\n",getpid());
-#endif
- kill(threads[0].pid, SIGTERM);
- while(1) __thread_wait_some_time();
- }
-#ifdef DEBUG
- else
- printf("EXIT ! %d\n",getpid());
-#endif
-
- /* stop ALL threads */
- kill(threads[1].pid, SIGTERM);
- __thread_wait_some_time();
- __kill_all_threads();
-}
-
-/* thread intern init */
-void __thread_init()
-{
- if (atexit(__thread_main_exit)==-1)
- exit(42);
-
-#ifdef DEBUG
- printf("INIT ! %d\n",getpid());
- memset(threads,0,sizeof(threads));
-#endif
-
- threads[0].pid = getpid();
-
- ++_max_used_thread_id;
- threads[1].stack_size=sizeof(__manager_thread_stack);
-#ifdef __parisc__
- threads[1].stack_addr=__manager_thread_stack;
-#else
- threads[1].stack_addr=&__manager_thread_stack[sizeof(__manager_thread_stack)];
-#endif
- threads[1].stack_begin=0;
- threads[1].func=__manager_thread;
-
- threads[1].pid = __clone(__mthread_starter, threads[1].stack_addr,
- CLONE_VM | CLONE_FS | CLONE_FILES, threads+1);
-
-#ifdef DEBUG
- printf("manager thread @ : %d\n",threads[1].pid);
-#endif
- __pthread_lock(&__manager_thread_data_go_lock); /* wait for manager to be ready */
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_join.c b/mdk-stage1/dietlibc/libpthread/pthread_join.c
deleted file mode 100644
index 39c076555..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_join.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include "thread_internal.h"
-#include <pthread.h>
-
-int pthread_join(pthread_t th, void **thread_return)
-{
- pthread_t j;
- _pthread_descr this, thread;
-
- __THREAD_INIT();
-
- this = __thread_self();
- j=__find_thread_id(th);
-
- if (j==-1) {
- return ESRCH;
- }
-
- thread = __get_thread_struct(j);
-
- /* error handling */
- if (thread==0) {
- return ESRCH;
- }
-
- if (this==thread) {
- return EDEADLK;
- }
-
- if (thread->detached || thread->joined) {
- return EINVAL;
- }
-
- return __thread_join(thread,thread_return);
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_key.c b/mdk-stage1/dietlibc/libpthread/pthread_key.c
deleted file mode 100644
index 8a77f281a..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_key.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-struct _pthread_fastlock __thread_keys_lock;
-struct _thread_key __thread_keys[PTHREAD_KEYS_MAX];
-
-void __thread_start__key(int id);
-void __thread_exit__key(int id);
-
-void __thread_start__key(int id)
-{
- int i;
-
- if (id<2) return;
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&__thread_keys_lock);
-
- for (i=0; i<PTHREAD_KEYS_MAX; i++) {
- __thread_keys[i].tkd[id]=0;
- }
-
- __pthread_unlock(&__thread_keys_lock);
- __NO_ASYNC_CANCEL_END;
-}
-
-void __thread_exit__key(int id)
-{
- int i,try;
-
- if (id<2) return;
-
- __NO_ASYNC_CANCEL_BEGIN;
-// __pthread_lock(&__thread_keys_lock);
-
- for (i=0; i<PTHREAD_KEYS_MAX; i++) {
- if ((__thread_keys[i].used) && (__thread_keys[i].destructor)) {
- for (try=0;__thread_keys[i].tkd[id] && (try<PTHREAD_DESTRUCTOR_ITERATIONS);++try)
- __thread_keys[i].destructor(__thread_keys[i].tkd[id]);
- }
- }
-
-// __pthread_unlock(&__thread_keys_lock);
- __NO_ASYNC_CANCEL_STOP;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_key_create.c b/mdk-stage1/dietlibc/libpthread/pthread_key_create.c
deleted file mode 100644
index 9718c695b..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_key_create.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-extern struct _pthread_fastlock __thread_keys_lock;
-extern struct _thread_key __thread_keys[PTHREAD_KEYS_MAX];
-int pthread_key_create(pthread_key_t *key, void (*destructor)(const void*))
-{
- int ret=-1,i;
-
- __THREAD_INIT();
-
- __NO_ASYNC_CANCEL_BEGIN;
- __pthread_lock(&__thread_keys_lock);
-
- for (i=0; i<PTHREAD_KEYS_MAX; i++) {
- if (!__thread_keys[i].used) {
- __thread_keys[i].used=1;
- __thread_keys[i].destructor=destructor;
- memset(__thread_keys[i].tkd,0,PTHREAD_THREADS_MAX*sizeof(void*));
- *key=i;
- ret=0;
- break;
- }
- }
-
- __pthread_unlock(&__thread_keys_lock);
- __NO_ASYNC_CANCEL_END;
-
- if (ret) return EAGAIN;
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_key_delete.c b/mdk-stage1/dietlibc/libpthread/pthread_key_delete.c
deleted file mode 100644
index 8f7fb577f..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_key_delete.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-extern struct _thread_key __thread_keys[PTHREAD_KEYS_MAX];
-int pthread_key_delete(pthread_key_t key)
-{
- __THREAD_INIT();
-
- if (key>=PTHREAD_KEYS_MAX) {
- return EINVAL;
- }
-
- __thread_keys[key].used=0;
-
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutex_destroy.c b/mdk-stage1/dietlibc/libpthread/pthread_mutex_destroy.c
deleted file mode 100644
index f5d66613c..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutex_destroy.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- __THREAD_INIT();
-
- if ((mutex->owner)||(mutex->lock.__spinlock==PTHREAD_SPIN_LOCKED)) {
- return EBUSY;
- }
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutex_init.c b/mdk-stage1/dietlibc/libpthread/pthread_mutex_init.c
deleted file mode 100644
index 65161d0ec..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutex_init.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_mutex_init(pthread_mutex_t *mutex,
- const pthread_mutexattr_t *mutexattr)
-{
- __THREAD_INIT();
-
- memset(mutex,0,sizeof(pthread_mutex_t));
- if (mutexattr) {
- mutex->kind=mutexattr->__mutexkind;
- }
- return 0;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutex_lock.c b/mdk-stage1/dietlibc/libpthread/pthread_mutex_lock.c
deleted file mode 100644
index 0df2bcd8d..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutex_lock.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <unistd.h>
-#include <sched.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-/* will never return EINVAL ! */
-
-int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- _pthread_descr this;
-
- __THREAD_INIT();
-
- this = __thread_self();
-
- if (this==mutex->owner) {
- if (mutex->kind==PTHREAD_MUTEX_ERRORCHECK_NP)
- return EDEADLK;
- if (mutex->kind==PTHREAD_MUTEX_RECURSIVE_NP) {
- ++(mutex->count);
- return 0;
- }
- }
-
- /* wait for mutex to free */
- __pthread_lock(&(mutex->lock));
- mutex->owner=this;
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutex_trylock.c b/mdk-stage1/dietlibc/libpthread/pthread_mutex_trylock.c
deleted file mode 100644
index 620d26150..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutex_trylock.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <unistd.h>
-#include <sched.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-/* will never return EINVAL ! */
-
-int pthread_mutex_trylock(pthread_mutex_t *mutex)
-{
- _pthread_descr this;
-
- __THREAD_INIT();
-
- this = __thread_self();
-
- if (this!=mutex->owner) {
- /* wait for mutex to free */
- if (__pthread_trylock(&(mutex->lock))) {
- return EBUSY;
- }
-
- mutex->owner=this;
- }
- else if (mutex->kind==PTHREAD_MUTEX_ERRORCHECK_NP) {
- return EDEADLK;
- }
-
- if (mutex->kind==PTHREAD_MUTEX_RECURSIVE_NP) ++(mutex->count);
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutex_unlock.c b/mdk-stage1/dietlibc/libpthread/pthread_mutex_unlock.c
deleted file mode 100644
index 0c12282c1..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutex_unlock.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <unistd.h>
-#include <sched.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-/* will never return EINVAL ! */
-
-int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- _pthread_descr this;
-
- __THREAD_INIT();
-
- this = __thread_self();
-
- if (this==mutex->owner) {
- if (mutex->kind==PTHREAD_MUTEX_RECURSIVE_NP) {
- if (--(mutex->count)) return 0;
- }
-
- mutex->owner=0;
- __pthread_unlock(&(mutex->lock));
- }
- else if (mutex->kind==PTHREAD_MUTEX_ERRORCHECK_NP) {
- return EPERM;
- }
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_getkind_np.c b/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_getkind_np.c
deleted file mode 100644
index 63cd9133c..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_getkind_np.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_mutexattr_getkind_np(const pthread_mutexattr_t *attr, int *kind)
-{
- __THREAD_INIT();
-
- *kind=attr->__mutexkind;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_init.c b/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_init.c
deleted file mode 100644
index ff60e4c74..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_init.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_mutexattr_init(pthread_mutexattr_t *attr)
-{
- __THREAD_INIT();
-
- attr->__mutexkind = 0;
- return 0;
-}
-
-int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) __attribute__((alias ("pthread_mutexattr_init")));
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_setkind_np.c b/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_setkind_np.c
deleted file mode 100644
index 8b110fe5a..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_mutexattr_setkind_np.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind)
-{
- __THREAD_INIT();
-
- if ((kind==PTHREAD_MUTEX_FAST_NP) || (kind==PTHREAD_MUTEX_RECURSIVE_NP) ||
- (kind==PTHREAD_MUTEX_ERRORCHECK_NP)) {
- attr->__mutexkind=kind;
- return 0;
- }
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_once.c b/mdk-stage1/dietlibc/libpthread/pthread_once.c
deleted file mode 100644
index 16d9cb392..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_once.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <pthread.h>
-#include "thread_internal.h"
-
-int __pthread_once (pthread_once_t* once_control, void (*init_routine)(void))
-{
- if (!(__testandset(once_control))) init_routine();
- return 0;
-}
-int pthread_once (pthread_once_t* once_control, void (*init_routine)(void)) __attribute__((alias("__pthread_once")));
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_self.c b/mdk-stage1/dietlibc/libpthread/pthread_self.c
deleted file mode 100644
index 394686dd4..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_self.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <unistd.h>
-#include <pthread.h>
-
-pthread_t pthread_self() { return getpid(); }
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_setcancelstate.c b/mdk-stage1/dietlibc/libpthread/pthread_setcancelstate.c
deleted file mode 100644
index f832bef70..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_setcancelstate.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_setcancelstate(int state, int *oldstate)
-{
- _pthread_descr thread;
-
- __THREAD_INIT();
-
- if ((state==PTHREAD_CANCEL_ENABLE) || (state==PTHREAD_CANCEL_DISABLE))
- {
- thread = __thread_self();
-
- if (oldstate) *oldstate = thread->cancelstate;
- thread->cancelstate = state;
-
- return 0;
- }
-
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_setcanceltype.c b/mdk-stage1/dietlibc/libpthread/pthread_setcanceltype.c
deleted file mode 100644
index f5669b70d..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_setcanceltype.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_setcanceltype(int type, int *oldtype)
-{
- _pthread_descr thread;
-
- __THREAD_INIT();
-
- if ((type==PTHREAD_CANCEL_DEFERRED) || (type==PTHREAD_CANCEL_ASYNCHRONOUS))
- {
- thread = __thread_self();
-
- if (oldtype) *oldtype = thread->canceltype;
- thread->canceltype = type;
-
- return 0;
- }
-
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c b/mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c
deleted file mode 100644
index df007c408..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_setschedparam.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pthread_setschedparam(pthread_t target_thread, int policy, const struct sched_param *param)
-{
- __THREAD_INIT();
-
- if (__find_thread_id(target_thread)<0) {
- return ESRCH;
- }
-
- if (((policy == SCHED_OTHER) && (param->sched_priority==0)) ||
- (((policy == SCHED_RR) || (policy == SCHED_FIFO)) &&
- ((param->sched_priority > 0) && (param->sched_priority <100))))
- return sched_setscheduler(target_thread, policy, param);
-
- return EINVAL;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_setspecific.c b/mdk-stage1/dietlibc/libpthread/pthread_setspecific.c
deleted file mode 100644
index b66ce31d0..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_setspecific.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-extern struct _thread_key __thread_keys[PTHREAD_KEYS_MAX];
-int pthread_setspecific(pthread_key_t key, const void *value)
-{
- int id;
- __THREAD_INIT();
-
- id=__find_thread_id(getpid());
- if ((key<PTHREAD_KEYS_MAX) && (__thread_keys[key].used)) {
- __thread_keys[key].tkd[id]=value;
- return 0;
- }
- return EINVAL;
-}
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c b/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c
deleted file mode 100644
index 691e9e51a..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sigmask.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-#include <pthread.h>
-
-int pthread_sigmask(int how, const sigset_t*newset, sigset_t *oldset) {
- return (sigprocmask(how,newset,oldset)==-1)?(*(__errno_location())):0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_spinlock.c b/mdk-stage1/dietlibc/libpthread/pthread_spinlock.c
deleted file mode 100644
index 463c186bd..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_spinlock.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <time.h>
-#include <pthread.h>
-#include "thread_internal.h"
-
-void __pthread_lock(struct _pthread_fastlock * lock)
-{
- int cnt = 0;
- struct timespec tm;
-
- while (__testandset(&lock->__spinlock)) {
- if (cnt < MAX_SPIN_COUNT) {
- sched_yield();
- cnt++;
- } else {
- tm.tv_sec = 0;
- tm.tv_nsec = SPIN_SLEEP_DURATION;
- __libc_nanosleep(&tm, 0);
- cnt = 0;
- }
- }
-}
-
-int __pthread_trylock(struct _pthread_fastlock * lock)
-{
- return __testandset(&lock->__spinlock);
-}
-
-int __pthread_unlock(struct _pthread_fastlock * lock)
-{
- lock->__spinlock = PTHREAD_SPIN_UNLOCKED;
- return 0;
-}
-
-
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_alloc.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_alloc.c
deleted file mode 100644
index 9fd4bcd95..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_alloc.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-#include <stdlib.h>
-
-static pthread_mutex_t mutex_alloc = PTHREAD_MUTEX_INITIALIZER;
-
-void free(void *ptr) {
- __NO_ASYNC_CANCEL_BEGIN;
- pthread_mutex_lock(&mutex_alloc);
- __libc_free(ptr);
- pthread_mutex_unlock(&mutex_alloc);
- __NO_ASYNC_CANCEL_END;
-}
-
-void *malloc(size_t size) {
- register void *ret;
- __NO_ASYNC_CANCEL_BEGIN;
- pthread_mutex_lock(&mutex_alloc);
- ret=__libc_malloc(size);
- pthread_mutex_unlock(&mutex_alloc);
- __NO_ASYNC_CANCEL_END;
- return ret;
-}
-
-void* realloc(void* ptr, size_t size) {
- register void *ret;
- __NO_ASYNC_CANCEL_BEGIN;
- pthread_mutex_lock(&mutex_alloc);
- ret=__libc_realloc(ptr, size);
- pthread_mutex_unlock(&mutex_alloc);
- __NO_ASYNC_CANCEL_END;
- return ret;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_close.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_close.c
deleted file mode 100644
index 84d5d5f36..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_close.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int close(int fd)
-{
- __TEST_CANCEL();
- return __libc_close(fd);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_create.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_create.c
deleted file mode 100644
index 9d47844f5..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_create.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int creat(const char *pathname, mode_t mode)
-{
- __TEST_CANCEL();
- return __libc_creat(pathname,mode);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_fcntl.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_fcntl.c
deleted file mode 100644
index c7c3fb884..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_fcntl.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int fcntl(int fd, int cmd, void *arg);
-int fcntl(int fd, int cmd, void *arg)
-{
- __TEST_CANCEL();
- return __libc_fcntl(fd,cmd,arg);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c
deleted file mode 100644
index 69857c7b3..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_fdatasync.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int fdatasync(int fd)
-{
- __TEST_CANCEL();
- return __libc_fdatasync(fd);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_fsync.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_fsync.c
deleted file mode 100644
index a2c995069..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_fsync.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int fsync(int fd)
-{
- __TEST_CANCEL();
- return __libc_fsync(fd);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_logging.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_logging.c
deleted file mode 100644
index f9f93dce2..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_logging.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <unistd.h>
-#include <stdarg.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-#include <syslog.h>
-
-static pthread_mutex_t mutex_syslog = PTHREAD_MUTEX_INITIALIZER;
-
-void closelog(void)
-{
- pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock,&mutex_syslog);
- pthread_mutex_lock(&mutex_syslog);
- __libc_closelog();
- pthread_cleanup_pop(1);
-}
-
-void openlog(const char *ident, int option, int facility)
-{
- pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock,&mutex_syslog);
- pthread_mutex_lock(&mutex_syslog);
- __libc_openlog(ident, option, facility);
- pthread_cleanup_pop(1);
-}
-
-void vsyslog(int priority, const char *format, va_list arg_ptr)
-{
- pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock,&mutex_syslog);
- pthread_mutex_lock(&mutex_syslog);
- __libc_vsyslog(priority, format, arg_ptr);
- pthread_cleanup_pop(1);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_nanosleep.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_nanosleep.c
deleted file mode 100644
index 699de4654..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_nanosleep.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <time.h>
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int nanosleep(const struct timespec *req, struct timespec *rem)
-{
- __TEST_CANCEL();
- return __libc_nanosleep(req,rem);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_open.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_open.c
deleted file mode 100644
index 8d9fb5523..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_open.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int __pthread_open(const char *pathname, int flags, mode_t mode);
-int __pthread_open(const char *pathname, int flags, mode_t mode)
-{
- __TEST_CANCEL();
- return __libc_open(pathname,flags,mode);
-}
-
-int open(const char *pathname, int flags, ...) __attribute__((alias("__pthread_open")));
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_pause.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_pause.c
deleted file mode 100644
index ab15ead11..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_pause.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int pause()
-{
- __TEST_CANCEL();
- return __libc_pause();
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_read.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_read.c
deleted file mode 100644
index 60f886003..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_read.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int read(int fd, void *buf, size_t count)
-{
- __TEST_CANCEL();
- return __libc_read(fd,buf,count);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_sigsuspend.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_sigsuspend.c
deleted file mode 100644
index 72cd783ae..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_sigsuspend.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int sigsuspend(const sigset_t *mask)
-{
- __TEST_CANCEL();
- return __libc_sigsuspend(mask);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_tcdrain.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_tcdrain.c
deleted file mode 100644
index d5d94978b..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_tcdrain.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-#include <termios.h>
-
-int tcdrain(int fd)
-{
- __TEST_CANCEL();
- return __libc_tcdrain(fd);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_waitpid.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_waitpid.c
deleted file mode 100644
index e5020221a..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_waitpid.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-#include <sys/wait.h>
-
-pid_t waitpid(pid_t pid, int *status, int options)
-{
- __TEST_CANCEL();
- return __libc_waitpid(pid,status,options);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_sys_write.c b/mdk-stage1/dietlibc/libpthread/pthread_sys_write.c
deleted file mode 100644
index 37541ae42..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_sys_write.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-int write(int fd, const void *buf, size_t count)
-{
- __TEST_CANCEL();
- return __libc_write(fd,buf,count);
-}
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_testcancel.c b/mdk-stage1/dietlibc/libpthread/pthread_testcancel.c
deleted file mode 100644
index 4151faca3..000000000
--- a/mdk-stage1/dietlibc/libpthread/pthread_testcancel.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <errno.h>
-
-#include <pthread.h>
-#include "thread_internal.h"
-
-void pthread_testcancel()
-{
- _pthread_descr thread;
- __THREAD_INIT();
-
- thread=__thread_self();
-
- if (thread && thread->canceled) {
- pthread_exit(PTHREAD_CANCELED);
- }
-}
diff --git a/mdk-stage1/dietlibc/libpthread/test.c b/mdk-stage1/dietlibc/libpthread/test.c
deleted file mode 100644
index 3272c1753..000000000
--- a/mdk-stage1/dietlibc/libpthread/test.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <stdio.h>
-#include <pthread.h>
-
-#include <unistd.h>
-#include <signal.h>
-
-#include <errno.h>
-
-int ra;
-
-void test(int sig)
-{
- printf("SIGNAL %d in %d\n",sig,getpid());
- fflush(stdout);
- signal(SIGHUP, test);
-}
-
-void* thread(void* arg)
-{
- int i;
- for (i=0;i<10; i++)
- {
- printf("child %ld %8p\n", pthread_self(),arg);
- sleep(1);
- }
- return arg;
-}
-
-void* thread2(void *arg)
-{
- pthread_t t;
- int i;
-
- printf("child %ld %8p\n", pthread_self(),arg);
- for (i=0; i<3; ++i) {
- printf("child starting next in %d secs %ld %8p\n", 3-i, pthread_self(),arg);
- sleep(1);
- }
- pthread_create(&t,0, thread, (void*)2);
- printf("new child @ %ld\n",t);
- return (void*)t;
-}
-
-int main(int argc, char*argv[])
-{
- pthread_t t;
-
- signal(SIGHUP, test);
-
- pthread_create(&t,0, thread2, 0);
- pthread_create(&t,0, thread, (void *)3);
- pthread_create(&t,0, thread, (void *)1);
-
- puts("main");
-
-#if 0
- {
- int i;
- for(i=0;i<4;i++) sleep(1);
- }
-#else
- {
- int *tt;
- int i = pthread_join(t,(void*)&tt);
- printf("join %d %p %d\n",i,tt,(*(__errno_location())));
- }
-#endif
-
- puts("main exit");
-
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libpthread/thread_internal.h b/mdk-stage1/dietlibc/libpthread/thread_internal.h
deleted file mode 100644
index 7843fb59d..000000000
--- a/mdk-stage1/dietlibc/libpthread/thread_internal.h
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef __THREAD_INTERNAL_H__
-#define __THREAD_INTERNAL_H__
-
-#include <pthread.h>
-#include <stdarg.h>
-#include <setjmp.h>
-#include "dietfeatures.h"
-#ifndef WANT_THREAD_SAFE
-#error "the diet libc is not compiled with thread safeness enabled!"
-#endif
-
-#undef errno
-
-/* cleanup */
-#define PTHREAD_MAX_CLEANUP 8
-struct thread_cleanup_t {
- void (*func)(void*);
- void *arg;
-};
-
-/* the thread descriptor / internal */
-struct _pthread_descr_struct {
- /* conditional variables */
- struct _pthread_descr_struct *waitnext; /* an other waiting thread or NULL */
- int waiting; /* internal waiting "lock" */
-
- /* thread/process data */
- int pid; /* Process id */
- int exited; /* Process is dead */
-
- int policy; /* thread scheduling policy */
- int priority; /* thread priority */
-
- /* errno handling */
- int errno;
- int h_errno;
-
- /* stack handling */
- unsigned int stack_size; /* stack size for setrlimit */
- void *stack_addr; /* stack address for clone */
- void *stack_begin; /* begin of lib-stack / lowest address (free) */
-
- /* thread exit handling */
- void *retval; /* thread return value */
- int joined; /* flag other thread has joined */
- jmp_buf jmp_exit; /* pthread_exit jump */
-
- /* thread flags */
- int detached; /* thread is detached */
- int canceled; /* thread canceled */
-
- /* cancel handling */
- int cancelstate; /* cancel state */
- int canceltype; /* type of cancellation */
-
- /* thread basics */
- void* (*func) (void* arg); /* thread function */
- void* arg; /* thread argument */
-
- /* create thread / manager thread lock */
- struct _pthread_fastlock go;
-
- /* cleanup stack */
- struct thread_cleanup_t cleanup_stack[PTHREAD_MAX_CLEANUP];
-
-} __attribute__ ((aligned(32)));
-
-/* thread keys */
-struct _thread_key {
- int used;
- void (*destructor)(const void*);
- const void *tkd[PTHREAD_THREADS_MAX];
-};
-
-/* internal stuff */
-int __testandset(int *spinlock);
-
-void __pthread_lock(struct _pthread_fastlock * lock);
-int __pthread_trylock(struct _pthread_fastlock * lock);
-int __pthread_unlock(struct _pthread_fastlock * lock);
-
-int __clone(void* (*fn)(void*), void* stack, int flags, void *arg);
-
-int __find_thread_id(int pid);
-_pthread_descr __get_thread_struct(int id);
-
-_pthread_descr __thread_get_free(void);
-_pthread_descr __thread_self(void);
-
-int __thread_join(_pthread_descr join, void **return_value);
-#define __thread_cleanup(th) (void)__thread_join((th),0)
-
-void __thread_wait_some_time(void);
-
-#define __NO_ASYNC_CANCEL_BEGIN { int oldtype; pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
-#define __NO_ASYNC_CANCEL_END pthread_setcanceltype(oldtype,0); pthread_testcancel(); }
-#define __NO_ASYNC_CANCEL_STOP pthread_setcanceltype(oldtype,0); }
-
-/* manager thread stuff */
-int signal_manager_thread(_pthread_descr td);
-
-/* init stuff */
-extern pthread_once_t __thread_inited;
-void __thread_init(void);
-#define __THREAD_INIT() __pthread_once(&__thread_inited, __thread_init)
-#define __TEST_CANCEL() pthread_testcancel()
-
-/* diet libc syscalls */
-
-void __libc_free(void *ptr);
-void *__libc_malloc(size_t size);
-void *__libc_realloc(void* ptr, size_t size);
-
-void __libc_closelog(void);
-void __libc_openlog(const char *ident, int option, int facility);
-void __libc_vsyslog(int priority, const char *format, va_list arg_ptr);
-
-pid_t __libc_fork(void);
-
-int __libc_close(int fd);
-int __libc_creat(const char *pathname, mode_t mode);
-int __libc_fcntl(int fd, int cmd, void *arg);
-int __libc_fsync(int fd);
-int __libc_fdatasync(int fd);
-int __libc_nanosleep(const struct timespec *req, struct timespec *rem);
-int __libc_open(const char *pathname, int flags, mode_t mode);
-int __libc_pause(void);
-int __libc_read(int fd, void *buf, size_t count);
-int __libc_sigsuspend(const sigset_t *mask);
-int __libc_tcdrain(int fd);
-pid_t __libc_waitpid(pid_t pid, int *status, int options);
-int __libc_write(int fd, const void *buf, size_t count);
-
-#endif