diff options
author | jasone <jasone@FreeBSD.org> | 2000-01-29 11:15:24 +0800 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-01-29 11:15:24 +0800 |
commit | f2c71e6a94d5e6adef8cb045312da6d27ee16bb6 (patch) | |
tree | 4a2972845bb367cb6cfa4e8b890cd79f186af81e /devel/linuxthreads | |
parent | 60bdca7cf60634abad83ad450556bf6bd734d721 (diff) | |
download | freebsd-ports-gnome-f2c71e6a94d5e6adef8cb045312da6d27ee16bb6.tar.gz freebsd-ports-gnome-f2c71e6a94d5e6adef8cb045312da6d27ee16bb6.tar.zst freebsd-ports-gnome-f2c71e6a94d5e6adef8cb045312da6d27ee16bb6.zip |
Back out changes to lock functions passed to dllockinit().
Don't compile the lockfile.c that comes with LinuxThreads.
Diffstat (limited to 'devel/linuxthreads')
-rw-r--r-- | devel/linuxthreads/Makefile | 10 | ||||
-rw-r--r-- | devel/linuxthreads/files/libc_thread.c | 160 | ||||
-rw-r--r-- | devel/linuxthreads/files/patch-aa | 84 |
3 files changed, 102 insertions, 152 deletions
diff --git a/devel/linuxthreads/Makefile b/devel/linuxthreads/Makefile index ac841a4da384..9842d616ffd5 100644 --- a/devel/linuxthreads/Makefile +++ b/devel/linuxthreads/Makefile @@ -15,10 +15,9 @@ ONLY_FOR_ARCHS= i386 MAINTAINER= jasone@freebsd.org -threads_files := _atomic_lock.S README.FreeBSD clone.S clone.h \ - freebsd-compat.h getgr_r.c gethostby_r.c getnetby_r.c getprotoby_r.c \ - getpw_r.c getservby_r.c lclone.c libc_calls.c libc_thread.c sched.c \ - uthread_file.c +threads_files := README.FreeBSD clone.S clone.h freebsd-compat.h getgr_r.c \ + gethostby_r.c getnetby_r.c getprotoby_r.c getpw_r.c getservby_r.c \ + lclone.c libc_calls.c libc_thread.c sched.c uthread_file.c WRKSRC= ${WRKDIR}/${PKGNAME} @@ -27,7 +26,8 @@ LIBSRC_BASE= ${SRC_BASE}/lib post-extract: @mv ${WRKDIR}/linuxthreads ${WRKDIR}/${PKGNAME} -.for src in no-tsd.c oldsemaphore.c weaks.c sysdeps/pthread/semaphore.h +.for src in lockfile.c no-tsd.c oldsemaphore.c weaks.c \ + sysdeps/pthread/semaphore.h @mv ${WRKSRC}/$(src) ${WRKSRC}/$(src).unused .endfor @cd ${FILESDIR} ; \ diff --git a/devel/linuxthreads/files/libc_thread.c b/devel/linuxthreads/files/libc_thread.c index 0b5d67f9a8e2..47da0af7ba44 100644 --- a/devel/linuxthreads/files/libc_thread.c +++ b/devel/linuxthreads/files/libc_thread.c @@ -36,63 +36,84 @@ #endif #include <dlfcn.h> -#include <errno.h> #include <stdlib.h> #include "pthread.h" +/* Our internal pthreads definitions are here. Set as needed */ +#if defined(COMPILING_UTHREADS) +#include "pthread_private.h" +#endif +#if defined(LINUXTHREADS) +#include <errno.h> #include "internals.h" +#include "spinlock.h" +#else +/* Your internal definition here */ +#endif -typedef struct { - volatile long lock; - volatile int nreaders; /* -1 when a write lock is held. */ -} rwlock_t; - -#define _RWLOCK_PROTECT(l) _spinlock(&((l)->lock)) -#define _RWLOCK_UNPROTECT(l) (l)->lock = 0 +/* These are from lib/libc/include */ +#if !defined(LINUXTHREADS) +#include "spinlock.h" +#endif -/* - * This is defined in lib/libc/stdlib/exit.c. It turns on thread safe behavior - * in libc if non-zero. +/* This is defined in lib/libc/stdlib/exit.c. It turns on thread safe + * behavior in libc if non-zero. */ extern int __isthreaded; -/* - * Optional. In case our code is dependant on the existence of +/* Optional. In case our code is dependant on the existence of * the posix priority extentions kernel option. */ +#if defined(LINUXTHREADS) #include <sys/sysctl.h> int _posix_priority_scheduling; +#endif #if defined(NEWLIBC) -/* - * The following are needed if we're going to get thread safe behavior in the - * time functions in lib/libc/stdtime/localtime.c. +/* The following are needed if we're going to get thread safe behavior + * in the time functions in lib/libc/stdtime/localtime.c */ +#if defined(COMPILING_UTHREADS) +static struct pthread_mutex _lcl_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static struct pthread_mutex _gmt_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static struct pthread_mutex _localtime_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static struct pthread_mutex _gmtime_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static pthread_mutex_t _lcl_mutex = &_lcl_mutexd; +static pthread_mutex_t _gmt_mutex = &_gmt_mutexd; +static pthread_mutex_t _localtime_mutex = &_localtime_mutexd; +static pthread_mutex_t _gmtime_mutex = &_gmtime_mutexd; +#endif +#if defined(LINUXTHREADS) static pthread_mutex_t _lcl_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _gmt_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _localtime_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _gmtime_mutex = PTHREAD_MUTEX_INITIALIZER; - +#else +/* Customize this based on your mutex declarations */ +static pthread_mutex_t _lcl_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _gmt_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _localtime_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _gmtime_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif extern pthread_mutex_t *lcl_mutex; extern pthread_mutex_t *gmt_mutex; extern pthread_mutex_t *localtime_mutex; extern pthread_mutex_t *gmtime_mutex; #endif -/* Use the constructor attribute so this gets run before main does. */ -static void _pthread_initialize(void) __attribute__((constructor)); +void *lock_create (void *context); +void rlock_acquire (void *lock); +void wlock_acquire (void *lock); +void lock_release (void *lock); +void lock_destroy (void *lock); -/* Defined in _atomic_lock.S. */ -long _atomic_lock(volatile long *); -void _spinlock(volatile long *lock); -void *lock_create (void *context); -void rlock_acquire (void *lock); -void wlock_acquire (void *lock); -void lock_release (void *lock); -void lock_destroy (void *lock); +/* Use the constructor attribute so this gets run before main does */ +static void _pthread_initialize(void) __attribute__((constructor)); static void _pthread_initialize(void) { + +#if defined(LINUXTHREADS) int mib[2]; size_t len; @@ -101,8 +122,9 @@ static void _pthread_initialize(void) mib[1] = CTL_P1003_1B_PRIORITY_SCHEDULING; if (-1 == sysctl (mib, 2, &_posix_priority_scheduling, &len, NULL, 0)) _posix_priority_scheduling = 0; +#endif - /* This turns on thread safe behaviour in libc when we link with it. */ + /* This turns on thread safe behaviour in libc when we link with it */ __isthreaded = 1; dllockinit (NULL, @@ -114,7 +136,7 @@ static void _pthread_initialize(void) NULL); #if defined(NEWLIBC) - /* Set up pointers for lib/libc/stdtime/localtime.c. */ + /* Set up pointers for lib/libc/stdtime/localtime.c */ lcl_mutex = &_lcl_mutex; gmt_mutex = &_gmt_mutex; localtime_mutex = &_localtime_mutex; @@ -122,82 +144,42 @@ static void _pthread_initialize(void) #endif } -void -_spinlock(volatile long *lock) +void _spinlock (int * spinlock) { - while(_atomic_lock(lock)) { - /* Spin. */ - } + __pthread_acquire(spinlock); } -/* - * Simple nested spinning reader/writer lock implementation. We can't use the - * normal library implementation for bootstrapping reasons. This implementation - * allows one writer or any number of concurrent readers. No lock grant - * ordering guarantees are made. - */ - -void * -lock_create (void *context) +void * lock_create (void *context) { - rwlock_t *retval; + pthread_rwlock_t *lock; - retval = (rwlock_t *)malloc(sizeof(rwlock_t)); - if (retval == NULL) - goto RETURN; + lock = malloc (sizeof (*lock)); + if (lock == NULL) + return (NULL); - bzero(retval, sizeof(rwlock_t)); - RETURN: - return ((void *)retval); + pthread_rwlock_init (lock, NULL); + return (lock); } -void -rlock_acquire (void *lock) +void rlock_acquire (void *lock) { - rwlock_t *rwlock = lock; - - _RWLOCK_PROTECT(rwlock); - while (rwlock->nreaders < 0) { - _RWLOCK_UNPROTECT(rwlock); - _RWLOCK_PROTECT(rwlock); - } - rwlock->nreaders++; - - _RWLOCK_UNPROTECT(rwlock); -} + pthread_rwlock_rdlock ((pthread_rwlock_t *)lock); -void -wlock_acquire (void *lock) -{ - rwlock_t *rwlock = lock; - - _RWLOCK_PROTECT(rwlock); - while (rwlock->nreaders != 0) { - _RWLOCK_UNPROTECT(rwlock); - _RWLOCK_PROTECT(rwlock); - } - rwlock->nreaders--; - - _RWLOCK_UNPROTECT(rwlock); } -void -lock_release (void *lock) +void wlock_acquire (void *lock) { - rwlock_t *rwlock = lock; + pthread_rwlock_wrlock ((pthread_rwlock_t *)lock); - _RWLOCK_PROTECT(rwlock); +} - if (rwlock->nreaders < 0) - rwlock->nreaders++; - else - rwlock->nreaders--; - - _RWLOCK_UNPROTECT(rwlock); +void lock_release (void *lock) +{ + pthread_rwlock_unlock ((pthread_rwlock_t *)lock); } -void -lock_destroy (void *lock) +void lock_destroy (void *lock) { - free(lock); + if (pthread_rwlock_destroy ((pthread_rwlock_t *)lock) == 0) + free (lock); } diff --git a/devel/linuxthreads/files/patch-aa b/devel/linuxthreads/files/patch-aa index b70ab705a617..a6404d925dd4 100644 --- a/devel/linuxthreads/files/patch-aa +++ b/devel/linuxthreads/files/patch-aa @@ -1,6 +1,6 @@ diff -ru ../linuxthreads/Examples/Makefile ./Examples/Makefile --- ../linuxthreads/Examples/Makefile Wed Mar 11 04:42:23 1998 -+++ ./Examples/Makefile Tue Jan 25 13:59:17 2000 ++++ ./Examples/Makefile Fri Jan 28 19:02:42 2000 @@ -1,8 +1,12 @@ CC=gcc -CFLAGS=-g -O -Wall -I.. -D_REENTRANT @@ -19,7 +19,7 @@ diff -ru ../linuxthreads/Examples/Makefile ./Examples/Makefile diff -ru ../linuxthreads/Makefile ./Makefile --- ../linuxthreads/Makefile Fri Jul 9 21:00:32 1999 -+++ ./Makefile Tue Jan 25 13:59:17 2000 ++++ ./Makefile Fri Jan 28 19:02:42 2000 @@ -1,68 +1,72 @@ -# Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. -# This file is part of the GNU C Library. @@ -59,11 +59,11 @@ diff -ru ../linuxthreads/Makefile ./Makefile +AINC = -I${LIBSRC_BASE}/libc/${MACHINE_ARCH} -I${.CURDIR}/sysdeps/${MACHINE_ARCH} + +# Contents of the library. -+SRCS := _atomic_lock.S attr.c cancel.c clone.S condvar.c errno.c getgr_r.c \ -+ gethostby_r.c getnetby_r.c getprotoby_r.c getpw_r.c getservby_r.c \ -+ join.c lclone.c libc_calls.c libc_thread.c lockfile.c manager.c \ -+ mutex.c pt-machine.c ptfork.c pthread.c ptlongjmp.c rwlock.c sched.c \ -+ semaphore.c signals.c specific.c spinlock.c uthread_file.c wrapsyscall.c ++SRCS := attr.c cancel.c clone.S condvar.c errno.c getgr_r.c gethostby_r.c \ ++ getnetby_r.c getprotoby_r.c getpw_r.c getservby_r.c join.c lclone.c \ ++ libc_calls.c libc_thread.c manager.c mutex.c pt-machine.c ptfork.c \ ++ pthread.c ptlongjmp.c rwlock.c sched.c semaphore.c signals.c \ ++ specific.c spinlock.c uthread_file.c wrapsyscall.c + +beforeinstall: + ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 \ @@ -161,10 +161,9 @@ diff -ru ../linuxthreads/Makefile ./Makefile + +.include <bsd.lib.mk> Only in .: README.FreeBSD -Only in .: _atomic_lock.S diff -ru ../linuxthreads/attr.c ./attr.c --- ../linuxthreads/attr.c Tue Oct 27 05:51:54 1998 -+++ ./attr.c Tue Jan 25 13:59:17 2000 ++++ ./attr.c Fri Jan 28 19:02:43 2000 @@ -27,7 +27,7 @@ attr->__detachstate = PTHREAD_CREATE_JOINABLE; @@ -178,7 +177,7 @@ Only in .: clone.S Only in .: clone.h diff -ru ../linuxthreads/errno.c ./errno.c --- ../linuxthreads/errno.c Wed Aug 26 08:57:28 1998 -+++ ./errno.c Tue Jan 25 13:59:17 2000 ++++ ./errno.c Fri Jan 28 19:02:43 2000 @@ -19,6 +19,12 @@ #include "pthread.h" #include "internals.h" @@ -201,7 +200,7 @@ Only in .: getpw_r.c Only in .: getservby_r.c diff -ru ../linuxthreads/internals.h ./internals.h --- ../linuxthreads/internals.h Fri Jul 16 16:18:19 1999 -+++ ./internals.h Tue Jan 25 13:59:17 2000 ++++ ./internals.h Fri Jan 28 19:02:43 2000 @@ -22,8 +22,10 @@ #include <signal.h> #include <unistd.h> @@ -227,42 +226,11 @@ Only in .: lclone.c Only in .: libc_calls.c Only in .: libc_thread.c Only in .: libgcc_r -diff -ru ../linuxthreads/lockfile.c ./lockfile.c ---- ../linuxthreads/lockfile.c Thu Jul 9 06:41:28 1998 -+++ ./lockfile.c Tue Jan 25 13:59:17 2000 -@@ -20,6 +20,7 @@ - #include <bits/libc-lock.h> - #include <stdio.h> - #include <pthread.h> -+#include "internals.h" - - #ifdef USE_IN_LIBIO - #include "../libio/libioP.h" -@@ -61,6 +62,7 @@ - #ifdef USE_IN_LIBIO - return __pthread_mutex_trylock (stream->_lock); - #else -+ return 0; - #endif - } - #ifdef USE_IN_LIBIO -@@ -68,7 +70,7 @@ - #endif - weak_alias (__ftrylockfile, ftrylockfile); - -- -+#if (0) - void - __fresetlockfiles (void) - { -@@ -85,3 +87,4 @@ - __pthread_mutexattr_destroy (&attr); - #endif - } -+#endif +Only in ../linuxthreads: lockfile.c +Only in .: lockfile.c.unused diff -ru ../linuxthreads/manager.c ./manager.c --- ../linuxthreads/manager.c Wed Jul 28 23:42:42 1999 -+++ ./manager.c Tue Jan 25 13:59:18 2000 ++++ ./manager.c Fri Jan 28 19:02:43 2000 @@ -115,7 +115,7 @@ /* Enter server loop */ while(1) { @@ -320,7 +288,7 @@ diff -ru ../linuxthreads/manager.c ./manager.c if (pid == -1) { diff -ru ../linuxthreads/mutex.c ./mutex.c --- ../linuxthreads/mutex.c Wed Nov 18 08:59:53 1998 -+++ ./mutex.c Tue Jan 25 13:59:18 2000 ++++ ./mutex.c Fri Jan 28 19:02:43 2000 @@ -24,7 +24,7 @@ #include "restart.h" @@ -336,7 +304,7 @@ Only in ../linuxthreads: oldsemaphore.c Only in .: oldsemaphore.c.unused diff -ru ../linuxthreads/ptfork.c ./ptfork.c --- ../linuxthreads/ptfork.c Mon Sep 6 12:32:07 1999 -+++ ./ptfork.c Tue Jan 25 13:59:18 2000 ++++ ./ptfork.c Fri Jan 28 19:02:43 2000 @@ -75,7 +75,7 @@ extern int __libc_fork(void); @@ -361,7 +329,7 @@ diff -ru ../linuxthreads/ptfork.c ./ptfork.c -weak_alias (__vfork, vfork); diff -ru ../linuxthreads/pthread.c ./pthread.c --- ../linuxthreads/pthread.c Fri Aug 20 12:00:47 1999 -+++ ./pthread.c Tue Jan 25 13:59:18 2000 ++++ ./pthread.c Fri Jan 28 19:02:43 2000 @@ -19,7 +19,10 @@ #include <stdio.h> #include <stdlib.h> @@ -572,7 +540,7 @@ diff -ru ../linuxthreads/pthread.c ./pthread.c __pthread_reset_main_thread(); diff -ru ../linuxthreads/ptlongjmp.c ./ptlongjmp.c --- ../linuxthreads/ptlongjmp.c Tue Oct 27 05:52:00 1998 -+++ ./ptlongjmp.c Tue Jan 25 13:59:18 2000 ++++ ./ptlongjmp.c Fri Jan 28 19:02:43 2000 @@ -19,13 +19,6 @@ #include "pthread.h" #include "internals.h" @@ -605,7 +573,7 @@ diff -ru ../linuxthreads/ptlongjmp.c ./ptlongjmp.c Only in .: sched.c diff -ru ../linuxthreads/semaphore.h ./semaphore.h --- ../linuxthreads/semaphore.h Thu Apr 15 06:50:56 1999 -+++ ./semaphore.h Tue Jan 25 13:59:18 2000 ++++ ./semaphore.h Fri Jan 28 19:02:43 2000 @@ -15,7 +15,7 @@ #ifndef _SEMAPHORE_H #define _SEMAPHORE_H 1 @@ -617,7 +585,7 @@ diff -ru ../linuxthreads/semaphore.h ./semaphore.h #ifndef _PTHREAD_DESCR_DEFINED diff -ru ../linuxthreads/signals.c ./signals.c --- ../linuxthreads/signals.c Mon Aug 23 10:46:35 1999 -+++ ./signals.c Tue Jan 25 13:59:18 2000 ++++ ./signals.c Fri Jan 28 19:02:43 2000 @@ -19,7 +19,6 @@ #include "pthread.h" #include "internals.h" @@ -669,7 +637,7 @@ diff -ru ../linuxthreads/signals.c ./signals.c } diff -ru ../linuxthreads/spinlock.c ./spinlock.c --- ../linuxthreads/spinlock.c Fri Jul 9 13:56:04 1999 -+++ ./spinlock.c Tue Jan 25 13:59:18 2000 ++++ ./spinlock.c Fri Jan 28 19:02:43 2000 @@ -17,6 +17,7 @@ #include <errno.h> #include <sched.h> @@ -698,7 +666,7 @@ diff -ru ../linuxthreads/spinlock.c ./spinlock.c struct timespec tm; diff -ru ../linuxthreads/spinlock.h ./spinlock.h --- ../linuxthreads/spinlock.h Thu Oct 29 06:31:12 1998 -+++ ./spinlock.h Tue Jan 25 13:59:18 2000 ++++ ./spinlock.h Fri Jan 28 19:02:43 2000 @@ -71,4 +71,6 @@ return 0; } @@ -708,7 +676,7 @@ diff -ru ../linuxthreads/spinlock.h ./spinlock.h #define LOCK_INITIALIZER {0, 0} diff -ru ../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h ./sysdeps/pthread/bits/pthreadtypes.h --- ../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h Thu Apr 15 06:52:26 1999 -+++ ./sysdeps/pthread/bits/pthreadtypes.h Tue Jan 25 13:59:18 2000 ++++ ./sysdeps/pthread/bits/pthreadtypes.h Fri Jan 28 19:02:44 2000 @@ -20,7 +20,6 @@ #define _BITS_PTHREADTYPES_H 1 @@ -728,7 +696,7 @@ diff -ru ../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h ./sysdeps/pthread/b size_t __guardsize; diff -ru ../linuxthreads/sysdeps/pthread/pthread.h ./sysdeps/pthread/pthread.h --- ../linuxthreads/sysdeps/pthread/pthread.h Tue Dec 8 08:10:25 1998 -+++ ./sysdeps/pthread/pthread.h Tue Jan 25 13:59:19 2000 ++++ ./sysdeps/pthread/pthread.h Fri Jan 28 19:02:44 2000 @@ -15,7 +15,7 @@ #ifndef _PTHREAD_H #define _PTHREAD_H 1 @@ -759,7 +727,7 @@ Only in ../linuxthreads/sysdeps/pthread: semaphore.h Only in ./sysdeps/pthread: semaphore.h.unused diff -ru ../linuxthreads/sysdeps/unix/sysv/linux/bits/local_lim.h ./sysdeps/unix/sysv/linux/bits/local_lim.h --- ../linuxthreads/sysdeps/unix/sysv/linux/bits/local_lim.h Thu Nov 12 10:03:14 1998 -+++ ./sysdeps/unix/sysv/linux/bits/local_lim.h Tue Jan 25 13:59:19 2000 ++++ ./sysdeps/unix/sysv/linux/bits/local_lim.h Fri Jan 28 19:02:44 2000 @@ -24,7 +24,7 @@ #endif @@ -771,7 +739,7 @@ diff -ru ../linuxthreads/sysdeps/unix/sysv/linux/bits/local_lim.h ./sysdeps/unix #ifdef __undef_NR_OPEN diff -ru ../linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h ./sysdeps/unix/sysv/linux/bits/sigthread.h --- ../linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h Sat Sep 12 14:33:14 1998 -+++ ./sysdeps/unix/sysv/linux/bits/sigthread.h Tue Jan 25 13:59:19 2000 ++++ ./sysdeps/unix/sysv/linux/bits/sigthread.h Fri Jan 28 19:02:44 2000 @@ -28,8 +28,8 @@ /* Modify the signal mask for the calling thread. The arguments have @@ -788,7 +756,7 @@ Only in ../linuxthreads: weaks.c Only in .: weaks.c.unused diff -ru ../linuxthreads/wrapsyscall.c ./wrapsyscall.c --- ../linuxthreads/wrapsyscall.c Tue Dec 1 11:34:20 1998 -+++ ./wrapsyscall.c Tue Jan 25 13:59:19 2000 ++++ ./wrapsyscall.c Fri Jan 28 19:02:44 2000 @@ -30,6 +30,10 @@ #include <sys/wait.h> #include <sys/socket.h> |