summaryrefslogtreecommitdiffstats
path: root/libpthread/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/linuxthreads')
-rw-r--r--libpthread/linuxthreads/Makefile92
-rw-r--r--libpthread/linuxthreads/pthread.c-OLDEXAMPLE121
-rw-r--r--libpthread/linuxthreads/sysdeps/Makefile49
-rw-r--r--libpthread/linuxthreads/sysdeps/sh64/Makefile.in (renamed from libpthread/linuxthreads/sysdeps/sh64/Makefile)31
4 files changed, 173 insertions, 120 deletions
diff --git a/libpthread/linuxthreads/Makefile b/libpthread/linuxthreads/Makefile
index 08ff8a2d8..4072d660f 100644
--- a/libpthread/linuxthreads/Makefile
+++ b/libpthread/linuxthreads/Makefile
@@ -16,56 +16,69 @@
# 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
-# Makefile for uClibc
TOPDIR=../../
include $(TOPDIR)Rules.mak
-# As long as there is only one subdir, we don't
-# have to worry about race conditions with multiple
-# $(AR)'s in subdirs running on linuxthreads.a.
-DIRS = sysdeps
+CFLAGS+=$(SSP_ALL_CFLAGS)
-#Adjust the soname version to avoid namespace collisions with glibc's libpthread
-LIBPTHREAD:=../libpthread.a
-ifeq ($(strip $(TARGET_ARCH)),sparc)
-SYSDEPS_DIR:=$(TARGET_ARCH)/sparc32
-else
-SYSDEPS_DIR:=$(TARGET_ARCH)
-endif
-CFLAGS += $(SSP_ALL_CFLAGS)
#This stuff will not compile without at least -O1
CFLAGS :=$(CFLAGS:-O0=-O1)
-
# set up system dependencies include dirs (NOTE: order matters!)
+# psm: don't think that the last include makes sense
+# they all should be already linked to $(TOPDIR)include
PTDIR = $(TOPDIR)libpthread/linuxthreads/
SYSDEPINC = -I$(PTDIR)sysdeps/pthread \
-I$(PTDIR)sysdeps/$(TARGET_ARCH) \
-I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH)
CFLAGS += $(SYSDEPINC)
-CSRC=attr.c cancel.c condvar.c errno.c events.c join.c lockfile.c manager.c \
- mutex.c oldsemaphore.c pt-machine.c ptfork.c pthread.c \
- ptlongjmp.c rwlock.c semaphore.c signals.c specific.c spinlock.c
+ARCH_CFLAGS = $(CFLAGS)
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
- CSRC += locale.c
+ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+ SHARED_START_FILES = $(TOPDIR)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
+ SHARED_END_FILES = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
endif
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(COBJS)
+LIB_NAME=libpthread
+AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
+SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
+SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
+
+ARCH_CSRC=$(wildcard sysdeps/$(TARGET_ARCH)/*.c)
+ARCH_OBJS=$(patsubst %.c,%.o, $(ARCH_CSRC))
+-include sysdeps/$(TARGET_ARCH)/Makefile.in
-# We need to make sure that we put all the top-level $(OBJS) into
-# our archive before executing subdirs. That way, when $(AR) is
-# run in the subdirs, it'll bump the generic top-level objects
-# out of our archive in favor of the machine-specific ones.
-all: $(LIBPTHREAD) subdirs
+CSRC = $(wildcard *.c)
+ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
+CSRC := $(filter-out locale.c,$(CSRC))
+endif
+
+OBJS=$(patsubst %.c,%.o, $(CSRC))
-$(LIBPTHREAD) ar-target: $(OBJS)
- $(AR) $(ARFLAGS) $(LIBPTHREAD) $(OBJS)
+ifeq ($(strip $(HAVE_SHARED)),y)
+all: $(SO_LIB_NAME)
+else
+all: $(AR_LIB_NAME)
+endif
-$(COBJS): %.o : %.c
+$(AR_LIB_NAME): $(OBJS) $(ARCH_OBJS)
+ $(INSTALL) -d $(TOPDIR)lib
+ $(RM) $(AR_LIB_NAME)
+ $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(OBJS)
+ $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(ARCH_OBJS)
+
+$(SO_LIB_NAME): $(AR_LIB_NAME)
+ $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $(SO_LIB_NAME)
+ $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
+ -o $(TOPDIR)lib/$(SO_FULL_NAME) $(SHARED_START_FILES) --whole-archive $(AR_LIB_NAME) \
+ --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
+ -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) $(SHARED_END_FILES)
+ $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION)
+ $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME)
+
+$(OBJS): %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
$(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
@@ -73,16 +86,13 @@ else
$(STRIPTOOL) -x -R .note -R .comment $*.o
endif
-clean: subdirs_clean
- $(RM) *.[oa] *~ core
-
-subdirs: $(patsubst %, _dir_%, $(DIRS))
-subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
-
-$(patsubst %, _dir_%, $(DIRS)): $(LIBPTHREAD)
- $(MAKE) -C $(patsubst _dir_%, %, $@)
-
-$(patsubst %, _dirclean_%, $(DIRS)):
- $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
+$(ARCH_OBJS): %.o : %.c
+ $(CC) $(ARCH_CFLAGS) -c $< -o $@
+ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
+ $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o
+else
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+endif
-.PHONY: dummy
+clean:
+ $(RM) *.o sysdeps/*/*.o *~ core
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 <andersee@debian.org>
+ *
+ * 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 <stdlib.h>
+#include <sched.h>
+#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#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/linuxthreads/sysdeps/Makefile b/libpthread/linuxthreads/sysdeps/Makefile
deleted file mode 100644
index dff461543..000000000
--- a/libpthread/linuxthreads/sysdeps/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Makefile for uClibc's pthread library
-#
-# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-#
-# 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
-# Makefile for uClibc
-
-TOPDIR=../../../
-include $(TOPDIR)Rules.mak
-
-# Generally most TARGET_ARCHs aren't going to want a make rule here as they
-# can generally just inline directly into the upper-level pt-machine.c. As
-# such, we offer this capability for platforms that either can't get away
-# with the inlining, or need to be able to do builds here for other reasons.
-
-DIRS =
-
-ifeq ($(TARGET_ARCH),sh64)
- DIRS += $(TARGET_ARCH)
-endif
-
-all: subdirs
-
-clean: subdirs_clean
- $(RM) *~ core
-
-subdirs: $(patsubst %, _dir_%, $(DIRS))
-subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
-
-$(patsubst %, _dir_%, $(DIRS)) : dummy
- $(MAKE) -C $(patsubst _dir_%, %, $@)
-
-$(patsubst %, _dirclean_%, $(DIRS)) : dummy
- $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
-
-.PHONY: dummy subdirs
-
diff --git a/libpthread/linuxthreads/sysdeps/sh64/Makefile b/libpthread/linuxthreads/sysdeps/sh64/Makefile.in
index 11b7cc0b5..fed7a83b7 100644
--- a/libpthread/linuxthreads/sysdeps/sh64/Makefile
+++ b/libpthread/linuxthreads/sysdeps/sh64/Makefile.in
@@ -16,34 +16,5 @@
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-LIBPTHREAD=../../../libpthread.a
-SOBJS = $(patsubst %.S,%.o, $(SSRC))
-CSRC = pt-machine.c
-COBJS = $(patsubst %.c,%.o, $(CSRC))
-
# We need to build as SHcompact for tas..
-CFLAGS := $(subst 32media,compact,$(CFLAGS))
-
-OBJS = $(SOBJS) $(COBJS)
-
-all: $(OBJS) $(LIBC)
-
-$(LIBC): ar-target
-
-ar-target: $(OBJS)
- $(AR) $(ARFLAGS) $(LIBPTHREAD) $(OBJS)
-
-$(SOBJS): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-clean:
- $(RM) *.[oa] *~ core
-
+ARCH_CFLAGS := $(subst 32media,compact,$(ARCH_CFLAGS))