summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-21 23:15:55 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-21 23:15:55 +0000
commitc310aa40efd3b2d954354e0550b1bbb6a8e7e349 (patch)
tree5d1bea630f01a194eaec72cc13485bf24cce310b
parentd21d530170abcaec33ba272b11cb6615eb2804de (diff)
Add glibc build support
* Makeconfig, Versions, configure.in, forward.c, libc_pthread_init.c, pthread/pthread-functions.h, shlib-versions, sysdeps/i386/Implies, sysdeps/mach/hurd/Implies, sysdeps/mach/hurd/i386/Implies: New files. * Makefile: Add glibc rules, enabled when IN_GLIBC is defined to yes, when $(..) is defined. * pthread/pt-initialize.c [IS_IN_libpthread] (pthread_functions): New variable. [IS_IN_libpthread] (__pthread_initialize): Call __libc_pthread_init.
-rw-r--r--Makeconfig10
-rw-r--r--Makefile299
-rw-r--r--Versions132
-rw-r--r--configure.in4
-rw-r--r--forward.c127
-rw-r--r--libc_pthread_init.c34
-rw-r--r--pthread/pt-initialize.c50
-rw-r--r--pthread/pthread-functions.h116
-rw-r--r--shlib-versions1
-rw-r--r--sysdeps/i386/Implies1
-rw-r--r--sysdeps/mach/hurd/Implies1
-rw-r--r--sysdeps/mach/hurd/i386/Implies1
12 files changed, 662 insertions, 114 deletions
diff --git a/Makeconfig b/Makeconfig
new file mode 100644
index 0000000..e7e567c
--- /dev/null
+++ b/Makeconfig
@@ -0,0 +1,10 @@
+# Makeconfig fragment for Hurd libpthread add-on.
+# This gets included at the end of the main glibc Makeconfig.
+
+have-thread-library = yes
+
+shared-thread-library = $(common-objpfx)libpthread/libpthread.so
+static-thread-library = $(common-objpfx)libpthread/libpthread.a
+bounded-thread-library = $(static-thread-library)
+
+rpath-dirs += libpthread
diff --git a/Makefile b/Makefile
index a1801f5..b291177 100644
--- a/Makefile
+++ b/Makefile
@@ -16,128 +16,147 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ifeq ($(..),)
+# non-glibc build
+IN_GLIBC = no
+else
+# glibc build
+IN_GLIBC = yes
+endif
+
+ifeq ($(IN_GLIBC),no)
dir := libpthread
makemode := library
+else
+subdir := libpthread
+
+pthread-version := 0.3
+
+srcdir = .
+endif
MICROKERNEL := mach
-SYSDEPS := lockfile.c
-
-LCLHDRS :=
-
-SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
- pt-attr-getguardsize.c pt-attr-getinheritsched.c \
- pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \
- pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \
- pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \
- pt-attr-setinheritsched.c pt-attr-setschedparam.c \
- pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \
- pt-attr-setstackaddr.c pt-attr-setstacksize.c \
- \
- pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \
- pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \
- pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \
- \
- pt-destroy-specific.c pt-init-specific.c \
- pt-key-create.c pt-key-delete.c \
- pt-getspecific.c pt-setspecific.c \
- \
- pt-once.c \
- \
- pt-alloc.c \
- pt-create.c \
- pt-getattr.c \
- pt-equal.c \
- pt-dealloc.c \
- pt-detach.c \
- pt-exit.c \
- pt-initialize.c \
- pt-join.c \
- pt-self.c \
- pt-sigmask.c \
- pt-spin-inlines.c \
- pt-cleanup.c \
- pt-setcancelstate.c \
- pt-setcanceltype.c \
- pt-testcancel.c \
- pt-cancel.c \
- \
- pt-mutexattr.c \
- pt-mutexattr-destroy.c pt-mutexattr-init.c \
- pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \
- pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \
- pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \
- pt-mutexattr-setpshared.c pt-mutexattr-settype.c \
- \
- pt-mutex-init.c pt-mutex-destroy.c \
- pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \
- pt-mutex-unlock.c \
- pt-mutex-transfer-np.c \
- pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \
- \
- pt-rwlock-attr.c \
- pt-rwlockattr-init.c pt-rwlockattr-destroy.c \
- pt-rwlockattr-getpshared.c pt-rwlockattr-setpshared.c \
- \
- pt-rwlock-init.c pt-rwlock-destroy.c \
- pt-rwlock-rdlock.c pt-rwlock-tryrdlock.c \
- pt-rwlock-trywrlock.c pt-rwlock-wrlock.c \
- pt-rwlock-timedrdlock.c pt-rwlock-timedwrlock.c \
- pt-rwlock-unlock.c \
- \
- pt-cond.c \
- pt-condattr-init.c pt-condattr-destroy.c \
- pt-condattr-getclock.c pt-condattr-getpshared.c \
- pt-condattr-setclock.c pt-condattr-setpshared.c \
- \
- pt-cond-destroy.c pt-cond-init.c \
- pt-cond-brdcast.c \
- pt-cond-signal.c \
- pt-cond-wait.c \
- pt-cond-timedwait.c \
- \
- pt-stack-alloc.c \
- pt-thread-alloc.c \
- pt-thread-dealloc.c \
- pt-thread-start.c \
- pt-thread-halt.c \
- pt-startup.c \
- \
- pt-getconcurrency.c pt-setconcurrency.c \
- \
- pt-block.c \
- pt-timedblock.c \
- pt-wakeup.c \
- pt-docancel.c \
- pt-sysdep.c \
- pt-setup.c \
- pt-machdep.c \
- pt-spin.c \
- \
- pt-sigstate-init.c \
- pt-sigstate-destroy.c \
- pt-sigstate.c \
- \
- pt-atfork.c \
- pt-kill.c \
- pt-getcpuclockid.c \
- \
- pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
- pt-yield.c \
- \
- sem-close.c sem-destroy.c sem-getvalue.c sem-init.c sem-open.c \
- sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \
- sem-wait.c \
- \
- cthreads-compat.c \
+SYSDEPS := lockfile
+
+LCLHDRS :=
+
+libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \
+ pt-attr-getguardsize pt-attr-getinheritsched \
+ pt-attr-getschedparam pt-attr-getschedpolicy pt-attr-getscope \
+ pt-attr-getstack pt-attr-getstackaddr pt-attr-getstacksize \
+ pt-attr-init pt-attr-setdetachstate pt-attr-setguardsize \
+ pt-attr-setinheritsched pt-attr-setschedparam \
+ pt-attr-setschedpolicy pt-attr-setscope pt-attr-setstack \
+ pt-attr-setstackaddr pt-attr-setstacksize \
+ \
+ pt-barrier-destroy pt-barrier-init pt-barrier-wait \
+ pt-barrier pt-barrierattr-destroy pt-barrierattr-init \
+ pt-barrierattr-getpshared pt-barrierattr-setpshared \
+ \
+ pt-destroy-specific pt-init-specific \
+ pt-key-create pt-key-delete \
+ pt-getspecific pt-setspecific \
+ \
+ pt-once \
+ \
+ pt-alloc \
+ pt-create \
+ pt-getattr \
+ pt-equal \
+ pt-dealloc \
+ pt-detach \
+ pt-exit \
+ pt-initialize \
+ pt-join \
+ pt-self \
+ pt-sigmask \
+ pt-spin-inlines \
+ pt-cleanup \
+ pt-setcancelstate \
+ pt-setcanceltype \
+ pt-testcancel \
+ pt-cancel \
+ \
+ pt-mutexattr \
+ pt-mutexattr-destroy pt-mutexattr-init \
+ pt-mutexattr-getprioceiling pt-mutexattr-getprotocol \
+ pt-mutexattr-getpshared pt-mutexattr-gettype \
+ pt-mutexattr-setprioceiling pt-mutexattr-setprotocol \
+ pt-mutexattr-setpshared pt-mutexattr-settype \
+ \
+ pt-mutex-init pt-mutex-destroy \
+ pt-mutex-lock pt-mutex-trylock pt-mutex-timedlock \
+ pt-mutex-unlock \
+ pt-mutex-transfer-np \
+ pt-mutex-getprioceiling pt-mutex-setprioceiling \
+ \
+ pt-rwlock-attr \
+ pt-rwlockattr-init pt-rwlockattr-destroy \
+ pt-rwlockattr-getpshared pt-rwlockattr-setpshared \
+ \
+ pt-rwlock-init pt-rwlock-destroy \
+ pt-rwlock-rdlock pt-rwlock-tryrdlock \
+ pt-rwlock-trywrlock pt-rwlock-wrlock \
+ pt-rwlock-timedrdlock pt-rwlock-timedwrlock \
+ pt-rwlock-unlock \
+ \
+ pt-cond \
+ pt-condattr-init pt-condattr-destroy \
+ pt-condattr-getclock pt-condattr-getpshared \
+ pt-condattr-setclock pt-condattr-setpshared \
+ \
+ pt-cond-destroy pt-cond-init \
+ pt-cond-brdcast \
+ pt-cond-signal \
+ pt-cond-wait \
+ pt-cond-timedwait \
+ \
+ pt-stack-alloc \
+ pt-thread-alloc \
+ pt-thread-dealloc \
+ pt-thread-start \
+ pt-thread-halt \
+ pt-startup \
+ \
+ pt-getconcurrency pt-setconcurrency \
+ \
+ pt-block \
+ pt-timedblock \
+ pt-wakeup \
+ pt-docancel \
+ pt-sysdep \
+ pt-setup \
+ pt-machdep \
+ pt-spin \
+ \
+ pt-sigstate-init \
+ pt-sigstate-destroy \
+ pt-sigstate \
+ \
+ pt-atfork \
+ pt-kill \
+ pt-getcpuclockid \
+ \
+ pt-getschedparam pt-setschedparam pt-setschedprio \
+ pt-yield \
+ \
+ sem-close sem-destroy sem-getvalue sem-init sem-open \
+ sem-post sem-timedwait sem-trywait sem-unlink \
+ sem-wait \
+ \
+ cthreads-compat \
$(SYSDEPS)
+ifeq ($(IN_GLIBC),no)
+SRCS := $(addsuffix .c,$(libpthread-routines))
OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS))))
OTHERTAGS =
libname = libpthread
+endif
-sysdeps_headers = \
+headers := \
pthread.h \
pthread/pthread.h \
pthread/pthreadtypes.h \
@@ -161,6 +180,21 @@ sysdeps_headers = \
bits/rwlock-attr.h \
bits/semaphore.h
+ifeq ($(IN_GLIBC),yes)
+distribute :=
+
+routines := forward libc_pthread_init
+shared-only-routines = forward
+
+vpath %.c
+
+extra-libs := libpthread
+extra-libs-others := $(extra-libs)
+install-lib-ldscripts := libpthread.so
+
+include ../Makeconfig
+endif
+
SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \
$(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \
$(srcdir)/sysdeps/ia32 \
@@ -174,22 +208,41 @@ SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \
VPATH += $(SYSDEP_PATH)
+ifeq ($(IN_GLIBC),no)
HURDLIBS = ihash
+else
+LDLIBS-pthread.so = -lihash
+endif
+ifeq ($(IN_GLIBC),no)
installhdrs :=
installhdrsubdir := .
include ../Makeconf
+endif
CPPFLAGS += \
-DENABLE_TLS \
$(addprefix -I, $(SYSDEP_PATH)) \
- -imacros $(srcdir)/include/libc-symbols.h \
-imacros $(srcdir)/not-in-libc.h
+ifeq ($(IN_GLIBC),no)
+CPPFLAGS += \
+ -imacros $(srcdir)/include/libc-symbols.h
+else
+CPPFLAGS += \
+ -imacros libc-symbols.h
+endif
+
+ifeq ($(IN_GLIBC),yes)
+CFLAGS-lockfile.c = -D_IO_MTSAFE_IO
+all: # Make this the default target; it will be defined in Rules.
+endif
+
+ifeq ($(IN_GLIBC),no)
install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a
-install-headers: $(addprefix $(includedir)/, $(sysdeps_headers))
+install-headers: $(addprefix $(includedir)/, $(headers))
# XXX: If $(libdir)/libpthread2.a is installed and
# $(libdir)/libpthread is not, we can have some issues.
@@ -206,10 +259,27 @@ $(libdir)/libpthread2.a: $(libdir)/libpthread.a
$(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a
mv $< $@
$(INSTALL_DATA) $(srcdir)/libpthread_pic.a $<
+endif
+
+ifeq ($(IN_GLIBC),yes)
+libc-link.so = $(common-objpfx)libc.so
+
+include ../Rules
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+# Depend on ld.so too to get proper versions of ld.so symbols.
+$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \
+ $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so) \
+ $(common-objpfx)/mach/libmachuser.so \
+ $(common-objpfx)/hurd/libhurduser.so
+endif
-.PHONY: $(addprefix $(includedir)/, $(sysdeps_headers))
+ifeq ($(IN_GLIBC),no)
+.PHONY: $(addprefix $(includedir)/, $(headers))
-$(addprefix $(includedir)/, $(sysdeps_headers)):
+$(addprefix $(includedir)/, $(headers)):
@set -e; \
t="$@"; \
t=$${t#$(includedir)/}; \
@@ -247,3 +317,4 @@ maintainer.; \
# $(libname).so.$(hurd-version): $(srcdir)/$(libname).map
#
# endif
+endif
diff --git a/Versions b/Versions
new file mode 100644
index 0000000..77eb870
--- /dev/null
+++ b/Versions
@@ -0,0 +1,132 @@
+libc {
+ GLIBC_2.13 {
+ pthread_attr_destroy; pthread_attr_getdetachstate;
+ pthread_attr_getinheritsched; pthread_attr_getschedparam;
+ pthread_attr_getschedpolicy; pthread_attr_getscope; pthread_attr_init;
+ pthread_attr_setdetachstate; pthread_attr_setinheritsched;
+ pthread_attr_setschedparam; pthread_attr_setschedpolicy;
+ pthread_attr_setscope;
+ pthread_condattr_destroy; pthread_condattr_init;
+ pthread_cond_broadcast; pthread_cond_destroy;
+ pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
+ pthread_cond_timedwait;
+ pthread_equal;
+ pthread_exit; pthread_getschedparam; pthread_setschedparam;
+ pthread_mutex_destroy; pthread_mutex_init;
+ pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock;
+ pthread_self; pthread_setcancelstate; pthread_setcanceltype;
+ __pthread_get_cleanup_stack;
+ GLIBC_PRIVATE {
+ __libc_pthread_init;
+ }
+}
+
+libpthread {
+ GLIBC_2.12 {
+ __pthread_errorcheck_mutexattr; __pthread_recursive_mutexattr;
+
+ _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
+
+ __pthread_get_cleanup_stack;
+
+ __pthread_mutex_transfer_np;
+
+ _pthread_mutex_destroy; _pthread_mutex_init;
+ _pthread_mutex_lock; _pthread_mutex_trylock; _pthread_mutex_unlock;
+ _pthread_rwlock_destroy; _pthread_rwlock_init;
+
+ _cthread_init_routine;
+
+ cthread_detach;
+ cthread_fork;
+ cthread_keycreate;
+ cthread_getspecific;
+ __libc_getspecific;
+ cthread_setspecific;
+ __mutex_lock_solid;
+ __mutex_unlock_solid;
+ _cthreads_flockfile;
+ _cthreads_ftrylockfile;
+ _cthreads_funlockfile;
+
+ flockfile; ftrylockfile; funlockfile;
+
+ pthread_atfork;
+
+ pthread_attr_destroy; pthread_attr_getdetachstate;
+ pthread_attr_getguardsize; pthread_attr_getinheritsched;
+ pthread_attr_getschedparam; pthread_attr_getschedpolicy;
+ pthread_attr_getscope; pthread_attr_getstack; pthread_attr_getstackaddr;
+ pthread_attr_getstacksize; pthread_attr_init; pthread_attr_setdetachstate;
+ pthread_attr_setguardsize; pthread_attr_setinheritsched;
+ pthread_attr_setschedparam; pthread_attr_setschedpolicy;
+ pthread_attr_setscope; pthread_attr_setstack; pthread_attr_setstackaddr;
+ pthread_attr_setstacksize;
+
+ pthread_barrier_destroy; pthread_barrier_init; pthread_barrier_wait;
+ pthread_barrierattr_destroy; pthread_barrierattr_getpshared;
+ pthread_barrierattr_init; pthread_barrierattr_setpshared;
+
+ pthread_cancel;
+
+ pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init;
+ pthread_cond_signal; pthread_cond_timedwait; pthread_cond_wait;
+
+ pthread_condattr_destroy; pthread_condattr_getclock;
+ pthread_condattr_getpshared; pthread_condattr_init;
+ pthread_condattr_setclock; pthread_condattr_setpshared;
+
+ pthread_create; pthread_detach; pthread_equal; pthread_exit;
+
+ pthread_getattr_np;
+
+ pthread_getconcurrency; pthread_getcpuclockid;
+ pthread_getschedparam; pthread_getspecific;
+
+ pthread_join;
+
+ pthread_key_create; pthread_key_delete;
+
+ pthread_kill;
+
+ pthread_mutex_destroy; pthread_mutex_getprioceiling;
+ pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling;
+ pthread_mutex_timedlock; pthread_mutex_transfer_np;
+ pthread_mutex_trylock; pthread_mutex_unlock;
+
+ pthread_mutexattr_destroy; pthread_mutexattr_getprioceiling;
+ pthread_mutexattr_getprotocol; pthread_mutexattr_getpshared;
+ pthread_mutexattr_gettype; pthread_mutexattr_init;
+ pthread_mutexattr_setprioceiling; pthread_mutexattr_setprotocol;
+ pthread_mutexattr_setpshared; pthread_mutexattr_settype;
+
+ pthread_once;
+
+ pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock;
+ pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock;
+ pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock;
+ pthread_rwlock_unlock; pthread_rwlock_wrlock;
+
+ pthread_rwlockattr_destroy; pthread_rwlockattr_getpshared;
+ pthread_rwlockattr_init; pthread_rwlockattr_setpshared;
+
+ pthread_self;
+
+ pthread_setcancelstate; pthread_setcanceltype;
+ pthread_setconcurrency; pthread_setschedparam;
+ pthread_setschedprio; pthread_setspecific;
+
+ pthread_sigmask;
+ pthread_testcancel;
+ pthread_yield;
+
+ sem_close; sem_destroy; sem_getvalue; sem_init; sem_open; sem_post;
+ sem_timedwait; sem_trywait; sem_unlink; sem_wait;
+
+ pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
+ pthread_spin_trylock; pthread_spin_unlock;
+ __pthread_spin_destroy; __pthread_spin_init;
+ __pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock;
+ _pthread_spin_lock;
+ }
+}
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..4e140b1
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES
+
+libc_add_on_canonical=libpthread
+libc_add_on_subdirs=.
diff --git a/forward.c b/forward.c
new file mode 100644
index 0000000..c07d7c0
--- /dev/null
+++ b/forward.c
@@ -0,0 +1,127 @@
+/* Copyright (C) 2002, 2003, 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <shlib-compat.h>
+#include <pthread-functions.h>
+
+/* Pointers to the libc functions. */
+struct pthread_functions __libc_pthread_functions attribute_hidden;
+
+
+# define FORWARD2(name, rettype, decl, params, defaction) \
+rettype \
+name decl \
+{ \
+ if (__libc_pthread_functions.ptr_##name == NULL) \
+ defaction; \
+ \
+ return __libc_pthread_functions.ptr_##name params; \
+}
+
+# define FORWARD(name, decl, params, defretval) \
+ FORWARD2 (name, int, decl, params, return defretval)
+
+FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
+
+FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0)
+
+FORWARD (pthread_attr_getdetachstate,
+ (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
+ 0)
+FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
+ (attr, detachstate), 0)
+
+FORWARD (pthread_attr_getinheritsched,
+ (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
+FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
+ (attr, inherit), 0)
+
+FORWARD (pthread_attr_getschedparam,
+ (const pthread_attr_t *attr, struct sched_param *param),
+ (attr, param), 0)
+FORWARD (pthread_attr_setschedparam,
+ (pthread_attr_t *attr, const struct sched_param *param),
+ (attr, param), 0)
+
+FORWARD (pthread_attr_getschedpolicy,
+ (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
+FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
+ (attr, policy), 0)
+
+FORWARD (pthread_attr_getscope,
+ (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
+FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
+ (attr, scope), 0)
+
+
+FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
+FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
+
+
+FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
+FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
+FORWARD (pthread_cond_init,
+ (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
+ (cond, cond_attr), 0)
+FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
+FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
+ (cond, mutex), 0)
+FORWARD (pthread_cond_timedwait,
+ (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime), (cond, mutex, abstime), 0)
+
+FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
+ (thread1, thread2), 1)
+
+
+/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
+FORWARD2 (pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
+
+
+FORWARD (pthread_getschedparam,
+ (pthread_t target_thread, int *policy, struct sched_param *param),
+ (target_thread, policy, param), 0)
+FORWARD (pthread_setschedparam,
+ (pthread_t target_thread, int policy,
+ const struct sched_param *param), (target_thread, policy, param), 0)
+
+
+FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
+
+FORWARD (pthread_mutex_init,
+ (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
+ (mutex, mutexattr), 0)
+
+FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
+
+FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
+
+
+FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
+
+
+FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
+ 0)
+
+FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
+
+struct __pthread_cancelation_handler *dummy_list;
+FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **, (void), (), return &dummy_list);
diff --git a/libc_pthread_init.c b/libc_pthread_init.c
new file mode 100644
index 0000000..e6c8b9f
--- /dev/null
+++ b/libc_pthread_init.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+#include <pthread-functions.h>
+
+void
+__libc_pthread_init (functions)
+ const struct pthread_functions *functions;
+{
+#ifdef SHARED
+ /* We copy the content of the variable pointed to by the FUNCTIONS
+ parameter to one in libc.so since this means access to the array
+ can be done with one memory access instead of two. */
+ memcpy (&__libc_pthread_functions, functions,
+ sizeof (__libc_pthread_functions));
+#endif
+}
diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c
index cf32b8b..f0ef8f8 100644
--- a/pthread/pt-initialize.c
+++ b/pthread/pt-initialize.c
@@ -23,11 +23,61 @@
#include <pt-internal.h>
#include <set-hooks.h>
+#include <pthread.h>
+#include <pthread-functions.h>
+
DEFINE_HOOK (__pthread_init, (void));
+#ifdef IS_IN_libpthread
+#ifdef SHARED
+static const struct pthread_functions pthread_functions =
+ {
+ .ptr_pthread_attr_destroy = __pthread_attr_destroy,
+ .ptr_pthread_attr_init = __pthread_attr_init,
+ .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate,
+ .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate,
+ .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched,
+ .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched,
+ .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam,
+ .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam,
+ .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy,
+ .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy,
+ .ptr_pthread_attr_getscope = __pthread_attr_getscope,
+ .ptr_pthread_attr_setscope = __pthread_attr_setscope,
+ .ptr_pthread_condattr_destroy = __pthread_condattr_destroy,
+ .ptr_pthread_condattr_init = __pthread_condattr_init,
+ .ptr_pthread_cond_broadcast = __pthread_cond_broadcast,
+ .ptr_pthread_cond_destroy = __pthread_cond_destroy,
+ .ptr_pthread_cond_init = __pthread_cond_init,
+ .ptr_pthread_cond_signal = __pthread_cond_signal,
+ .ptr_pthread_cond_wait = __pthread_cond_wait,
+ .ptr_pthread_cond_timedwait = __pthread_cond_timedwait,
+ .ptr_pthread_equal = __pthread_equal,
+ .ptr_pthread_exit = __pthread_exit,
+ .ptr_pthread_getschedparam = __pthread_getschedparam,
+ .ptr_pthread_setschedparam = __pthread_setschedparam,
+ .ptr_pthread_mutex_destroy = _pthread_mutex_destroy,
+ .ptr_pthread_mutex_init = _pthread_mutex_init,
+ .ptr_pthread_mutex_lock = __pthread_mutex_lock,
+ .ptr_pthread_mutex_trylock = __pthread_mutex_trylock,
+ .ptr_pthread_mutex_unlock = __pthread_mutex_unlock,
+ .ptr_pthread_self = __pthread_self,
+ .ptr_pthread_setcancelstate = __pthread_setcancelstate,
+ .ptr_pthread_setcanceltype = __pthread_setcanceltype,
+ .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack,
+ };
+# define ptr_pthread_functions &pthread_functions
+#else
+# define ptr_pthread_functions NULL
+#endif
+#endif /* IS_IN_libpthread */
+
/* Initialize the pthreads library. */
void
__pthread_initialize (void)
{
+#ifdef IS_IN_libpthread
+ __libc_pthread_init(ptr_pthread_functions);
+#endif
RUN_HOOK (__pthread_init, ());
}
diff --git a/pthread/pthread-functions.h b/pthread/pthread-functions.h
new file mode 100644
index 0000000..c0ba858
--- /dev/null
+++ b/pthread/pthread-functions.h
@@ -0,0 +1,116 @@
+/* Copyright (C) 2003, 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _PTHREAD_FUNCTIONS_H
+#define _PTHREAD_FUNCTIONS_H 1
+
+#include <pthread.h>
+
+int __pthread_attr_destroy (pthread_attr_t *);
+int __pthread_attr_init (pthread_attr_t *);
+int __pthread_attr_getdetachstate (const pthread_attr_t *, int *);
+int __pthread_attr_setdetachstate (pthread_attr_t *, int);
+int __pthread_attr_getinheritsched (const pthread_attr_t *, int *);
+int __pthread_attr_setinheritsched (pthread_attr_t *, int);
+int __pthread_attr_getschedparam (const pthread_attr_t *,
+ struct sched_param *);
+int __pthread_attr_setschedparam (pthread_attr_t *,
+ const struct sched_param *);
+int __pthread_attr_getschedpolicy (const pthread_attr_t *, int *);
+int __pthread_attr_setschedpolicy (pthread_attr_t *, int);
+int __pthread_attr_getscope (const pthread_attr_t *, int *);
+int __pthread_attr_setscope (pthread_attr_t *, int);
+int __pthread_condattr_destroy (pthread_condattr_t *);
+int __pthread_condattr_init (pthread_condattr_t *);
+int __pthread_cond_broadcast (pthread_cond_t *);
+int __pthread_cond_destroy (pthread_cond_t *);
+int __pthread_cond_init (pthread_cond_t *,
+ const pthread_condattr_t *);
+int __pthread_cond_signal (pthread_cond_t *);
+int __pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *);
+int __pthread_cond_timedwait (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
+int __pthread_equal (pthread_t, pthread_t);
+void __pthread_exit (void *);
+int __pthread_getschedparam (pthread_t, int *, struct sched_param *);
+int __pthread_setschedparam (pthread_t, int,
+ const struct sched_param *);
+int _pthread_mutex_destroy (pthread_mutex_t *);
+int _pthread_mutex_init (pthread_mutex_t *,
+ const pthread_mutexattr_t *);
+int __pthread_mutex_lock (pthread_mutex_t *);
+int __pthread_mutex_trylock (pthread_mutex_t *);
+int __pthread_mutex_unlock (pthread_mutex_t *);
+pthread_t __pthread_self (void);
+int __pthread_setcancelstate (int, int *);
+int __pthread_setcanceltype (int, int *);
+struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
+
+/* Data type shared with libc. The libc uses it to pass on calls to
+ the thread functions. Wine pokes directly into this structure,
+ so if possible avoid breaking it and append new hooks to the end. */
+struct pthread_functions
+{
+ int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
+ int (*ptr_pthread_attr_init) (pthread_attr_t *);
+ int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *,
+ struct sched_param *);
+ int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *,
+ const struct sched_param *);
+ int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int);
+ int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *);
+ int (*ptr_pthread_condattr_init) (pthread_condattr_t *);
+ int (*ptr_pthread_cond_broadcast) (pthread_cond_t *);
+ int (*ptr_pthread_cond_destroy) (pthread_cond_t *);
+ int (*ptr_pthread_cond_init) (pthread_cond_t *,
+ const pthread_condattr_t *);
+ int (*ptr_pthread_cond_signal) (pthread_cond_t *);
+ int (*ptr_pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
+ int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
+ int (*ptr_pthread_equal) (pthread_t, pthread_t);
+ void (*ptr_pthread_exit) (void *);
+ int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
+ int (*ptr_pthread_setschedparam) (pthread_t, int,
+ const struct sched_param *);
+ int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_init) (pthread_mutex_t *,
+ const pthread_mutexattr_t *);
+ int (*ptr_pthread_mutex_lock) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_trylock) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *);
+ pthread_t (*ptr_pthread_self) (void);
+ int (*ptr_pthread_setcancelstate) (int, int *);
+ int (*ptr_pthread_setcanceltype) (int, int *);
+ struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void);
+};
+
+/* Variable in libc.so. */
+extern struct pthread_functions __libc_pthread_functions attribute_hidden;
+
+void __libc_pthread_init (const struct pthread_functions *functions);
+
+#endif /* pthread-functions.h */
diff --git a/shlib-versions b/shlib-versions
new file mode 100644
index 0000000..b320be0
--- /dev/null
+++ b/shlib-versions
@@ -0,0 +1 @@
+.*-.*-.* libpthread=0.3
diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies
new file mode 100644
index 0000000..d799fa1
--- /dev/null
+++ b/sysdeps/i386/Implies
@@ -0,0 +1 @@
+ia32
diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies
new file mode 100644
index 0000000..16b8348
--- /dev/null
+++ b/sysdeps/mach/hurd/Implies
@@ -0,0 +1 @@
+hurd
diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies
new file mode 100644
index 0000000..d799fa1
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/Implies
@@ -0,0 +1 @@
+ia32