From c310aa40efd3b2d954354e0550b1bbb6a8e7e349 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 23:15:55 +0000 Subject: 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. --- Makefile | 299 +++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 185 insertions(+), 114 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3 From 69e89a859882e4f675dd5491edc969159d8a4002 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 22 Apr 2012 00:38:26 +0200 Subject: __pthread_timedblock: switch to clock_gettime Use `clock_gettime' with the provided clock instead of `gettimeofday', linking to rt. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Switch to `clock_gettime'. * Makefile [!IN_GLIBC] (LDLIBS): Link to rt. [IN_GLIBC] ($(objpfx)libpthread.so): Likewise. * Makefile.am (libpthread_a_LDADD): Likewise. --- Makefile | 2 ++ Makefile.am | 2 ++ sysdeps/mach/pt-timedblock.c | 13 ++++++------- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b291177..bee4e3c 100644 --- a/Makefile +++ b/Makefile @@ -210,8 +210,10 @@ VPATH += $(SYSDEP_PATH) ifeq ($(IN_GLIBC),no) HURDLIBS = ihash +LDLIBS = -lrt else LDLIBS-pthread.so = -lihash +$(objpfx)libpthread.so: $(common-objpfx)rt/librt.so endif ifeq ($(IN_GLIBC),no) diff --git a/Makefile.am b/Makefile.am index e1c062c..36ede54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -166,3 +166,5 @@ libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ sigwaitinfo.c \ signal-dispatch-lowlevel.c \ sigprocmask.c + +libpthread_a_LDADD = -lrt diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 88beaa2..d72ef73 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -36,27 +36,26 @@ __pthread_timedblock (struct __pthread *thread, error_t err; mach_msg_header_t msg; mach_msg_timeout_t timeout; - struct timeval now; + struct timespec now; /* We have an absolute time and now we have to convert it to a relative time. Arg. */ - err = gettimeofday(&now, NULL); + err = clock_gettime (clock_id, &now); assert (! err); if (now.tv_sec > abstime->tv_sec || (now.tv_sec == abstime->tv_sec - && now.tv_usec > ((abstime->tv_nsec + 999) / 1000))) + && now.tv_nsec > abstime->tv_nsec)) return ETIMEDOUT; timeout = (abstime->tv_sec - now.tv_sec) * 1000; - if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec) - timeout += (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; + if (abstime->tv_nsec >= now.tv_nsec) + timeout += (abstime->tv_nsec - now.tv_nsec + 999999) / 1000000; else /* Need to do a carry. */ - timeout -= (now.tv_usec + 999) / 1000 - - ((abstime->tv_nsec + 999999) / 1000000); + timeout -= (now.tv_nsec - abstime->tv_nsec + 999999) / 1000000; err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, -- cgit v1.2.3 From 23e100abfe088d846df479ab176cba28f43a7814 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 00:50:37 +0000 Subject: Set -B option to find libpthread.so * Makefile (extra-B-pthread.so): Define. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b291177..73f90da 100644 --- a/Makefile +++ b/Makefile @@ -264,6 +264,8 @@ endif ifeq ($(IN_GLIBC),yes) libc-link.so = $(common-objpfx)libc.so +extra-B-pthread.so = -B$(common-objpfx)libpthread/ + include ../Rules # Depend on libc.so so a DT_NEEDED is generated in the shared objects. -- cgit v1.2.3 From cf4bfa4a4c5216e2d07a7fec4aa6487fa56003c9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 16:52:46 +0000 Subject: Install bits/pthreadtypes.h And make it expose only types, not the rest of the pthread API. * Makefile (headers): Add bits/pthreadtypes.h. * sysdeps/generic/bits/pthreadtypes.h: Include instead of --- Makefile | 1 + sysdeps/generic/bits/pthreadtypes.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 73f90da..4bc0101 100644 --- a/Makefile +++ b/Makefile @@ -164,6 +164,7 @@ headers := \ \ bits/pthread.h \ bits/pthread-np.h \ + bits/pthreadtypes.h \ bits/mutex.h \ bits/condition.h \ bits/condition-attr.h \ diff --git a/sysdeps/generic/bits/pthreadtypes.h b/sysdeps/generic/bits/pthreadtypes.h index e5cbfd2..70368ff 100644 --- a/sysdeps/generic/bits/pthreadtypes.h +++ b/sysdeps/generic/bits/pthreadtypes.h @@ -24,6 +24,6 @@ #ifndef _BITS_PTHREADTYPES_H #define _BITS_PTHREADTYPES_H 1 -#include +#include #endif /* bits/pthreadtypes.h */ -- cgit v1.2.3 From 9741579ea63731ff5651cd3185d04c71bae2fe14 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 16:55:40 +0000 Subject: Fix glibc add-on installation rules * Makefile [IN_GLIBC=no] (inst_libdir): Define to $(libdir). (install, .PHONY, libpthread2.a, libpthread2_pic.a): Use $(inst_libdir) instead of $(libdir), enable in IN_GLIBC=yes too. [IN_GLIBC=yes] ($(inst_libdir)/libpthread.so): Define to create symlink. --- Makefile | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4bc0101..153d66b 100644 --- a/Makefile +++ b/Makefile @@ -242,27 +242,39 @@ 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 +$(inst_libdir) = $(libdir) +endif + +ifeq ($(IN_GLIBC),no) +install: install-headers install-headers: $(addprefix $(includedir)/, $(headers)) -# XXX: If $(libdir)/libpthread2.a is installed and -# $(libdir)/libpthread is not, we can have some issues. -.PHONY: $(libdir)/libpthread.a $(libdir)/libpthread_pic.a +install: $(inst_libdir)/libpthread2.a $(inst_libdir)/libpthread2_pic.a +else +subdir_install: $(inst_libdir)/libpthread2.a +endif + +# XXX: If $(inst_libdir)/libpthread2.a is installed and +# $(inst_libdir)/libpthread is not, we can have some issues. +.PHONY: $(inst_libdir)/libpthread.a $(inst_libdir)/libpthread_pic.a # XXX: These rules are a hack. But it is better than messing with # ../Makeconf at the moment. Note that the linker scripts # $(srcdir)/libpthread.a and $(srcdir)/libpthread_pic.a get overwritten # when building in $(srcdir) and not a seperate build directory. -$(libdir)/libpthread2.a: $(libdir)/libpthread.a +$(inst_libdir)/libpthread2.a: $(inst_libdir)/libpthread.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread.a $< -$(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a +$(inst_libdir)/libpthread2_pic.a: $(inst_libdir)/libpthread_pic.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread_pic.a $< -endif ifeq ($(IN_GLIBC),yes) +$(inst_libdir)/libpthread.so: $(objpfx)libpthread.so$(libpthread.so-version) \ + $(+force) + ln -sf libpthread.so$(libpthread.so-version) $@ + libc-link.so = $(common-objpfx)libc.so extra-B-pthread.so = -B$(common-objpfx)libpthread/ -- cgit v1.2.3 From 36b80faf23f4585721355ad2501225776a0ce392 Mon Sep 17 00:00:00 2001 From: Thomas DiModica Date: Sat, 4 Aug 2012 00:37:16 +0200 Subject: Fix typo * Makefile (inst_libdir) [!IN_GLIBC]: Set variable to $(libdir) instead of expanding it. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e8c77e3..efb486e 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ all: # Make this the default target; it will be defined in Rules. endif ifeq ($(IN_GLIBC),no) -$(inst_libdir) = $(libdir) +inst_libdir = $(libdir) endif ifeq ($(IN_GLIBC),no) -- cgit v1.2.3 From 549aba4335946c26f2701c2b43be0e6148d27c09 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 7 Aug 2012 13:19:58 +0200 Subject: Fix libpthread.so symlink * Makefile ($(inst_libdir)/libpthread.so): Symlink from absolute path $(slibdir)/libpthread.so$(libpthread.so-version) instead of relative, as both files may not be in the same directory (e.g. in Debian). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index efb486e..b6e5602 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ $(inst_libdir)/libpthread2_pic.a: $(inst_libdir)/libpthread_pic.a ifeq ($(IN_GLIBC),yes) $(inst_libdir)/libpthread.so: $(objpfx)libpthread.so$(libpthread.so-version) \ $(+force) - ln -sf libpthread.so$(libpthread.so-version) $@ + ln -sf $(slibdir)/libpthread.so$(libpthread.so-version) $@ libc-link.so = $(common-objpfx)libc.so -- cgit v1.2.3 From af7d78e726cb0d3248c461cfee27fe15121dacd1 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 22:36:56 +0200 Subject: Rename ia32 sysdep directories to i386. * sysdeps/i386/Implies: Remove file. * sysdeps/mach/hurd/i386/Implies: Likewise. * sysdeps/ia32/bits/memory.h: Rename to sysdeps/i386/bits/memory.h. * sysdeps/ia32/bits/pt-atomic.h: Rename to sysdeps/i386/bits/pt-atomic.h. * sysdeps/ia32/bits/spin-lock-inline.h: Rename to sysdeps/i386/bits/spin-lock-inline.h. * sysdeps/ia32/bits/spin-lock.h: Rename to sysdeps/i386/bits/spin-lock.h. * sysdeps/ia32/machine-sp.h: Rename to sysdeps/i386/machine-sp.h. * sysdeps/ia32/pt-machdep.h: Rename to sysdeps/i386/pt-machdep.h. * sysdeps/mach/hurd/ia32/pt-machdep.c: Rename to sysdeps/mach/hurd/i386/pt-machdep.c. * sysdeps/mach/hurd/ia32/pt-setup.c: Rename to sysdeps/mach/hurd/i386/pt-setup.c. * Makefile (SYSDEP_PATH): Adapt to that. --- Makefile | 6 +- sysdeps/i386/Implies | 1 - sysdeps/i386/bits/memory.h | 40 +++++++++++++ sysdeps/i386/bits/pt-atomic.h | 66 ++++++++++++++++++++++ sysdeps/i386/bits/spin-lock-inline.h | 98 ++++++++++++++++++++++++++++++++ sysdeps/i386/bits/spin-lock.h | 39 +++++++++++++ sysdeps/i386/machine-sp.h | 30 ++++++++++ sysdeps/i386/pt-machdep.h | 29 ++++++++++ sysdeps/ia32/bits/memory.h | 40 ------------- sysdeps/ia32/bits/pt-atomic.h | 66 ---------------------- sysdeps/ia32/bits/spin-lock-inline.h | 98 -------------------------------- sysdeps/ia32/bits/spin-lock.h | 39 ------------- sysdeps/ia32/machine-sp.h | 30 ---------- sysdeps/ia32/pt-machdep.h | 29 ---------- sysdeps/mach/hurd/i386/Implies | 1 - sysdeps/mach/hurd/i386/pt-machdep.c | 83 +++++++++++++++++++++++++++ sysdeps/mach/hurd/i386/pt-setup.c | 106 +++++++++++++++++++++++++++++++++++ sysdeps/mach/hurd/ia32/pt-machdep.c | 83 --------------------------- sysdeps/mach/hurd/ia32/pt-setup.c | 106 ----------------------------------- 19 files changed, 494 insertions(+), 496 deletions(-) delete mode 100644 sysdeps/i386/Implies create mode 100644 sysdeps/i386/bits/memory.h create mode 100644 sysdeps/i386/bits/pt-atomic.h create mode 100644 sysdeps/i386/bits/spin-lock-inline.h create mode 100644 sysdeps/i386/bits/spin-lock.h create mode 100644 sysdeps/i386/machine-sp.h create mode 100644 sysdeps/i386/pt-machdep.h delete mode 100644 sysdeps/ia32/bits/memory.h delete mode 100644 sysdeps/ia32/bits/pt-atomic.h delete mode 100644 sysdeps/ia32/bits/spin-lock-inline.h delete mode 100644 sysdeps/ia32/bits/spin-lock.h delete mode 100644 sysdeps/ia32/machine-sp.h delete mode 100644 sysdeps/ia32/pt-machdep.h delete mode 100644 sysdeps/mach/hurd/i386/Implies create mode 100644 sysdeps/mach/hurd/i386/pt-machdep.c create mode 100644 sysdeps/mach/hurd/i386/pt-setup.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-machdep.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-setup.c (limited to 'Makefile') diff --git a/Makefile b/Makefile index b6e5602..fdfe3ae 100644 --- a/Makefile +++ b/Makefile @@ -196,9 +196,9 @@ install-lib-ldscripts := libpthread.so include ../Makeconfig endif -SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ - $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \ - $(srcdir)/sysdeps/ia32 \ +SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/i386 \ + $(srcdir)/sysdeps/$(MICROKERNEL)/i386 \ + $(srcdir)/sysdeps/i386 \ $(srcdir)/sysdeps/$(MICROKERNEL)/hurd \ $(srcdir)/sysdeps/$(MICROKERNEL) \ $(srcdir)/sysdeps/hurd \ diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/i386/bits/memory.h b/sysdeps/i386/bits/memory.h new file mode 100644 index 0000000..932c408 --- /dev/null +++ b/sysdeps/i386/bits/memory.h @@ -0,0 +1,40 @@ +/* Memory barrier operations. i386 version. + Copyright (C) 2002, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_MEMORY_H +#define _BITS_MEMORY_H 1 + +/* Prevent read and write reordering across this function. */ +static inline void +__memory_barrier (void) +{ + int i; + + /* Any lock'ed instruction will do. We just do a simple + increment. */ + __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory"); +} + +/* Prevent read reordering across this function. */ +#define __memory_read_barrier __memory_barrier + +/* Prevent write reordering across this function. */ +#define __memory_write_barrier __memory_barrier + +#endif diff --git a/sysdeps/i386/bits/pt-atomic.h b/sysdeps/i386/bits/pt-atomic.h new file mode 100644 index 0000000..0dfc1f6 --- /dev/null +++ b/sysdeps/i386/bits/pt-atomic.h @@ -0,0 +1,66 @@ +/* Atomic operations. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +typedef __volatile int __atomic_t; + +static inline void +__atomic_inc (__atomic_t *__var) +{ + __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline void +__atomic_dec (__atomic_t *__var) +{ + __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline int +__atomic_dec_and_test (__atomic_t *__var) +{ + unsigned char __ret; + + __asm__ __volatile ("lock; decl %0; sete %1" + : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); + return __ret != 0; +} + +/* We assume that an __atomicptr_t is only used for pointers to + word-aligned objects, and use the lowest bit for a simple lock. */ +typedef __volatile int * __atomicptr_t; + +/* Actually we don't implement that yet, and assume that we run on + something that has the i486 instruction set. */ +static inline int +__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, + void * __newval) +{ + char __ret; + int __dummy; + + __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" + : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) + : "r" (__newval), "m" (*__ptr), "a" (__oldval)); + return __ret; +} + +#endif diff --git a/sysdeps/i386/bits/spin-lock-inline.h b/sysdeps/i386/bits/spin-lock-inline.h new file mode 100644 index 0000000..e5ed3de --- /dev/null +++ b/sysdeps/i386/bits/spin-lock-inline.h @@ -0,0 +1,98 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * Never include this file directly; use or instead. + */ + +#ifndef _BITS_SPIN_LOCK_INLINE_H +#define _BITS_SPIN_LOCK_INLINE_H 1 + +#include +#include + +__BEGIN_DECLS + +#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES + +# ifndef __EBUSY +# include +# define __EBUSY EBUSY +# endif + +# ifndef __PT_SPIN_INLINE +# define __PT_SPIN_INLINE __extern_inline +# endif + +__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_destroy (__pthread_spinlock_t *__lock) +{ + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, + int __pshared); + +__PT_SPIN_INLINE int +__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) +{ + *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_trylock (__pthread_spinlock_t *__lock) +{ + int __locked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); + return __locked ? __EBUSY : 0; +} + +__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); +extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); + +__extern_inline int +__pthread_spin_lock (__pthread_spinlock_t *__lock) +{ + if (__pthread_spin_trylock (__lock)) + return _pthread_spin_lock (__lock); + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_unlock (__pthread_spinlock_t *__lock) +{ + int __unlocked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); + return 0; +} + +#endif /* Use extern inlines or force inlines. */ + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/i386/bits/spin-lock.h new file mode 100644 index 0000000..5ae81e1 --- /dev/null +++ b/sysdeps/i386/bits/spin-lock.h @@ -0,0 +1,39 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * Never include this file directly; use or instead. + */ + +#ifndef _BITS_SPIN_LOCK_H +#define _BITS_SPIN_LOCK_H 1 + +#include + +__BEGIN_DECLS + +/* The type of a spin lock object. */ +typedef __volatile int __pthread_spinlock_t; + +/* Initializer for a spin lock object. */ +# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/machine-sp.h b/sysdeps/i386/machine-sp.h new file mode 100644 index 0000000..cef6ab7 --- /dev/null +++ b/sysdeps/i386/machine-sp.h @@ -0,0 +1,30 @@ +/* Machine-specific function to return the stack pointer. i386 version. + Copyright (C) 1994, 1997, 2001, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 _MACHINE_SP_H +#define _MACHINE_SP_H + +/* Return the current stack pointer. */ + +#define __thread_stack_pointer() ({ \ + register void *__sp__ asm("esp"); \ + __sp__; \ +}) + +#endif /* machine-sp.h */ diff --git a/sysdeps/i386/pt-machdep.h b/sysdeps/i386/pt-machdep.h new file mode 100644 index 0000000..6d45636 --- /dev/null +++ b/sysdeps/i386/pt-machdep.h @@ -0,0 +1,29 @@ +/* Machine dependent pthreads internal defenitions. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _PT_MACHDEP_H +#define _PT_MACHDEP_H 1 + +struct pthread_mcontext +{ + void *pc; + void *sp; +}; + +#endif /* pt-machdep.h */ diff --git a/sysdeps/ia32/bits/memory.h b/sysdeps/ia32/bits/memory.h deleted file mode 100644 index 932c408..0000000 --- a/sysdeps/ia32/bits/memory.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Memory barrier operations. i386 version. - Copyright (C) 2002, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_MEMORY_H -#define _BITS_MEMORY_H 1 - -/* Prevent read and write reordering across this function. */ -static inline void -__memory_barrier (void) -{ - int i; - - /* Any lock'ed instruction will do. We just do a simple - increment. */ - __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory"); -} - -/* Prevent read reordering across this function. */ -#define __memory_read_barrier __memory_barrier - -/* Prevent write reordering across this function. */ -#define __memory_write_barrier __memory_barrier - -#endif diff --git a/sysdeps/ia32/bits/pt-atomic.h b/sysdeps/ia32/bits/pt-atomic.h deleted file mode 100644 index 0dfc1f6..0000000 --- a/sysdeps/ia32/bits/pt-atomic.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Atomic operations. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -typedef __volatile int __atomic_t; - -static inline void -__atomic_inc (__atomic_t *__var) -{ - __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline void -__atomic_dec (__atomic_t *__var) -{ - __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline int -__atomic_dec_and_test (__atomic_t *__var) -{ - unsigned char __ret; - - __asm__ __volatile ("lock; decl %0; sete %1" - : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); - return __ret != 0; -} - -/* We assume that an __atomicptr_t is only used for pointers to - word-aligned objects, and use the lowest bit for a simple lock. */ -typedef __volatile int * __atomicptr_t; - -/* Actually we don't implement that yet, and assume that we run on - something that has the i486 instruction set. */ -static inline int -__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, - void * __newval) -{ - char __ret; - int __dummy; - - __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) - : "r" (__newval), "m" (*__ptr), "a" (__oldval)); - return __ret; -} - -#endif diff --git a/sysdeps/ia32/bits/spin-lock-inline.h b/sysdeps/ia32/bits/spin-lock-inline.h deleted file mode 100644 index e5ed3de..0000000 --- a/sysdeps/ia32/bits/spin-lock-inline.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_SPIN_LOCK_INLINE_H -#define _BITS_SPIN_LOCK_INLINE_H 1 - -#include -#include - -__BEGIN_DECLS - -#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES - -# ifndef __EBUSY -# include -# define __EBUSY EBUSY -# endif - -# ifndef __PT_SPIN_INLINE -# define __PT_SPIN_INLINE __extern_inline -# endif - -__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_destroy (__pthread_spinlock_t *__lock) -{ - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, - int __pshared); - -__PT_SPIN_INLINE int -__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) -{ - *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_trylock (__pthread_spinlock_t *__lock) -{ - int __locked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); - return __locked ? __EBUSY : 0; -} - -__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); -extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); - -__extern_inline int -__pthread_spin_lock (__pthread_spinlock_t *__lock) -{ - if (__pthread_spin_trylock (__lock)) - return _pthread_spin_lock (__lock); - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_unlock (__pthread_spinlock_t *__lock) -{ - int __unlocked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); - return 0; -} - -#endif /* Use extern inlines or force inlines. */ - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock.h deleted file mode 100644 index 5ae81e1..0000000 --- a/sysdeps/ia32/bits/spin-lock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_SPIN_LOCK_H -#define _BITS_SPIN_LOCK_H 1 - -#include - -__BEGIN_DECLS - -/* The type of a spin lock object. */ -typedef __volatile int __pthread_spinlock_t; - -/* Initializer for a spin lock object. */ -# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/machine-sp.h b/sysdeps/ia32/machine-sp.h deleted file mode 100644 index cef6ab7..0000000 --- a/sysdeps/ia32/machine-sp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Machine-specific function to return the stack pointer. i386 version. - Copyright (C) 1994, 1997, 2001, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 _MACHINE_SP_H -#define _MACHINE_SP_H - -/* Return the current stack pointer. */ - -#define __thread_stack_pointer() ({ \ - register void *__sp__ asm("esp"); \ - __sp__; \ -}) - -#endif /* machine-sp.h */ diff --git a/sysdeps/ia32/pt-machdep.h b/sysdeps/ia32/pt-machdep.h deleted file mode 100644 index 6d45636..0000000 --- a/sysdeps/ia32/pt-machdep.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Machine dependent pthreads internal defenitions. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _PT_MACHDEP_H -#define _PT_MACHDEP_H 1 - -struct pthread_mcontext -{ - void *pc; - void *sp; -}; - -#endif /* pt-machdep.h */ diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/mach/hurd/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/i386/pt-machdep.c new file mode 100644 index 0000000..f3c8cf5 --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-machdep.c @@ -0,0 +1,83 @@ +/* Machine dependent pthreads code. Hurd/i386 version. + Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +#include +#include +#include +#include +#include + +#define HURD_TLS_DESC_DECL(desc, tcb) \ + struct descriptor desc = \ + { /* low word: */ \ + 0xffff /* limit 0..15 */ \ + | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ + , /* high word: */ \ + ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ + | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ + | (0xf << 16) /* limit 16..19 */ \ + | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ + | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ + } + +int +__thread_set_pcsptp (thread_t thread, + int set_ip, void *ip, + int set_sp, void *sp, + int set_tp, void *tp) +{ + error_t err; + struct i386_thread_state state; + mach_msg_type_number_t state_count; + + state_count = i386_THREAD_STATE_COUNT; + + err = __thread_get_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, &state_count); + if (err) + return err; + + if (set_sp) + state.uesp = (unsigned int) sp; + if (set_ip) + state.eip = (unsigned int) ip; + if (set_tp) { + HURD_TLS_DESC_DECL(desc, tp); + int sel; + + asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); + if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + err = __i386_set_ldt (thread, sel, &desc, 1); + else + err = __i386_set_gdt (thread, &sel, desc); + if (err) + return err; + state.gs = sel; + } + + err = __thread_set_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, + i386_THREAD_STATE_COUNT); + if (err) + return err; + + return 0; +} diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/i386/pt-setup.c new file mode 100644 index 0000000..73fd43d --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-setup.c @@ -0,0 +1,106 @@ +/* Setup thread stack. Hurd/i386 version. + Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +/* The stack layout used on the i386 is: + + ----------------- + | ARG | + ----------------- + | START_ROUTINE | + ----------------- + | 0 | + ----------------- + | | + | Fast TSD | + | | + ----------------- + + We need to reserve __hurd_threadvar_max `unsigned long int's' of + (fast) thread-specific data (TSD) for the Hurd. */ + +/* Set up the stack for THREAD, such that it appears as if + START_ROUTINE and ARG were passed to the new thread's entry-point. + Return the stack pointer for the new thread. */ +static void * +stack_setup (struct __pthread *thread, + void *(*start_routine)(void *), void *arg) +{ + error_t err; + uintptr_t *bottom, *top; + + /* Calculate the top of the new stack. */ + bottom = thread->stackaddr; + top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); + + /* Next, make room for the TSDs. */ + top -= __hurd_threadvar_max; + + if (start_routine) + { + /* And then the call frame. */ + top -= 3; + top = (uintptr_t *) ((uintptr_t) top & ~0xf); + top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[1] = (uintptr_t) start_routine; + top[0] = (uintptr_t) thread; + *--top = 0; /* Fake return address. */ + } + + if (thread->guardsize) + { + err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, + thread->guardsize, 0, 0); + assert_perror (err); + } + + return top; +} + +int +__pthread_setup (struct __pthread *thread, + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), + void *(*start_routine)(void *), void *arg) +{ + error_t err; + mach_port_t ktid; + + thread->mcontext.pc = entry_point; + thread->mcontext.sp = stack_setup (thread, start_routine, arg); + + thread->tcb->self = thread->kernel_thread; + + ktid = __mach_thread_self (); + if (thread->kernel_thread != ktid) + { + err = __thread_set_pcsptp (thread->kernel_thread, + 1, thread->mcontext.pc, + 1, thread->mcontext.sp, + 1, thread->tcb); + assert_perror (err); + } + __mach_port_deallocate (__mach_task_self (), ktid); + + return 0; +} diff --git a/sysdeps/mach/hurd/ia32/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c deleted file mode 100644 index f3c8cf5..0000000 --- a/sysdeps/mach/hurd/ia32/pt-machdep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Machine dependent pthreads code. Hurd/i386 version. - Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include -#include -#include -#include - -#define HURD_TLS_DESC_DECL(desc, tcb) \ - struct descriptor desc = \ - { /* low word: */ \ - 0xffff /* limit 0..15 */ \ - | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ - , /* high word: */ \ - ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ - | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ - | (0xf << 16) /* limit 16..19 */ \ - | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ - | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ - } - -int -__thread_set_pcsptp (thread_t thread, - int set_ip, void *ip, - int set_sp, void *sp, - int set_tp, void *tp) -{ - error_t err; - struct i386_thread_state state; - mach_msg_type_number_t state_count; - - state_count = i386_THREAD_STATE_COUNT; - - err = __thread_get_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, &state_count); - if (err) - return err; - - if (set_sp) - state.uesp = (unsigned int) sp; - if (set_ip) - state.eip = (unsigned int) ip; - if (set_tp) { - HURD_TLS_DESC_DECL(desc, tp); - int sel; - - asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ - err = __i386_set_ldt (thread, sel, &desc, 1); - else - err = __i386_set_gdt (thread, &sel, desc); - if (err) - return err; - state.gs = sel; - } - - err = __thread_set_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, - i386_THREAD_STATE_COUNT); - if (err) - return err; - - return 0; -} diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c deleted file mode 100644 index 73fd43d..0000000 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Setup thread stack. Hurd/i386 version. - Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -/* The stack layout used on the i386 is: - - ----------------- - | ARG | - ----------------- - | START_ROUTINE | - ----------------- - | 0 | - ----------------- - | | - | Fast TSD | - | | - ----------------- - - We need to reserve __hurd_threadvar_max `unsigned long int's' of - (fast) thread-specific data (TSD) for the Hurd. */ - -/* Set up the stack for THREAD, such that it appears as if - START_ROUTINE and ARG were passed to the new thread's entry-point. - Return the stack pointer for the new thread. */ -static void * -stack_setup (struct __pthread *thread, - void *(*start_routine)(void *), void *arg) -{ - error_t err; - uintptr_t *bottom, *top; - - /* Calculate the top of the new stack. */ - bottom = thread->stackaddr; - top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); - - /* Next, make room for the TSDs. */ - top -= __hurd_threadvar_max; - - if (start_routine) - { - /* And then the call frame. */ - top -= 3; - top = (uintptr_t *) ((uintptr_t) top & ~0xf); - top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - top[1] = (uintptr_t) start_routine; - top[0] = (uintptr_t) thread; - *--top = 0; /* Fake return address. */ - } - - if (thread->guardsize) - { - err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, - thread->guardsize, 0, 0); - assert_perror (err); - } - - return top; -} - -int -__pthread_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - error_t err; - mach_port_t ktid; - - thread->mcontext.pc = entry_point; - thread->mcontext.sp = stack_setup (thread, start_routine, arg); - - thread->tcb->self = thread->kernel_thread; - - ktid = __mach_thread_self (); - if (thread->kernel_thread != ktid) - { - err = __thread_set_pcsptp (thread->kernel_thread, - 1, thread->mcontext.pc, - 1, thread->mcontext.sp, - 1, thread->tcb); - assert_perror (err); - } - __mach_port_deallocate (__mach_task_self (), ktid); - - return 0; -} -- cgit v1.2.3