aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MOVED1
-rw-r--r--devel/Makefile1
-rw-r--r--devel/linuxthreads/Makefile280
-rw-r--r--devel/linuxthreads/distinfo2
-rw-r--r--devel/linuxthreads/files/Makefile.libgcc_r22
-rw-r--r--devel/linuxthreads/files/Makefile.libstdc++19
-rw-r--r--devel/linuxthreads/files/Makefile.libsupc++19
-rw-r--r--devel/linuxthreads/files/README.FreeBSD161
-rw-r--r--devel/linuxthreads/files/_pthreadtypes.h45
-rw-r--r--devel/linuxthreads/files/clone.S143
-rw-r--r--devel/linuxthreads/files/clone.h42
-rw-r--r--devel/linuxthreads/files/condwait-patch369
-rw-r--r--devel/linuxthreads/files/freebsd-compat.h186
-rw-r--r--devel/linuxthreads/files/getgr_r.c144
-rw-r--r--devel/linuxthreads/files/gethostby_r.c172
-rw-r--r--devel/linuxthreads/files/getlogin.c113
-rw-r--r--devel/linuxthreads/files/getnetby_r.c111
-rw-r--r--devel/linuxthreads/files/getprotoby_r.c111
-rw-r--r--devel/linuxthreads/files/getpw_r.c111
-rw-r--r--devel/linuxthreads/files/getservby_r.c119
-rw-r--r--devel/linuxthreads/files/lclone.c92
-rw-r--r--devel/linuxthreads/files/ldwrap117
-rw-r--r--devel/linuxthreads/files/libc_calls.c157
-rw-r--r--devel/linuxthreads/files/libc_thread.c146
-rw-r--r--devel/linuxthreads/files/localtime.c1739
-rw-r--r--devel/linuxthreads/files/patch-aa1459
-rw-r--r--devel/linuxthreads/files/patch-barrier21
-rw-r--r--devel/linuxthreads/files/patch-intrpipe149
-rw-r--r--devel/linuxthreads/files/patch-spinlock.c59
-rw-r--r--devel/linuxthreads/files/sched.c334
-rw-r--r--devel/linuxthreads/files/strptime.sed9
-rw-r--r--devel/linuxthreads/files/telldir.c182
-rw-r--r--devel/linuxthreads/files/ttyname.c215
-rw-r--r--devel/linuxthreads/files/uthread_file.c408
-rw-r--r--devel/linuxthreads/files/wraputhread.c1751
-rw-r--r--devel/linuxthreads/pkg-descr15
-rw-r--r--devel/linuxthreads/pkg-message3
-rw-r--r--devel/linuxthreads/pkg-plist38
38 files changed, 1 insertions, 9064 deletions
diff --git a/MOVED b/MOVED
index 50a12980c037..75a96c284625 100644
--- a/MOVED
+++ b/MOVED
@@ -4385,3 +4385,4 @@ x11-toolkits/ruby-wx||2013-06-07|Has expired: Does not work with Ruby 1.9
sysutils/userspace-rcu|sysutils/liburcu|2013-06-07|Renamed correctly according to upstream
mail/mixminion||2013-06-07|Has expired: This port requires python version, we haven't in the ports tree already
devel/gprbuild-aux|devel/gprbuild|2013-06-10|Has expired: Deprecated in favour of devel/gprbuild
+devel/linuxthreads||2013-06-10|Has expired: Broken for more than 6 month
diff --git a/devel/Makefile b/devel/Makefile
index b0a36619fd3f..439606b40147 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -1147,7 +1147,6 @@
SUBDIR += linux-f10-sdl12
SUBDIR += linux-kmod-compat
SUBDIR += linux_kdump
- SUBDIR += linuxthreads
SUBDIR += lion
SUBDIR += llvm
SUBDIR += llvm-devel
diff --git a/devel/linuxthreads/Makefile b/devel/linuxthreads/Makefile
deleted file mode 100644
index b57598f81a90..000000000000
--- a/devel/linuxthreads/Makefile
+++ /dev/null
@@ -1,280 +0,0 @@
-# Created by: Richard Seaman, Jr. <dick@tar.com>
-# $FreeBSD$
-
-PORTNAME= linuxthreads
-PORTVERSION= 2.2.3
-PORTREVISION= 24
-CATEGORIES= devel
-MASTER_SITES= ${MASTER_SITE_GNU}
-MASTER_SITE_SUBDIR= glibc
-DISTNAME= glibc-linuxthreads-${PORTVERSION}
-
-MAINTAINER= ports@FreeBSD.org
-COMMENT= POSIX pthreads implementation using rfork to generate kernel threads
-
-USE_LDCONFIG= yes
-
-DEPRECATED= Broken for more than 6 month
-EXPIRATION_DATE= 2013-03-05
-
-.if defined(LINUXTHREADS_WRAP_API)
-USE_PERL5_BUILD=true
-.endif
-
-.include <bsd.port.pre.mk>
-
-BROKEN= does not build
-
-# This port only works on i386 right now.
-ONLY_FOR_ARCHS= i386
-
-USING_GCC4= true
-MAKE_ENV+= USING_GCC4=true
-
-.if defined(LINUXTHREADS_INSTALL_LIBLTHREAD_PIC_ARCHIVE)
-MAKE_ENV+= INSTALL_LIBLTHREAD_PIC_ARCHIVE=yes
-.endif
-.if defined(LINUXTHREADS_MAX_STACK_SIZE)
-MAKE_ENV+= LINUXTHREADS_STACK_SIZE=${LINUXTHREADS_MAX_STACK_SIZE}
-.endif
-.if defined(LINUXTHREADS_MAX_THREADS)
-MAKE_ENV+= LINUXTHREADS_MAX_THREADS=${LINUXTHREADS_MAX_THREADS}
-.endif
-.if defined(LINUXTHREADS_DETECT_UNSAFE_EXIT)
-MAKE_ENV+= LINUXTHREADS_DETECT_UNSAFE_EXIT=yes
-.endif
-.if defined(LINUXTHREADS_WRAP_API)
-MAKE_ENV+= LINUXTHREADS_WRAP_API=yes
-MAKE_ENV+= LINUXTHREADS_WRAP_LD="sh ${FILESDIR}/ldwrap"
-.endif
-.if defined(LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING)
-MAKE_ENV+= LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING=yes
-.endif
-.if defined(LINUXTHREADS_ALT_RESTARTSIG)
-MAKE_ENV+= LINUXTHREADS_ALT_RESTARTSIG=${LINUXTHREADS_ALT_RESTARTSIG}
-.endif
-
-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 \
- wraputhread.c localtime.c getlogin.c telldir.c ttyname.c
-
-threads_files2 := _pthreadtypes.h
-
-WRKSRC= ${WRKDIR}/${PKGNAME}
-SRC_BASE= /usr/src
-LIBSRC_BASE= ${SRC_BASE}/lib
-
-pre-fetch:
-.if !defined(LINUXTHREADS_WITH_CONDWAIT_PATCH)
- @${ECHO}
- @${ECHO} You can use an experimental patch to reduce the number of
- @${ECHO} condition variable triggered context switches by defining
- @${ECHO} LINUXTHREADS_WITH_CONDWAIT_PATCH
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_DETECT_UNSAFE_EXIT)
- @${ECHO}
- @${ECHO} "Some unsafe calls to exit() can be detected by defining"
- @${ECHO} "LINUXTHREADS_DETECT_UNSAFE_EXIT, see files/README.FreeBSD"
- @${ECHO} "for more info."
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_MAX_STACK_SIZE)
- @${ECHO}
- @${ECHO} "The maximum stack size (default 2097152) can be overridden"
- @${ECHO} "by defining LINUXTHREADS_MAX_STACK_SIZE,"
- @${ECHO} "see files/README.FreeBSD for more info."
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_MAX_THREADS)
- @${ECHO}
- @${ECHO} "The maximum number of threads (default 1024) can be"
- @${ECHO} "overriden by defining LINUXTHREADS_MAX_THREADS,"
- @${ECHO} "see files/README.FreeBSD for more info."
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_WRAP_API)
- @${ECHO}
- @${ECHO} "Some conflicts with native threads can be avoided by defining"
- @${ECHO} "LINUXTHREADS_WRAP_API, see files/README.FreeBSD"
- @${ECHO} "for more info."
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING)
- @${ECHO}
- @${ECHO} "Use of POSIX priority scheduling can be turned off by"
- @${ECHO} "defining LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING,"
- @${ECHO} "see files/README.FreeBSD for more info."
- @${ECHO}
-.endif
-.if !defined(LINUXTHREADS_ALT_RESTARTSIG)
- @${ECHO}
- @${ECHO} "An alternate restart signal can be selected by"
- @${ECHO} "defining LINUXTHREADS_ALT_RESTARTSIG,"
- @${ECHO} "see files/README.FreeBSD for more info."
- @${ECHO}
-.endif
- @if ${TEST} -f /usr/src/gnu/lib/libgcc/Makefile; then \
- : ; \
- else \
- ${ECHO_MSG} ">>The linuxthreads port needs source code for libgcc"; \
- ${ECHO_MSG} ">>Please install FreeBSD source code in /usr/src"; \
- ${FALSE}; \
- fi
-.if defined(USING_GCC3) || defined(USING_GCC4)
- @if ${TEST} -f /usr/src/gnu/lib/libstdc++/Makefile; then \
- : ; \
- else \
- ${ECHO_MSG} ">>The linuxthreads port needs source code for libstdc++"; \
- ${ECHO_MSG} ">>Please install FreeBSD source code in /usr/src"; \
- ${FALSE}; \
- fi
- @if ${TEST} -f /usr/src/gnu/lib/libsupc++/Makefile; then \
- : ; \
- else \
- ${ECHO_MSG} ">>The linuxthreads port needs source code for libsupc++"; \
- ${ECHO_MSG} ">>Please install FreeBSD source code in /usr/src"; \
- ${FALSE}; \
- fi
-.endif
-
-post-extract:
- @${MV} ${WRKDIR}/linuxthreads ${WRKSRC}
- @${MV} ${WRKDIR}/linuxthreads_db ${WRKSRC}
-.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} ; \
- ${CP} -p ${threads_files} ${WRKSRC}/.
- @${SED} -f ${FILESDIR}/strptime.sed \
- /usr/src/lib/libc/stdtime/strptime.c \
- > ${WRKSRC}/strptime.c
- @${MKDIR} ${WRKSRC}/sys
- @cd ${FILESDIR} ; \
- ${CP} -p ${threads_files2} ${WRKSRC}/sys/.
- @${MKDIR} ${WRKSRC}/libgcc_r
- @${TEST} -f ${WRKSRC}/libgcc_r/Makefile || \
- ${LN} -s ${FILESDIR}/Makefile.libgcc_r ${WRKSRC}/libgcc_r/Makefile
- @${SED} -e 's/^LIB=[ ]*gcc$$/LIB= lgcc_r/;' \
- -e 's/^SHLIB_NAME=[ ]*libgcc_s\.so\./SHLIB_NAME= liblgcc_s.so./' \
- -e 's=$${.CURDIR}=/usr/src/gnu/lib/libgcc=g' \
- /usr/src/gnu/lib/libgcc/Makefile \
- > ${WRKSRC}/libgcc_r/Makefile.inc.tmp && \
- ${MV} ${WRKSRC}/libgcc_r/Makefile.inc.tmp \
- ${WRKSRC}/libgcc_r/Makefile.inc
-.if defined(USING_GCC3) || defined(USING_GCC4)
- @${MKDIR} ${WRKSRC}/libstdc++
- @${TEST} -f ${WRKSRC}/libstdc++/Makefile || \
- ${LN} -s ${FILESDIR}/Makefile.libstdc++ ${WRKSRC}/libstdc++/Makefile
- @${SED} -e 's/^LIB=[ ]*stdc\+\+$$/LIB= lstdc++/;' \
- -e 's=$${.CURDIR}=/usr/src/gnu/lib/libstdc++=g' \
- /usr/src/gnu/lib/libstdc++/Makefile \
- > ${WRKSRC}/libstdc++/Makefile.inc.tmp && \
- ${MV} ${WRKSRC}/libstdc++/Makefile.inc.tmp \
- ${WRKSRC}/libstdc++/Makefile.inc
- @${MKDIR} ${WRKSRC}/libsupc++
- @${TEST} -f ${WRKSRC}/libsupc++/Makefile || \
- ${LN} -s ${FILESDIR}/Makefile.libsupc++ ${WRKSRC}/libsupc++/Makefile
- @${SED} -e 's/^LIB=[ ]*supc\+\+$$/LIB= lsupc++/;' \
- -e 's=$${.CURDIR}=/usr/src/gnu/lib/libsupc++=g' \
- /usr/src/gnu/lib/libsupc++/Makefile \
- > ${WRKSRC}/libsupc++/Makefile.inc.tmp && \
- ${MV} ${WRKSRC}/libsupc++/Makefile.inc.tmp \
- ${WRKSRC}/libsupc++/Makefile.inc
-.endif
-
-.if defined(LINUXTHREADS_WITH_CONDWAIT_PATCH) || defined(LINUXTHREADS_WRAP_API)
-post-patch:
-.if defined(LINUXTHREADS_WITH_CONDWAIT_PATCH)
- @${ECHO_MSG} "===> Applying experimental patch condwait-patch"
- @if ${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/condwait-patch; then \
- ${ECHO_MSG} "===> Patch condwait-patch applied successfully"; \
- else \
- ${ECHO_MSG} ">>Patch condwait-patch failed to apply cleanly"; \
- ${FALSE}; \
- fi
-.endif
-.if defined(LINUXTHREADS_WRAP_API)
- {PERL} -pi -e '$$func=$$1 if m/^extern\s+\S+\s+\*?(\S+)\s+\(/; $$alias="#ifdef COMPILING_WRAPUTHREAD\n\t__attribute__((weak, alias(\"_$$func\")))\n#endif\n"; $$wrap="#ifndef COMPILING_LINUXTHREADS\n\t__asm__(\"linuxthreads_$$func\")\n#endif\n"; $$alias="" if ( $$func =~ m/^(pthread_spin|_pthread_cleanup|pthread_rwlockattr_[gs]etkind_np|pthread_kill_other_threads_np)/ ); s=__THROW=\n$$wrap$$alias\t__THROW= unless m/^#/;' ${WRKSRC}/sysdeps/pthread/pthread.h ${WRKSRC}/sysdeps/unix/sysv/linux/bits/sigthread.h
-.endif
-.endif
-
-pre-build:
- @cd ${WRKSRC}/libgcc_r ; \
- ${SETENV} ${MAKE_ENV} ${MAKE}
-.if defined(USING_GCC3) || defined(USING_GCC4)
- cd ${WRKSRC}/libstdc++ ; \
- ${SETENV} ${MAKE_ENV} ${MAKE}
- @cd ${WRKSRC}/libsupc++ ; \
- ${SETENV} ${MAKE_ENV} ${MAKE}
-.endif
-
-pre-su-install:
- ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 ${PREFIX}/lib
- @cd ${WRKSRC}/libgcc_r ; \
- ${SETENV} ${MAKE_ENV} ${MAKE} install
-.if defined(USING_GCC3) || defined(USING_GCC4)
- @cd ${WRKSRC}/libstdc++ ; \
- ${SETENV} ${MAKE_ENV} ${MAKE} install
- @cd ${WRKSRC}/libsupc++ ; \
- ${SETENV} ${MAKE_ENV} ${MAKE} install
-.endif
-
-post-install:
- ${CAT} ${PKGMESSAGE}
-
-.if defined(NO_PROFILE)
-PLIST_SUB= PROFILE:="@comment "
-.else
-PLIST_SUB= PROFILE:=""
-.endif
-.if defined(NO_PIC)
-PLIST_SUB+= PIC:="@comment "
-.else
-PLIST_SUB+= PIC:=""
-.endif
-.if defined(INSTALL_PIC_ARCHIVE)
-PLIST_SUB+= PICARCHIVE:=""
-.else
-PLIST_SUB+= PICARCHIVE:="@comment "
-.endif
-.if defined(INSTALL_PIC_ARCHIVE)
-PLIST_SUB+= LIBLGCC_R_PICARCHIVE:=""
-.else
-PLIST_SUB+= LIBLGCC_R_PICARCHIVE:="@comment "
-.endif
-.if defined(INSTALL_PIC_ARCHIVE) || defined(LINUXTHREADS_INSTALL_LIBLTHREAD_PIC_ARCHIVE)
-PLIST_SUB+= LIBLTHREADPICARCHIVE:=""
-.else
-PLIST_SUB+= LIBLTHREADPICARCHIVE:="@comment "
-.endif
-.if defined(USING_GCC4)
-PLIST_SUB+= GCC3OR4ONLY:=""
-PLIST_SUB+= GCC4ONLY:=""
-.if defined(LINUXTHREADS_WRAP_API)
-PLIST_SUB+= LTHREADSHMAJOR:="7"
-.else
-PLIST_SUB+= LTHREADSHMAJOR:="6"
-.endif
-.elif defined(USING_GCC3)
-PLIST_SUB+= GCC3OR4ONLY:=""
-PLIST_SUB+= GCC4ONLY:="@comment "
-.if defined(LINUXTHREADS_WRAP_API)
-PLIST_SUB+= LTHREADSHMAJOR:="5"
-.else
-PLIST_SUB+= LTHREADSHMAJOR:="3"
-.endif
-.else
-PLIST_SUB+= GCC3OR4ONLY:="@comment "
-PLIST_SUB+= GCC4ONLY:="@comment "
-.if defined(LINUXTHREADS_WRAP_API)
-PLIST_SUB+= LTHREADSHMAJOR:="4"
-.else
-PLIST_SUB+= LTHREADSHMAJOR:="2"
-.endif
-.endif
-PLIST_SUB+= LIBSTDCPPMAJOR:="6"
-
-.include <bsd.port.post.mk>
diff --git a/devel/linuxthreads/distinfo b/devel/linuxthreads/distinfo
deleted file mode 100644
index fc3d2de9b41f..000000000000
--- a/devel/linuxthreads/distinfo
+++ /dev/null
@@ -1,2 +0,0 @@
-SHA256 (glibc-linuxthreads-2.2.3.tar.gz) = 10e87b3f7690fa03904a53934eae17577a90fa9b53d348a116af2fcea6746e2a
-SIZE (glibc-linuxthreads-2.2.3.tar.gz) = 215313
diff --git a/devel/linuxthreads/files/Makefile.libgcc_r b/devel/linuxthreads/files/Makefile.libgcc_r
deleted file mode 100644
index d6ec9cd3c9a9..000000000000
--- a/devel/linuxthreads/files/Makefile.libgcc_r
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/Makefile.libgcc_r,v 1.6 2007-07-03 08:38:00 pav Exp $
-
-PREFIX?= ${DESTDIR}/usr/local
-LIBDIR= ${PREFIX:S,^${DESTDIR},,}/lib
-SHLIBDIR= ${PREFIX:S,^${DESTDIR},,}/lib
-.if defined(USING_GCC4)
-INSTALL_PIC_ARCHIVE=yes
-.endif
-
-CFLAGS+=-D_PTHREADS -I../ -D__USE_UNIX98
-CFLAGS+=-I../sysdeps/i386 -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux
-CXXFLAGS= ${CXXINCLUDES} ${CFLAGS:C/-std=[a-z:0-9]+//}
-
-installincludes:
-
-.include "Makefile.inc"
-
-#
-# Override various things that are set in the main Makefile.
-#
-
-.undef SUBDIR
diff --git a/devel/linuxthreads/files/Makefile.libstdc++ b/devel/linuxthreads/files/Makefile.libstdc++
deleted file mode 100644
index 3b31477c43e3..000000000000
--- a/devel/linuxthreads/files/Makefile.libstdc++
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/Makefile.libstdc++,v 1.3 2007-03-21 21:49:04 tegge Exp $
-
-PREFIX?= ${DESTDIR}/usr/local
-LIBDIR= ${PREFIX:S,^${DESTDIR},,}/lib
-
-CFLAGS+=-D_PTHREADS -I../ -D__USE_UNIX98
-CFLAGS+=-I../sysdeps/i386 -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux
-CXXFLAGS= ${CXXINCLUDES} ${CFLAGS:C/-std=[a-z:0-9]+//}
-LDADD=../libgcc_r/liblgcc_r.a
-
-installincludes:
-
-.include "Makefile.inc"
-
-#
-# Override various things that are set in the main Makefile.
-#
-
-.undef SUBDIR
diff --git a/devel/linuxthreads/files/Makefile.libsupc++ b/devel/linuxthreads/files/Makefile.libsupc++
deleted file mode 100644
index a71ccb6fb781..000000000000
--- a/devel/linuxthreads/files/Makefile.libsupc++
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/Makefile.libsupc++,v 1.3 2007-03-21 21:49:04 tegge Exp $
-
-PREFIX?= ${DESTDIR}/usr/local
-LIBDIR= ${PREFIX:S,^${DESTDIR},,}/lib
-
-CFLAGS+=-D_PTHREADS -I../ -D__USE_UNIX98
-CFLAGS+=-I../sysdeps/i386 -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux
-CXXFLAGS= ${CXXINCLUDES} ${CFLAGS:C/-std=[a-z:0-9]+//}
-LDADD=../libgcc_r/liblgcc_r.a
-
-installincludes:
-
-.include "Makefile.inc"
-
-#
-# Override various things that are set in the main Makefile.
-#
-
-.undef SUBDIR
diff --git a/devel/linuxthreads/files/README.FreeBSD b/devel/linuxthreads/files/README.FreeBSD
deleted file mode 100644
index 7aacaa3b5190..000000000000
--- a/devel/linuxthreads/files/README.FreeBSD
+++ /dev/null
@@ -1,161 +0,0 @@
-Some brief notes:
-
-1) This package is intended to run on FreeBSD 5.0-current or FreeBSD 4.X, i386
-processors only.
-
-Do not use libc_r with the linuxthreads port, and do not compile/link with the
--pthread option (which pulls in libc_r). Rather, link with libc (which you will
-get by default).
-
-Compile your applications that use the linuxthreads port with the following
-command line options:
-
- -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -llthread -llgcc_r
-
-Note that the include (-I<path>) directive shown here should appear before any
-other include directive that would cause the compiler to find the FreeBSD file
-/usr/include/pthread.h. Using the FreeBSD pthread.h instead of the linuxthreads
-pthread.h will result in an app that fails in many odd and maybe spectacular
-ways.
-
-In order to facilitate porting applications which expect a libpthread, you can
-create the following symlinks if you want:
-
- ln -s /usr/local/lib/liblthread.a /usr/lib/libpthread.a
- ln -s /usr/local/lib/liblthread_p.a /usr/lib/libpthread_p.a
- ln -s /usr/local/lib/liblthread.so.2 /usr/lib/libpthread.so.2
- ln -s /usr/local/lib/liblthread.so.2 /usr/lib/libpthread.so
- /sbin/ldconfig -m /usr/lib
-
-If you do this, you can instead use:
-
- -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -lpthread -llgcc_r
-
-Another option is to create a custom gcc specs file that tells the linker which
-version of libgcc to use. To do this, create a file with the following in it:
-
---- (/foo/specs) cut here ---
-*libgcc:
-/usr/local/lib/liblgcc_r.a
---- (/foo/specs) cut here ---
-
-Then use the following command line options:
-
- -B/foo/ -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -llthread
-
-or if you created symlinks:
-
- -B/foo/ -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -lpthread
-
-2) If you plan on having lots of threads, check the sysctl value of
-kern.maxproc. Each kernel thread counts against maxproc. You can increase
-maxproc by changing the MAXUSERS value in your kernel config file. maxproc is
-set at 20 + 16 * MAXUSERS.
-
-3) Be aware of the following libc issues:
-
- a) Not all libc calls are thread safe. In particular gmtime, localtime, etc
- are not thread safe. In general, where the pthreads spec calls for "_r"
- functions, these are either not provided, or if provided are not thread safe
- (in most cases) and the related libc calls are not thread safe. This differs
- somewhat from the FreeBSD libc_r library, where some, but not all, of these
- functions are both thread safe and have "_r" versions.
-
- b) Not all of the libc calls that are supposed to be cancellation points are
- implemented as such. While linux threads has the cancel functions
- implemented, deferred cancellation will not work as required by POSIX
- 1003.1c-1995, since the co-operation needed from libc is not complete.
-
- c) The mutex wrapper functions only provide standard linuxthreads mutexes
- (i.e. non-recursive mutexes). This might lead to deadlocks if libc
- depends on recursive mutexes.
-
-4) Be aware of the following libgcc issue:
-
- FreeBSD 4.* (gcc 2.*):
-
- __register_frame_info() and __get_eh_info() from libgcc.a are linked
- into shared libraries that use exceptions, e.g. libstdc++. Those
- functions are not compatible with linuxthreads due to pthread_mutex_t
- and pthread_once_t having different sizes and static initializers.
- Linking the shared linuxthreads library before any such library causes
- the liblgcc_r.a version of those functions to be used.
-
- FreeBSD 5.* (gcc 3.*):
-
- __register_frame_info() and __frame_state_for() from libgcc.a are
- linked into shared libraries that use exceptions, e.g. libstdc++.
- Those functions are not compatible with linuxthreads due to
- pthread_mutex_t and pthread_once_t having different sizes and static
- initializers. Linking the shared linuxthreads library before any such
- library causes the liblgcc_r.a version of those functions to be used.
- Use liblstdc++ and liblsupc++.
-
- Experimental wrapper support:
-
- If the linuxthreads library has been compiled with
- LINUXTHREADS_WRAP_API defined in the ports makefile then
- the API functions are internally prefixed with linuxthreads_
- to avoid conflict with native threads. Weak symbols without
- that prefix points to the wrapper functions (internally
- prefixed by _) that makes the linuxthreads functions available
- with the native threads API. Applications including the
- linuxthreads version of pthread.h will try to call the
- prefixed methods (e.g. linuxthreads_pthread_create) while
- applications including the native pthread.h will use the
- wrapper functions. This allows for some level of coexistence
- of libraries compiled with linuxthreads header file and
- libraries compiled with native threads header files as long
- as none of the pthread data types leaks out as function arguments
- or structure members.
-
-5) Exit handling is broken.
-
- If the linuxthreads library has been compiled with
- LINUXTHREADS_DETECT_UNSAFE_EXIT defined in the ports makefile then
- the library tries to avoid further calls to functions registered
- with atexit if not called from the main thread or if other threads
- were active. Since this implicitly indicates a failure to do
- proper cleanup, the exit code is then changed to 1.
-
- If the linuxthreads library has been compiled without
- LINUXTHREADS_DETECT_UNSAFE_EXIT, then calls to exit() has a
- slightly higher probability of crashing or hanging the program when
- other threads are active. If another thread than the main thread
- performs the exit call, the exit code will appear to be 0.
-
- If multiple threads calls exit then the application will likely
- crash.
-
- If other threads has been joined by the main thread before it calls
- exit then exit handling should be fairly safe and the correct exit
- code can be detected by the parent process.
-
-6) If the rate of sched_yield() calls is very high (due to
- malloc / spinlock interaction) then
- LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING can be defined when
- compiling the linuxthreads library. This has the same effect
- as if the kernel was compiled without the _KPOSIX_PRIORITY_SCHEDULING
- option, but limited to the linuxthread library.
-
-7) libraries using SIGUSR2 or SIGUSR1 will conflict with linuxthreads.
- SIGUSR1 is hardcoded in the FreeBSD kernel (cf. RFLINUXTHPN flag
- passed to rfork()), but the linuxthreads library can be changed to use
- another signal instead of SIGUSR2 by defining LINUXTHREADS_ALT_RESTARTSIG
- to the alternate signal number (e.g. 32).
-
-8) By default, the maximum thread stack size is 2 MB, and the maximum
- number of threads is 1024. Layout of stacks are based on the
- maximum thread stack size. This means that 2 GB of the address space
- can be used by thread stacks, limiting what is left for other
- purposes (text, data, bss, heap, mmap). To shrink the address range
- used for thread stacks, the maximum thread stack size can be changed
- by defining LINUXTHREADS_MAX_STACK_SIZE to a suitable value, e.g.
- 1048576. The maximum number of threads can be changed by defining
- LINUXTHREADS_MAX_THREADS to a suitable value, e.g. 2048.
- The product of the maximum thread stack size and the maximum number
- of threads should not exceed 2 GB. The maximum stack size must be
- a power of 2.
-
-9) The complete FreeBSD source code matching the installed userland
- must be installed in /usr/src before building linuxthreads.
diff --git a/devel/linuxthreads/files/_pthreadtypes.h b/devel/linuxthreads/files/_pthreadtypes.h
deleted file mode 100644
index 7b485dc568de..000000000000
--- a/devel/linuxthreads/files/_pthreadtypes.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * Copyright (c) 2005 Yahoo! Technologies Norway AS
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _LINUXTHREADS_SYS__PTHREADTYPES_H
-#define _LINUXTHREADS_SYS__PTHREADTYPES_H
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-
-#include <sched.h>
-
-#ifdef _BITS_TYPES_H
-#include <bits/pthreadtypes.h>
-#else
-#define _BITS_TYPES_H
-#include <bits/pthreadtypes.h>
-#undef _BITS_TYPES_H
-#endif
-
-#endif
diff --git a/devel/linuxthreads/files/clone.S b/devel/linuxthreads/files/clone.S
deleted file mode 100644
index 9782fc52a3e5..000000000000
--- a/devel/linuxthreads/files/clone.S
+++ /dev/null
@@ -1,143 +0,0 @@
- .file "clone.S"
-#include <sys/syscall.h>
-#if __FreeBSD__ >= 5
-#include <machine/asm.h>
-#else
-#include "DEFS.h"
-#endif
-#include "SYS.h"
-#define KERNEL
-#define _KERNEL
-#include <sys/errno.h>
-#undef _KERNEL
-#undef KERNEL
-
-#undef DEBUG
-
-/*
- * 8 12 16 20
- * _clone (__fn, __childstack, __flags, __arg);
- *
- * Here's the idea:
- * __childstack is the TOS for the new rforked thread
- * __flags are the rfork flags
- * __fn is the userland function go be started for the new thread
- * as in:
- *
- * int __fn (void * __arg)
- *
- */
-.stabs "clone.S",100,0,0,Ltext0
- .text
-Ltext0:
- .type CNAME(_clone),@function
- .stabd 68,0,1
-ENTRY(_clone)
- pushl %ebp
- movl %esp, %ebp
- pushl %esi
- PIC_PROLOGUE
-
- /*
- * Push thread info onto the new thread's stack
- */
- movl 12(%ebp), %esi /* get stack addr */
-
- subl $4, %esi
- andl $-16, %esi /* Align stack addr */
- movl 20(%ebp), %eax /* get __arg */
- movl %eax, (%esi)
-
- subl $4, %esi
- movl 8(%ebp), %eax /* get __fn */
- movl %eax, (%esi)
-
- .stabd 68,0,2
- /*
- * Prepare and execute rfork
- */
- pushl 16(%ebp)
- pushl $0 /* fake return address */
-
- leal SYS_rfork, %eax
- KERNCALL
- jb 2f
-
- .stabd 68,0,3
- /*
- * Check to see if we are in the parent or child
- */
- cmpl $0, %edx
- jnz 1f
- addl $8, %esp
- PIC_EPILOGUE
- popl %esi
- movl %ebp, %esp
- popl %ebp
- ret
- .p2align 2
-
- /*
- * If we are in the child (new thread), then
- * set-up the call to the internal subroutine. If it
- * returns, then call _exit.
- */
- .stabd 68,0,4
-1:
- movl %esi,%esp
-#ifdef DEBUG
- movl %esp, _stackaddr
- movl (%esp), %eax
- movl %eax, _stack
- movl 4(%esp), %eax
- movl %eax,_stack+4
- movl 8(%esp), %eax
- movl %eax,_stack+8
-#endif
- popl %eax
-#ifdef DEBUG
- movl %eax,_fcn
-#endif
- movl $0, %ebp
- call *%eax
- addl $8, %esp
-
- /*
- * Exit system call
- */
- call PIC_PLT(_exit)
-
- .stabd 68,0,5
-2: addl $8, %esp
- PIC_EPILOGUE
- popl %esi
- movl %ebp, %esp
- popl %ebp
- PIC_PROLOGUE
- /* Copy of libc .cerror since libc .cerror must be called from libc */
- pushl %eax
- /* The caller must execute the PIC prologue before jumping to cerror. */
- call PIC_PLT(CNAME(__error))
- popl %ecx
- PIC_EPILOGUE
- movl %ecx,(%eax)
- movl $-1,%eax
- movl $-1,%edx
- ret
-
-.stabs "_clone:f67",36,0,6,CNAME(_clone)
-Lfe1:
- .size CNAME(_clone),Lfe1-CNAME(_clone)
-
-#ifdef DEBUG
- .data
- .globl _stack
-_stack: .long 0
- .long 0
- .long 0
- .long 0
- .globl _stackaddr
-_stackaddr: .long 0
- .globl _fcn
-_fcn: .long 0
-#endif
diff --git a/devel/linuxthreads/files/clone.h b/devel/linuxthreads/files/clone.h
deleted file mode 100644
index e6b0e7f7519f..000000000000
--- a/devel/linuxthreads/files/clone.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Definitions of constants and data structure for POSIX 1003.1b-1993
- scheduling interface.
- Copyright (C) 1996, 1997 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 CLONE_H
-#define CLONE_H
-
-/* Cloning flags. */
-#define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
-#define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
-#define CLONE_FS 0x00000200 /* Set if fs info shared between processes.*/
-#define CLONE_FILES 0x00000400 /* Set if open files shared between processes*/
-#define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
-#define CLONE_PID 0x00001000 /* Set if pid shared. */
-
-/* Clone current process. */
-extern int __clone __P ((int (*__fn) (void *__arg), void *__child_stack,
- int __flags, void *__arg));
-
-extern int _clone __P ((int (*__fn) (void *__arg), void *__child_stack,
- int __flags, void *__arg));
-
-extern int clone __P ((int (*__fn) (void *__arg), void *__child_stack,
- int __flags, void *__arg));
-
-#endif
diff --git a/devel/linuxthreads/files/condwait-patch b/devel/linuxthreads/files/condwait-patch
deleted file mode 100644
index d3952813a402..000000000000
--- a/devel/linuxthreads/files/condwait-patch
+++ /dev/null
@@ -1,369 +0,0 @@
-diff -ru ../../work.nc/linuxthreads-2.2.3_19/condvar.c ./condvar.c
---- ../../work.nc/linuxthreads-2.2.3_19/condvar.c Thu Apr 12 23:02:02 2001
-+++ ./condvar.c Tue Jan 10 18:14:20 2006
-@@ -55,6 +55,11 @@
- return did_remove;
- }
-
-+extern int __pthread_mutex_condwait_completelock(pthread_mutex_t *mutex);
-+
-+#define CVA_AVAIL 1
-+#define CVA_EXTRA_RESTART 2
-+
- int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
- {
- volatile pthread_descr self = thread_self();
-@@ -74,6 +79,7 @@
-
- /* Register extrication interface */
- THREAD_SETMEM(self, p_condvar_avail, 0);
-+ THREAD_SETMEM(self, p_condwait_mutex, mutex);
- __pthread_set_own_extricate_if(self, &extr);
-
- /* Atomically enqueue thread for waiting, but only if it is not
-@@ -102,10 +108,15 @@
- while (1)
- {
- suspend(self);
-- if (THREAD_GETMEM(self, p_condvar_avail) == 0
-+ if ((THREAD_GETMEM(self, p_condvar_avail) & CVA_AVAIL) == 0
- && (THREAD_GETMEM(self, p_woken_by_cancel) == 0
- || THREAD_GETMEM(self, p_cancelstate) != PTHREAD_CANCEL_ENABLE))
- {
-+ if ((THREAD_GETMEM(self, p_condvar_avail) &
-+ CVA_EXTRA_RESTART) == 0 &&
-+ !__compare_and_swap(&self->p_condvar_avail,
-+ 0, CVA_EXTRA_RESTART))
-+ break; /* CVA_AVAIL set by other thread */
- /* Count resumes that don't belong to us. */
- spurious_wakeup_count++;
- continue;
-@@ -121,15 +132,35 @@
- if (THREAD_GETMEM(self, p_woken_by_cancel)
- && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) {
- THREAD_SETMEM(self, p_woken_by_cancel, 0);
-- pthread_mutex_lock(mutex);
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL) {
-+ if ((THREAD_GETMEM(self, p_condvar_avail) & CVA_EXTRA_RESTART) != 0) {
-+ if (spurious_wakeup_count > 0)
-+ spurious_wakeup_count--;
-+ else
-+ suspend(self);
-+ }
-+ __pthread_mutex_condwait_completelock(mutex);
-+ } else
-+ pthread_mutex_lock(mutex);
- __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
- }
-
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL &&
-+ (THREAD_GETMEM(self, p_condvar_avail) & CVA_EXTRA_RESTART) != 0) {
-+ if (spurious_wakeup_count > 0)
-+ spurious_wakeup_count--;
-+ else
-+ suspend(self);
-+ }
-+
- /* Put back any resumes we caught that don't belong to us. */
- while (spurious_wakeup_count--)
- restart(self);
-
-- pthread_mutex_lock(mutex);
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL)
-+ __pthread_mutex_condwait_completelock(mutex);
-+ else
-+ pthread_mutex_lock(mutex);
- return 0;
- }
-
-@@ -155,6 +186,7 @@
-
- /* Register extrication interface */
- THREAD_SETMEM(self, p_condvar_avail, 0);
-+ THREAD_SETMEM(self, p_condwait_mutex, mutex);
- __pthread_set_own_extricate_if(self, &extr);
-
- /* Enqueue to wait on the condition and check for cancellation. */
-@@ -196,10 +228,15 @@
- suspend(self);
- }
-
-- if (THREAD_GETMEM(self, p_condvar_avail) == 0
-+ if ((THREAD_GETMEM(self, p_condvar_avail) & CVA_AVAIL) == 0
- && (THREAD_GETMEM(self, p_woken_by_cancel) == 0
- || THREAD_GETMEM(self, p_cancelstate) != PTHREAD_CANCEL_ENABLE))
- {
-+ if ((THREAD_GETMEM(self, p_condvar_avail) &
-+ CVA_EXTRA_RESTART) == 0 &&
-+ !__compare_and_swap(&self->p_condvar_avail,
-+ 0, CVA_EXTRA_RESTART))
-+ break; /* CVA_AVAIL set by other thread */
- /* Count resumes that don't belong to us. */
- spurious_wakeup_count++;
- continue;
-@@ -215,15 +252,35 @@
- if (THREAD_GETMEM(self, p_woken_by_cancel)
- && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) {
- THREAD_SETMEM(self, p_woken_by_cancel, 0);
-- pthread_mutex_lock(mutex);
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL) {
-+ if ((THREAD_GETMEM(self, p_condvar_avail) & CVA_EXTRA_RESTART) != 0) {
-+ if (spurious_wakeup_count > 0)
-+ spurious_wakeup_count--;
-+ else
-+ suspend(self);
-+ }
-+ __pthread_mutex_condwait_completelock(mutex);
-+ } else
-+ pthread_mutex_lock(mutex);
- __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
- }
-
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL &&
-+ (THREAD_GETMEM(self, p_condvar_avail) & CVA_EXTRA_RESTART) != 0) {
-+ if (spurious_wakeup_count > 0)
-+ spurious_wakeup_count--;
-+ else
-+ suspend(self);
-+ }
-+
- /* Put back any resumes we caught that don't belong to us. */
- while (spurious_wakeup_count--)
- restart(self);
-
-- pthread_mutex_lock(mutex);
-+ if (THREAD_GETMEM(self, p_condwait_mutex) == NULL)
-+ __pthread_mutex_condwait_completelock(mutex);
-+ else
-+ pthread_mutex_lock(mutex);
- return 0;
- }
-
-@@ -237,14 +294,34 @@
- int pthread_cond_signal(pthread_cond_t *cond)
- {
- pthread_descr th;
-+ long oldcva;
-
- __pthread_lock(&cond->__c_lock, NULL);
- th = dequeue(&cond->__c_waiting);
- __pthread_unlock(&cond->__c_lock);
- if (th != NULL) {
-- th->p_condvar_avail = 1;
-- WRITE_MEMORY_BARRIER();
-- restart(th);
-+ pthread_mutex_t *mutex = th->p_condwait_mutex;
-+ if ((th->p_condvar_avail & CVA_AVAIL) == 0 &&
-+ mutex != NULL &&
-+ (mutex->__m_kind == PTHREAD_MUTEX_ERRORCHECK_NP ||
-+ mutex->__m_kind == PTHREAD_MUTEX_TIMED_NP) &&
-+ __pthread_alt_condwait_queuelock(&mutex->__m_lock, th) == 0) {
-+ th->p_condwait_mutex = NULL;
-+ WRITE_MEMORY_BARRIER();
-+ do {
-+ READ_MEMORY_BARRIER();
-+ oldcva = th->p_condvar_avail;
-+ } while (!__compare_and_swap(&th->p_condvar_avail,
-+ oldcva,
-+ oldcva | CVA_AVAIL));
-+ WRITE_MEMORY_BARRIER();
-+ if ((oldcva & CVA_EXTRA_RESTART) != 0)
-+ restart(th);
-+ } else {
-+ th->p_condvar_avail = CVA_AVAIL;
-+ WRITE_MEMORY_BARRIER();
-+ restart(th);
-+ }
- }
- return 0;
- }
-@@ -252,6 +329,7 @@
- int pthread_cond_broadcast(pthread_cond_t *cond)
- {
- pthread_descr tosignal, th;
-+ long oldcva;
-
- __pthread_lock(&cond->__c_lock, NULL);
- /* Copy the current state of the waiting queue and empty it */
-@@ -260,9 +338,28 @@
- __pthread_unlock(&cond->__c_lock);
- /* Now signal each process in the queue */
- while ((th = dequeue(&tosignal)) != NULL) {
-- th->p_condvar_avail = 1;
-- WRITE_MEMORY_BARRIER();
-- restart(th);
-+ pthread_mutex_t *mutex = th->p_condwait_mutex;
-+ if ((th->p_condvar_avail & CVA_AVAIL) == 0 &&
-+ mutex != NULL &&
-+ (mutex->__m_kind == PTHREAD_MUTEX_ERRORCHECK_NP ||
-+ mutex->__m_kind == PTHREAD_MUTEX_TIMED_NP) &&
-+ __pthread_alt_condwait_queuelock(&mutex->__m_lock, th) == 0) {
-+ th->p_condwait_mutex = NULL;
-+ WRITE_MEMORY_BARRIER();
-+ do {
-+ READ_MEMORY_BARRIER();
-+ oldcva = th->p_condvar_avail;
-+ } while (!__compare_and_swap(&th->p_condvar_avail,
-+ oldcva,
-+ oldcva | CVA_AVAIL));
-+ WRITE_MEMORY_BARRIER();
-+ if ((oldcva & CVA_EXTRA_RESTART) != 0)
-+ restart(th);
-+ } else {
-+ th->p_condvar_avail = CVA_AVAIL;
-+ WRITE_MEMORY_BARRIER();
-+ restart(th);
-+ }
- }
- return 0;
- }
-Only in .: condvar.c~
-diff -ru ../../work.nc/linuxthreads-2.2.3_19/internals.h ./internals.h
---- ../../work.nc/linuxthreads-2.2.3_19/internals.h Tue Jan 10 17:13:14 2006
-+++ ./internals.h Tue Jan 10 17:33:30 2006
-@@ -125,6 +125,13 @@
- int pr_lock_count;
- } pthread_readlock_info;
-
-+
-+struct wait_node {
-+ struct wait_node *next; /* Next node in null terminated linked list */
-+ pthread_descr thr; /* The thread waiting with this node */
-+ int abandoned; /* Atomic flag */
-+};
-+
- struct _pthread_descr_struct {
- union {
- struct {
-@@ -176,7 +183,7 @@
- struct pthread_atomic p_resume_count; /* number of times restart() was
- called on thread */
- char p_woken_by_cancel; /* cancellation performed wakeup */
-- char p_condvar_avail; /* flag if conditional variable became avail */
-+ long p_condvar_avail; /* flag if conditional variable became avail */
- char p_sem_avail; /* flag if semaphore became available */
- pthread_extricate_if *p_extricate; /* See above */
- pthread_readlock_info *p_readlock_list; /* List of readlock info structs */
-@@ -189,6 +196,8 @@
- hp_timing_t p_cpuclock_offset; /* Initial CPU clock for thread. */
- #endif
- /* New elements must be added at the end. */
-+ pthread_mutex_t *p_condwait_mutex;
-+ struct wait_node p_condwait_waitnode;
- } __attribute__ ((aligned(32))); /* We need to align the structure so that
- doubles are aligned properly. This is 8
- bytes on MIPS and 16 bytes on MIPS64.
-Only in .: internals.h~
-diff -ru ../../work.nc/linuxthreads-2.2.3_19/mutex.c ./mutex.c
---- ../../work.nc/linuxthreads-2.2.3_19/mutex.c Sun Jan 7 05:35:20 2001
-+++ ./mutex.c Tue Jan 10 17:13:46 2006
-@@ -92,6 +92,24 @@
- }
- strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
-
-+int __pthread_mutex_condwait_completelock(pthread_mutex_t *mutex)
-+{
-+ pthread_descr self;
-+
-+ switch(mutex->__m_kind) {
-+ case PTHREAD_MUTEX_ERRORCHECK_NP:
-+ self = thread_self();
-+ if (mutex->__m_owner == self) return EDEADLK;
-+ mutex->__m_owner = self;
-+ return 0;
-+ case PTHREAD_MUTEX_TIMED_NP:
-+ return 0;
-+ default:
-+ return EINVAL;
-+ }
-+}
-+
-+
- int __pthread_mutex_lock(pthread_mutex_t * mutex)
- {
- pthread_descr self;
-diff -ru ../../work.nc/linuxthreads-2.2.3_19/spinlock.c ./spinlock.c
---- ../../work.nc/linuxthreads-2.2.3_19/spinlock.c Tue Jan 10 17:13:14 2006
-+++ ./spinlock.c Tue Jan 10 17:13:46 2006
-@@ -231,12 +231,6 @@
- */
-
-
--struct wait_node {
-- struct wait_node *next; /* Next node in null terminated linked list */
-- pthread_descr thr; /* The thread waiting with this node */
-- int abandoned; /* Atomic flag */
--};
--
- static long wait_node_free_list;
- #if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
- static int wait_node_free_list_spinlock;
-@@ -359,6 +353,55 @@
- }
-
- #endif
-+
-+int __pthread_alt_condwait_queuelock(struct _pthread_fastlock * lock,
-+ pthread_descr th)
-+{
-+#if defined HAS_COMPARE_AND_SWAP
-+ long oldstatus, newstatus;
-+#endif
-+
-+#if defined TEST_FOR_COMPARE_AND_SWAP
-+ if (!__pthread_has_cas)
-+#endif
-+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
-+ {
-+ __pthread_acquire(&lock->__spinlock);
-+
-+ if (lock->__status == 0) {
-+ WRITE_MEMORY_BARRIER();
-+ lock->__spinlock = __LT_SPINLOCK_INIT;
-+ return 1;
-+ }
-+ th->p_condwait_waitnode.abandoned = 0;
-+ th->p_condwait_waitnode.next = (struct wait_node *) lock->__status;
-+ th->p_condwait_waitnode.thr = th;
-+ lock->__status = (long) &th->p_condwait_waitnode;
-+
-+ WRITE_MEMORY_BARRIER();
-+ lock->__spinlock = __LT_SPINLOCK_INIT;
-+ return 0;
-+ }
-+#endif
-+
-+#if defined HAS_COMPARE_AND_SWAP
-+ do {
-+ oldstatus = lock->__status;
-+ if (oldstatus == 0) {
-+ return 1;
-+ }
-+ th->p_condwait_waitnode.thr = th;
-+ newstatus = (long) &th->p_condwait_waitnode;
-+ th->p_condwait_waitnode.abandoned = 0;
-+ th->p_condwait_waitnode.next = (struct wait_node *) oldstatus;
-+ /* Make sure the store in wait_node.next completes before performing
-+ the compare-and-swap */
-+ MEMORY_BARRIER();
-+ } while(! __compare_and_swap(&lock->__status, oldstatus, newstatus));
-+ return 0;
-+#endif
-+}
-+
-
- void __pthread_alt_lock(struct _pthread_fastlock * lock,
- pthread_descr self)
-diff -ru ../../work.nc/linuxthreads-2.2.3_19/spinlock.h ./spinlock.h
---- ../../work.nc/linuxthreads-2.2.3_19/spinlock.h Tue Jan 10 17:13:14 2006
-+++ ./spinlock.h Tue Jan 10 17:13:46 2006
-@@ -130,6 +130,9 @@
- timed-out waits. Warning: do not mix these operations with the above ones
- over the same lock object! */
-
-+extern int __pthread_alt_condwait_queuelock(struct _pthread_fastlock * lock,
-+ pthread_descr th);
-+
- extern void __pthread_alt_lock(struct _pthread_fastlock * lock,
- pthread_descr self);
-
diff --git a/devel/linuxthreads/files/freebsd-compat.h b/devel/linuxthreads/files/freebsd-compat.h
deleted file mode 100644
index 470cb51827d8..000000000000
--- a/devel/linuxthreads/files/freebsd-compat.h
+++ /dev/null
@@ -1,186 +0,0 @@
-#include <poll.h>
-#include <bits/local_lim.h>
-#include <sys/queue.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-
-#if __FreeBSD__ >= 5
-#define __libc_accept __sys_accept
-#define __libc_close __sys_close
-#define __libc_connect __sys_connect
-#define __libc_fcntl __sys_fcntl
-#define __libc_fork __sys_fork
-#define __libc_fsync __sys_fsync
-#define __libc_nanosleep __sys_nanosleep
-#define __libc_open __sys_open
-#define __libc_read __sys_read
-#define __libc_waitpid __waitpid
-#define __libc_write __sys_write
-#define __libc_longjmp __longjmp
-#define __libc_siglongjmp __siglongjmp
-#define __libc_msync __sys_msync
-#define __libc_recvfrom __sys_recvfrom
-#define __libc_recvmsg __sys_recvmsg
-#define __libc_sendmsg __sys_sendmsg
-#define __libc_sendto __sys_sendto
-#define __libc_sigaction __sys_sigaction
-#define __libc_poll __sys_poll
-#define __libc_getpid __sys_getpid
-#else
-#define __libc_accept _accept
-#define __libc_close _close
-#define __libc_connect _connect
-#define __libc_fcntl _fcntl
-#define __libc_fork _fork
-#define __libc_fsync _fsync
-#define __libc_nanosleep _nanosleep
-#define __libc_open _open
-#define __libc_read _read
-#define __libc_waitpid __waitpid
-#define __libc_write _write
-#define __libc_longjmp __longjmp
-#define __libc_siglongjmp __siglongjmp
-#define __libc_msync _msync
-#define __libc_recvfrom _recvfrom
-#define __libc_recvmsg _recvmsg
-#define __libc_sendmsg _sendmsg
-#define __libc_sendto _sendto
-#define __libc_sigaction _sigaction
-#define __libc_poll _poll
-#define __libc_getpid _getpid
-#endif
-#define __libc_wait __wait
-#define __libc_system __system
-#define __getpid __libc_getpid
-#define __poll __libc_poll
-#define __libc_tcdrain __tcdrain
-#define __libc_pause __pause
-#define __libc_current_sigrtmin current_sigrtmin
-#define __libc_current_sigrtmax current_sigrtmax
-#define __libc_allocate_rtsig allocate_rtsig
-#define __getpagesize getpagesize
-int __sched_setparam(pid_t, const struct sched_param *);
-int __sched_getparam(pid_t, struct sched_param *);
-int __sched_setscheduler(pid_t, int, const struct sched_param *);
-int __sched_getscheduler(pid_t);
-int __sched_yield(void);
-int __sched_get_priority_max(int);
-int __sched_get_priority_min(int);
-int __sched_rr_get_interval(pid_t, struct timespec *);
-#define __gettimeofday _gettimeofday
-#define __jmp_buf jmp_buf
-#define _h_errno h_errno
-#define __ptr_t void *
-#define __pid_t pid_t
-
-ssize_t __libc_write(int, const void *, size_t);
-ssize_t __libc_read(int, void *, size_t);
-pid_t __libc_waitpid(pid_t wpid, int *status, int options);
-int __libc_poll(struct pollfd *_pfd, unsigned int _nfsd, int _timeout);
-pid_t __libc_getpid(void);
-pid_t __libc_waitpid(pid_t, int *, int);
-int __libc_sigaction(int, const struct sigaction *, struct sigaction *);
-int __libc_fcntl(int, int, ...);
-int __libc_fsync(int);
-int __libc_msync(void *, size_t, int);
-int __libc_open(const char *, int, ...);
-int __libc_pause(void);
-ssize_t __libc_pwrite(int, const void *, size_t, off_t);
-ssize_t __libc_pread(int, void *, size_t, off_t);
-int __libc_tcdrain(int);
-pid_t __libc_wait(int *);
-int __libc_system(const char *);
-int __libc_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
-int __libc_connect(int, const struct sockaddr *, socklen_t);
-ssize_t __libc_recvfrom(int, void *, size_t, int, struct sockaddr *,
- socklen_t *);
-ssize_t __libc_recvmsg(int, struct msghdr *, int);
-ssize_t __libc_sendmsg(int, const struct msghdr *, int);
-ssize_t __libc_sendto(int, const void *,
- size_t, int, const struct sockaddr *, socklen_t);
-
-#ifndef __P
-# define __P(args) args
-#endif
-
-#ifndef __THROW
-#define __THROW
-#endif
-
-#ifndef __restrict
-#define __restrict
-#endif
-
-#define SHLIB_COMPAT(lib, old, new) 0
-
-#define versioned_symbol(libname, realname, aliasname, libver) __strong_reference(realname,aliasname)
-
-#define link_warning(symbol, warning) __warn_references(symbol, warning);
-
-#ifndef __PMT
-# define __PMT(args) args
-#endif
-
-# define strong_alias(name, aliasname) \
- extern __typeof (name) aliasname __attribute__ ((alias (#name)));
-
-# define weak_alias(name, aliasname) \
- extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
-
-#define ENOTSUP EOPNOTSUPP
-
-#define __builtin_expect(x,y) (x)
-#define internal_function
-
-
-#undef PAGE_SIZE
-#define PAGE_SIZE getpagesize()
-
-#define MAP_ANONYMOUS MAP_ANON
-#define MAP_GROWSDOWN MAP_STACK
-
-#define __WCLONE WLINUXCLONE
-
-#define SIGCONTEXT struct sigcontext *
-#define SIGCONTEXT_EXTRA_ARGS
-
-# define __WAIT_STATUS_DEFN int *
-
-# define __SOCKADDR_ARG struct sockaddr *
-# define __CONST_SOCKADDR_ARG __const struct sockaddr *
-
-#define __ptr_t void *
-#define __pid_t pid_t
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-
-/* XXXX check this for FreeBSD */
-/* i386 only */
-#define JB_SP 2
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) ((int *)(jmpbuf[0]._jb[JB_SP]))[1])
-
-#define spinlock_t int
-#define _SPINLOCK_INITIALIZER 0
-#define _SPINLOCK(x) __pthread_acquire(x)
-#define _SPINUNLOCK(x) *(x) = 0
-/*#define TEST_FOR_COMPARE_AND_SWAP*/
-
-#define __set_errno(val) errno = (val)
-
-#define DEFAULT_PRIORITY 20
-
-void __libc_longjmp __P((jmp_buf, int)) __dead2;
-void __libc_siglongjmp __P((sigjmp_buf, int)) __dead2;
-
-int _gettimeofday __P((struct timeval *, struct timezone *));
-pid_t _getpid __P((void));
-int _sigaction __P((int, const struct sigaction *, struct sigaction *));
-int _poll __P((struct pollfd *_pfd, unsigned _nfds, int _timeout));
-
-#include "clone.h"
-
-
diff --git a/devel/linuxthreads/files/getgr_r.c b/devel/linuxthreads/files/getgr_r.c
deleted file mode 100644
index c7ad11ddefb3..000000000000
--- a/devel/linuxthreads/files/getgr_r.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 1999 Richard Seaman, Jr.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Richard Seaman, Jr.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RICHARD SEAMAN, Jr. AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-#include <grp.h>
-#include "pthread.h"
-
-static pthread_mutex_t getgr_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct group *ret, struct group *result,
- char *buf, int buflen)
-{
- int len;
- int count;
- char **gr_mem;
- char *buf1;
-
- if (!buf) return -1;
-
- *result = *ret;
-
- result->gr_name = (char *) buf;
- /* This is the size. */
- len = strlen (ret->gr_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->gr_name, ret->gr_name);
-
- result->gr_passwd = (char *) buf;
- /* This is the size. */
- len = strlen (ret->gr_passwd) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->gr_passwd, ret->gr_passwd);
-
- count = 0;
- gr_mem = ret->gr_mem;
- while (*gr_mem){
- count++;
- gr_mem++;
- }
- len = sizeof (*gr_mem)*(count+1);
- if (len > buflen) return -1;
- buf1 = buf;
- buflen -= len;
- buf += len;
- gr_mem = ret->gr_mem;
- while (*gr_mem){
- len = strlen (*gr_mem) + 1;
- if (len > buflen) return -1;
- buf1 = buf;
- strcpy (buf, *gr_mem);
- buflen -= len;
- buf += len;
- buf1 += sizeof (buf1);
- gr_mem++;
- }
- buf1 = NULL;
- return 0;
-}
-
-int getgrnam_r (const char *name, struct group *result,
- char *buffer, size_t buflen,
- struct group ** resptr)
-{
- struct group * p;
- int retval;
-
- pthread_mutex_lock (&getgr_mutex);
- p = getgrnam (name);
- if (p == NULL) {
- *resptr = NULL;
- retval = ESRCH;
- } else
- if (convert (p, result, buffer, buflen) != 0) {
- *resptr = NULL;
- retval = ERANGE;
- } else {
- *resptr = result;
- retval = 0;
- }
- pthread_mutex_unlock (&getgr_mutex);
- return retval;
-}
-
-int getgrgid_r (uid_t uid, struct group *result,
- char *buffer, size_t buflen,
- struct group ** resptr)
-{
- struct group * p;
- int retval;
-
- pthread_mutex_lock (&getgr_mutex);
- p = getgrgid (uid);
- if (p == NULL) {
- *resptr = NULL;
- retval = ESRCH;
- } else
- if (convert (p, result, buffer, buflen) != 0) {
- *resptr = NULL;
- retval = ERANGE;
- } else {
- *resptr = result;
- retval = 0;
- }
- pthread_mutex_unlock (&getgr_mutex);
- return retval;
-}
diff --git a/devel/linuxthreads/files/gethostby_r.c b/devel/linuxthreads/files/gethostby_r.c
deleted file mode 100644
index 8a171aac05c3..000000000000
--- a/devel/linuxthreads/files/gethostby_r.c
+++ /dev/null
@@ -1,172 +0,0 @@
-#include "pthread.h"
-#include <netdb.h>
-#include <osreldate.h>
-#include <string.h>
-
-#ifdef __sparc__
-#define NEED_ALIGNED_ACCESS
-#endif
-
-#if __FreeBSD_version < 502104
-
-static pthread_mutex_t gethostby_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct hostent *host, struct hostent *result,
- char *buf, int buflen, int *h_errnop)
-{
- int len, i;
-
- if (!buf || !h_errnop) return -1;
- *h_errnop = h_errno;
-
- *result = *host;
- result->h_name = (char *) buf;
- /* This is the size. */
- len = strlen (host->h_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy ((char *) result->h_name, host->h_name);
-
- /* How many aliases and how big the buffer should be? There
- is always a NULL pointer. */
- for (len = sizeof (char *), i = 0; host->h_aliases [i]; i++)
- {
- /* It should be size of (char *) and the length of string
- plus 1. */
- len += strlen (host->h_aliases [i]) + 1 + sizeof (char *);
- }
- if (len > buflen) return -1;
- buflen -= len;
-
- /* This is an array of char * for h_aliases. */
-#ifdef NEED_ALIGNED_ACCESS
- {
- int extra;
- extra = 4 - (((unsigned long) buf) & 3);
- if (extra != 4) {
- if (buflen < extra)
- return -1;
- buf = (char *) buf + extra;
- }
- }
-#endif
- result->h_aliases = (char **) buf;
- buf += (i + 1) * sizeof (char *);
-
- /* We copy the aliases now. */
- for (i = 0; host->h_aliases [i]; i++)
- {
- result->h_aliases [i] = (char *) buf;
- strcpy (result->h_aliases [i], host->h_aliases [i]);
- buf += strlen (host->h_aliases [i]) + 1;
- }
- /* This is the last one */
- result->h_aliases [i] = NULL;
-
-#if BSD >= 43 || defined(h_addr)
- for (len = sizeof (char *), i = 0; host->h_addr_list [i]; i++)
- {
- /* It should be size of (char *) and the length of string
- plus 1. */
- len += host->h_length + sizeof (char *);
- }
- if (len > buflen) return -1;
-
- /* This is an array of char * for h_addr_list. */
-#ifdef NEED_ALIGNED_ACCESS
- {
- int extra;
- extra = 4 - (((unsigned long) buf) & 0x3);
- if (extra != 4) {
- if (buflen < extra)
- return -1;
- buf = ((char *) buf) + extra;
- }
- }
-#endif
- result->h_addr_list = (char **) buf;
- buf += (i + 1) * sizeof (char *);
-
- /* We copy the h_addr_list now. */
- for (i = 0; host->h_addr_list [i]; i++)
- {
- result->h_addr_list [i] = (char *) buf;
- memcpy (result->h_addr_list [i], host->h_addr_list [i], host->h_length);
- buf += host->h_length;
- }
- /* This is the last one */
- result->h_addr_list [i] = NULL;
-#else
- len = strlen (host->h_addr) + 1 + sizeof (char *);
- if (len > buflen) return -1;
-
- result->h_addr = (char *) buf;
- strcpy (result->h_addr, host->h_addr);
-#endif
- return 0;
-}
-
-#if __FreeBSD__ < 5 || __FreeBSD_version >= 501101
-struct hostent *
-gethostbyaddr_r (const char *addr, int length, int type,
- struct hostent *result, char *buffer, int buflen,
- int *h_errnop)
-{
- struct hostent *host;
-
- pthread_mutex_lock (&gethostby_mutex);
-
- host = gethostbyaddr (addr, length, type);
- if (!host ||
- convert (host, result, buffer, buflen, h_errnop) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&gethostby_mutex);
- return result;
-}
-#endif
-
-struct hostent *
-gethostbyname_r (const char *name,
- struct hostent *result, char *buffer, int buflen,
- int *h_errnop)
-{
- struct hostent *host;
-
- pthread_mutex_lock (&gethostby_mutex);
-
- host = gethostbyname (name);
- if (!host ||
- convert (host, result, buffer, buflen, h_errnop) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&gethostby_mutex);
- return result;
-}
-
-struct hostent *
-gethostent_r (struct hostent *result, char *buffer, int buflen,
- int *h_errnop)
-{
- struct hostent *host;
-
- pthread_mutex_lock (&gethostby_mutex);
-
- host = gethostent ();
- if (!host ||
- convert (host, result, buffer, buflen, h_errnop) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&gethostby_mutex);
- return result;
-}
-
-#endif /* #if __FreeBSD_version < 502104 */
diff --git a/devel/linuxthreads/files/getlogin.c b/devel/linuxthreads/files/getlogin.c
deleted file mode 100644
index 11bf59bab4ec..000000000000
--- a/devel/linuxthreads/files/getlogin.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/gen/getlogin.c,v 1.4.2.1 2001/03/05 09:06:50 obrien Exp $
- */
-
-#if __FreeBSD__ < 5
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <errno.h>
-#include <pwd.h>
-#include <utmp.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifndef _THREAD_SAFE
-#define THREAD_LOCK()
-#define THREAD_UNLOCK()
-#else
-#include <pthread.h>
-extern int __isthreaded;
-static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
-#define THREAD_LOCK() if (__isthreaded) pthread_mutex_lock(&logname_mutex)
-#define THREAD_UNLOCK() if (__isthreaded) pthread_mutex_unlock(&logname_mutex)
-#endif /* _THREAD_SAFE */
-
-int _logname_valid; /* known to setlogin() */
-int _getlogin(char *, unsigned int);
-
-static char *
-getlogin_basic(int *status)
-{
- static char logname[MAXLOGNAME];
-
- if (_logname_valid == 0) {
-#ifdef __NETBSD_SYSCALLS
- if (__getlogin(logname, sizeof(logname) - 1) < 0) {
-#else
- if (_getlogin(logname, sizeof(logname)) < 0) {
-#endif
- *status = errno;
- return (NULL);
- }
- _logname_valid = 1;
- }
- *status = 0;
- return (*logname ? logname : NULL);
-}
-
-char *
-getlogin(void)
-{
- char *result;
- int status;
-
- THREAD_LOCK();
- result = getlogin_basic(&status);
- THREAD_UNLOCK();
- return (result);
-}
-
-int
-getlogin_r(char *logname, int namelen)
-{
- char *result;
- int len;
- int status;
-
- THREAD_LOCK();
- result = getlogin_basic(&status);
- if (status == 0) {
- if ((len = strlen(result) + 1) > namelen)
- status = ERANGE;
- else
- strncpy(logname, result, len);
- }
- THREAD_UNLOCK();
- return (status);
-}
-#endif /* __FreeBSD__ < 5 */
diff --git a/devel/linuxthreads/files/getnetby_r.c b/devel/linuxthreads/files/getnetby_r.c
deleted file mode 100644
index e6c6b6b1f2f6..000000000000
--- a/devel/linuxthreads/files/getnetby_r.c
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "pthread.h"
-#include <netdb.h>
-#include <string.h>
-#include <sys/param.h>
-
-#if (__FreeBSD_version >= 700000 && __FreeBSD_version < 700016) || \
- __FreeBSD_version < 601103
-
-static pthread_mutex_t getnetby_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct netent *ret, struct netent *result,
- char *buf, int buflen)
-{
- int len, i;
-
- if (!buf) return -1;
-
- *result = *ret;
- result->n_name = (char *) buf;
- /* This is the size. */
- len = strlen (ret->n_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->n_name, ret->n_name);
-
- /* How many aliases and how big the buffer should be? There
- is always a NULL pointer. */
- for (len = sizeof (char *), i = 0; ret->n_aliases [i]; i++)
- {
- /* It should be size of (char *) and the length of string
- plus 1. */
- len += strlen (ret->n_aliases [i]) + 1 + sizeof (char *);
- }
- if (len > buflen) return -1;
-
- /* This is an array of char * for n_aliases. */
- result->n_aliases = (char **) buf;
- buf += (i + 1) * sizeof (char *);
-
- /* We copy the aliases now. */
- for (i = 0; ret->n_aliases [i]; i++)
- {
- result->n_aliases [i] = (char *) buf;
- strcpy (result->n_aliases [i], ret->n_aliases [i]);
- buf += strlen (ret->n_aliases [i]) + 1;
- }
- /* This is the last one */
- result->n_aliases [i] = NULL;
-
- return 0;
-}
-
-struct netent *
-getnetbyaddr_r (long net, int type,
- struct netent *result, char *buffer, int buflen)
-{
- struct netent *ret;
-
- pthread_mutex_lock (&getnetby_mutex);
-
- ret = getnetbyaddr (net, type);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getnetby_mutex);
- return result;
-}
-
-struct netent *
-getnetbyname_r (const char *name,
- struct netent *result, char *buffer, int buflen)
-{
- struct netent *ret;
-
- pthread_mutex_lock (&getnetby_mutex);
-
- ret = getnetbyname (name);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getnetby_mutex);
- return result;
-}
-
-struct netent *
-getnetent_r (struct netent *result, char *buffer, int buflen)
-{
- struct netent *ret;
-
- pthread_mutex_lock (&getnetby_mutex);
-
- ret = getnetent ();
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getnetby_mutex);
- return result;
-}
-
-#endif /* #if __FreeBSD_version < 601103 */
diff --git a/devel/linuxthreads/files/getprotoby_r.c b/devel/linuxthreads/files/getprotoby_r.c
deleted file mode 100644
index 211cfaeeb26e..000000000000
--- a/devel/linuxthreads/files/getprotoby_r.c
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "pthread.h"
-#include <netdb.h>
-#include <string.h>
-#include <sys/param.h>
-
-#if (__FreeBSD_version >= 700000 && __FreeBSD_version < 700016) || \
- __FreeBSD_version < 601103
-
-static pthread_mutex_t getprotoby_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct protoent *ret, struct protoent *result,
- char *buf, int buflen)
-{
- int len, i;
-
- if (!buf) return -1;
-
- *result = *ret;
- result->p_name = (char *) buf;
- /* This is the size. */
- len = strlen (ret->p_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->p_name, ret->p_name);
-
- /* How many aliases and how big the buffer should be? There
- is always a NULL pointer. */
- for (len = sizeof (char *), i = 0; ret->p_aliases [i]; i++)
- {
- /* It should be size of (char *) and the length of string
- plus 1. */
- len += strlen (ret->p_aliases [i]) + 1 + sizeof (char *);
- }
- if (len > buflen) return -1;
-
- /* This is an array of char * for p_aliases. */
- result->p_aliases = (char **) buf;
- buf += (i + 1) * sizeof (char *);
-
- /* We copy the aliases now. */
- for (i = 0; ret->p_aliases [i]; i++)
- {
- result->p_aliases [i] = (char *) buf;
- strcpy (result->p_aliases [i], ret->p_aliases [i]);
- buf += strlen (ret->p_aliases [i]) + 1;
- }
- /* This is the last one */
- result->p_aliases [i] = NULL;
-
- return 0;
-}
-
-struct protoent *
-getprotobynumber_r (int proto,
- struct protoent *result, char *buffer, int buflen)
-{
- struct protoent *ret;
-
- pthread_mutex_lock (&getprotoby_mutex);
-
- ret = getprotobynumber (proto);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getprotoby_mutex);
- return result;
-}
-
-struct protoent *
-getprotobyname_r (const char *name,
- struct protoent *result, char *buffer, int buflen)
-{
- struct protoent *ret;
-
- pthread_mutex_lock (&getprotoby_mutex);
-
- ret = getprotobyname (name);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getprotoby_mutex);
- return result;
-}
-
-struct protoent *
-getprotoent_r (struct protoent *result, char *buffer, int buflen)
-{
- struct protoent *ret;
-
- pthread_mutex_lock (&getprotoby_mutex);
-
- ret = getprotoent ();
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getprotoby_mutex);
- return result;
-}
-
-#endif /* #if __FreeBSD_version < 601103 */
diff --git a/devel/linuxthreads/files/getpw_r.c b/devel/linuxthreads/files/getpw_r.c
deleted file mode 100644
index 246a4479a9e7..000000000000
--- a/devel/linuxthreads/files/getpw_r.c
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-#include <pwd.h>
-#include <osreldate.h>
-#include "pthread.h"
-
-#if __FreeBSD_version < 500112
-static pthread_mutex_t getpw_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct passwd *ret, struct passwd *result,
- char *buf, int buflen)
-{
- int len;
-
- if (!buf) return -1;
-
- *result = *ret;
-
- result->pw_name = (char *) buf;
- /* This is the size. */
- len = strlen (ret->pw_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->pw_name, ret->pw_name);
-
- result->pw_passwd = (char *) buf;
- /* This is the size. */
- len = strlen (ret->pw_passwd) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->pw_passwd, ret->pw_passwd);
-
- result->pw_gecos = (char *) buf;
- /* This is the size. */
- len = strlen (ret->pw_gecos) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->pw_gecos, ret->pw_gecos);
-
- result->pw_dir = (char *) buf;
- /* This is the size. */
- len = strlen (ret->pw_dir) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->pw_dir, ret->pw_dir);
-
- result->pw_shell = (char *) buf;
- /* This is the size. */
- len = strlen (ret->pw_shell) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- buf += len;
- strcpy (result->pw_shell, ret->pw_shell);
-
- return 0;
-}
-
-int getpwnam_r (const char *name, struct passwd *result,
- char *buffer, size_t buflen,
- struct passwd ** resptr)
-{
- struct passwd * p;
- int retval;
-
- pthread_mutex_lock (&getpw_mutex);
- p = getpwnam (name);
- if (p == NULL) {
- *resptr = NULL;
- retval = ESRCH;
- } else
- if (convert (p, result, buffer, buflen) != 0) {
- *resptr = NULL;
- retval = ERANGE;
- } else {
- *resptr = result;
- retval = 0;
- }
- pthread_mutex_unlock (&getpw_mutex);
- return retval;
-}
-
-int getpwuid_r (uid_t uid, struct passwd *result,
- char *buffer, size_t buflen,
- struct passwd ** resptr)
-{
- struct passwd * p;
- int retval;
-
- pthread_mutex_lock (&getpw_mutex);
- p = getpwuid (uid);
- if (p == NULL) {
- *resptr = NULL;
- retval = ESRCH;
- } else
- if (convert (p, result, buffer, buflen) != 0) {
- *resptr = NULL;
- retval = ERANGE;
- } else {
- *resptr = result;
- retval = 0;
- }
- pthread_mutex_unlock (&getpw_mutex);
- return retval;
-}
-#endif
diff --git a/devel/linuxthreads/files/getservby_r.c b/devel/linuxthreads/files/getservby_r.c
deleted file mode 100644
index 8030edd49635..000000000000
--- a/devel/linuxthreads/files/getservby_r.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "pthread.h"
-#include <netdb.h>
-#include <string.h>
-#include <sys/param.h>
-
-#if (__FreeBSD_version >= 700000 && __FreeBSD_version < 700016) || \
- __FreeBSD_version < 601103
-
-static pthread_mutex_t getservby_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static int
-convert (struct servent *ret, struct servent *result,
- char *buf, int buflen)
-{
- int len, i;
-
- if (!buf) return -1;
-
- *result = *ret;
- /* This is the size. */
- len = strlen (ret->s_name) + 1;
- if (len > buflen) return -1;
- buflen -= len;
- result->s_name = (char *) buf;
- buf += len;
- strcpy (result->s_name, ret->s_name);
-
- /* How many aliases and how big the buffer should be? There
- is always a NULL pointer. */
- for (len = sizeof (char *), i = 0; ret->s_aliases [i]; i++)
- {
- /* It should be size of (char *) and the length of string
- plus 1. */
- len += strlen (ret->s_aliases [i]) + 1 + sizeof (char *);
- }
- if (len > buflen) return -1;
- buflen -= len;
-
- /* This is an array of char * for s_aliases. */
- result->s_aliases = (char **) buf;
- buf += (i + 1) * sizeof (char *);
-
- /* We copy the aliases now. */
- for (i = 0; ret->s_aliases [i]; i++)
- {
- result->s_aliases [i] = (char *) buf;
- strcpy (result->s_aliases [i], ret->s_aliases [i]);
- buf += strlen (ret->s_aliases [i]) + 1;
- }
- /* This is the last one */
- result->s_aliases [i] = NULL;
-
- /* s_proto */
- len = strlen (ret->s_proto) + 1;
- if (len > buflen) return -1;
- buf += len;
- result->s_proto = (char *) buf;
- strcpy (result->s_proto, ret->s_proto);
-
- return 0;
-}
-
-struct servent *
-getservbyport_r (int port, const char *proto,
- struct servent *result, char *buffer, int buflen)
-{
- struct servent *ret;
-
- pthread_mutex_lock (&getservby_mutex);
-
- ret = getservbyport (port, proto);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getservby_mutex);
- return result;
-}
-
-struct servent *
-getservbyname_r (const char *name, const char *proto,
- struct servent *result, char *buffer, int buflen)
-{
- struct servent *ret;
-
- pthread_mutex_lock (&getservby_mutex);
-
- ret = getservbyname (name, proto);
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getservby_mutex);
- return result;
-}
-
-struct servent *
-getservent_r (struct servent *result, char *buffer, int buflen)
-{
- struct servent *ret;
-
- pthread_mutex_lock (&getservby_mutex);
-
- ret = getservent ();
- if (!ret ||
- convert (ret, result, buffer, buflen) != 0)
- {
- result = NULL;
- }
-
- pthread_mutex_unlock (&getservby_mutex);
- return result;
-}
-
-#endif /* #if __FreeBSD_version < 601103 */
diff --git a/devel/linuxthreads/files/lclone.c b/devel/linuxthreads/files/lclone.c
deleted file mode 100644
index 35623bbed0f0..000000000000
--- a/devel/linuxthreads/files/lclone.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 1999 Richard Seaman, Jr.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Richard Seaman, Jr.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RICHARD SEAMAN, Jr. AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/unistd.h>
-#include <errno.h>
-#include <clone.h>
-
-int clone (int (*__fn) (void *), void *__child_stack,
- int __flags, void *__arg) __attribute__ ((weak, alias("__clone")));
-
-extern int __clone (int (*__fn) (void *), void *__child_stack,
- int __flags, void *__arg)
-{
- int bsd_flags;
- int exit_signal;
-
- /* We don't have qn equivalent to CLONE_PID yet */
- if (__flags & CLONE_PID)
- return (-1);
-
- if (__child_stack == (void *)0)
- return (-1);
-
- /* RFTHREAD probably not necessary here, but it shouldn't hurt either */
- bsd_flags = RFPROC | RFTHREAD;
-
- /* We only allow one alternative to SIGCHLD, and thats
- * SIGUSR1. This is less flexible than Linux, but
- * we don't really have a way to pass a one byte
- * exit signal to rfork, which is what Linux passes to
- * its clone syscall. OTOH, we haven't seen Linux use
- * a value other than 0 (which implies SIGCHLD), SIGCHLD,
- * or SIGUSER1 so far.
- */
- exit_signal = ((unsigned int)__flags) & CSIGNAL;
- switch (exit_signal){
- case 0:
- case SIGCHLD:
- /* SIGCHLD is the default for BSD, so we don't have
- * to do anything special in this case.
- */
- break;
- case SIGUSR1:
- bsd_flags |= RFLINUXTHPN;
- break;
- default:
- return (-1);
- }
-
- if (__flags & CLONE_VM)
- bsd_flags |= RFMEM;
- if (__flags & CLONE_SIGHAND)
- bsd_flags |= RFSIGSHARE;
- if (!(__flags & CLONE_FILES))
- bsd_flags |= RFFDG;
-
- /* _clone is in clone.S, and takes bsd style rfork flags */
- return (_clone (__fn, __child_stack, bsd_flags, __arg));
-}
diff --git a/devel/linuxthreads/files/ldwrap b/devel/linuxthreads/files/ldwrap
deleted file mode 100644
index 9415c7dac375..000000000000
--- a/devel/linuxthreads/files/ldwrap
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/sh -e
-#
-# Gross hack. Wrapper for ld that renames various functions to avoid
-# conflicts between linuxthreads and native threads
-#
-echo "[ldwrap $@]"
-if test "$1" = "-o" -a "$2" != "wraputhread.o.tmp" -a "$2" != "wraputhread.Po.tmp" -a "$2" != "wraputhread.So.tmp"
-then
- target=$2
- shift
- shift
- ld -o $target.tmp "$@"
-objcopy \
---redefine-sym _pthread_cleanup_pop=linuxthreads__pthread_cleanup_pop \
---redefine-sym _pthread_cleanup_pop_restore=linuxthreads__pthread_cleanup_pop_restore \
---redefine-sym _pthread_cleanup_push=linuxthreads__pthread_cleanup_push \
---redefine-sym _pthread_cleanup_push_defer=linuxthreads__pthread_cleanup_push_defer \
---redefine-sym pthread_atfork=linuxthreads_pthread_atfork \
---redefine-sym pthread_attr_destroy=linuxthreads_pthread_attr_destroy \
---redefine-sym pthread_attr_getdetachstate=linuxthreads_pthread_attr_getdetachstate \
---redefine-sym pthread_attr_getguardsize=linuxthreads_pthread_attr_getguardsize \
---redefine-sym pthread_attr_getinheritsched=linuxthreads_pthread_attr_getinheritsched \
---redefine-sym pthread_attr_getschedparam=linuxthreads_pthread_attr_getschedparam \
---redefine-sym pthread_attr_getschedpolicy=linuxthreads_pthread_attr_getschedpolicy \
---redefine-sym pthread_attr_getscope=linuxthreads_pthread_attr_getscope \
---redefine-sym pthread_attr_getstack=linuxthreads_pthread_attr_getstack \
---redefine-sym pthread_attr_getstackaddr=linuxthreads_pthread_attr_getstackaddr \
---redefine-sym pthread_attr_getstacksize=linuxthreads_pthread_attr_getstacksize \
---redefine-sym pthread_attr_init=linuxthreads_pthread_attr_init \
---redefine-sym pthread_attr_setdetachstate=linuxthreads_pthread_attr_setdetachstate \
---redefine-sym pthread_attr_setguardsize=linuxthreads_pthread_attr_setguardsize \
---redefine-sym pthread_attr_setinheritsched=linuxthreads_pthread_attr_setinheritsched \
---redefine-sym pthread_attr_setschedparam=linuxthreads_pthread_attr_setschedparam \
---redefine-sym pthread_attr_setschedpolicy=linuxthreads_pthread_attr_setschedpolicy \
---redefine-sym pthread_attr_setscope=linuxthreads_pthread_attr_setscope \
---redefine-sym pthread_attr_setstack=linuxthreads_pthread_attr_setstack \
---redefine-sym pthread_attr_setstackaddr=linuxthreads_pthread_attr_setstackaddr \
---redefine-sym pthread_attr_setstacksize=linuxthreads_pthread_attr_setstacksize \
---redefine-sym pthread_barrier_destroy=linuxthreads_pthread_barrier_destroy \
---redefine-sym pthread_barrier_init=linuxthreads_pthread_barrier_init \
---redefine-sym pthread_barrier_wait=linuxthreads_pthread_barrier_wait \
---redefine-sym pthread_barrierattr_destroy=linuxthreads_pthread_barrierattr_destroy \
---redefine-sym pthread_barrierattr_getpshared=linuxthreads_pthread_barrierattr_getpshared \
---redefine-sym pthread_barrierattr_init=linuxthreads_pthread_barrierattr_init \
---redefine-sym pthread_barrierattr_setpshared=linuxthreads_pthread_barrierattr_setpshared \
---redefine-sym pthread_cancel=linuxthreads_pthread_cancel \
---redefine-sym pthread_cond_broadcast=linuxthreads_pthread_cond_broadcast \
---redefine-sym pthread_cond_destroy=linuxthreads_pthread_cond_destroy \
---redefine-sym pthread_cond_init=linuxthreads_pthread_cond_init \
---redefine-sym pthread_cond_signal=linuxthreads_pthread_cond_signal \
---redefine-sym pthread_cond_timedwait=linuxthreads_pthread_cond_timedwait \
---redefine-sym pthread_cond_wait=linuxthreads_pthread_cond_wait \
---redefine-sym pthread_condattr_destroy=linuxthreads_pthread_condattr_destroy \
---redefine-sym pthread_condattr_getpshared=linuxthreads_pthread_condattr_getpshared \
---redefine-sym pthread_condattr_init=linuxthreads_pthread_condattr_init \
---redefine-sym pthread_condattr_setpshared=linuxthreads_pthread_condattr_setpshared \
---redefine-sym pthread_create=linuxthreads_pthread_create \
---redefine-sym pthread_detach=linuxthreads_pthread_detach \
---redefine-sym pthread_equal=linuxthreads_pthread_equal \
---redefine-sym pthread_exit=linuxthreads_pthread_exit \
---redefine-sym pthread_getattr_np=linuxthreads_pthread_getattr_np \
---redefine-sym pthread_getconcurrency=linuxthreads_pthread_getconcurrency \
---redefine-sym pthread_getcpuclockid=linuxthreads_pthread_getcpuclockid \
---redefine-sym pthread_getschedparam=linuxthreads_pthread_getschedparam \
---redefine-sym pthread_getspecific=linuxthreads_pthread_getspecific \
---redefine-sym pthread_join=linuxthreads_pthread_join \
---redefine-sym pthread_key_create=linuxthreads_pthread_key_create \
---redefine-sym pthread_key_delete=linuxthreads_pthread_key_delete \
---redefine-sym pthread_kill=linuxthreads_pthread_kill \
---redefine-sym pthread_kill_other_threads_np=linuxthreads_pthread_kill_other_threads_np \
---redefine-sym pthread_mutex_destroy=linuxthreads_pthread_mutex_destroy \
---redefine-sym pthread_mutex_init=linuxthreads_pthread_mutex_init \
---redefine-sym pthread_mutex_lock=linuxthreads_pthread_mutex_lock \
---redefine-sym pthread_mutex_timedlock=linuxthreads_pthread_mutex_timedlock \
---redefine-sym pthread_mutex_trylock=linuxthreads_pthread_mutex_trylock \
---redefine-sym pthread_mutex_unlock=linuxthreads_pthread_mutex_unlock \
---redefine-sym pthread_mutexattr_destroy=linuxthreads_pthread_mutexattr_destroy \
---redefine-sym pthread_mutexattr_getpshared=linuxthreads_pthread_mutexattr_getpshared \
---redefine-sym pthread_mutexattr_gettype=linuxthreads_pthread_mutexattr_gettype \
---redefine-sym pthread_mutexattr_init=linuxthreads_pthread_mutexattr_init \
---redefine-sym pthread_mutexattr_setpshared=linuxthreads_pthread_mutexattr_setpshared \
---redefine-sym pthread_mutexattr_settype=linuxthreads_pthread_mutexattr_settype \
---redefine-sym pthread_once=linuxthreads_pthread_once \
---redefine-sym pthread_rwlock_destroy=linuxthreads_pthread_rwlock_destroy \
---redefine-sym pthread_rwlock_init=linuxthreads_pthread_rwlock_init \
---redefine-sym pthread_rwlock_rdlock=linuxthreads_pthread_rwlock_rdlock \
---redefine-sym pthread_rwlock_timedrdlock=linuxthreads_pthread_rwlock_timedrdlock \
---redefine-sym pthread_rwlock_timedwrlock=linuxthreads_pthread_rwlock_timedwrlock \
---redefine-sym pthread_rwlock_tryrdlock=linuxthreads_pthread_rwlock_tryrdlock \
---redefine-sym pthread_rwlock_trywrlock=linuxthreads_pthread_rwlock_trywrlock \
---redefine-sym pthread_rwlock_unlock=linuxthreads_pthread_rwlock_unlock \
---redefine-sym pthread_rwlock_wrlock=linuxthreads_pthread_rwlock_wrlock \
---redefine-sym pthread_rwlockattr_destroy=linuxthreads_pthread_rwlockattr_destroy \
---redefine-sym pthread_rwlockattr_getkind_np=linuxthreads_pthread_rwlockattr_getkind_np \
---redefine-sym pthread_rwlockattr_getpshared=linuxthreads_pthread_rwlockattr_getpshared \
---redefine-sym pthread_rwlockattr_init=linuxthreads_pthread_rwlockattr_init \
---redefine-sym pthread_rwlockattr_setkind_np=linuxthreads_pthread_rwlockattr_setkind_np \
---redefine-sym pthread_rwlockattr_setpshared=linuxthreads_pthread_rwlockattr_setpshared \
---redefine-sym pthread_self=linuxthreads_pthread_self \
---redefine-sym pthread_setcancelstate=linuxthreads_pthread_setcancelstate \
---redefine-sym pthread_setcanceltype=linuxthreads_pthread_setcanceltype \
---redefine-sym pthread_setconcurrency=linuxthreads_pthread_setconcurrency \
---redefine-sym pthread_setschedparam=linuxthreads_pthread_setschedparam \
---redefine-sym pthread_setspecific=linuxthreads_pthread_setspecific \
---redefine-sym pthread_sigmask=linuxthreads_pthread_sigmask \
---redefine-sym pthread_spin_destroy=linuxthreads_pthread_spin_destroy \
---redefine-sym pthread_spin_init=linuxthreads_pthread_spin_init \
---redefine-sym pthread_spin_lock=linuxthreads_pthread_spin_lock \
---redefine-sym pthread_spin_trylock=linuxthreads_pthread_spin_trylock \
---redefine-sym pthread_spin_unlock=linuxthreads_pthread_spin_unlock \
---redefine-sym pthread_testcancel=linuxthreads_pthread_testcancel \
---redefine-sym pthread_yield=linuxthreads_pthread_yield \
-$target.tmp $target
- rm -f $target.tmp
-else
- exec ld "$@"
-fi
diff --git a/devel/linuxthreads/files/libc_calls.c b/devel/linuxthreads/files/libc_calls.c
deleted file mode 100644
index 02511261a568..000000000000
--- a/devel/linuxthreads/files/libc_calls.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 1998 Richard Seaman, Jr.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Richard Seaman, Jr.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RICHARD SEAMAN, Jr. AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#ifndef _THREAD_SAFE
-#define _THREAD_SAFE
-#endif
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/msg.h>
-#include <sys/ttycom.h>
-#include <osreldate.h>
-#include <time.h>
-#include "pthread.h"
-#include "internals.h"
-
-#ifndef NEWLIBC
-
-char * asctime (const struct tm *timeptr)
-{
- pthread_descr self = thread_self();
-
- return (asctime_r(timeptr, self->time_buf));
-}
-
-char * ctime(const time_t * const timep)
-{
- pthread_descr self = thread_self();
-
- return (ctime_r(timep, self->time_buf));
-}
-
-
-struct tm *localtime (const time_t * const timep)
-{
- pthread_descr self = thread_self();
-
- return (localtime_r(timep, &self->local_tm));
-}
-
-struct tm * gmtime(const time_t * const timep)
-{
- pthread_descr self = thread_self();
-
- return (gmtime_r(timep, &self->local_tm));
-}
-#endif
-
-/* The following wrappers impement cancallation points */
-
-
-#if __STDC__
-int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
-#else
-int msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)
- int msqid;
- void *msgp;
- size_t msgsz;
- long msgtyp;
- int msgflg;
-#endif
-{
- int ret;
- int oldtype;
-
- /* This is a cancellation point */
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
- ret = msgsys(3, msqid, msgp, msgsz, msgtyp, msgflg);
-
- /* This is a cancellation point */
- pthread_setcanceltype (oldtype, NULL);
- return (ret);
-
-}
-
-#if __STDC__
-#if __FreeBSD_version > 500100
-int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
-#else
-int msgsnd(int msqid, void *msgp, size_t msgsz, int msgflg)
-#endif
-#else
-int msgsnd(msqid, msgp, msgsz, msgflg)
- int msqid;
-#if __FreeBSD_version > 500100
- const void *msgp;
-#else
- void *msgp;
-#endif
- size_t msgsz;
- int msgflg;
-#endif
-{
- int ret;
- int oldtype;
-
- /* This is a cancellation point */
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
- ret = msgsys(2, msqid, msgp, msgsz, msgflg);
-
- /* This is a cancellation point */
- pthread_setcanceltype (oldtype, NULL);
- return (ret);
-
-}
-
-#if __STDC__
-int tcdrain (int fd)
-#else
-int tcdrain (fd)
- int fd;
-#endif
-{
- int ret;
- int oldtype;
-
- /* This is a cancellation point */
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
- ret = ioctl(fd, TIOCDRAIN, 0);
-
- /* This is a cancellation point */
- pthread_setcanceltype (oldtype, NULL);
- return (ret);
-}
diff --git a/devel/linuxthreads/files/libc_thread.c b/devel/linuxthreads/files/libc_thread.c
deleted file mode 100644
index 86db711d9995..000000000000
--- a/devel/linuxthreads/files/libc_thread.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 1999 Richard Seaman, Jr.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Richard Seaman, Jr.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RICHARD SEAMAN, Jr. AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#ifndef _THREAD_SAFE
-#define _THREAD_SAFE
-#endif
-
-#include <dlfcn.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
-
-/* 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.
- */
-extern int __isthreaded;
-
-/* 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
-
-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)
-#if !defined(LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING)
- int mib[2];
- size_t len;
-
- len = sizeof (_posix_priority_scheduling);
- mib[0] = CTL_P1003_1B;
- mib[1] = CTL_P1003_1B_PRIORITY_SCHEDULING;
- if (-1 == sysctl (mib, 2, &_posix_priority_scheduling, &len, NULL, 0))
- _posix_priority_scheduling = 0;
-#endif
-#endif
-
- /* This turns on thread safe behaviour in libc when we link with it */
- __isthreaded = 1;
-
-}
-
-void _spinlock (int * spinlock)
-{
- __pthread_acquire(spinlock);
-}
-
-
-void _spinunlock(int *spinlock)
-{
- *spinlock = 0;
-}
-
-void * lock_create (void *context)
-{
- pthread_rwlock_t *lock;
-
- lock = malloc (sizeof (*lock));
- if (lock == NULL)
- return (NULL);
-
- pthread_rwlock_init (lock, NULL);
- return (lock);
-}
-
-void rlock_acquire (void *lock)
-{
- pthread_rwlock_rdlock ((pthread_rwlock_t *)lock);
-
-}
-
-void wlock_acquire (void *lock)
-{
- pthread_rwlock_wrlock ((pthread_rwlock_t *)lock);
-
-}
-
-void lock_release (void *lock)
-{
- pthread_rwlock_unlock ((pthread_rwlock_t *)lock);
-}
-
-void lock_destroy (void *lock)
-{
- if (pthread_rwlock_destroy ((pthread_rwlock_t *)lock) == 0)
- free (lock);
-}
diff --git a/devel/linuxthreads/files/localtime.c b/devel/linuxthreads/files/localtime.c
deleted file mode 100644
index 7b44f021fe88..000000000000
--- a/devel/linuxthreads/files/localtime.c
+++ /dev/null
@@ -1,1739 +0,0 @@
-/*
-** This file is in the public domain, so clarified as of
-** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
-**
-** $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/localtime.c,v 1.3 2002-09-06 15:02:24 tegge Exp $
-*/
-
-#ifndef lint
-#ifndef NOID
-static char elsieid[] __attribute__ ((unused)) = "@(#)localtime.c 7.57";
-#endif /* !defined NOID */
-#endif /* !defined lint */
-
-/*
-** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
-** POSIX-style TZ environment variable handling from Guy Harris
-** (guy@auspex.com).
-*/
-
-/*LINTLIBRARY*/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include "private.h"
-
-#include "tzfile.h"
-
-#define __isthreaded 1
-#define _MUTEX_LOCK(x) pthread_mutex_lock(x)
-#define _MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
-
-/*
-** SunOS 4.1.1 headers lack O_BINARY.
-*/
-
-#ifdef O_BINARY
-#define OPEN_MODE (O_RDONLY | O_BINARY)
-#endif /* defined O_BINARY */
-#ifndef O_BINARY
-#define OPEN_MODE O_RDONLY
-#endif /* !defined O_BINARY */
-
-#ifndef WILDABBR
-/*
-** Someone might make incorrect use of a time zone abbreviation:
-** 1. They might reference tzname[0] before calling tzset (explicitly
-** or implicitly).
-** 2. They might reference tzname[1] before calling tzset (explicitly
-** or implicitly).
-** 3. They might reference tzname[1] after setting to a time zone
-** in which Daylight Saving Time is never observed.
-** 4. They might reference tzname[0] after setting to a time zone
-** in which Standard Time is never observed.
-** 5. They might reference tm.TM_ZONE after calling offtime.
-** What's best to do in the above cases is open to debate;
-** for now, we just set things up so that in any of the five cases
-** WILDABBR is used. Another possibility: initialize tzname[0] to the
-** string "tzname[0] used before set", and similarly for the other cases.
-** And another: initialize tzname[0] to "ERA", with an explanation in the
-** manual page of what this "time zone abbreviation" means (doing this so
-** that tzname[0] has the "normal" length of three characters).
-*/
-#define WILDABBR " "
-#endif /* !defined WILDABBR */
-
-static char wildabbr[] = "WILDABBR";
-
-static const char gmt[] = "GMT";
-
-struct ttinfo { /* time type information */
- long tt_gmtoff; /* GMT offset in seconds */
- int tt_isdst; /* used to set tm_isdst */
- int tt_abbrind; /* abbreviation list index */
- int tt_ttisstd; /* TRUE if transition is std time */
- int tt_ttisgmt; /* TRUE if transition is GMT */
-};
-
-struct lsinfo { /* leap second information */
- time_t ls_trans; /* transition time */
- long ls_corr; /* correction to apply */
-};
-
-#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
-
-#ifdef TZNAME_MAX
-#define MY_TZNAME_MAX TZNAME_MAX
-#endif /* defined TZNAME_MAX */
-#ifndef TZNAME_MAX
-#define MY_TZNAME_MAX 255
-#endif /* !defined TZNAME_MAX */
-
-struct state {
- int leapcnt;
- int timecnt;
- int typecnt;
- int charcnt;
- time_t ats[TZ_MAX_TIMES];
- unsigned char types[TZ_MAX_TIMES];
- struct ttinfo ttis[TZ_MAX_TYPES];
- char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt),
- (2 * (MY_TZNAME_MAX + 1)))];
- struct lsinfo lsis[TZ_MAX_LEAPS];
-};
-
-struct rule {
- int r_type; /* type of rule--see below */
- int r_day; /* day number of rule */
- int r_week; /* week number of rule */
- int r_mon; /* month number of rule */
- long r_time; /* transition time of rule */
-};
-
-#define JULIAN_DAY 0 /* Jn - Julian day */
-#define DAY_OF_YEAR 1 /* n - day of year */
-#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
-
-/*
-** Prototypes for static functions.
-*/
-
-static long detzcode(const char * codep);
-static const char * getzname(const char * strp);
-static const char * getnum(const char * strp, int * nump, int min,
- int max);
-static const char * getsecs(const char * strp, long * secsp);
-static const char * getoffset(const char * strp, long * offsetp);
-static const char * getrule(const char * strp, struct rule * rulep);
-static void gmtload(struct state * sp);
-static void gmtsub(const time_t * timep, long offset,
- struct tm * tmp);
-static void localsub(const time_t * timep, long offset,
- struct tm * tmp);
-static int increment_overflow(int * number, int delta);
-static int normalize_overflow(int * tensptr, int * unitsptr,
- int base);
-static void settzname(void);
-static time_t time1(struct tm * tmp,
- void(*funcp) (const time_t *,
- long, struct tm *),
- long offset);
-static time_t time2(struct tm *tmp,
- void(*funcp) (const time_t *,
- long, struct tm*),
- long offset, int * okayp);
-static void timesub(const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp);
-static int tmcomp(const struct tm * atmp,
- const struct tm * btmp);
-static time_t transtime(time_t janfirst, int year,
- const struct rule * rulep, long offset);
-static int tzload(const char * name, struct state * sp);
-static int tzparse(const char * name, struct state * sp,
- int lastditch);
-
-#ifdef ALL_STATE
-static struct state * lclptr;
-static struct state * gmtptr;
-#endif /* defined ALL_STATE */
-
-#ifndef ALL_STATE
-static struct state lclmem;
-static struct state gmtmem;
-#define lclptr (&lclmem)
-#define gmtptr (&gmtmem)
-#endif /* State Farm */
-
-#ifndef TZ_STRLEN_MAX
-#define TZ_STRLEN_MAX 255
-#endif /* !defined TZ_STRLEN_MAX */
-
-static char lcl_TZname[TZ_STRLEN_MAX + 1];
-static int lcl_is_set;
-static int gmt_is_set;
-static pthread_mutex_t lcl_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t gmt_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-char * tzname[2] = {
- wildabbr,
- wildabbr
-};
-
-/*
-** Section 4.12.3 of X3.159-1989 requires that
-** Except for the strftime function, these functions [asctime,
-** ctime, gmtime, localtime] return values in one of two static
-** objects: a broken-down time structure and an array of char.
-** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
-*/
-
-static struct tm tm;
-
-#ifdef USG_COMPAT
-time_t timezone = 0;
-int daylight = 0;
-#endif /* defined USG_COMPAT */
-
-#ifdef ALTZONE
-time_t altzone = 0;
-#endif /* defined ALTZONE */
-
-static long
-detzcode(codep)
-const char * const codep;
-{
- long result;
- int i;
-
- result = (codep[0] & 0x80) ? ~0L : 0L;
- for (i = 0; i < 4; ++i)
- result = (result << 8) | (codep[i] & 0xff);
- return result;
-}
-
-static void
-settzname(void)
-{
- struct state * sp = lclptr;
- int i;
-
- tzname[0] = wildabbr;
- tzname[1] = wildabbr;
-#ifdef USG_COMPAT
- daylight = 0;
- timezone = 0;
-#endif /* defined USG_COMPAT */
-#ifdef ALTZONE
- altzone = 0;
-#endif /* defined ALTZONE */
-#ifdef ALL_STATE
- if (sp == NULL) {
- tzname[0] = tzname[1] = gmt;
- return;
- }
-#endif /* defined ALL_STATE */
- for (i = 0; i < sp->typecnt; ++i) {
- const struct ttinfo * const ttisp = &sp->ttis[i];
-
- tzname[ttisp->tt_isdst] =
- &sp->chars[ttisp->tt_abbrind];
-#ifdef USG_COMPAT
- if (ttisp->tt_isdst)
- daylight = 1;
- if (i == 0 || !ttisp->tt_isdst)
- timezone = -(ttisp->tt_gmtoff);
-#endif /* defined USG_COMPAT */
-#ifdef ALTZONE
- if (i == 0 || ttisp->tt_isdst)
- altzone = -(ttisp->tt_gmtoff);
-#endif /* defined ALTZONE */
- }
- /*
- ** And to get the latest zone names into tzname. . .
- */
- for (i = 0; i < sp->timecnt; ++i) {
- const struct ttinfo * const ttisp =
- &sp->ttis[
- sp->types[i]];
-
- tzname[ttisp->tt_isdst] =
- &sp->chars[ttisp->tt_abbrind];
- }
-}
-
-static int
-tzload(name, sp)
-const char * name;
-struct state * const sp;
-{
- const char * p;
- int i;
- int fid;
-
- /* XXX The following is from OpenBSD, and I'm not sure it is correct */
- if (name != NULL && issetugid() != 0)
- if ((name[0] == ':' && name[1] == '/') ||
- name[0] == '/' || strchr(name, '.'))
- name = NULL;
- if (name == NULL && (name = TZDEFAULT) == NULL)
- return -1;
- {
- int doaccess;
- struct stat stab;
- /*
- ** Section 4.9.1 of the C standard says that
- ** "FILENAME_MAX expands to an integral constant expression
- ** that is the size needed for an array of char large enough
- ** to hold the longest file name string that the implementation
- ** guarantees can be opened."
- */
- char fullname[FILENAME_MAX + 1];
-
- if (name[0] == ':')
- ++name;
- doaccess = name[0] == '/';
- if (!doaccess) {
- if ((p = TZDIR) == NULL)
- return -1;
- if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname)
- return -1;
- (void) strcpy(fullname, p);
- (void) strcat(fullname, "/");
- (void) strcat(fullname, name);
- /*
- ** Set doaccess if '.' (as in "../") shows up in name.
- */
- if (strchr(name, '.') != NULL)
- doaccess = TRUE;
- name = fullname;
- }
- if (doaccess && access(name, R_OK) != 0)
- return -1;
- if ((fid = open(name, OPEN_MODE)) == -1)
- return -1;
- if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode))
- return -1;
- }
- {
- struct tzhead * tzhp;
- char buf[sizeof *sp + sizeof *tzhp];
- int ttisstdcnt;
- int ttisgmtcnt;
-
- i = read(fid, buf, sizeof buf);
- if (close(fid) != 0)
- return -1;
- p = buf;
- p += (sizeof tzhp->tzh_magic) + (sizeof tzhp->tzh_reserved);
- ttisstdcnt = (int) detzcode(p);
- p += 4;
- ttisgmtcnt = (int) detzcode(p);
- p += 4;
- sp->leapcnt = (int) detzcode(p);
- p += 4;
- sp->timecnt = (int) detzcode(p);
- p += 4;
- sp->typecnt = (int) detzcode(p);
- p += 4;
- sp->charcnt = (int) detzcode(p);
- p += 4;
- if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
- sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
- sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
- sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
- (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
- (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
- return -1;
- if (i - (p - buf) < sp->timecnt * 4 + /* ats */
- sp->timecnt + /* types */
- sp->typecnt * (4 + 2) + /* ttinfos */
- sp->charcnt + /* chars */
- sp->leapcnt * (4 + 4) + /* lsinfos */
- ttisstdcnt + /* ttisstds */
- ttisgmtcnt) /* ttisgmts */
- return -1;
- for (i = 0; i < sp->timecnt; ++i) {
- sp->ats[i] = detzcode(p);
- p += 4;
- }
- for (i = 0; i < sp->timecnt; ++i) {
- sp->types[i] = (unsigned char) *p++;
- if (sp->types[i] >= sp->typecnt)
- return -1;
- }
- for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- ttisp->tt_gmtoff = detzcode(p);
- p += 4;
- ttisp->tt_isdst = (unsigned char) *p++;
- if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
- return -1;
- ttisp->tt_abbrind = (unsigned char) *p++;
- if (ttisp->tt_abbrind < 0 ||
- ttisp->tt_abbrind > sp->charcnt)
- return -1;
- }
- for (i = 0; i < sp->charcnt; ++i)
- sp->chars[i] = *p++;
- sp->chars[i] = '\0'; /* ensure '\0' at end */
- for (i = 0; i < sp->leapcnt; ++i) {
- struct lsinfo * lsisp;
-
- lsisp = &sp->lsis[i];
- lsisp->ls_trans = detzcode(p);
- p += 4;
- lsisp->ls_corr = detzcode(p);
- p += 4;
- }
- for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- if (ttisstdcnt == 0)
- ttisp->tt_ttisstd = FALSE;
- else {
- ttisp->tt_ttisstd = *p++;
- if (ttisp->tt_ttisstd != TRUE &&
- ttisp->tt_ttisstd != FALSE)
- return -1;
- }
- }
- for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- if (ttisgmtcnt == 0)
- ttisp->tt_ttisgmt = FALSE;
- else {
- ttisp->tt_ttisgmt = *p++;
- if (ttisp->tt_ttisgmt != TRUE &&
- ttisp->tt_ttisgmt != FALSE)
- return -1;
- }
- }
- }
- return 0;
-}
-
-static const int mon_lengths[2][MONSPERYEAR] = {
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-};
-
-static const int year_lengths[2] = {
- DAYSPERNYEAR, DAYSPERLYEAR
-};
-
-/*
-** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found. Return a pointer to that
-** character.
-*/
-
-static const char *
-getzname(strp)
-const char * strp;
-{
- char c;
-
- while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
- c != '+')
- ++strp;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number from that string.
-** Check that the number is within a specified range; if it is not, return
-** NULL.
-** Otherwise, return a pointer to the first character not part of the number.
-*/
-
-static const char *
-getnum(strp, nump, min, max)
-const char * strp;
-int * const nump;
-const int min;
-const int max;
-{
- char c;
- int num;
-
- if (strp == NULL || !is_digit(c = *strp))
- return NULL;
- num = 0;
- do {
- num = num * 10 + (c - '0');
- if (num > max)
- return NULL; /* illegal value */
- c = *++strp;
- } while (is_digit(c));
- if (num < min)
- return NULL; /* illegal value */
- *nump = num;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number of seconds,
-** in hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the number
-** of seconds.
-*/
-
-static const char *
-getsecs(strp, secsp)
-const char * strp;
-long * const secsp;
-{
- int num;
-
- /*
- ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
- ** "M10.4.6/26", which does not conform to Posix,
- ** but which specifies the equivalent of
- ** ``02:00 on the first Sunday on or after 23 Oct''.
- */
- strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
- if (strp == NULL)
- return NULL;
- *secsp = num * (long) SECSPERHOUR;
- if (*strp == ':') {
- ++strp;
- strp = getnum(strp, &num, 0, MINSPERHOUR - 1);
- if (strp == NULL)
- return NULL;
- *secsp += num * SECSPERMIN;
- if (*strp == ':') {
- ++strp;
- /* `SECSPERMIN' allows for leap seconds. */
- strp = getnum(strp, &num, 0, SECSPERMIN);
- if (strp == NULL)
- return NULL;
- *secsp += num;
- }
- }
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract an offset, in
-** [+-]hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the time.
-*/
-
-static const char *
-getoffset(strp, offsetp)
-const char * strp;
-long * const offsetp;
-{
- int neg = 0;
-
- if (*strp == '-') {
- neg = 1;
- ++strp;
- } else if (*strp == '+')
- ++strp;
- strp = getsecs(strp, offsetp);
- if (strp == NULL)
- return NULL; /* illegal time */
- if (neg)
- *offsetp = -*offsetp;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a rule in the form
-** date[/time]. See POSIX section 8 for the format of "date" and "time".
-** If a valid rule is not found, return NULL.
-** Otherwise, return a pointer to the first character not part of the rule.
-*/
-
-static const char *
-getrule(strp, rulep)
-const char * strp;
-struct rule * const rulep;
-{
- if (*strp == 'J') {
- /*
- ** Julian day.
- */
- rulep->r_type = JULIAN_DAY;
- ++strp;
- strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR);
- } else if (*strp == 'M') {
- /*
- ** Month, week, day.
- */
- rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
- ++strp;
- strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_week, 1, 5);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
- } else if (is_digit(*strp)) {
- /*
- ** Day of year.
- */
- rulep->r_type = DAY_OF_YEAR;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
- } else return NULL; /* invalid format */
- if (strp == NULL)
- return NULL;
- if (*strp == '/') {
- /*
- ** Time specified.
- */
- ++strp;
- strp = getsecs(strp, &rulep->r_time);
- } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */
- return strp;
-}
-
-/*
-** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the
-** year, a rule, and the offset from GMT at the time that rule takes effect,
-** calculate the Epoch-relative time that rule takes effect.
-*/
-
-static time_t
-transtime(janfirst, year, rulep, offset)
-const time_t janfirst;
-const int year;
-const struct rule * const rulep;
-const long offset;
-{
- int leapyear;
- time_t value;
- int i;
- int d, m1, yy0, yy1, yy2, dow;
-
- INITIALIZE(value);
- leapyear = isleap(year);
- switch (rulep->r_type) {
-
- case JULIAN_DAY:
- /*
- ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
- ** years.
- ** In non-leap years, or if the day number is 59 or less, just
- ** add SECSPERDAY times the day number-1 to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
- if (leapyear && rulep->r_day >= 60)
- value += SECSPERDAY;
- break;
-
- case DAY_OF_YEAR:
- /*
- ** n - day of year.
- ** Just add SECSPERDAY times the day number to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + rulep->r_day * SECSPERDAY;
- break;
-
- case MONTH_NTH_DAY_OF_WEEK:
- /*
- ** Mm.n.d - nth "dth day" of month m.
- */
- value = janfirst;
- for (i = 0; i < rulep->r_mon - 1; ++i)
- value += mon_lengths[leapyear][i] * SECSPERDAY;
-
- /*
- ** Use Zeller's Congruence to get day-of-week of first day of
- ** month.
- */
- m1 = (rulep->r_mon + 9) % 12 + 1;
- yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
- yy1 = yy0 / 100;
- yy2 = yy0 % 100;
- dow = ((26 * m1 - 2) / 10 +
- 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
- if (dow < 0)
- dow += DAYSPERWEEK;
-
- /*
- ** "dow" is the day-of-week of the first day of the month. Get
- ** the day-of-month (zero-origin) of the first "dow" day of the
- ** month.
- */
- d = rulep->r_day - dow;
- if (d < 0)
- d += DAYSPERWEEK;
- for (i = 1; i < rulep->r_week; ++i) {
- if (d + DAYSPERWEEK >=
- mon_lengths[leapyear][rulep->r_mon - 1])
- break;
- d += DAYSPERWEEK;
- }
-
- /*
- ** "d" is the day-of-month (zero-origin) of the day we want.
- */
- value += d * SECSPERDAY;
- break;
- }
-
- /*
- ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in
- ** question. To get the Epoch-relative time of the specified local
- ** time on that day, add the transition time and the current offset
- ** from GMT.
- */
- return value + rulep->r_time + offset;
-}
-
-/*
-** Given a POSIX section 8-style TZ string, fill in the rule tables as
-** appropriate.
-*/
-
-static int
-tzparse(name, sp, lastditch)
-const char * name;
-struct state * const sp;
-const int lastditch;
-{
- const char * stdname;
- const char * dstname;
- size_t stdlen;
- size_t dstlen;
- long stdoffset;
- long dstoffset;
- time_t * atp;
- unsigned char * typep;
- char * cp;
- int load_result;
-
- INITIALIZE(dstname);
- stdname = name;
- if (lastditch) {
- stdlen = strlen(name); /* length of standard zone name */
- name += stdlen;
- if (stdlen >= sizeof sp->chars)
- stdlen = (sizeof sp->chars) - 1;
- stdoffset = 0;
- } else {
- name = getzname(name);
- stdlen = name - stdname;
- if (stdlen < 3)
- return -1;
- if (*name == '\0')
- return -1; /* was "stdoffset = 0;" */
- else {
- name = getoffset(name, &stdoffset);
- if (name == NULL)
- return -1;
- }
- }
- load_result = tzload(TZDEFRULES, sp);
- if (load_result != 0)
- sp->leapcnt = 0; /* so, we're off a little */
- if (*name != '\0') {
- dstname = name;
- name = getzname(name);
- dstlen = name - dstname; /* length of DST zone name */
- if (dstlen < 3)
- return -1;
- if (*name != '\0' && *name != ',' && *name != ';') {
- name = getoffset(name, &dstoffset);
- if (name == NULL)
- return -1;
- } else dstoffset = stdoffset - SECSPERHOUR;
- if (*name == ',' || *name == ';') {
- struct rule start;
- struct rule end;
- int year;
- time_t janfirst;
- time_t starttime;
- time_t endtime;
-
- ++name;
- if ((name = getrule(name, &start)) == NULL)
- return -1;
- if (*name++ != ',')
- return -1;
- if ((name = getrule(name, &end)) == NULL)
- return -1;
- if (*name != '\0')
- return -1;
- sp->typecnt = 2; /* standard time and DST */
- /*
- ** Two transitions per year, from EPOCH_YEAR to 2037.
- */
- sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
- if (sp->timecnt > TZ_MAX_TIMES)
- return -1;
- sp->ttis[0].tt_gmtoff = -dstoffset;
- sp->ttis[0].tt_isdst = 1;
- sp->ttis[0].tt_abbrind = stdlen + 1;
- sp->ttis[1].tt_gmtoff = -stdoffset;
- sp->ttis[1].tt_isdst = 0;
- sp->ttis[1].tt_abbrind = 0;
- atp = sp->ats;
- typep = sp->types;
- janfirst = 0;
- for (year = EPOCH_YEAR; year <= 2037; ++year) {
- starttime = transtime(janfirst, year, &start,
- stdoffset);
- endtime = transtime(janfirst, year, &end,
- dstoffset);
- if (starttime > endtime) {
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- } else {
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- }
- janfirst += year_lengths[isleap(year)] *
- SECSPERDAY;
- }
- } else {
- long theirstdoffset;
- long theirdstoffset;
- long theiroffset;
- int isdst;
- int i;
- int j;
-
- if (*name != '\0')
- return -1;
- if (load_result != 0)
- return -1;
- /*
- ** Initial values of theirstdoffset and theirdstoffset.
- */
- theirstdoffset = 0;
- for (i = 0; i < sp->timecnt; ++i) {
- j = sp->types[i];
- if (!sp->ttis[j].tt_isdst) {
- theirstdoffset =
- -sp->ttis[j].tt_gmtoff;
- break;
- }
- }
- theirdstoffset = 0;
- for (i = 0; i < sp->timecnt; ++i) {
- j = sp->types[i];
- if (sp->ttis[j].tt_isdst) {
- theirdstoffset =
- -sp->ttis[j].tt_gmtoff;
- break;
- }
- }
- /*
- ** Initially we're assumed to be in standard time.
- */
- isdst = FALSE;
- theiroffset = theirstdoffset;
- /*
- ** Now juggle transition times and types
- ** tracking offsets as you do.
- */
- for (i = 0; i < sp->timecnt; ++i) {
- j = sp->types[i];
- sp->types[i] = sp->ttis[j].tt_isdst;
- if (sp->ttis[j].tt_ttisgmt) {
- /* No adjustment to transition time */
- } else {
- /*
- ** If summer time is in effect, and the
- ** transition time was not specified as
- ** standard time, add the summer time
- ** offset to the transition time;
- ** otherwise, add the standard time
- ** offset to the transition time.
- */
- /*
- ** Transitions from DST to DDST
- ** will effectively disappear since
- ** POSIX provides for only one DST
- ** offset.
- */
- if (isdst && !sp->ttis[j].tt_ttisstd) {
- sp->ats[i] += dstoffset -
- theirdstoffset;
- } else {
- sp->ats[i] += stdoffset -
- theirstdoffset;
- }
- }
- theiroffset = -sp->ttis[j].tt_gmtoff;
- if (sp->ttis[j].tt_isdst)
- theirdstoffset = theiroffset;
- else theirstdoffset = theiroffset;
- }
- /*
- ** Finally, fill in ttis.
- ** ttisstd and ttisgmt need not be handled.
- */
- sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = FALSE;
- sp->ttis[0].tt_abbrind = 0;
- sp->ttis[1].tt_gmtoff = -dstoffset;
- sp->ttis[1].tt_isdst = TRUE;
- sp->ttis[1].tt_abbrind = stdlen + 1;
- }
- } else {
- dstlen = 0;
- sp->typecnt = 1; /* only standard time */
- sp->timecnt = 0;
- sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = 0;
- sp->ttis[0].tt_abbrind = 0;
- }
- sp->charcnt = stdlen + 1;
- if (dstlen != 0)
- sp->charcnt += dstlen + 1;
- if (sp->charcnt > sizeof sp->chars)
- return -1;
- cp = sp->chars;
- (void) strncpy(cp, stdname, stdlen);
- cp += stdlen;
- *cp++ = '\0';
- if (dstlen != 0) {
- (void) strncpy(cp, dstname, dstlen);
- *(cp + dstlen) = '\0';
- }
- return 0;
-}
-
-static void
-gmtload(sp)
-struct state * const sp;
-{
- if (tzload(gmt, sp) != 0)
- (void) tzparse(gmt, sp, TRUE);
-}
-
-static void
-tzsetwall_basic(void)
-{
- if (lcl_is_set < 0)
- return;
- lcl_is_set = -1;
-
-#ifdef ALL_STATE
- if (lclptr == NULL) {
- lclptr = (struct state *) malloc(sizeof *lclptr);
- if (lclptr == NULL) {
- settzname(); /* all we can do */
- return;
- }
- }
-#endif /* defined ALL_STATE */
- if (tzload((char *) NULL, lclptr) != 0)
- gmtload(lclptr);
- settzname();
-}
-
-void
-tzsetwall(void)
-{
- _MUTEX_LOCK(&lcl_mutex);
- tzsetwall_basic();
- _MUTEX_UNLOCK(&lcl_mutex);
-}
-
-static void
-tzset_basic(void)
-{
- const char * name;
-
- name = getenv("TZ");
- if (name == NULL) {
- tzsetwall_basic();
- return;
- }
-
- if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0)
- return;
- lcl_is_set = (strlen(name) < sizeof(lcl_TZname));
- if (lcl_is_set)
- (void) strcpy(lcl_TZname, name);
-
-#ifdef ALL_STATE
- if (lclptr == NULL) {
- lclptr = (struct state *) malloc(sizeof *lclptr);
- if (lclptr == NULL) {
- settzname(); /* all we can do */
- return;
- }
- }
-#endif /* defined ALL_STATE */
- if (*name == '\0') {
- /*
- ** User wants it fast rather than right.
- */
- lclptr->leapcnt = 0; /* so, we're off a little */
- lclptr->timecnt = 0;
- lclptr->ttis[0].tt_gmtoff = 0;
- lclptr->ttis[0].tt_abbrind = 0;
- (void) strcpy(lclptr->chars, gmt);
- } else if (tzload(name, lclptr) != 0)
- if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
- (void) gmtload(lclptr);
- settzname();
-}
-
-void
-tzset(void)
-{
- _MUTEX_LOCK(&lcl_mutex);
- tzset_basic();
- _MUTEX_UNLOCK(&lcl_mutex);
-}
-
-/*
-** The easy way to behave "as if no library function calls" localtime
-** is to not call it--so we drop its guts into "localsub", which can be
-** freely called. (And no, the PANS doesn't require the above behavior--
-** but it *is* desirable.)
-**
-** The unused offset argument is for the benefit of mktime variants.
-*/
-
-/*ARGSUSED*/
-static void
-localsub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-struct tm * const tmp;
-{
- struct state * sp;
- const struct ttinfo * ttisp;
- int i;
- const time_t t = *timep;
-
- sp = lclptr;
-#ifdef ALL_STATE
- if (sp == NULL) {
- gmtsub(timep, offset, tmp);
- return;
- }
-#endif /* defined ALL_STATE */
- if (sp->timecnt == 0 || t < sp->ats[0]) {
- i = 0;
- while (sp->ttis[i].tt_isdst)
- if (++i >= sp->typecnt) {
- i = 0;
- break;
- }
- } else {
- for (i = 1; i < sp->timecnt; ++i)
- if (t < sp->ats[i])
- break;
- i = sp->types[i - 1];
- }
- ttisp = &sp->ttis[i];
- /*
- ** To get (wrong) behavior that's compatible with System V Release 2.0
- ** you'd replace the statement below with
- ** t += ttisp->tt_gmtoff;
- ** timesub(&t, 0L, sp, tmp);
- */
- timesub(&t, ttisp->tt_gmtoff, sp, tmp);
- tmp->tm_isdst = ttisp->tt_isdst;
- tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
-#ifdef TM_ZONE
- tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
-#endif /* defined TM_ZONE */
-}
-
-struct tm *
-localtime_r(timep, p_tm)
-const time_t * const timep;
-struct tm *p_tm;
-{
- _MUTEX_LOCK(&lcl_mutex);
- tzset_basic();
- localsub(timep, 0L, p_tm);
- _MUTEX_UNLOCK(&lcl_mutex);
- return(p_tm);
-}
-
-struct tm *
-localtime(timep)
-const time_t * const timep;
-{
- static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t localtime_key = (pthread_key_t) -1;
- struct tm *p_tm;
-
- if (__isthreaded != 0) {
- pthread_mutex_lock(&localtime_mutex);
- if (localtime_key == (pthread_key_t) -1) {
- if (pthread_key_create(&localtime_key, free) < 0) {
- pthread_mutex_unlock(&localtime_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&localtime_mutex);
- p_tm = pthread_getspecific(localtime_key);
- if (p_tm == NULL) {
- if ((p_tm = (struct tm *)malloc(sizeof(struct tm)))
- == NULL)
- return(NULL);
- pthread_setspecific(localtime_key, p_tm);
- }
- pthread_mutex_lock(&lcl_mutex);
- tzset_basic();
- localsub(timep, 0L, p_tm);
- pthread_mutex_unlock(&lcl_mutex);
- return(p_tm);
- } else {
- tzset_basic();
- localsub(timep, 0L, &tm);
- return(&tm);
- }
-}
-
-/*
-** gmtsub is to gmtime as localsub is to localtime.
-*/
-
-static void
-gmtsub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-struct tm * const tmp;
-{
- _MUTEX_LOCK(&gmt_mutex);
- if (!gmt_is_set) {
- gmt_is_set = TRUE;
-#ifdef ALL_STATE
- gmtptr = (struct state *) malloc(sizeof *gmtptr);
- if (gmtptr != NULL)
-#endif /* defined ALL_STATE */
- gmtload(gmtptr);
- }
- _MUTEX_UNLOCK(&gmt_mutex);
- timesub(timep, offset, gmtptr, tmp);
-#ifdef TM_ZONE
- /*
- ** Could get fancy here and deliver something such as
- ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero,
- ** but this is no time for a treasure hunt.
- */
- if (offset != 0)
- tmp->TM_ZONE = wildabbr;
- else {
-#ifdef ALL_STATE
- if (gmtptr == NULL)
- tmp->TM_ZONE = gmt;
- else tmp->TM_ZONE = gmtptr->chars;
-#endif /* defined ALL_STATE */
-#ifndef ALL_STATE
- tmp->TM_ZONE = gmtptr->chars;
-#endif /* State Farm */
- }
-#endif /* defined TM_ZONE */
-}
-
-struct tm *
-gmtime(timep)
-const time_t * const timep;
-{
- static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
- static pthread_key_t gmtime_key = (pthread_key_t) -1;
- struct tm *p_tm;
-
- if (__isthreaded != 0) {
- pthread_mutex_lock(&gmtime_mutex);
- if (gmtime_key == (pthread_key_t) -1) {
- if (pthread_key_create(&gmtime_key, free) < 0) {
- pthread_mutex_unlock(&gmtime_mutex);
- return(NULL);
- }
- }
- pthread_mutex_unlock(&gmtime_mutex);
- /*
- * Changed to follow POSIX.1 threads standard, which
- * is what BSD currently has.
- */
- if ((p_tm = pthread_getspecific(gmtime_key)) == NULL) {
- if ((p_tm = (struct tm *)malloc(sizeof(struct tm)))
- == NULL) {
- return(NULL);
- }
- pthread_setspecific(gmtime_key, p_tm);
- }
- gmtsub(timep, 0L, p_tm);
- return(p_tm);
- }
- else {
- gmtsub(timep, 0L, &tm);
- return(&tm);
- }
-}
-
-struct tm *
-gmtime_r(const time_t * timep, struct tm * tm)
-{
- gmtsub(timep, 0L, tm);
- return(tm);
-}
-
-#ifdef STD_INSPIRED
-
-struct tm *
-offtime(timep, offset)
-const time_t * const timep;
-const long offset;
-{
- gmtsub(timep, offset, &tm);
- return &tm;
-}
-
-#endif /* defined STD_INSPIRED */
-
-static void
-timesub(timep, offset, sp, tmp)
-const time_t * const timep;
-const long offset;
-const struct state * const sp;
-struct tm * const tmp;
-{
- const struct lsinfo * lp;
- long days;
- long rem;
- int y;
- int yleap;
- const int * ip;
- long corr;
- int hit;
- int i;
-
- corr = 0;
- hit = 0;
-#ifdef ALL_STATE
- i = (sp == NULL) ? 0 : sp->leapcnt;
-#endif /* defined ALL_STATE */
-#ifndef ALL_STATE
- i = sp->leapcnt;
-#endif /* State Farm */
- while (--i >= 0) {
- lp = &sp->lsis[i];
- if (*timep >= lp->ls_trans) {
- if (*timep == lp->ls_trans) {
- hit = ((i == 0 && lp->ls_corr > 0) ||
- lp->ls_corr > sp->lsis[i - 1].ls_corr);
- if (hit)
- while (i > 0 &&
- sp->lsis[i].ls_trans ==
- sp->lsis[i - 1].ls_trans + 1 &&
- sp->lsis[i].ls_corr ==
- sp->lsis[i - 1].ls_corr + 1) {
- ++hit;
- --i;
- }
- }
- corr = lp->ls_corr;
- break;
- }
- }
- days = *timep / SECSPERDAY;
- rem = *timep % SECSPERDAY;
-#ifdef mc68k
- if (*timep == 0x80000000) {
- /*
- ** A 3B1 muffs the division on the most negative number.
- */
- days = -24855;
- rem = -11648;
- }
-#endif /* defined mc68k */
- rem += (offset - corr);
- while (rem < 0) {
- rem += SECSPERDAY;
- --days;
- }
- while (rem >= SECSPERDAY) {
- rem -= SECSPERDAY;
- ++days;
- }
- tmp->tm_hour = (int) (rem / SECSPERHOUR);
- rem = rem % SECSPERHOUR;
- tmp->tm_min = (int) (rem / SECSPERMIN);
- /*
- ** A positive leap second requires a special
- ** representation. This uses "... ??:59:60" et seq.
- */
- tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
- tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
- if (tmp->tm_wday < 0)
- tmp->tm_wday += DAYSPERWEEK;
- y = EPOCH_YEAR;
-#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
- while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
- int newy;
-
- newy = y + days / DAYSPERNYEAR;
- if (days < 0)
- --newy;
- days -= (newy - y) * DAYSPERNYEAR +
- LEAPS_THRU_END_OF(newy - 1) -
- LEAPS_THRU_END_OF(y - 1);
- y = newy;
- }
- tmp->tm_year = y - TM_YEAR_BASE;
- tmp->tm_yday = (int) days;
- ip = mon_lengths[yleap];
- for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
- days = days - (long) ip[tmp->tm_mon];
- tmp->tm_mday = (int) (days + 1);
- tmp->tm_isdst = 0;
-#ifdef TM_GMTOFF
- tmp->TM_GMTOFF = offset;
-#endif /* defined TM_GMTOFF */
-}
-
-char *
-ctime(timep)
-const time_t * const timep;
-{
-/*
-** Section 4.12.3.2 of X3.159-1989 requires that
-** The ctime funciton converts the calendar time pointed to by timer
-** to local time in the form of a string. It is equivalent to
-** asctime(localtime(timer))
-*/
- return asctime(localtime(timep));
-}
-
-char *
-ctime_r(timep, buf)
-const time_t * const timep;
-char *buf;
-{
- struct tm tm;
- return asctime_r(localtime_r(timep, &tm), buf);
-}
-
-/*
-** Adapted from code provided by Robert Elz, who writes:
-** The "best" way to do mktime I think is based on an idea of Bob
-** Kridle's (so its said...) from a long time ago.
-** [kridle@xinet.com as of 1996-01-16.]
-** It does a binary search of the time_t space. Since time_t's are
-** just 32 bits, its a max of 32 iterations (even at 64 bits it
-** would still be very reasonable).
-*/
-
-#ifndef WRONG
-#define WRONG (-1)
-#endif /* !defined WRONG */
-
-/*
-** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
-*/
-
-static int
-increment_overflow(number, delta)
-int * number;
-int delta;
-{
- int number0;
-
- number0 = *number;
- *number += delta;
- return (*number < number0) != (delta < 0);
-}
-
-static int
-normalize_overflow(tensptr, unitsptr, base)
-int * const tensptr;
-int * const unitsptr;
-const int base;
-{
- int tensdelta;
-
- tensdelta = (*unitsptr >= 0) ?
- (*unitsptr / base) :
- (-1 - (-1 - *unitsptr) / base);
- *unitsptr -= tensdelta * base;
- return increment_overflow(tensptr, tensdelta);
-}
-
-static int
-tmcomp(atmp, btmp)
-const struct tm * const atmp;
-const struct tm * const btmp;
-{
- int result;
-
- if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
- (result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
- (result = (atmp->tm_mday - btmp->tm_mday)) == 0 &&
- (result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
- (result = (atmp->tm_min - btmp->tm_min)) == 0)
- result = atmp->tm_sec - btmp->tm_sec;
- return result;
-}
-
-static time_t
-time2(tmp, funcp, offset, okayp)
-struct tm * const tmp;
-void (* const funcp)(const time_t*, long, struct tm*);
-const long offset;
-int * const okayp;
-{
- const struct state * sp;
- int dir;
- int bits;
- int i, j ;
- int saved_seconds;
- time_t newt;
- time_t t;
- struct tm yourtm, mytm;
-
- *okayp = FALSE;
- yourtm = *tmp;
- if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR))
- return WRONG;
- if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
- return WRONG;
- if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR))
- return WRONG;
- /*
- ** Turn yourtm.tm_year into an actual year number for now.
- ** It is converted back to an offset from TM_YEAR_BASE later.
- */
- if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
- return WRONG;
- while (yourtm.tm_mday <= 0) {
- if (increment_overflow(&yourtm.tm_year, -1))
- return WRONG;
- i = yourtm.tm_year + (1 < yourtm.tm_mon);
- yourtm.tm_mday += year_lengths[isleap(i)];
- }
- while (yourtm.tm_mday > DAYSPERLYEAR) {
- i = yourtm.tm_year + (1 < yourtm.tm_mon);
- yourtm.tm_mday -= year_lengths[isleap(i)];
- if (increment_overflow(&yourtm.tm_year, 1))
- return WRONG;
- }
- for ( ; ; ) {
- i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon];
- if (yourtm.tm_mday <= i)
- break;
- yourtm.tm_mday -= i;
- if (++yourtm.tm_mon >= MONSPERYEAR) {
- yourtm.tm_mon = 0;
- if (increment_overflow(&yourtm.tm_year, 1))
- return WRONG;
- }
- }
- if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE))
- return WRONG;
- if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN)
- saved_seconds = 0;
- else if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) {
- /*
- ** We can't set tm_sec to 0, because that might push the
- ** time below the minimum representable time.
- ** Set tm_sec to 59 instead.
- ** This assumes that the minimum representable time is
- ** not in the same minute that a leap second was deleted from,
- ** which is a safer assumption than using 58 would be.
- */
- if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
- return WRONG;
- saved_seconds = yourtm.tm_sec;
- yourtm.tm_sec = SECSPERMIN - 1;
- } else {
- saved_seconds = yourtm.tm_sec;
- yourtm.tm_sec = 0;
- }
- /*
- ** Divide the search space in half
- ** (this works whether time_t is signed or unsigned).
- */
- bits = TYPE_BIT(time_t) - 1;
- /*
- ** If time_t is signed, then 0 is just above the median,
- ** assuming two's complement arithmetic.
- ** If time_t is unsigned, then (1 << bits) is just above the median.
- */
- t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
- for ( ; ; ) {
- (*funcp)(&t, offset, &mytm);
- dir = tmcomp(&mytm, &yourtm);
- if (dir != 0) {
- if (bits-- < 0)
- return WRONG;
- if (bits < 0)
- --t; /* may be needed if new t is minimal */
- else if (dir > 0)
- t -= ((time_t) 1) << bits;
- else t += ((time_t) 1) << bits;
- continue;
- }
- if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
- break;
- /*
- ** Right time, wrong type.
- ** Hunt for right time, right type.
- ** It's okay to guess wrong since the guess
- ** gets checked.
- */
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
- sp = (const struct state *)
- (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
-#ifdef ALL_STATE
- if (sp == NULL)
- return WRONG;
-#endif /* defined ALL_STATE */
- for (i = sp->typecnt - 1; i >= 0; --i) {
- if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
- continue;
- for (j = sp->typecnt - 1; j >= 0; --j) {
- if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
- continue;
- newt = t + sp->ttis[j].tt_gmtoff -
- sp->ttis[i].tt_gmtoff;
- (*funcp)(&newt, offset, &mytm);
- if (tmcomp(&mytm, &yourtm) != 0)
- continue;
- if (mytm.tm_isdst != yourtm.tm_isdst)
- continue;
- /*
- ** We have a match.
- */
- t = newt;
- goto label;
- }
- }
- return WRONG;
- }
-label:
- newt = t + saved_seconds;
- if ((newt < t) != (saved_seconds < 0))
- return WRONG;
- t = newt;
- (*funcp)(&t, offset, tmp);
- *okayp = TRUE;
- return t;
-}
-
-static time_t
-time1(tmp, funcp, offset)
-struct tm * const tmp;
-void (* const funcp)(const time_t *, long, struct tm *);
-const long offset;
-{
- time_t t;
- const struct state * sp;
- int samei, otheri;
- int okay;
-
- if (tmp->tm_isdst > 1)
- tmp->tm_isdst = 1;
- t = time2(tmp, funcp, offset, &okay);
-#ifdef PCTS
- /*
- ** PCTS code courtesy Grant Sullivan (grant@osf.org).
- */
- if (okay)
- return t;
- if (tmp->tm_isdst < 0)
- tmp->tm_isdst = 0; /* reset to std and try again */
-#endif /* defined PCTS */
-#ifndef PCTS
- if (okay || tmp->tm_isdst < 0)
- return t;
-#endif /* !defined PCTS */
- /*
- ** We're supposed to assume that somebody took a time of one type
- ** and did some math on it that yielded a "struct tm" that's bad.
- ** We try to divine the type they started from and adjust to the
- ** type they need.
- */
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
- sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
-#ifdef ALL_STATE
- if (sp == NULL)
- return WRONG;
-#endif /* defined ALL_STATE */
- for (samei = sp->typecnt - 1; samei >= 0; --samei) {
- if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
- continue;
- for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) {
- if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
- continue;
- tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- t = time2(tmp, funcp, offset, &okay);
- if (okay)
- return t;
- tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- }
- }
- return WRONG;
-}
-
-time_t
-mktime(tmp)
-struct tm * const tmp;
-{
- time_t mktime_return_value;
- _MUTEX_LOCK(&lcl_mutex);
- tzset_basic();
- mktime_return_value = time1(tmp, localsub, 0L);
- _MUTEX_UNLOCK(&lcl_mutex);
- return(mktime_return_value);
-}
-
-#ifdef STD_INSPIRED
-
-time_t
-timelocal(tmp)
-struct tm * const tmp;
-{
- tmp->tm_isdst = -1; /* in case it wasn't initialized */
- return mktime(tmp);
-}
-
-time_t
-timegm(tmp)
-struct tm * const tmp;
-{
- tmp->tm_isdst = 0;
- return time1(tmp, gmtsub, 0L);
-}
-
-time_t
-timeoff(tmp, offset)
-struct tm * const tmp;
-const long offset;
-{
- tmp->tm_isdst = 0;
- return time1(tmp, gmtsub, offset);
-}
-
-#endif /* defined STD_INSPIRED */
-
-#ifdef CMUCS
-
-/*
-** The following is supplied for compatibility with
-** previous versions of the CMUCS runtime library.
-*/
-
-long
-gtime(tmp)
-struct tm * const tmp;
-{
- const time_t t = mktime(tmp);
-
- if (t == WRONG)
- return -1;
- return t;
-}
-
-#endif /* defined CMUCS */
-
-/*
-** XXX--is the below the right way to conditionalize??
-*/
-
-#ifdef STD_INSPIRED
-
-/*
-** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599
-** shall correspond to "Wed Dec 31 23:59:59 GMT 1986", which
-** is not the case if we are accounting for leap seconds.
-** So, we provide the following conversion routines for use
-** when exchanging timestamps with POSIX conforming systems.
-*/
-
-static long
-leapcorr(timep)
-time_t * timep;
-{
- struct state * sp;
- struct lsinfo * lp;
- int i;
-
- sp = lclptr;
- i = sp->leapcnt;
- while (--i >= 0) {
- lp = &sp->lsis[i];
- if (*timep >= lp->ls_trans)
- return lp->ls_corr;
- }
- return 0;
-}
-
-time_t
-time2posix(t)
-time_t t;
-{
- tzset();
- return t - leapcorr(&t);
-}
-
-time_t
-posix2time(t)
-time_t t;
-{
- time_t x;
- time_t y;
-
- tzset();
- /*
- ** For a positive leap second hit, the result
- ** is not unique. For a negative leap second
- ** hit, the corresponding time doesn't exist,
- ** so we return an adjacent second.
- */
- x = t + leapcorr(&t);
- y = x - leapcorr(&x);
- if (y < t) {
- do {
- x++;
- y = x - leapcorr(&x);
- } while (y < t);
- if (t != y)
- return x - 1;
- } else if (y > t) {
- do {
- --x;
- y = x - leapcorr(&x);
- } while (y > t);
- if (t != y)
- return x + 1;
- }
- return x;
-}
-
-#endif /* defined STD_INSPIRED */
diff --git a/devel/linuxthreads/files/patch-aa b/devel/linuxthreads/files/patch-aa
deleted file mode 100644
index b6c0af1834c8..000000000000
--- a/devel/linuxthreads/files/patch-aa
+++ /dev/null
@@ -1,1459 +0,0 @@
-diff -ru ../../work/linuxthreads-2.2.3/Examples/Makefile ./Examples/Makefile
---- ../../work/linuxthreads-2.2.3/Examples/Makefile Wed Mar 11 12:42:23 1998
-+++ ./Examples/Makefile Thu Jun 7 22:59:29 2001
-@@ -1,6 +1,6 @@
- CC=gcc
--CFLAGS=-g -O -Wall -I.. -D_REENTRANT
--LIBPTHREAD=../libpthread.a
-+CFLAGS=-g -O -Wall -I/usr/local/include/pthread/linuxthreads -D_REENTRANT
-+LIBPTHREAD=-L/usr/local/lib -llthread -llgcc_r
-
- PROGS=ex1 ex2 ex3 ex4 ex5 proxy
-
-diff -ru ../../work/linuxthreads-2.2.3/Makefile ./Makefile
---- ../../work/linuxthreads-2.2.3/Makefile Wed Apr 25 21:50:59 2001
-+++ ./Makefile Thu Jun 7 23:13:52 2001
-@@ -1,128 +1,149 @@
--# Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
--# This file is part of the GNU C Library.
-+LIB=lthread
-+.if defined(LINUXTHREADS_WRAP_API)
-+.if defined(USING_GCC4)
-+SHLIB_MAJOR= 7
-+.elif defined(USING_GCC3)
-+SHLIB_MAJOR= 5
-+.else
-+SHLIB_MAJOR= 4
-+.endif
-+.else
-+.if defined(USING_GCC4)
-+SHLIB_MAJOR= 6
-+.elif defined(USING_GCC3)
-+SHLIB_MAJOR= 3
-+.else
-+SHLIB_MAJOR= 2
-+.endif
-+.endif
-+SHLIB_MINOR= 2
-+
-+.if defined(INSTALL_LIBLTHREAD_PIC_ARCHIVE)
-+INSTALL_PIC_ARCHIVE= yes
-+.endif
-+
-+.if !defined(MACHINE_ARCH)
-+MACHINE_ARCH != /usr/bin/uname -m
-+.endif
-+
-+.if !defined(LIBSRC_BASE)
-+LIBSRC_BASE = /usr/src/lib
-+.endif
-+
-+.if !defined(PREFIX)
-+PREFIX= ${DESTDIR}/usr/local
-+.endif
-+
-+LIBDIR= ${PREFIX:S,^${DESTDIR},,}/lib
-+
-+CFLAGS +=-g -O2 -Wall
-+#CFLAGS +=-g -O0 -Wall -DDEBUG
-+CFLAGS +=-DCOMPILING_LINUXTHREADS
-+#CFLAGS += -D__NO_WEAK_PTHREAD_ALIASES
-+
-+CFLAGS += -I${.CURDIR}
-+CFLAGS += -I${.CURDIR}/sysdeps/${MACHINE_ARCH}
-+CFLAGS += -I${.CURDIR}/sysdeps/pthread
-+CFLAGS += -I${.CURDIR}/sysdeps/unix/sysv/linux
-+CFLAGS += -I${LIBSRC_BASE}/libc/stdtime
-+#CFLAGS += -I${LIBSRC_BASE}/libc/${MACHINE_ARCH}
-+CFLAGS += -DLIBC_RCS
-+CFLAGS += -DLINUXTHREADS
-+CFLAGS += -D__USE_UNIX98
-+CFLAGS += -D__USE_XOPEN2K -D_STACK_GROWS_DOWN -DNEWLIBC -D_THREAD_SAFE
-+.if defined(LINUXTHREADS_MAX_STACK_SIZE)
-+CFLAGS += -DSTACK_SIZE=$(LINUXTHREADS_MAX_STACK_SIZE)
-+.endif
-+.if defined(LINUXTHREADS_MAX_THREADS)
-+CFLAGS += -DPTHREAD_THREADS_MAX=$(LINUXTHREADS_MAX_THREADS)
-+.endif
-+.if defined(LINUXTHREADS_DETECT_UNSAFE_EXIT)
-+CFLAGS += -DLINUXTHREADS_DETECT_UNSAFE_EXIT
-+.endif
-+
-+.if defined(LINUXTHREADS_WRAP_API)
-+CFLAGS += -DLINUXTHREADS_WRAP_API
-+LD=${LINUXTHREADS_WRAP_LD}
-+.endif
-+
-+.if defined(LINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING)
-+CFLAGS += -DLINUXTHREADS_NO_POSIX_PRIORITY_SCHEDULING
-+.endif
-+
-+.if defined(LINUXTHREADS_ALT_RESTARTSIG)
-+CFLAGS += -DLINUXTHREADS_ALT_RESTARTSIG=${LINUXTHREADS_ALT_RESTARTSIG}
-+.endif
-+
-+CFLAGS += -I${LIBSRC_BASE}/libc/${MACHINE_ARCH} -I${.CURDIR}/sysdeps/${MACHINE_ARCH}
-+
-+# Contents of the library.
-+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 wraputhread.c wrapsyscall.c \
-+ barrier.c localtime.c getlogin.c telldir.c ttyname.c strptime.c
-+
-+.if defined(USING_GCC4)
-+SOBJS += libgcc_r/unwind-sjlj.o libgcc_r/unwind-dw2.o libgcc_r/unwind-dw2-fde-glibc.o
-+.elif defined(USING_GCC3)
-+SOBJS += libgcc_r/unwind-sjlj.o libgcc_r/unwind-dw2.o libgcc_r/unwind-dw2-fde.o
-+.else
-+SOBJS += libgcc_r/frame.o libgcc_r/_eh.o
-+.endif
-+
-+beforeinstall:
-+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 \
-+ ${PREFIX}/include/pthread/linuxthreads
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/sysdeps/pthread/pthread.h \
-+ ${PREFIX}/include/pthread/linuxthreads/pthread.h
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/semaphore.h \
-+ ${PREFIX}/include/pthread/linuxthreads/semaphore.h
-+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 \
-+ ${PREFIX}/include/pthread/linuxthreads/bits
-+.for hdr in libc-lock.h libc-tsd.h pthreadtypes.h stdio-lock.h initspin.h
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/sysdeps/pthread/bits/$(hdr) \
-+ ${PREFIX}/include/pthread/linuxthreads/bits/$(hdr)
-+.endfor
-+.for hdr in local_lim.h posix_opt.h sigthread.h
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/sysdeps/unix/sysv/linux/bits/$(hdr) \
-+ ${PREFIX}/include/pthread/linuxthreads/bits/$(hdr)
-+.endfor
-+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 \
-+ ${PREFIX}/include/pthread/linuxthreads/sys
-+.for hdr in _pthreadtypes.h
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/sys/$(hdr) \
-+ ${PREFIX}/include/pthread/linuxthreads/sys/$(hdr)
-+.endfor
-+.for hdr in pt-machine.h useldt.h
-+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
-+ ${.CURDIR}/sysdeps/i386/$(hdr) \
-+ ${PREFIX}/include/pthread/linuxthreads/$(hdr)
-+.endfor
-+ ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 0755 ${PREFIX}/lib
-
--# 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.
--
--#
--# Sub-makefile for linuxthreads portion of the library.
--#
--subdir := linuxthreads
--
--linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
-- Banner)
--
--headers := pthread.h semaphore.h
--distribute := internals.h queue.h restart.h spinlock.h
--
--routines := weaks no-tsd
--
--extra-libs := libpthread
--extra-libs-others := $(extra-libs)
--
--libpthread-routines := attr cancel condvar join manager mutex ptfork \
-- ptlongjmp pthread signals specific errno lockfile \
-- semaphore spinlock wrapsyscall rwlock pt-machine \
-- oldsemaphore events getcpuclockid pspinlock barrier \
-- ptclock_gettime ptclock_settime
--
--nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
--initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
--LDFLAGS-pthread.so = $(nodelete-$(have-z-nodelete)) \
-- $(initfirst-$(have-z-initfirst))
--
--vpath %.c Examples
--
--tst-cancel-ARGS = "$(objpfx)"
--CFLAGS-tst-cancel.c = -fno-inline
--
--include ../Makeconfig
--
--ifeq ($(build-shared),yes)
--before-compile := $(objpfx)crti.o
--extra-objs = crti.o
--
--CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions
--endif
--
--librt-tests = ex10 ex11
--tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
-- tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
-- ex17 tst-cancel
--
--ifeq (yes,$(build-shared))
--tests-nodelete-yes = unload
--endif
--
--include ../Rules
--
--extra-B-pthread.so = -B$(common-objpfx)linuxthreads/
--
--znodelete-yes = -DHAVE_Z_NODELETE
--CFLAGS-mutex.c += -D__NO_WEAK_PTHREAD_ALIASES
--CFLAGS-specific.c += -D__NO_WEAK_PTHREAD_ALIASES
--CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ALIASES $(znodelete-$(have-z-nodelete))
--CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES
--CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_
--CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\"
--
--# 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.
--$(objpfx)libpthread.so: $(common-objpfx)libc.so \
-- $(common-objpfx)libc_nonshared.a
--
--# Make sure we link with the thread library.
--ifeq ($(build-shared),yes)
--$(addprefix $(objpfx),$(tests)): $(objpfx)libpthread.so
--$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
--$(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
--else
--$(addprefix $(objpfx),$(tests)): $(objpfx)libpthread.a
--$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
--endif
--ifeq ($(build-bounded),yes)
--$(tests:%=$(objpfx)%-bp): $(objpfx)libpthread_b.a
--$(librt-tests:%=$(objpfx)%-bp): $(common-objpfx)rt/librt_b.a
--endif
--
--ifeq ($(build-shared),yes)
--vpath pt-initfini.c $(full_config_sysdirs)
--
--$(objpfx)pt-initfini.s: pt-initfini.c
-- $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
-- $(patsubst -f%,-fno-%,$(exceptions)) -o $@
--
--# We only have one kind of startup code files. Static binaries and
--# shared libraries are build using the PIC version.
--$(objpfx)crti.S: $(objpfx)pt-initfini.s
-- sed -n -e '1,/@HEADER_ENDS/p' \
-- -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
-- -e '/@TRAILER_BEGINS/,$$p' $< > $@
--
--$(objpfx)defs.h: $(objpfx)pt-initfini.s
-- sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
-- $(AWK) -f ../csu/defs.awk > $@
--
--$(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
-- $(compile.S) -g0 $(ASFLAGS-.os) -o $@
--
--generated += crti.S defs.h pt-initfini.s
--endif
--
--ifeq (yes,$(build-static-nss))
--otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-- $(resolvobjdir)/libresolv.a
--endif
-+
-+.include <bsd.lib.mk>
-+
-+.if defined(LINUXTHREADS_WRAP_API)
-+.c.o:
-+ ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
-+ @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET}
-+ @mv ${.TARGET}.tmp ${.TARGET}
-+
-+.c.po:
-+ ${CC} -pg ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
-+ @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -X -r ${.TARGET}
-+ @mv ${.TARGET}.tmp ${.TARGET}
-+
-+.c.So:
-+ ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
-+ @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET}
-+ @mv ${.TARGET}.tmp ${.TARGET}
-+.endif
-+
-diff -ru ../../work/linuxthreads-2.2.3/attr.c ./attr.c
---- ../../work/linuxthreads-2.2.3/attr.c Tue Mar 27 04:52:55 2001
-+++ ./attr.c Thu Jun 7 22:59:29 2001
-@@ -18,11 +18,14 @@
- #include <string.h>
- #include <unistd.h>
- #include <sys/param.h>
-+#include <sys/time.h>
- #include <sys/resource.h>
- #include "pthread.h"
- #include "internals.h"
-+#if 0
- #include <shlib-compat.h>
- #include <stackinfo.h>
-+#endif
-
- int __pthread_attr_init_2_1(pthread_attr_t *attr)
- {
-@@ -30,7 +33,7 @@
-
- attr->__detachstate = PTHREAD_CREATE_JOINABLE;
- attr->__schedpolicy = SCHED_OTHER;
-- attr->__schedparam.sched_priority = 0;
-+ attr->__schedparam.sched_priority = DEFAULT_PRIORITY;
- attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
- attr->__scope = PTHREAD_SCOPE_SYSTEM;
- attr->__guardsize = ps;
-@@ -283,6 +286,9 @@
-
- attr->__inheritsched = descr->p_inheritsched;
- attr->__scope = PTHREAD_SCOPE_SYSTEM;
-+ if (descr == &__pthread_initial_thread)
-+ attr->__stacksize = 3 * STACK_SIZE;
-+ else
- attr->__stacksize = (char *)(descr + 1) - (char *)descr->p_guardaddr
- - descr->p_guardsize;
- attr->__guardsize = descr->p_guardsize;
-@@ -295,6 +301,9 @@
- otherwise the range of the stack area cannot be computed. */
- attr->__stacksize += attr->__guardsize;
- #endif
-+ if (descr == &__pthread_initial_thread)
-+ attr->__stackaddr = __pthread_initial_thread_bos + 3 * STACK_SIZE;
-+ else
- #ifndef _STACK_GROWS_UP
- attr->__stackaddr = (char *)(descr + 1);
- #else
-diff -ru ../../work/linuxthreads-2.2.3/cancel.c ./cancel.c
---- ../../work/linuxthreads-2.2.3/cancel.c Thu Apr 12 23:10:53 2001
-+++ ./cancel.c Thu Jun 7 22:59:29 2001
-@@ -20,8 +20,10 @@
- #include "internals.h"
- #include "spinlock.h"
- #include "restart.h"
--#include <stackinfo.h>
-
-+#if 1
-+#define FRAME_LEFT(frame, other) 0
-+#else
- #ifdef _STACK_GROWS_DOWN
- # define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
- #elif _STACK_GROWS_UP
-@@ -29,6 +31,7 @@
- #else
- # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
- #endif
-+#endif
-
-
- int pthread_setcancelstate(int state, int * oldstate)
-@@ -202,9 +201,11 @@
- break;
- }
-
-+#if 0
- /* And the TSD which needs special help. */
- if (THREAD_GETMEM(self, p_libc_specific[_LIBC_TSD_KEY_RPC_VARS]) != NULL)
- __rpc_thread_destroy ();
-+#endif
- }
-
- #ifndef SHARED
-diff -ru ../../work/linuxthreads-2.2.3/errno.c ./errno.c
---- ../../work/linuxthreads-2.2.3/errno.c Sat Dec 4 20:31:49 1999
-+++ ./errno.c Thu Jun 7 22:59:29 2001
-@@ -18,14 +18,17 @@
- #include <netdb.h>
- #include "pthread.h"
- #include "internals.h"
-+#include <osreldate.h>
-
--int * __errno_location()
-+int * __error()
- {
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_errnop);
- }
-
--int * __h_errno_location()
-+#if __FreeBSD_version < 502104
-+
-+int * __h_error()
- {
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_h_errnop);
-@@ -37,3 +40,5 @@
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_resp);
- }
-+
-+#endif /* #if __FreeBSD_version < 502104 */
-diff -ru ../../work/linuxthreads-2.2.3/internals.h ./internals.h
---- ../../work/linuxthreads-2.2.3/internals.h Wed Apr 25 21:50:59 2001
-+++ ./internals.h Thu Jun 7 22:59:29 2001
-@@ -20,6 +20,7 @@
- /* Includes */
-
- #include <limits.h>
-+#include <netinet/in.h>
- #include <resolv.h>
- #include <setjmp.h>
- #include <signal.h>
-@@ -31,9 +32,8 @@
- extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
- #include "pt-machine.h"
-+#include "freebsd-compat.h"
- #include "semaphore.h"
--#include "../linuxthreads_db/thread_dbP.h"
--#include <hp-timing.h>
-
- #ifndef THREAD_GETMEM
- # define THREAD_GETMEM(descr, member) descr->member
-@@ -161,13 +161,18 @@
- char p_sigwaiting; /* true if a sigwait() is in progress */
- struct pthread_start_args p_start_args; /* arguments for thread creation */
- void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
-+ TAILQ_ENTRY(_pthread_descr_struct) qe;
-+ char time_buf[26];
-+ struct tm local_tm;
- void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
- int p_userstack; /* nonzero if the user provided the stack */
- void *p_guardaddr; /* address of guard area or NULL */
- size_t p_guardsize; /* size of guard area */
- int p_nr; /* Index of descriptor in __pthread_handles */
-+#if 0
- int p_report_events; /* Nonzero if events must be reported. */
- td_eventbuf_t p_eventbuf; /* Data for event. */
-+#endif
- struct pthread_atomic p_resume_count; /* number of times restart() was
- called on thread */
- char p_woken_by_cancel; /* cancellation performed wakeup */
-@@ -293,11 +298,13 @@
-
- extern volatile int __pthread_threads_debug;
-
-+#if 0
- /* Globally enabled events. */
- extern volatile td_thr_events_t __pthread_threads_events;
-
- /* Pointer to descriptor of thread with last event. */
- extern volatile pthread_descr __pthread_last_event;
-+#endif
-
- /* Flag which tells whether we are executing on SMP kernel. */
- extern int __pthread_smp_kernel;
-@@ -510,8 +517,10 @@
- extern int __pthread_spin_init (pthread_spinlock_t *__lock, int __pshared);
- extern int __pthread_spin_destroy (pthread_spinlock_t *__lock);
-
-+#if 0
- extern int __pthread_clock_gettime (hp_timing_t freq, struct timespec *tp);
- extern void __pthread_clock_settime (hp_timing_t offset);
-+#endif
-
-
- /* Global pointers to old or new suspend functions */
-@@ -545,7 +555,7 @@
- /* Prototypes for compatibility functions. */
- extern int __pthread_attr_init_2_1 (pthread_attr_t *__attr);
- extern int __pthread_attr_init_2_0 (pthread_attr_t *__attr);
--extern int __pthread_create_2_1 (pthread_t *__restrict __thread,
-+extern int __pthread_create_2_1 (pthread_t *__restrict __xthread,
- const pthread_attr_t *__attr,
- void *(*__start_routine) (void *),
- void *__restrict __arg);
-diff -ru ../../work/linuxthreads-2.2.3/join.c ./join.c
---- ../../work/linuxthreads-2.2.3/join.c Thu Apr 12 21:02:02 2001
-+++ ./join.c Thu Jun 7 22:59:29 2001
-@@ -43,6 +43,7 @@
- /* Store return value */
- __pthread_lock(THREAD_GETMEM(self, p_lock), self);
- THREAD_SETMEM(self, p_retval, retval);
-+#if 0
- /* See whether we have to signal the death. */
- if (THREAD_GETMEM(self, p_report_events))
- {
-@@ -64,6 +65,7 @@
- __linuxthreads_death_event();
- }
- }
-+#endif
- /* Say that we've terminated */
- THREAD_SETMEM(self, p_terminated, 1);
- /* See if someone is joining on us */
-diff -ru ../../work/linuxthreads-2.2.3/manager.c ./manager.c
---- ../../work/linuxthreads-2.2.3/manager.c Wed Apr 25 21:50:59 2001
-+++ ./manager.c Thu Jun 7 22:59:29 2001
-@@ -54,8 +54,10 @@
- (set to 1 by gdb) */
- volatile int __pthread_threads_debug;
-
-+#if 0
- /* Globally enabled events. */
- volatile td_thr_events_t __pthread_threads_events;
-+#endif
-
- /* Pointer to thread descriptor with last event. */
- volatile pthread_descr __pthread_last_event;
-@@ -92,9 +94,9 @@
-
- static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
- void * (*start_routine)(void *), void *arg,
-- sigset_t *mask, int father_pid,
-+ sigset_t *mask, int father_pid/*,
- int report_events,
-- td_thr_events_t *event_maskp);
-+ td_thr_events_t *event_maskp*/);
- static void pthread_handle_free(pthread_t th_id);
- static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
- __attribute__ ((noreturn));
-@@ -160,9 +162,9 @@
- request.req_args.create.fn,
- request.req_args.create.arg,
- &request.req_args.create.mask,
-- request.req_thread->p_pid,
-+ request.req_thread->p_pid/*,
- request.req_thread->p_report_events,
-- &request.req_thread->p_eventbuf.eventmask);
-+ &request.req_thread->p_eventbuf.eventmask*/);
- restart(request.req_thread);
- break;
- case REQ_FREE:
-@@ -277,6 +279,7 @@
- __pthread_do_exit(outcome, CURRENT_STACK_FRAME);
- }
-
-+#if 0
- static int
- __attribute__ ((noreturn))
- pthread_start_thread_event(void *arg)
-@@ -297,6 +300,7 @@
- /* Continue with the real function. */
- pthread_start_thread (arg);
- }
-+#endif
-
- static int pthread_allocate_stack(const pthread_attr_t *attr,
- pthread_descr default_new_thread,
-@@ -476,9 +480,9 @@
-
- static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
- void * (*start_routine)(void *), void *arg,
-- sigset_t * mask, int father_pid,
-+ sigset_t * mask, int father_pid/*,
- int report_events,
-- td_thr_events_t *event_maskp)
-+ td_thr_events_t *event_maskp*/)
- {
- size_t sseg;
- int pid;
-@@ -549,6 +553,12 @@
- }
- new_thread->p_priority =
- new_thread->p_start_args.schedparam.sched_priority;
-+ } else {
-+ new_thread->p_detached = PTHREAD_CREATE_JOINABLE;
-+ new_thread->p_userstack = 0;
-+ new_thread->p_start_args.schedpolicy = SCHED_OTHER;
-+ new_thread->p_start_args.schedparam.sched_priority = DEFAULT_PRIORITY;
-+ new_thread->p_priority = DEFAULT_PRIORITY;
- }
- /* Finish setting up arguments to pthread_start_thread */
- new_thread->p_start_args.start_routine = start_routine;
-@@ -563,6 +573,7 @@
- /* Do the cloning. We have to use two different functions depending
- on whether we are debugging or not. */
- pid = 0; /* Note that the thread never can have PID zero. */
-+#if 0
- if (report_events)
- {
- /* See whether the TD_CREATE event bit is set in any of the
-@@ -619,6 +630,7 @@
- }
- }
- }
-+#endif
- if (pid == 0)
- {
- #ifdef NEED_SEPARATE_REGISTER_STACK
-@@ -628,9 +640,18 @@
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
- __pthread_sig_cancel, new_thread);
- #else
-+ /* Block all signals during thread creation to avoid new thread
-+ * overwriting thread manager stack.
-+ */
-+ sigset_t allblock_mask;
-+ sigset_t oldmask;
-+
-+ sigfillset(&allblock_mask);
-+ sigprocmask(SIG_SETMASK, &allblock_mask, &oldmask);
- pid = __clone(pthread_start_thread, (void **) new_thread,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
- __pthread_sig_cancel, new_thread);
-+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
- #endif /* !NEED_SEPARATE_REGISTER_STACK */
- }
- /* Check if cloning succeeded */
-@@ -738,6 +759,7 @@
- /* Mark thread as exited, and if detached, free its resources */
- __pthread_lock(th->p_lock, NULL);
- th->p_exited = 1;
-+#if 0
- /* If we have to signal this event do it now. */
- if (th->p_report_events)
- {
-@@ -757,6 +779,7 @@
- __linuxthreads_reap_event();
- }
- }
-+#endif
- detached = th->p_detached;
- __pthread_unlock(th->p_lock);
- if (detached)
-@@ -834,10 +857,20 @@
-
- /* Process-wide exit() */
-
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+extern int __pthread_exit_requested_bymainthread;
-+extern int __pthread_exit_alone;
-+#endif
-+
- static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
- {
- pthread_descr th;
- __pthread_exit_requested = 1;
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+ __pthread_exit_alone = 1;
-+ if (issuing_thread == __pthread_main_thread)
-+ __pthread_exit_requested_bymainthread = 1;
-+#endif
- __pthread_exit_code = exitcode;
- /* Send the CANCEL signal to all running threads, including the main
- thread, but excluding the thread from which the exit request originated
-@@ -846,6 +875,13 @@
- for (th = issuing_thread->p_nextlive;
- th != issuing_thread;
- th = th->p_nextlive) {
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+ /* Cancelled thread might have been in critical region unless terminated */
-+ if (th->p_terminated == 0) {
-+ __pthread_exit_alone = 0;
-+ __pthread_exit_code = 1;
-+ }
-+#endif
- kill(th->p_pid, __pthread_sig_cancel);
- }
- /* Now, wait for all these threads, so that they don't become zombies
-diff -ru ../../work/linuxthreads-2.2.3/ptfork.c ./ptfork.c
---- ../../work/linuxthreads-2.2.3/ptfork.c Sun Jan 7 04:35:20 2001
-+++ ./ptfork.c Thu Jun 7 22:59:29 2001
-@@ -84,7 +84,6 @@
-
- pthread_call_handlers(pthread_atfork_prepare);
- __pthread_once_fork_prepare();
-- __flockfilelist();
-
- pid = __libc_fork();
-
-@@ -97,7 +96,6 @@
-
- pthread_mutex_init(&pthread_atfork_lock, NULL);
- } else {
-- __funlockfilelist();
- __pthread_once_fork_parent();
- pthread_call_handlers(pthread_atfork_parent);
-
-diff -ru ../../work/linuxthreads-2.2.3/pthread.c ./pthread.c
---- ../../work/linuxthreads-2.2.3/pthread.c Wed Apr 25 21:50:59 2001
-+++ ./pthread.c Thu Jun 7 22:59:29 2001
-@@ -15,17 +15,19 @@
-
- /* Thread creation, initialization, and basic low-level routines */
-
-+#include <sys/types.h>
-+#include <sys/time.h>
- #include <errno.h>
- #include <stddef.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
-+#include <signal.h>
- #include <fcntl.h>
- #include <sys/wait.h>
- #include <sys/resource.h>
- #include <sys/sysctl.h>
--#include <shlib-compat.h>
- #include "pthread.h"
- #include "internals.h"
- #include "spinlock.h"
-@@ -43,7 +43,7 @@
- #endif
-
- /* These variables are used by the setup code. */
--extern int _errno;
-+extern int _errno __asm__("errno");
- extern int _h_errno;
-
- /* Descriptor of the initial thread */
-@@ -60,7 +60,7 @@
- NULL, /* pthread_descr p_nextlock */
- PTHREAD_THREADS_MAX, /* pthread_t p_tid */
- 0, /* int p_pid */
-- 0, /* int p_priority */
-+ DEFAULT_PRIORITY, /* int p_priority */
- &__pthread_handles[0].h_lock, /* struct _pthread_fastlock * p_lock */
- 0, /* int p_signal */
- NULL, /* sigjmp_buf * p_signal_buf */
-@@ -84,13 +84,18 @@
- PTHREAD_START_ARGS_INITIALIZER(NULL),
- /* struct pthread_start_args p_start_args */
- {NULL}, /* void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE] */
-+ {NULL, NULL}, /* TAILQ_ENTRY(_pthread_descr_struct) qe */
-+ {NULL}, /* char timebuf[26] */
-+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL}, /* struct tm local_tm */
- {NULL}, /* void * p_libc_specific[_LIBC_TSD_KEY_N] */
- 1, /* int p_userstack */
- NULL, /* void * p_guardaddr */
- 0, /* size_t p_guardsize */
- 0, /* Always index 0 */
-+#if 0
- 0, /* int p_report_events */
- {{{0, }}, 0, NULL}, /* td_eventbuf_t p_eventbuf */
-+#endif
- __ATOMIC_INITIALIZER, /* struct pthread_atomic p_resume_count */
- 0, /* char p_woken_by_cancel */
- 0, /* char p_condvar_avail */
-@@ -117,7 +122,7 @@
- NULL, /* pthread_descr p_nextlock */
- 0, /* int p_tid */
- 0, /* int p_pid */
-- 0, /* int p_priority */
-+ DEFAULT_PRIORITY, /* int p_priority */
- &__pthread_handles[1].h_lock, /* struct _pthread_fastlock * p_lock */
- 0, /* int p_signal */
- NULL, /* sigjmp_buf * p_signal_buf */
-@@ -141,13 +146,18 @@
- PTHREAD_START_ARGS_INITIALIZER(__pthread_manager),
- /* struct pthread_start_args p_start_args */
- {NULL}, /* void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE] */
-+ {NULL, NULL}, /* TAILQ_ENTRY(_pthread_descr_struct) qe */
-+ {NULL}, /* char timebuf[26] */
-+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL}, /* struct tm local_tm */
- {NULL}, /* void * p_libc_specific[_LIBC_TSD_KEY_N] */
- 0, /* int p_userstack */
- NULL, /* void * p_guardaddr */
- 0, /* size_t p_guardsize */
- 1, /* Always index 1 */
-+#if 0
- 0, /* int p_report_events */
- {{{0, }}, 0, NULL}, /* td_eventbuf_t p_eventbuf */
-+#endif
- __ATOMIC_INITIALIZER, /* struct pthread_atomic p_resume_count */
- 0, /* char p_woken_by_cancel */
- 0, /* char p_condvar_avail */
-@@ -185,6 +195,10 @@
- /* For process-wide exit() */
-
- int __pthread_exit_requested;
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+int __pthread_exit_requested_bymainthread = 0;
-+int __pthread_exit_alone = 1;
-+#endif
- int __pthread_exit_code;
-
- /* Maximum stack size. */
-@@ -216,11 +228,7 @@
-
- /* Forward declarations */
-
--static void pthread_onexit_process(int retcode, void *arg);
--#ifndef HAVE_Z_NODELETE
--static void pthread_atexit_process(void *arg, int retcode);
--static void pthread_atexit_retcode(void *arg, int retcode);
--#endif
-+static void pthread_onexit_process(void);
- static void pthread_handle_sigcancel(int sig);
- static void pthread_handle_sigrestart(int sig);
- static void pthread_handle_sigdebug(int sig);
-@@ -238,8 +246,12 @@
- #ifndef __SIGRTMIN
- static int current_rtmin = -1;
- static int current_rtmax = -1;
--int __pthread_sig_restart = SIGUSR1;
--int __pthread_sig_cancel = SIGUSR2;
-+#ifdef LINUXTHREADS_ALT_RESTARTSIG
-+int __pthread_sig_restart = LINUXTHREADS_ALT_RESTARTSIG;
-+#else
-+int __pthread_sig_restart = SIGUSR2;
-+#endif
-+int __pthread_sig_cancel = SIGUSR1;
- int __pthread_sig_debug;
- #else
- static int current_rtmin;
-@@ -250,8 +258,8 @@
- int __pthread_sig_cancel = __SIGRTMIN + 1;
- int __pthread_sig_debug = __SIGRTMIN + 2;
- #else
--int __pthread_sig_restart = SIGUSR1;
--int __pthread_sig_cancel = SIGUSR2;
-+int __pthread_sig_restart = SIGUSR2;
-+int __pthread_sig_cancel = SIGUSR1;
- int __pthread_sig_debug;
- #endif
-
-@@ -348,26 +356,17 @@
- static int
- is_smp_system (void)
- {
-- static const int sysctl_args[] = { CTL_KERN, KERN_VERSION };
-- char buf[512];
-+ static const int sysctl_args[] = { CTL_HW, HW_NCPU };
-+ int buf;
- size_t reslen = sizeof (buf);
-
-- /* Try reading the number using `sysctl' first. */
-- if (__sysctl ((int *) sysctl_args,
-- sizeof (sysctl_args) / sizeof (sysctl_args[0]),
-- buf, &reslen, NULL, 0) < 0)
-- {
-- /* This was not successful. Now try reading the /proc filesystem. */
-- int fd = __open ("/proc/sys/kernel/version", O_RDONLY);
-- if (__builtin_expect (fd, 0) == -1
-- || (reslen = __read (fd, buf, sizeof (buf))) <= 0)
-- /* This also didn't work. We give up and say it's a UP machine. */
-- buf[0] = '\0';
--
-- __close (fd);
-- }
--
-- return strstr (buf, "SMP") != NULL;
-+ buf = 1;
-+ if (sysctl ((int *) sysctl_args,
-+ sizeof (sysctl_args) / sizeof (sysctl_args[0]),
-+ &buf, &reslen, NULL, 0) < 0)
-+ return 0;
-+
-+ return buf > 1;
- }
-
-
-@@ -448,13 +447,7 @@
- /* Register an exit function to kill all other threads. */
- /* Do it early so that user-registered atexit functions are called
- before pthread_*exit_process. */
--#ifndef HAVE_Z_NODELETE
-- if (__builtin_expect (&__dso_handle != NULL, 1))
-- __cxa_atexit ((void (*) (void *)) pthread_atexit_process, NULL,
-- __dso_handle);
-- else
--#endif
-- __on_exit (pthread_onexit_process, NULL);
-+ atexit(pthread_onexit_process);
- /* How many processors. */
- __pthread_smp_kernel = is_smp_system ();
- }
-@@ -502,12 +495,6 @@
- int pid;
- struct pthread_request request;
-
--#ifndef HAVE_Z_NODELETE
-- if (__builtin_expect (&__dso_handle != NULL, 1))
-- __cxa_atexit ((void (*) (void *)) pthread_atexit_retcode, NULL,
-- __dso_handle);
--#endif
--
- if (__pthread_max_stacksize == 0)
- __pthread_init_max_stacksize ();
- /* If basic initialization not done yet (e.g. we're called from a
-@@ -525,6 +512,7 @@
- }
- /* Start the thread manager */
- pid = 0;
-+#if 0
- if (__builtin_expect (__pthread_initial_thread.p_report_events, 0))
- {
- /* It's a bit more complicated. We have to report the creation of
-@@ -572,17 +560,20 @@
- __pthread_unlock(__pthread_manager_thread.p_lock);
- }
- }
-+#endif
-
- if (__builtin_expect (pid, 0) == 0)
- {
- #ifdef NEED_SEPARATE_REGISTER_STACK
- pid = __clone2(__pthread_manager, (void **) __pthread_manager_thread_bos,
- THREAD_MANAGER_STACK_SIZE,
-- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
-+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
-+ __pthread_sig_cancel,
- (void *)(long)manager_pipe[0]);
- #else
- pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_tos,
-- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
-+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
-+ __pthread_sig_cancel,
- (void *)(long)manager_pipe[0]);
- #endif
- }
-@@ -715,7 +706,7 @@
- __pthread_unlock(&handle->h_lock);
- return errno;
- }
-- th->p_priority = policy == SCHED_OTHER ? 0 : param->sched_priority;
-+ th->p_priority = param->sched_priority;
- __pthread_unlock(&handle->h_lock);
- if (__pthread_manager_request >= 0)
- __pthread_manager_adjust_prio(th->p_priority);
-@@ -751,7 +742,7 @@
-
- /* Process-wide exit() request */
-
--static void pthread_onexit_process(int retcode, void *arg)
-+static void pthread_onexit_process(void)
- {
- if (__builtin_expect (__pthread_manager_request, 0) >= 0) {
- struct pthread_request request;
-@@ -759,7 +750,7 @@
-
- request.req_thread = self;
- request.req_kind = REQ_PROCESS_EXIT;
-- request.req_args.exit.code = retcode;
-+ request.req_args.exit.code = 0;
- __libc_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- suspend(self);
-@@ -768,25 +759,34 @@
- if (self == __pthread_main_thread)
- {
- waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+ /*
-+ * If other threads have been canceled then proper cleanup
-+ * cannot be performed since a canceled thread might have
-+ * been inside a critical region of code with a spinlock
-+ * held, a system mutex held, or a mutex partially held.
-+ */
-+ if (__pthread_exit_alone == 0)
-+ _exit(1);
-+#endif
- free (__pthread_manager_thread_bos);
- __pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
- }
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+ /*
-+ * If other threads have been canceled then proper cleanup
-+ * cannot be performed since a canceled thread might have
-+ * been inside a critical region of code with a spinlock
-+ * held, a system mutex held, or a mutex partially held.
-+ */
-+ if (__pthread_exit_alone == 0) {
-+ __pthread_exit_code = 1;
-+ _exit(1);
-+ }
-+#endif
- }
- }
-
--#ifndef HAVE_Z_NODELETE
--static int __pthread_atexit_retcode;
--
--static void pthread_atexit_process(void *arg, int retcode)
--{
-- pthread_onexit_process (retcode ?: __pthread_atexit_retcode, arg);
--}
--
--static void pthread_atexit_retcode(void *arg, int retcode)
--{
-- __pthread_atexit_retcode = retcode;
--}
--#endif
-
- /* The handler for the RESTART signal just records the signal received
- in the thread descriptor, and optionally performs a siglongjmp
-@@ -818,6 +812,11 @@
- if (__builtin_expect (__pthread_exit_requested, 0)) {
- /* Main thread should accumulate times for thread manager and its
- children, so that timings for main thread account for all threads. */
-+#ifdef LINUXTHREADS_DETECT_UNSAFE_EXIT
-+ if (self == __pthread_main_thread &&
-+ __pthread_exit_requested_bymainthread != 0)
-+ return;
-+#endif
- if (self == __pthread_main_thread)
- waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
- _exit(__pthread_exit_code);
-@@ -894,7 +891,7 @@
- {
- struct sigaction sa;
- /* Terminate all other threads and thread manager */
-- pthread_onexit_process(0, NULL);
-+ pthread_onexit_process();
- /* Make current thread the main thread in case the calling thread
- changes its mind, does not exec(), and creates new threads instead. */
- __pthread_reset_main_thread();
-@@ -967,7 +964,7 @@
- __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
- {
- sigset_t unblock, initial_mask;
-- int was_signalled = 0;
-+ int was_signalled = 1;
- sigjmp_buf jmpbuf;
-
- if (atomic_decrement(&self->p_resume_count) == 0) {
-@@ -1131,3 +1128,17 @@
- static const int *const __pthread_require_wrappers =
- &__pthread_provide_wrappers;
- #endif
-+
-+/* Force our version of uthreads stub functions to be linked in */
-+extern int _pthread_mutex_init(pthread_mutex_t **mutex, const pthread_mutexattr_t *mattr);
-+static int (*unusedref)(pthread_mutex_t **mutex, const pthread_mutexattr_t *mattr) __attribute__ ((unused)) = _pthread_mutex_init;
-+
-+extern void _flockfile(FILE *fp);
-+static void (*unusedref2)(FILE *fp) __attribute__ ((unused)) = _flockfile;
-+
-+extern int *__error(void);
-+static int *(*unusedref3)(void) __attribute__ ((unused)) = __error;
-+
-+static
-+struct tm *(*unusedref4)(const time_t *) __attribute__ ((unused)) = localtime;
-+
-diff -ru ../../work/linuxthreads-2.2.3/ptlongjmp.c ./ptlongjmp.c
---- ../../work/linuxthreads-2.2.3/ptlongjmp.c Thu Apr 12 21:02:02 2001
-+++ ./ptlongjmp.c Thu Jun 7 22:59:29 2001
-@@ -18,14 +18,15 @@
- #include <setjmp.h>
- #include "pthread.h"
- #include "internals.h"
--#include <stackinfo.h>
-
-+#if 0
- /* These functions are not declared anywhere since they shouldn't be
- used at another place but here. */
- extern void __libc_siglongjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
- extern void __libc_longjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
-+#endif
-
-
- static void pthread_cleanup_upto(__jmp_buf target)
-@@ -63,12 +64,12 @@
-
- void siglongjmp(sigjmp_buf env, int val)
- {
-- pthread_cleanup_upto(env->__jmpbuf);
-+ pthread_cleanup_upto((void *) env);
- __libc_siglongjmp(env, val);
- }
-
- void longjmp(jmp_buf env, int val)
- {
-- pthread_cleanup_upto(env->__jmpbuf);
-+ pthread_cleanup_upto((void *) env);
- __libc_longjmp(env, val);
- }
-diff -ru ../../work/linuxthreads-2.2.3/restart.h ./restart.h
---- ../../work/linuxthreads-2.2.3/restart.h Mon Apr 17 17:18:55 2000
-+++ ./restart.h Thu Jun 7 22:59:29 2001
-@@ -13,7 +13,6 @@
- /* GNU Library General Public License for more details. */
-
- #include <signal.h>
--#include <kernel-features.h>
-
- /* Primitives for controlling thread execution */
-
-diff -ru ../../work/linuxthreads-2.2.3/semaphore.c ./semaphore.c
---- ../../work/linuxthreads-2.2.3/semaphore.c Thu Apr 12 21:02:02 2001
-+++ ./semaphore.c Thu Jun 7 22:59:29 2001
-@@ -21,7 +21,6 @@
- #include "spinlock.h"
- #include "restart.h"
- #include "queue.h"
--#include <shlib-compat.h>
-
- int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
- {
-diff -ru ../../work/linuxthreads-2.2.3/semaphore.h ./semaphore.h
---- ../../work/linuxthreads-2.2.3/semaphore.h Fri Feb 9 18:04:08 2001
-+++ ./semaphore.h Thu Jun 7 22:59:29 2001
-@@ -15,7 +15,6 @@
- #ifndef _SEMAPHORE_H
- #define _SEMAPHORE_H 1
-
--#include <features.h>
- #include <sys/types.h>
- #ifdef __USE_XOPEN2K
- # define __need_timespec
-diff -ru ../../work/linuxthreads-2.2.3/signals.c ./signals.c
---- ../../work/linuxthreads-2.2.3/signals.c Tue Apr 17 15:17:16 2001
-+++ ./signals.c Thu Jun 7 22:59:29 2001
-@@ -20,7 +20,6 @@
- #include "internals.h"
- #include "spinlock.h"
- #include <ucontext.h>
--#include <sigcontextinfo.h>
-
- int pthread_sigmask(int how, const sigset_t * newmask, sigset_t * oldmask)
- {
-@@ -69,15 +68,15 @@
- }
-
- /* User-provided signal handlers */
--typedef void (*arch_sighandler_t) (int, SIGCONTEXT);
-+typedef void (*arch_sighandler_t) (int, int, SIGCONTEXT);
- static union
- {
- arch_sighandler_t old;
-- void (*rt) (int, struct siginfo *, struct ucontext *);
-+ void (*rt) (int, siginfo_t *, ucontext_t *);
- } sighandler[NSIG];
-
- /* The wrapper around user-provided signal handlers */
--static void pthread_sighandler(int signo, SIGCONTEXT ctx)
-+static void pthread_sighandler(int signo, int code, SIGCONTEXT ctx)
- {
- pthread_descr self;
- char * in_sighandler;
-@@ -94,14 +93,14 @@
- in_sighandler = THREAD_GETMEM(self, p_in_sighandler);
- if (in_sighandler == NULL)
- THREAD_SETMEM(self, p_in_sighandler, CURRENT_STACK_FRAME);
-- CALL_SIGHANDLER(sighandler[signo].old, signo, ctx);
-+ sighandler[signo].old(signo, code, ctx);
- if (in_sighandler == NULL)
- THREAD_SETMEM(self, p_in_sighandler, NULL);
- }
-
- /* The same, this time for real-time signals. */
--static void pthread_sighandler_rt(int signo, struct siginfo *si,
-- struct ucontext *uc)
-+static void pthread_sighandler_rt(int signo, siginfo_t *si,
-+ ucontext_t *uc)
- {
- pthread_descr self;
- char * in_sighandler;
-@@ -130,6 +129,7 @@
- {
- struct sigaction newact;
- struct sigaction *newactp;
-+ arch_sighandler_t user_oact;
-
- if (sig == __pthread_sig_restart ||
- sig == __pthread_sig_cancel ||
-@@ -145,20 +145,34 @@
- && sig > 0 && sig < NSIG)
- {
- if (act->sa_flags & SA_SIGINFO)
-- newact.sa_handler = (__sighandler_t) pthread_sighandler_rt;
-+ newact.sa_handler = (__sighandler_t *) pthread_sighandler_rt;
- else
-- newact.sa_handler = (__sighandler_t) pthread_sighandler;
-+ newact.sa_handler = (__sighandler_t *) pthread_sighandler;
- }
- newactp = &newact;
- }
- else
- newactp = NULL;
-+ if (sig > 0 && sig < NSIG)
-+ {
-+ user_oact = sighandler[sig].old;
-+ if (act &&
-+ ((__sighandler_t *) user_oact == SIG_IGN ||
-+ (__sighandler_t *) user_oact == SIG_DFL))
-+ /* For the assignment is does not matter whether it's a normal
-+ or real-time signal. */
-+ sighandler[sig].old = (arch_sighandler_t) act->sa_handler;
-+ }
- if (__libc_sigaction(sig, newactp, oact) == -1)
-- return -1;
-+ {
-+ if (act && sig > 0 && sig < NSIG)
-+ sighandler[sig].old = user_oact;
-+ return -1;
-+ }
- if (sig > 0 && sig < NSIG)
- {
- if (oact != NULL)
-- oact->sa_handler = (__sighandler_t) sighandler[sig].old;
-+ oact->sa_handler = (__sighandler_t *) user_oact;
- if (act)
- /* For the assignment is does not matter whether it's a normal
- or real-time signal. */
-diff -ru ../../work/linuxthreads-2.2.3/spinlock.c ./spinlock.c
---- ../../work/linuxthreads-2.2.3/spinlock.c Tue Mar 27 04:52:56 2001
-+++ ./spinlock.c Thu Jun 7 22:59:29 2001
-@@ -24,10 +24,6 @@
- #include "spinlock.h"
- #include "restart.h"
-
--#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
--static void __pthread_acquire(int * spinlock);
--#endif
--
-
- /* The status field of a spinlock is a pointer whose least significant
- bit is a locked flag.
-@@ -701,7 +697,7 @@
- - When nanosleep() returns, we try again, doing MAX_SPIN_COUNT
- sched_yield(), then sleeping again if needed. */
-
--static void __pthread_acquire(int * spinlock)
-+void __pthread_acquire(int * spinlock)
- {
- int cnt = 0;
- struct timespec tm;
-diff -ru ../../work/linuxthreads-2.2.3/spinlock.h ./spinlock.h
---- ../../work/linuxthreads-2.2.3/spinlock.h Fri Feb 9 18:04:08 2001
-+++ ./spinlock.h Thu Jun 7 22:59:29 2001
-@@ -180,6 +180,8 @@
- #endif
- }
-
-+void __pthread_acquire(int * spinlock);
-+
- /* Operations on pthread_atomic, which is defined in internals.h */
-
- static inline long atomic_increment(struct pthread_atomic *pa)
-diff -ru ../../work/linuxthreads-2.2.3/sysdeps/pthread/bits/pthreadtypes.h ./sysdeps/pthread/bits/pthreadtypes.h
---- ../../work/linuxthreads-2.2.3/sysdeps/pthread/bits/pthreadtypes.h Fri Feb 9 18:04:09 2001
-+++ ./sysdeps/pthread/bits/pthreadtypes.h Thu Jun 7 22:59:29 2001
-@@ -20,7 +20,6 @@
- #define _BITS_PTHREADTYPES_H 1
-
- #define __need_schedparam
--#include <bits/sched.h>
-
- /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
- struct _pthread_fastlock
-@@ -42,7 +41,7 @@
- {
- int __detachstate;
- int __schedpolicy;
-- struct __sched_param __schedparam;
-+ struct sched_param __schedparam;
- int __inheritsched;
- int __scope;
- size_t __guardsize;
-diff -ru ../../work/linuxthreads-2.2.3/sysdeps/pthread/pthread.h ./sysdeps/pthread/pthread.h
---- ../../work/linuxthreads-2.2.3/sysdeps/pthread/pthread.h Tue Mar 27 04:52:56 2001
-+++ ./sysdeps/pthread/pthread.h Thu Jun 7 22:59:29 2001
-@@ -15,7 +15,9 @@
- #ifndef _PTHREAD_H
- #define _PTHREAD_H 1
-
--#include <features.h>
-+#ifndef __THROW
-+#define __THROW
-+#endif
-
- #include <sched.h>
- #include <time.h>
-@@ -160,7 +162,7 @@
- /* Create a thread with given attributes ATTR (or default attributes
- if ATTR is NULL), and call function START_ROUTINE with given
- arguments ARG. */
--extern int pthread_create (pthread_t *__restrict __thread,
-+extern int pthread_create (pthread_t *__restrict __xthread,
- __const pthread_attr_t *__restrict __attr,
- void *(*__start_routine) (void *),
- void *__restrict __arg) __THROW;
-@@ -588,7 +590,7 @@
- extern int pthread_setcanceltype (int __type, int *__oldtype) __THROW;
-
- /* Cancel THREAD immediately or at the next possibility. */
--extern int pthread_cancel (pthread_t __thread) __THROW;
-+extern int pthread_cancel (pthread_t __xthread) __THROW;
-
- /* Test for pending cancellation for the current thread and terminate
- the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
-diff -ru ../../work/linuxthreads-2.2.3/sysdeps/unix/sysv/linux/bits/local_lim.h ./sysdeps/unix/sysv/linux/bits/local_lim.h
---- ../../work/linuxthreads-2.2.3/sysdeps/unix/sysv/linux/bits/local_lim.h Fri Jun 9 19:17:35 2000
-+++ ./sysdeps/unix/sysv/linux/bits/local_lim.h Thu Jun 7 22:59:29 2001
-@@ -33,7 +33,7 @@
- #endif
-
- /* The kernel sources contain a file with all the needed information. */
--#include <linux/limits.h>
-+#include <limits.h>
-
- /* Have to remove NR_OPEN? */
- #ifdef __undef_NR_OPEN
-@@ -64,7 +64,9 @@
- /* The number of threads per process. */
- #define _POSIX_THREAD_THREADS_MAX 64
- /* This is the value this implementation supports. */
-+#ifndef PTHREAD_THREADS_MAX
- #define PTHREAD_THREADS_MAX 1024
-+#endif
-
- /* Maximum amount by which a process can descrease its asynchronous I/O
- priority level. */
-diff -ru ../../work/linuxthreads-2.2.3/sysdeps/unix/sysv/linux/bits/sigthread.h ./sysdeps/unix/sysv/linux/bits/sigthread.h
---- ../../work/linuxthreads-2.2.3/sysdeps/unix/sysv/linux/bits/sigthread.h Thu Aug 31 21:45:04 2000
-+++ ./sysdeps/unix/sysv/linux/bits/sigthread.h Thu Jun 7 22:59:29 2001
-@@ -29,10 +29,10 @@
- /* Modify the signal mask for the calling thread. The arguments have
- the same meaning as for sigprocmask(2). */
- extern int pthread_sigmask (int __how,
-- __const __sigset_t *__restrict __newmask,
-- __sigset_t *__restrict __oldmask)__THROW;
-+ __const sigset_t *__restrict __newmask,
-+ sigset_t *__restrict __oldmask)__THROW;
-
- /* Send signal SIGNO to the given thread. */
--extern int pthread_kill (pthread_t __thread, int __signo) __THROW;
-+extern int pthread_kill (pthread_t __xthread, int __signo) __THROW;
-
- #endif /* bits/sigthread.h */
-diff -ru ../../work/linuxthreads-2.2.3/wrapsyscall.c ./wrapsyscall.c
---- ../../work/linuxthreads-2.2.3/wrapsyscall.c Wed Apr 25 21:50:59 2001
-+++ ./wrapsyscall.c Thu Jun 7 22:59:29 2001
-@@ -18,6 +18,8 @@
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-+#include <sys/types.h>
-+#include <sys/time.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <pthread.h>
-@@ -29,6 +29,7 @@
- #include <sys/resource.h>
- #include <sys/wait.h>
- #include <sys/socket.h>
-+#include "internals.h"
-
-
- #ifndef SHARED
-@@ -85,15 +86,19 @@
- CANCELABLE_SYSCALL (int, fsync, (int fd), (fd))
-
-
-+#if 0
- /* lseek(2). */
- CANCELABLE_SYSCALL (off_t, lseek, (int fd, off_t offset, int whence),
- (fd, offset, whence))
- strong_alias (lseek, __lseek)
-+#endif
-
-
-+#if 0
- /* lseek64(2). */
- CANCELABLE_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence),
- (fd, offset, whence))
-+#endif
-
-
- /* msync(2). */
-@@ -109,44 +114,54 @@
-
- /* open(2). */
- CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...),
-- (pathname, flags, va_arg (ap, mode_t)), flags)
-+ (pathname, flags, va_arg (ap, int)), flags)
- strong_alias (open, __open)
-
-
-+#if 0
- /* open64(3). */
- CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...),
- (pathname, flags, va_arg (ap, mode_t)), flags)
- strong_alias (open64, __open64)
-+#endif
-
-
- /* pause(2). */
- CANCELABLE_SYSCALL (int, pause, (void), ())
-
-
-+#if 0
- /* pread(3). */
- CANCELABLE_SYSCALL (ssize_t, pread, (int fd, void *buf, size_t count,
- off_t offset),
- (fd, buf, count, offset))
-+#endif
-
-
-+#if 0
- /* pread64(3). */
- CANCELABLE_SYSCALL (ssize_t, pread64, (int fd, void *buf, size_t count,
- off64_t offset),
- (fd, buf, count, offset))
- strong_alias (pread64, __pread64)
-+#endif
-
-
-+#if 0
- /* pwrite(3). */
- CANCELABLE_SYSCALL (ssize_t, pwrite, (int fd, const void *buf, size_t n,
- off_t offset),
- (fd, buf, n, offset))
-+#endif
-
-
-+#if 0
- /* pwrite64(3). */
- CANCELABLE_SYSCALL (ssize_t, pwrite64, (int fd, const void *buf, size_t n,
- off64_t offset),
- (fd, buf, n, offset))
- strong_alias (pwrite64, __pwrite64)
-+#endif
-
-
- /* read(2). */
-@@ -165,7 +180,9 @@
-
- /* wait(2). */
- CANCELABLE_SYSCALL (__pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc))
-+#if 0
- strong_alias (wait, __wait)
-+#endif
-
-
- /* waitpid(2). */
-@@ -194,9 +211,11 @@
- (fd, addr, len))
- strong_alias (connect, __connect)
-
-+#if 0
- /* recv(2). */
- CANCELABLE_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags),
- (fd, buf, n, flags))
-+#endif
-
- /* recvfrom(2). */
- CANCELABLE_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags,
-@@ -207,11 +226,13 @@
- CANCELABLE_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags),
- (fd, message, flags))
-
-+#if 0
- /* send(2). */
- CANCELABLE_SYSCALL (ssize_t, send, (int fd, const __ptr_t buf, size_t n,
- int flags),
- (fd, buf, n, flags))
- strong_alias (send, __send)
-+#endif
-
- /* sendmsg(2). */
- CANCELABLE_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message,
diff --git a/devel/linuxthreads/files/patch-barrier b/devel/linuxthreads/files/patch-barrier
deleted file mode 100644
index f60402d634c0..000000000000
--- a/devel/linuxthreads/files/patch-barrier
+++ /dev/null
@@ -1,21 +0,0 @@
---- internals.h.orig Tue May 16 00:23:50 2006
-+++ internals.h Tue May 16 00:24:21 2006
-@@ -395,12 +395,14 @@
- #endif
- }
-
--/* If MEMORY_BARRIER isn't defined in pt-machine.h, assume the architecture
-- doesn't need a memory barrier instruction (e.g. Intel x86). Some
-- architectures distinguish between full, read and write barriers. */
-+/* If MEMORY_BARRIER isn't defined in pt-machine.h, assume the
-+ architecture doesn't need a memory barrier instruction (e.g. Intel
-+ x86). Still we need the compiler to respect the barrier and emit
-+ all outstanding operations which modify memory. Some architectures
-+ distinguish between full, read and write barriers. */
-
- #ifndef MEMORY_BARRIER
--#define MEMORY_BARRIER()
-+#define MEMORY_BARRIER() asm ("" : : : "memory")
- #endif
- #ifndef READ_MEMORY_BARRIER
- #define READ_MEMORY_BARRIER() MEMORY_BARRIER()
diff --git a/devel/linuxthreads/files/patch-intrpipe b/devel/linuxthreads/files/patch-intrpipe
deleted file mode 100644
index 583c2d61fb70..000000000000
--- a/devel/linuxthreads/files/patch-intrpipe
+++ /dev/null
@@ -1,149 +0,0 @@
-diff -ru ../../work.PRE4/linuxthreads-2.2.3_21/freebsd-compat.h ./freebsd-compat.h
---- ../../work.PRE4/linuxthreads-2.2.3_21/freebsd-compat.h Sat Jun 8 20:18:05 2002
-+++ ./freebsd-compat.h Mon Mar 19 22:31:38 2007
-@@ -4,6 +4,7 @@
- #include <sched.h>
- #include <sys/types.h>
- #include <sys/time.h>
-+#include <sys/errno.h>
-
-
- #if __FreeBSD__ >= 5
-@@ -77,6 +78,26 @@
-
- ssize_t __libc_write(int, const void *, size_t);
- ssize_t __libc_read(int, void *, size_t);
-+static inline ssize_t
-+__libc_safe_write(int fd, const void *buf, size_t wsize)
-+{
-+ ssize_t written;
-+
-+ do {
-+ written = __libc_write(fd, buf, wsize);
-+ } while (written < 0 && errno == EINTR);
-+ return (written);
-+}
-+static inline ssize_t
-+__libc_safe_read(int fd, void *buf, size_t rsize)
-+{
-+ ssize_t got;
-+
-+ do {
-+ got = __libc_read(fd, buf, rsize);
-+ } while (got < 0 && errno == EINTR);
-+ return (got);
-+}
- pid_t __libc_waitpid(pid_t wpid, int *status, int options);
- int __libc_poll(struct pollfd *_pfd, unsigned int _nfsd, int _timeout);
- pid_t __libc_getpid(void);
-diff -ru ../../work.PRE4/linuxthreads-2.2.3_21/join.c ./join.c
---- ../../work.PRE4/linuxthreads-2.2.3_21/join.c Mon Mar 19 22:29:45 2007
-+++ ./join.c Mon Mar 19 22:33:43 2007
-@@ -79,7 +79,7 @@
- if (self == __pthread_main_thread && __pthread_manager_request >= 0) {
- request.req_thread = self;
- request.req_kind = REQ_MAIN_THREAD_EXIT;
-- __libc_write(__pthread_manager_request, (char *)&request, sizeof(request));
-+ __libc_safe_write(__pthread_manager_request, (char *)&request, sizeof(request));
- suspend(self);
- /* Main thread flushes stdio streams and runs atexit functions.
- It also calls a handler within LinuxThreads which sends a process exit
-@@ -174,7 +174,7 @@
- request.req_thread = self;
- request.req_kind = REQ_FREE;
- request.req_args.free.thread_id = thread_id;
-- __libc_write(__pthread_manager_request,
-+ __libc_safe_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- }
- return 0;
-@@ -212,7 +212,7 @@
- request.req_thread = thread_self();
- request.req_kind = REQ_FREE;
- request.req_args.free.thread_id = thread_id;
-- __libc_write(__pthread_manager_request,
-+ __libc_safe_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- }
- return 0;
-diff -ru ../../work.PRE4/linuxthreads-2.2.3_21/manager.c ./manager.c
---- ../../work.PRE4/linuxthreads-2.2.3_21/manager.c Mon Mar 19 22:29:45 2007
-+++ ./manager.c Mon Mar 19 22:33:49 2007
-@@ -132,7 +132,7 @@
- /* Raise our priority to match that of main thread */
- __pthread_manager_adjust_prio(__pthread_main_thread->p_priority);
- /* Synchronize debugging of the thread manager */
-- n = __libc_read(reqfd, (char *)&request, sizeof(request));
-+ n = __libc_safe_read(reqfd, (char *)&request, sizeof(request));
- ASSERT(n == sizeof(request) && request.req_kind == REQ_DEBUG);
- ufd.fd = reqfd;
- ufd.events = POLLIN;
-@@ -152,7 +152,7 @@
- }
- /* Read and execute request */
- if (n == 1 && (ufd.revents & POLLIN)) {
-- n = __libc_read(reqfd, (char *)&request, sizeof(request));
-+ n = __libc_safe_read(reqfd, (char *)&request, sizeof(request));
- ASSERT(n == sizeof(request));
- switch(request.req_kind) {
- case REQ_CREATE:
-@@ -268,7 +268,7 @@
- if (__pthread_threads_debug && __pthread_sig_debug > 0) {
- request.req_thread = self;
- request.req_kind = REQ_DEBUG;
-- __libc_write(__pthread_manager_request,
-+ __libc_safe_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- suspend(self);
- }
-@@ -917,7 +917,7 @@
- struct pthread_request request;
- request.req_thread = 0;
- request.req_kind = REQ_KICK;
-- __libc_write(__pthread_manager_request, (char *) &request, sizeof(request));
-+ __libc_safe_write(__pthread_manager_request, (char *) &request, sizeof(request));
- }
- }
-
-diff -ru ../../work.PRE4/linuxthreads-2.2.3_21/pthread.c ./pthread.c
---- ../../work.PRE4/linuxthreads-2.2.3_21/pthread.c Mon Mar 19 22:29:45 2007
-+++ ./pthread.c Mon Mar 19 22:34:57 2007
-@@ -605,7 +605,7 @@
- }
- /* Synchronize debugging of the thread manager */
- request.req_kind = REQ_DEBUG;
-- __libc_write(__pthread_manager_request, (char *) &request, sizeof(request));
-+ __libc_safe_write(__pthread_manager_request, (char *) &request, sizeof(request));
- return 0;
- }
-
-@@ -627,7 +627,7 @@
- request.req_args.create.arg = arg;
- sigprocmask(SIG_SETMASK, (const sigset_t *) NULL,
- &request.req_args.create.mask);
-- __libc_write(__pthread_manager_request, (char *) &request, sizeof(request));
-+ __libc_safe_write(__pthread_manager_request, (char *) &request, sizeof(request));
- suspend(self);
- retval = THREAD_GETMEM(self, p_retcode);
- if (__builtin_expect (retval, 0) == 0)
-@@ -759,7 +759,7 @@
- request.req_thread = self;
- request.req_kind = REQ_PROCESS_EXIT;
- request.req_args.exit.code = 0;
-- __libc_write(__pthread_manager_request,
-+ __libc_safe_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- suspend(self);
- /* Main thread should accumulate times for thread manager and its
-diff -ru ../../work.PRE4/linuxthreads-2.2.3_21/semaphore.c ./semaphore.c
---- ../../work.PRE4/linuxthreads-2.2.3_21/semaphore.c Mon Mar 19 22:29:45 2007
-+++ ./semaphore.c Mon Mar 19 22:34:21 2007
-@@ -167,7 +167,7 @@
- }
- request.req_kind = REQ_POST;
- request.req_args.post = sem;
-- __libc_write(__pthread_manager_request,
-+ __libc_safe_write(__pthread_manager_request,
- (char *) &request, sizeof(request));
- }
- return 0;
diff --git a/devel/linuxthreads/files/patch-spinlock.c b/devel/linuxthreads/files/patch-spinlock.c
deleted file mode 100644
index 56e74ed9530d..000000000000
--- a/devel/linuxthreads/files/patch-spinlock.c
+++ /dev/null
@@ -1,59 +0,0 @@
---- spinlock.c.orig Tue Mar 27 04:52:56 2001
-+++ spinlock.c Tue Jan 10 09:44:39 2006
-@@ -72,8 +72,6 @@
- #endif
-
- #if defined HAS_COMPARE_AND_SWAP
--again:
--
- /* On SMP, try spinning to get the lock. */
-
- if (__pthread_smp_kernel) {
-@@ -94,6 +92,8 @@
- lock->__spinlock += (spin_count - lock->__spinlock) / 8;
- }
-
-+again:
-+
- /* No luck, try once more or suspend. */
-
- do {
-@@ -110,7 +110,7 @@
- }
-
- if (self != NULL) {
-- THREAD_SETMEM(self, p_nextlock, (pthread_descr) (oldstatus & ~1L));
-+ THREAD_SETMEM(self, p_nextlock, (pthread_descr) oldstatus);
- /* Make sure the store in p_nextlock completes before performing
- the compare-and-swap */
- MEMORY_BARRIER();
-@@ -188,7 +188,7 @@
- multiprocessor Alphas) could perform such reordering even though
- the loads are dependent. */
- READ_MEMORY_BARRIER();
-- thr = *ptr;
-+ thr = (pthread_descr)((long)(thr->p_nextlock) & ~1L);
- }
- /* Prevent reordering of the load of lock->__status above and
- thr->p_nextlock below */
-@@ -198,17 +198,16 @@
- /* If max prio thread is at head, remove it with compare-and-swap
- to guard against concurrent lock operation. This removal
- also has the side effect of marking the lock as released
-- because the new status comes from thr->p_nextlock whose
-- least significant bit is clear. */
-+ by clearing the least significant bit. */
- thr = (pthread_descr) (oldstatus & ~1L);
- if (! __compare_and_swap_with_release_semantics
-- (&lock->__status, oldstatus, (long)(thr->p_nextlock)))
-+ (&lock->__status, oldstatus, (long)(thr->p_nextlock) & ~1L))
- goto again;
- } else {
- /* No risk of concurrent access, remove max prio thread normally.
- But in this case we must also flip the least significant bit
- of the status to mark the lock as released. */
-- thr = *maxptr;
-+ thr = (pthread_descr)((long)*maxptr & ~1L);
- *maxptr = thr->p_nextlock;
-
- do {
diff --git a/devel/linuxthreads/files/sched.c b/devel/linuxthreads/files/sched.c
deleted file mode 100644
index bd543fd65789..000000000000
--- a/devel/linuxthreads/files/sched.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Extensively modified and added to by Richard Seaman, Jr. <dick@tar.com>
- *
- */
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
-#include <errno.h>
-#include "pthread.h"
-#include "internals.h"
-
-int _sched_yield(void);
-int _sched_setparam(pid_t pid, const struct sched_param *param);
-int _sched_getparam(pid_t pid, struct sched_param *param);
-int _sched_setscheduler(pid_t pid, int policy,
- const struct sched_param *param);
-int _sched_getscheduler(pid_t pid);
-int _sched_get_priority_max(int policy);
-int _sched_get_priority_min(int policy);
-int _sched_rr_get_interval(pid_t pid, struct timespec *interval);
-
-int __sched_setparam(pid_t pid, const struct sched_param *param);
-int __sched_setscheduler(pid_t pid, int policy,
- const struct sched_param *param);
-int __sched_getscheduler(pid_t pid);
-int __sched_get_priority_max(int policy);
-int __sched_get_priority_min(int policy);
-int __sched_getparam(pid_t pid, struct sched_param *param);
-int __sched_rr_get_interval(pid_t pid, struct timespec *interval);
-
-extern int _posix_priority_scheduling;
-
-int
-sched_yield(void)
-{
- if (_posix_priority_scheduling)
- return (_sched_yield());
- else
- syscall(SYS_yield);
- return(0);
-}
-
-#ifdef HAVE_FIXED_SCHED_FUNCTIONS
-int __sched_setparam(pid_t pid, const struct sched_param *param)
-{
- if (_posix_priority_scheduling)
- return (_sched_setparam(pid, param));
- else {
- errno = ENOSYS;
- return (-1);
- }
-}
-
-int __sched_setscheduler(pid_t pid, int policy,
- const struct sched_param *param)
-{
- if (_posix_priority_scheduling) {
- return (_sched_setscheduler(pid, policy, param));
- } else {
- errno = ENOSYS;
- return (-1);
- }
-}
-int __sched_getscheduler(pid_t pid)
-{
- if (_posix_priority_scheduling) {
- return (_sched_getscheduler(pid));
- } else {
- errno = ENOSYS;
- return (-1);
- }
-}
-int __sched_get_priority_max(int policy)
-{
- if (_posix_priority_scheduling)
- return (_sched_get_priority_max (policy));
- else
- errno = ENOSYS;
- return (-1);
-}
-int __sched_get_priority_min(int policy)
-{
- if (_posix_priority_scheduling)
- return (_sched_get_priority_min (policy));
- else
- errno = ENOSYS;
- return (-1);
-}
-
-int __sched_getparam(pid_t pid, struct sched_param *param)
-{
- if (_posix_priority_scheduling)
- return (_sched_getparam(pid, param));
- else {
- errno = ENOSYS;
- return (-1);
- }
-}
-
-int __sched_rr_get_interval(pid_t pid, struct timespec *interval)
-{
- if (_posix_priority_scheduling)
- return (_sched_rr_get_interval(pid, interval));
- else {
- errno = ENOSYS;
- return (-1);
- }
-}
-#else
-
-#include <sys/rtprio.h>
-#include <sys/types.h>
-
-/* Defines take from sys/posix4/ksched.c */
-#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
-#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
-#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
-#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
-#define p4prio_to_p_nice(P) (-(P + PRIO_MIN))
-#define p_nice_to_p4prio(P) (-(P - PRIO_MAX))
-#define P_NICE_PRIO_MIN p_nice_to_p4prio(PRIO_MAX)
-#define P_NICE_PRIO_MAX p_nice_to_p4prio(PRIO_MIN)
-
-int _getpriority __P((int, int));
-int _setpriority __P((int, int, int));
-
-int __sched_setparam(pid_t pid, const struct sched_param *param)
-{
- int policy = __sched_getscheduler (pid);
-
- if (policy == -1)
- return (-1);
- return (__sched_setscheduler (pid, policy, param));
-}
-
-int sched_setparam(pid_t pid, const struct sched_param *param)
- __attribute__ ((weak, alias("__sched_setparam")));
-
-int __sched_setscheduler(pid_t pid, int policy,
- const struct sched_param *param)
-{
- struct rtprio rtp;
- int max, min;
- int ret;
- int curtype;
-
- max = __sched_get_priority_max(policy);
- if (max == -1)
- return (-1);
- min = __sched_get_priority_min(policy);
- if (min == -1)
- return (-1);
- if (param->sched_priority > max ||
- param->sched_priority < min) {
- errno = EINVAL;
- return (-1);
- }
-
- switch (policy) {
- case SCHED_FIFO:
- rtp.type = RTP_PRIO_FIFO;
- rtp.prio = p4prio_to_rtpprio (param->sched_priority);
- return (rtprio (RTP_SET, pid, &rtp));
-
- case SCHED_RR:
- rtp.type = RTP_PRIO_REALTIME;
- rtp.prio = p4prio_to_rtpprio (param->sched_priority);
- return (rtprio (RTP_SET, pid, &rtp));
-
- case SCHED_OTHER:
- curtype = __sched_getscheduler (pid);
- if (curtype != SCHED_OTHER) {
- rtp.type = RTP_PRIO_NORMAL;
- rtp.prio = p4prio_to_rtpprio (0);
- ret = rtprio (RTP_SET, pid, &rtp);
- if (ret)
- return (ret);
- }
- return (_setpriority (PRIO_PROCESS, pid,
- p4prio_to_p_nice (param->sched_priority)));
-
- default:
- errno = EINVAL;
- return (-1);
- }
-}
-
-int sched_setscheduler(pid_t pid, int policy,
- const struct sched_param *param)
- __attribute__ ((weak, alias("__sched_setscheduler")));
-
-int __sched_getscheduler(pid_t pid)
-{
- int ret;
- struct rtprio rtp;
-
- ret = rtprio (RTP_LOOKUP, pid, &rtp);
- if (!ret) {
- switch (rtp.type) {
- case RTP_PRIO_FIFO:
- ret = SCHED_FIFO;
- break;
-
- case RTP_PRIO_REALTIME:
- ret = SCHED_RR;
- break;
-
- default:
- ret = SCHED_OTHER;
- break;
- }
- }
- return (ret);
-}
-
-int sched_getscheduler(pid_t pid)
- __attribute__ ((weak, alias("__sched_getscheduler")));
-
-int __sched_get_priority_max(int policy)
-{
- switch (policy)
- {
- case SCHED_FIFO:
- case SCHED_RR:
- return (P1B_PRIO_MAX);
-
- case SCHED_OTHER:
- return(P_NICE_PRIO_MAX);
-
- default:
- errno = EINVAL;
- return (-1);
- }
-}
-
-int sched_get_priority_max(int policy)
- __attribute__ ((weak, alias("__sched_get_priority_max")));
-
-int __sched_get_priority_min(int policy)
-{
- switch (policy)
- {
- case SCHED_FIFO:
- case SCHED_RR:
- return (P1B_PRIO_MIN);
-
- case SCHED_OTHER:
- return(P_NICE_PRIO_MIN);
-
- default:
- errno = EINVAL;
- return (-1);
- }
-}
-
-int sched_get_priority_min(int policy)
- __attribute__ ((weak, alias("__sched_get_priority_min")));
-
-
-int __sched_getparam(pid_t pid, struct sched_param *param)
-{
- int ret = 0;
- struct rtprio rtp;
-
- ret = rtprio (RTP_LOOKUP, pid, &rtp);
- if (!ret) {
- switch (rtp.type) {
- case RTP_PRIO_FIFO:
- case RTP_PRIO_REALTIME:
- param->sched_priority = rtpprio_to_p4prio(rtp.prio);
- break;
-
- default:
- errno = 0;
- ret = _getpriority (PRIO_PROCESS, pid);
- if (ret == -1 && errno != 0)
- return (-1);
-
- param->sched_priority = p_nice_to_p4prio(ret);
- break;
- }
- }
- return (ret);
-
-}
-
-int sched_getparam(pid_t pid, struct sched_param *param)
- __attribute__ ((weak, alias("__sched_getparam")));
-
-int __sched_rr_get_interval(pid_t pid, struct timespec *interval)
-{
- if (_posix_priority_scheduling)
- return (_sched_rr_get_interval(pid, interval));
- else {
- errno = ENOSYS;
- return (-1);
- }
-}
-
-int sched_rr_get_interval(pid_t pid, struct timespec *interval)
- __attribute__ ((weak, alias("__sched_rr_get_interval")));
-
-#endif
diff --git a/devel/linuxthreads/files/strptime.sed b/devel/linuxthreads/files/strptime.sed
deleted file mode 100644
index de66d0666609..000000000000
--- a/devel/linuxthreads/files/strptime.sed
+++ /dev/null
@@ -1,9 +0,0 @@
-1i\
-#if __FreeBSD__ == 4
-/.*MUTEX_STATIC.*/d
-/^#include "pthread_private.h"/d
-s/\&_gotgmt_mutexd/PTHREAD_MUTEX_INITIALIZER/
-s/\&logname_lock/PTHREAD_MUTEX_INITIALIZER/
-s/#include <libc_private.h>/extern int __isthreaded;/
-$a\
-#endif /* __FreeBSD__ == 4 */
diff --git a/devel/linuxthreads/files/telldir.c b/devel/linuxthreads/files/telldir.c
deleted file mode 100644
index 31f573d5322a..000000000000
--- a/devel/linuxthreads/files/telldir.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/gen/telldir.c,v 1.4.12.1 2001/03/05 09:39:59 obrien Exp $
- */
-
-#if __FreeBSD__ < 5
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-/*
- * The option SINGLEUSE may be defined to say that a telldir
- * cookie may be used only once before it is freed. This option
- * is used to avoid having memory usage grow without bound.
- */
-#define SINGLEUSE
-
-/*
- * One of these structures is malloced to describe the current directory
- * position each time telldir is called. It records the current magic
- * cookie returned by getdirentries and the offset within the buffer
- * associated with that return value.
- */
-struct ddloc {
- struct ddloc *loc_next;/* next structure in list */
- long loc_index; /* key associated with structure */
- long loc_seek; /* magic cookie returned by getdirentries */
- long loc_loc; /* offset of entry in buffer */
- const DIR* loc_dirp; /* directory which used this entry */
-};
-
-#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */
-#define LOCHASH(i) ((i)&(NDIRHASH-1))
-
-static long dd_loccnt; /* Index of entry for sequential readdir's */
-static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
-
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-extern int __isthreaded;
-static pthread_mutex_t telldir_mutex = PTHREAD_MUTEX_INITIALIZER;
-#define THREAD_LOCK() if (__isthreaded) pthread_mutex_lock(&telldir_mutex)
-#define THREAD_UNLOCK() if (__isthreaded) pthread_mutex_unlock(&telldir_mutex)
-#else
-#define THREAD_LOCK()
-#define THREAD_UNLOCK()
-#endif
-
-/*
- * return a pointer into a directory
- */
-long
-telldir(dirp)
- const DIR *dirp;
-{
- int index;
- struct ddloc *lp;
-
- if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
- return (-1);
- THREAD_LOCK();
- index = dd_loccnt++;
- lp->loc_index = index;
- lp->loc_seek = dirp->dd_seek;
- lp->loc_loc = dirp->dd_loc;
- lp->loc_dirp = dirp;
- lp->loc_next = dd_hash[LOCHASH(index)];
- dd_hash[LOCHASH(index)] = lp;
- THREAD_UNLOCK();
- return (index);
-}
-
-/*
- * seek to an entry in a directory.
- * Only values returned by "telldir" should be passed to seekdir.
- */
-void
-_seekdir(dirp, loc)
- DIR *dirp;
- long loc;
-{
- struct ddloc *lp;
- struct ddloc **prevlp;
- struct dirent *dp;
-
- THREAD_LOCK();
- prevlp = &dd_hash[LOCHASH(loc)];
- lp = *prevlp;
- while (lp != NULL) {
- if (lp->loc_index == loc)
- break;
- prevlp = &lp->loc_next;
- lp = lp->loc_next;
- }
- if (lp == NULL) {
- THREAD_UNLOCK();
- return;
- }
-#ifdef SINGLEUSE
- *prevlp = lp->loc_next;
-#endif
- THREAD_UNLOCK();
- if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
- goto found;
- (void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET);
- dirp->dd_seek = lp->loc_seek;
- dirp->dd_loc = 0;
- while (dirp->dd_loc < lp->loc_loc) {
- dp = readdir(dirp);
- if (dp == NULL)
- break;
- }
-found:
-#ifdef SINGLEUSE
- free((caddr_t)lp);
-#endif
-}
-
-/*
- * Reclaim memory for telldir cookies which weren't used.
- */
-void
-_reclaim_telldir(dirp)
- const DIR *dirp;
-{
- struct ddloc *lp;
- struct ddloc **prevlp;
- int i;
-
- THREAD_LOCK();
- for (i = 0; i < NDIRHASH; i++) {
- prevlp = &dd_hash[i];
- lp = *prevlp;
- while (lp != NULL) {
- if (lp->loc_dirp == dirp) {
- *prevlp = lp->loc_next;
- free((caddr_t)lp);
- lp = *prevlp;
- continue;
- }
- prevlp = &lp->loc_next;
- lp = lp->loc_next;
- }
- }
- THREAD_UNLOCK();
-}
-#endif /* __FreeBSD__ < 5 */
diff --git a/devel/linuxthreads/files/ttyname.c b/devel/linuxthreads/files/ttyname.c
deleted file mode 100644
index 85452e869a69..000000000000
--- a/devel/linuxthreads/files/ttyname.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libc/gen/ttyname.c,v 1.10.6.2 2002/10/15 19:46:46 fjoe Exp $
- */
-
-#if __FreeBSD__ < 5
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <unistd.h>
-#include <db.h>
-#include <string.h>
-#include <paths.h>
-
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-static pthread_mutex_t ttyname_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_key_t ttyname_key;
-static int ttyname_init = 0;
-char *__ttyname_basic(int fd);
-
-char *
-ttyname(int fd)
-{
- char *ret;
-
- ret = __ttyname_basic(fd);
-
- return (ret);
-}
-
-char *
-__ttyname_r_basic(int fd, char *buf, size_t len)
-{
- register struct dirent *dirp;
- register DIR *dp;
- struct stat dsb;
- struct stat sb;
- char *rval;
- int minlen;
-
- rval = NULL;
-
- /* Must be a terminal. */
- if (!isatty(fd))
- return (rval);
- /* Must be a character device. */
- if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
- return (rval);
- /* Must have enough room */
- if (len <= sizeof(_PATH_DEV))
- return (rval);
-
- if ((dp = opendir(_PATH_DEV)) != NULL) {
- memcpy(buf, _PATH_DEV, sizeof(_PATH_DEV));
- for (rval = NULL; (dirp = readdir(dp)) != NULL;) {
- if (dirp->d_fileno != sb.st_ino)
- continue;
- minlen = (len - (sizeof(_PATH_DEV) - 1)) < (dirp->d_namlen + 1) ?
- (len - (sizeof(_PATH_DEV) - 1)) : (dirp->d_namlen + 1);
- memcpy(buf + sizeof(_PATH_DEV) - 1, dirp->d_name, minlen);
- if (stat(buf, &dsb) || sb.st_dev != dsb.st_dev ||
- sb.st_ino != dsb.st_ino)
- continue;
- rval = buf;
- break;
- }
- (void) closedir(dp);
- }
- return (rval);
-}
-
-char *
-__ttyname_basic(int fd)
-{
- char *buf;
-
- pthread_mutex_lock(&ttyname_lock);
- if (ttyname_init == 0) {
- if (pthread_key_create(&ttyname_key, free)) {
- pthread_mutex_unlock(&ttyname_lock);
- return (NULL);
- }
- ttyname_init = 1;
- }
- pthread_mutex_unlock(&ttyname_lock);
-
- /* Must have thread specific data field to put data */
- if ((buf = pthread_getspecific(ttyname_key)) == NULL) {
- if ((buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN)) != NULL) {
- if (pthread_setspecific(ttyname_key, buf) != 0) {
- free(buf);
- return (NULL);
- }
- } else {
- return (NULL);
- }
- }
- return (__ttyname_r_basic(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN));
-}
-
-char *
-ttyname_r(int fd, char *buf, size_t len)
-{
- char *ret;
-
- ret = __ttyname_r_basic(fd, buf, len);
- return (ret);
-}
-#else
-static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
-static char *oldttyname __P((int, struct stat *));
-
-char *
-ttyname(fd)
- int fd;
-{
- struct stat sb;
- struct termios ttyb;
- DB *db;
- DBT data, key;
- struct {
- mode_t type;
- dev_t dev;
- } bkey;
-
- /* Must be a terminal. */
- if (tcgetattr(fd, &ttyb) < 0)
- return (NULL);
- /* Must be a character device. */
- if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
- return (NULL);
-
- if ( (db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)) ) {
- memset(&bkey, 0, sizeof(bkey));
- bkey.type = S_IFCHR;
- bkey.dev = sb.st_rdev;
- key.data = &bkey;
- key.size = sizeof(bkey);
- if (!(db->get)(db, &key, &data, 0)) {
- bcopy(data.data,
- buf + sizeof(_PATH_DEV) - 1, data.size);
- (void)(db->close)(db);
- return (buf);
- }
- (void)(db->close)(db);
- }
- return (oldttyname(fd, &sb));
-}
-
-static char *
-oldttyname(fd, sb)
- int fd;
- struct stat *sb;
-{
- register struct dirent *dirp;
- register DIR *dp;
- struct stat dsb;
-
- if ((dp = opendir(_PATH_DEV)) == NULL)
- return (NULL);
-
- while ( (dirp = readdir(dp)) ) {
- if (dirp->d_fileno != sb->st_ino)
- continue;
- bcopy(dirp->d_name, buf + sizeof(_PATH_DEV) - 1,
- dirp->d_namlen + 1);
- if (stat(buf, &dsb) || sb->st_dev != dsb.st_dev ||
- sb->st_ino != dsb.st_ino)
- continue;
- (void)closedir(dp);
- return (buf);
- }
- (void)closedir(dp);
- return (NULL);
-}
-#endif
-#endif /* __FreeBSD__ < 5 */
diff --git a/devel/linuxthreads/files/uthread_file.c b/devel/linuxthreads/files/uthread_file.c
deleted file mode 100644
index 596e7f9a2eaa..000000000000
--- a/devel/linuxthreads/files/uthread_file.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: uthread_file.c,v 1.7 1999/06/20 08:28:20 jb Exp $
- *
- * POSIX stdio FILE locking functions. These assume that the locking
- * is only required at FILE structure level, not at file descriptor
- * level too.
- *
- */
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "pthread.h"
-#include "internals.h"
-#include "spinlock.h"
-#include "restart.h"
-
-#if __FreeBSD__ == 4
-
-/*
- * Weak symbols for externally visible functions in this file:
- */
-#pragma weak flockfile=_flockfile
-#pragma weak ftrylockfile=_ftrylockfile
-#pragma weak funlockfile=_funlockfile
-
-/*
- * The FILE lock structure. The FILE *fp is locked if the owner is
- * not NULL. If not locked, the file lock structure can be
- * reassigned to a different file by setting fp.
- */
-struct file_lock {
- LIST_ENTRY(file_lock) entry; /* Entry if file list. */
- TAILQ_HEAD(lock_head, _pthread_descr_struct)
- l_head; /* Head of queue for threads */
- /* waiting on this lock. */
- FILE *fp; /* The target file. */
- pthread_descr owner; /* Thread that owns lock. */
- int count; /* Lock count for owner. */
-};
-
-/*
- * The number of file lock lists into which the file pointer is
- * hashed. Ideally, the FILE structure size would have been increased,
- * but this causes incompatibility, so separate data structures are
- * required.
- */
-#define NUM_HEADS 128
-
-/*
- * This macro casts a file pointer to a long integer and right
- * shifts this by the number of bytes in a pointer. The shifted
- * value is then remaindered using the maximum number of hash
- * entries to produce and index into the array of static lock
- * structures. If there is a collision, a linear search of the
- * dynamic list of locks linked to each static lock is perfomed.
- */
-#define file_idx(_p) ((((u_long) _p) >> sizeof(void *)) % NUM_HEADS)
-
-/*
- * Global array of file locks. The first lock for each hash bucket is
- * allocated statically in the hope that there won't be too many
- * collisions that require a malloc and an element added to the list.
- */
-struct static_file_lock {
- LIST_HEAD(file_list_head, file_lock) head;
- struct file_lock fl;
-} flh[NUM_HEADS];
-
-/* Set to non-zero when initialisation is complete: */
-static int init_done = 0;
-
-/* Lock for accesses to the hash table: */
-static spinlock_t hash_lock = _SPINLOCK_INITIALIZER;
-
-/*
- * Find a lock structure for a FILE, return NULL if the file is
- * not locked:
- */
-static
-struct file_lock *
-find_lock(int idx, FILE *fp)
-{
- struct file_lock *p;
-
- /* Check if the file is locked using the static structure: */
- if (flh[idx].fl.fp == fp && flh[idx].fl.owner != NULL)
- /* Return a pointer to the static lock: */
- p = &flh[idx].fl;
- else {
- /* Point to the first dynamic lock: */
- p = flh[idx].head.lh_first;
-
- /*
- * Loop through the dynamic locks looking for the
- * target file:
- */
- while (p != NULL && (p->fp != fp || p->owner == NULL))
- /* Not this file, try the next: */
- p = p->entry.le_next;
- }
- return(p);
-}
-
-
-/*
- * Lock a file, assuming that there is no lock structure currently
- * assigned to it.
- */
-static
-struct file_lock *
-do_lock(int idx, FILE *fp)
-{
- struct file_lock *p;
-
- /* Check if the static structure is not being used: */
- if (flh[idx].fl.owner == NULL) {
- /* Return a pointer to the static lock: */
- p = &flh[idx].fl;
- }
- else {
- /* Point to the first dynamic lock: */
- p = flh[idx].head.lh_first;
-
- /*
- * Loop through the dynamic locks looking for a
- * lock structure that is not being used:
- */
- while (p != NULL && p->owner != NULL)
- /* This one is used, try the next: */
- p = p->entry.le_next;
- }
-
- /*
- * If an existing lock structure has not been found,
- * allocate memory for a new one:
- */
- if (p == NULL && (p = (struct file_lock *)
- malloc(sizeof(struct file_lock))) != NULL) {
- /* Add the new element to the list: */
- LIST_INSERT_HEAD(&flh[idx].head, p, entry);
- }
-
- /* Check if there is a lock structure to acquire: */
- if (p != NULL) {
- /* Acquire the lock for the running thread: */
- p->fp = fp;
- p->owner = thread_self();
- p->count = 1;
- TAILQ_INIT(&p->l_head);
- }
- return(p);
-}
-
-void
-_flockfile(FILE * fp)
-{
- int idx = file_idx(fp);
- struct file_lock *p;
- pthread_descr self = thread_self();
-
- /* Check if this is a real file: */
- if (fp->_file >= 0) {
- /* Lock the hash table: */
- _SPINLOCK(&hash_lock);
-
- /* Check if the static array has not been initialised: */
- if (!init_done) {
- /* Initialise the global array: */
- memset(flh,0,sizeof(flh));
-
- /* Flag the initialisation as complete: */
- init_done = 1;
- }
-
- /* Get a pointer to any existing lock for the file: */
- if ((p = find_lock(idx, fp)) == NULL) {
- /*
- * The file is not locked, so this thread can
- * grab the lock:
- */
- p = do_lock(idx, fp);
-
- /* Unlock the hash table: */
- _SPINUNLOCK(&hash_lock);
-
- /*
- * The file is already locked, so check if the
- * running thread is the owner:
- */
- } else if (p->owner == self) {
- /*
- * The running thread is already the
- * owner, so increment the count of
- * the number of times it has locked
- * the file:
- */
- p->count++;
-
- /* Unlock the hash table: */
- _SPINUNLOCK(&hash_lock);
- } else {
- /*
- * The file is locked for another thread.
- * Append this thread to the queue of
- * threads waiting on the lock.
- */
- TAILQ_INSERT_TAIL(&p->l_head,self,qe);
-
- /* Unlock the hash table: */
- _SPINUNLOCK(&hash_lock);
-
- /* Wait on the FILE lock: */
- suspend (self);
- }
- }
- return;
-}
-
-int
-_ftrylockfile(FILE * fp)
-{
- int ret = -1;
- int idx = file_idx(fp);
- struct file_lock *p;
- pthread_descr self = thread_self();
-
- /* Check if this is a real file: */
- if (fp->_file >= 0) {
- /* Lock the hash table: */
- _SPINLOCK(&hash_lock);
-
- /* Get a pointer to any existing lock for the file: */
- if ((p = find_lock(idx, fp)) == NULL) {
- /*
- * The file is not locked, so this thread can
- * grab the lock:
- */
- p = do_lock(idx, fp);
-
- /*
- * The file is already locked, so check if the
- * running thread is the owner:
- */
- } else if (p->owner == self) {
- /*
- * The running thread is already the
- * owner, so increment the count of
- * the number of times it has locked
- * the file:
- */
- p->count++;
- } else {
- /*
- * The file is locked for another thread,
- * so this try fails.
- */
- p = NULL;
- }
-
- /* Check if the lock was obtained: */
- if (p != NULL)
- /* Return success: */
- ret = 0;
-
- /* Unlock the hash table: */
- _SPINUNLOCK(&hash_lock);
-
- }
- return (ret);
-}
-
-void
-_funlockfile(FILE * fp)
-{
- int idx = file_idx(fp);
- struct file_lock *p;
- pthread_descr self = thread_self();
-
- /* Check if this is a real file: */
- if (fp->_file >= 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- /* XXX RLC _thread_kern_sig_defer(); */
-
- /* Lock the hash table: */
- _SPINLOCK(&hash_lock);
-
- /*
- * Get a pointer to the lock for the file and check that
- * the running thread is the one with the lock:
- */
- if ((p = find_lock(idx, fp)) != NULL &&
- p->owner == self) {
- /*
- * Check if this thread has locked the FILE
- * more than once:
- */
- if (p->count > 1)
- /*
- * Decrement the count of the number of
- * times the running thread has locked this
- * file:
- */
- p->count--;
- else {
- /*
- * The running thread will release the
- * lock now:
- */
- p->count = 0;
-
- /* Get the new owner of the lock: */
- if ((p->owner = TAILQ_FIRST(&p->l_head)) != NULL) {
- /* Pop the thread off the queue: */
- TAILQ_REMOVE(&p->l_head,p->owner,qe);
-
- /*
- * This is the first lock for the new
- * owner:
- */
- p->count = 1;
-
- /* Allow the new owner to run: */
- restart(p->owner);
- }
- }
- }
-
- /* Unlock the hash table: */
- _SPINUNLOCK(&hash_lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- /* XXX RLC _thread_kern_sig_undefer(); */
- }
- return;
-}
-
-void __fresetlockfiles()
-{
- int idx;
- struct file_lock *p;
-
- _SPINLOCK(&hash_lock);
- for (idx = 0; idx < NUM_HEADS; idx++) {
-
- /* Zero the static lock */
- p = &flh[idx].fl;
- p->owner = NULL;
- p->fp = NULL;
- p->count = 0;
- TAILQ_INIT(&p->l_head);
-
- /* Loop through the dynamic locks
- * and free them.
- */
-
- while (flh[idx].head.lh_first != NULL) {
- p = flh[idx].head.lh_first;
- LIST_REMOVE(p, entry);
- free (p);
- }
- }
- _SPINUNLOCK(&hash_lock);
-}
-
-#else
-
-void __fresetlockfiles()
-{
- /* XXX: Should do something */
-}
-#endif
diff --git a/devel/linuxthreads/files/wraputhread.c b/devel/linuxthreads/files/wraputhread.c
deleted file mode 100644
index be6a250e9926..000000000000
--- a/devel/linuxthreads/files/wraputhread.c
+++ /dev/null
@@ -1,1751 +0,0 @@
-/*
- * Copyright (c) 2005 Yahoo! Technologies Norway AS
- * Copyright (c) 2003 Overture Services Norway AS
- * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/wraputhread.c,v 1.5 2007-03-21 21:40:24 tegge Exp $
- */
-
-#ifdef LINUXTHREADS_WRAP_API
-#define COMPILING_WRAPUTHREAD
-#endif
-#include <pthread.h>
-#include <stdlib.h>
-#include <sys/errno.h>
-
-#ifdef LINUXTHREADS_WRAP_API
-#define __pthread_attr_destroy linuxthreads_pthread_attr_destroy
-#define __pthread_attr_getdetachstate linuxthreads_pthread_attr_getdetachstate
-#define __pthread_attr_getinheritsched linuxthreads_pthread_attr_getinheritsched
-#define __pthread_attr_getschedparam linuxthreads_pthread_attr_getschedparam
-#define __pthread_attr_getschedpolicy linuxthreads_pthread_attr_getschedpolicy
-#define __pthread_attr_getscope linuxthreads_pthread_attr_getscope
-#define __pthread_attr_init linuxthreads_pthread_attr_init
-#define __pthread_attr_setdetachstate linuxthreads_pthread_attr_setdetachstate
-#define __pthread_attr_setinheritsched linuxthreads_pthread_attr_setinheritsched
-#define __pthread_attr_setschedparam linuxthreads_pthread_attr_setschedparam
-#define __pthread_attr_setschedpolicy linuxthreads_pthread_attr_setschedpolicy
-#define __pthread_attr_setscope linuxthreads_pthread_attr_setscope
-#define __pthread_barrier_destroy linuxthreads_pthread_barrier_destroy
-#define __pthread_barrier_init linuxthreads_pthread_barrier_init
-#define __pthread_barrier_wait linuxthreads_pthread_barrier_wait
-#define __pthread_barrierattr_destroy linuxthreads_pthread_barrierattr_destroy
-#define __pthread_barrierattr_init linuxthreads_pthread_barrierattr_init
-#define __pthread_barrierattr_setpshared linuxthreads_pthread_barrierattr_setpshared
-#define __pthread_cancel linuxthreads_pthread_cancel
-#define __pthread_condattr_destroy linuxthreads_pthread_condattr_destroy
-#define __pthread_condattr_getpshared linuxthreads_pthread_condattr_getpshared
-#define __pthread_condattr_init linuxthreads_pthread_condattr_init
-#define __pthread_condattr_setpshared linuxthreads_pthread_condattr_setpshared
-#define __pthread_cond_broadcast linuxthreads_pthread_cond_broadcast
-#define __pthread_cond_destroy linuxthreads_pthread_cond_destroy
-#define __pthread_cond_init linuxthreads_pthread_cond_init
-#define __pthread_cond_signal linuxthreads_pthread_cond_signal
-#define __pthread_cond_timedwait linuxthreads_pthread_cond_timedwait
-#define __pthread_cond_wait linuxthreads_pthread_cond_wait
-#define __pthread_create linuxthreads_pthread_create
-#define __pthread_detach linuxthreads_pthread_detach
-#define __pthread_equal linuxthreads_pthread_equal
-#define __pthread_exit linuxthreads_pthread_exit
-#define __pthread_getattr_np linuxthreads_pthread_getattr_np
-#define __pthread_getcpuclockid linuxthreads_pthread_getcpuclockid
-#define __pthread_getschedparam linuxthreads_pthread_getschedparam
-#define __pthread_join linuxthreads_pthread_join
-#define __pthread_key_delete linuxthreads_pthread_key_delete
-#define __pthread_kill linuxthreads_pthread_kill
-#define __pthread_rwlockattr_init linuxthreads_pthread_rwlockattr_init
-#define __pthread_rwlockattr_getpshared linuxthreads_pthread_rwlockattr_getpshared
-#define __pthread_rwlockattr_setpshared linuxthreads_pthread_rwlockattr_setpshared
-#define __pthread_rwlockattr_destroy linuxthreads_pthread_rwlockattr_destroy
-#define __pthread_self linuxthreads_pthread_self
-#define __pthread_setcanceltype linuxthreads_pthread_setcanceltype
-#define __pthread_setcancelstate linuxthreads_pthread_setcancelstate
-#define __pthread_setschedparam linuxthreads_pthread_setschedparam
-#define __pthread_sigmask linuxthreads_pthread_sigmask
-#define __pthread_testcancel linuxthreads_pthread_testcancel
-#else
-#define __pthread_attr_destroy pthread_attr_destroy
-#define __pthread_attr_getdetachstate pthread_attr_getdetachstate
-#define __pthread_attr_getinheritsched pthread_attr_getinheritsched
-#define __pthread_attr_getschedparam pthread_attr_getschedparam
-#define __pthread_attr_getschedpolicy pthread_attr_getschedpolicy
-#define __pthread_attr_getscope pthread_attr_getscope
-#define __pthread_attr_init pthread_attr_init
-#define __pthread_attr_setdetachstate pthread_attr_setdetachstate
-#define __pthread_attr_setinheritsched pthread_attr_setinheritsched
-#define __pthread_attr_setschedparam pthread_attr_setschedparam
-#define __pthread_attr_setschedpolicy pthread_attr_setschedpolicy
-#define __pthread_attr_setscope pthread_attr_setscope
-#define __pthread_barrier_destroy pthread_barrier_destroy
-#define __pthread_barrier_init pthread_barrier_init
-#define __pthread_barrier_wait pthread_barrier_wait
-#define __pthread_barrierattr_destroy pthread_barrierattr_destroy
-#define __pthread_barrierattr_init pthread_barrierattr_init
-#define __pthread_barrierattr_setpshared pthread_barrierattr_setpshared
-#define __pthread_cancel pthread_cancel
-#define __pthread_condattr_destroy pthread_condattr_destroy
-#define __pthread_condattr_getpshared pthread_condattr_getpshared
-#define __pthread_condattr_init pthread_condattr_init
-#define __pthread_condattr_setpshared pthread_condattr_setpshared
-#define __pthread_cond_broadcast pthread_cond_broadcast
-#define __pthread_cond_destroy pthread_cond_destroy
-#define __pthread_cond_init pthread_cond_init
-#define __pthread_cond_signal pthread_cond_signal
-#define __pthread_cond_timedwait pthread_cond_timedwait
-#define __pthread_cond_wait pthread_cond_wait
-#define __pthread_create pthread_create
-#define __pthread_detach pthread_detach
-#define __pthread_equal pthread_equal
-#define __pthread_exit pthread_exit
-#define __pthread_getattr_np pthread_getattr_np
-#define __pthread_getschedparam pthread_getschedparam
-#define __pthread_join pthread_join
-#define __pthread_key_delete pthread_key_delete
-#define __pthread_kill pthread_kill
-#define __pthread_rwlockattr_init pthread_rwlockattr_init
-#define __pthread_rwlockattr_getpshared pthread_rwlockattr_getpshared
-#define __pthread_rwlockattr_setpshared pthread_rwlockattr_setpshared
-#define __pthread_rwlockattr_destroy pthread_rwlockattr_destroy
-#define __pthread_self pthread_self
-#define __pthread_setcanceltype pthread_setcanceltype
-#define __pthread_setcancelstate pthread_setcancelstate
-#define __pthread_setschedparam pthread_setschedparam
-#define __pthread_sigmask pthread_sigmask
-#define __pthread_testcancel pthread_testcancel
-#endif
-
-int __pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
-int __pthread_attr_destroy(pthread_attr_t *);
-int __pthread_attr_getdetachstate(const pthread_attr_t *, int *);
-int __pthread_attr_getguardsize(const pthread_attr_t *, size_t *);
-int __pthread_attr_getinheritsched(const pthread_attr_t *, int *);
-int __pthread_attr_getschedparam(const pthread_attr_t *,
- struct sched_param *);
-int __pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
-int __pthread_attr_getscope(const pthread_attr_t *, int *);
-int __pthread_attr_getstack(const pthread_attr_t *, void **, size_t *);
-int __pthread_attr_getstackaddr(const pthread_attr_t *, void **);
-int __pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
-int __pthread_attr_init(pthread_attr_t *);
-int __pthread_attr_setdetachstate(pthread_attr_t *, int);
-int __pthread_attr_setguardsize(pthread_attr_t *, size_t);
-int __pthread_attr_setinheritsched(pthread_attr_t *, int);
-int __pthread_attr_setschedparam(pthread_attr_t *,
- const struct sched_param *);
-int __pthread_attr_setschedpolicy(pthread_attr_t *, int);
-int __pthread_attr_setscope(pthread_attr_t *, int);
-int __pthread_attr_setstack(pthread_attr_t *, void *, size_t);
-int __pthread_attr_setstackaddr(pthread_attr_t *, void *);
-int __pthread_attr_setstacksize(pthread_attr_t *, size_t);
-int __pthread_barrier_destroy(pthread_barrier_t *);
-int __pthread_barrier_init(pthread_barrier_t *,
- const pthread_barrierattr_t *,
- unsigned int);
-int __pthread_barrier_wait(pthread_barrier_t *);
-int __pthread_barrierattr_destroy(pthread_barrierattr_t *);
-int __pthread_barrierattr_getpshared(const pthread_barrierattr_t *, int *);
-int __pthread_barrierattr_init(pthread_barrierattr_t *);
-int __pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
-int __pthread_cancel(pthread_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_timedwait(pthread_cond_t *,
- pthread_mutex_t *,
- const struct timespec *);
-int __pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
-int __pthread_condattr_destroy(pthread_condattr_t *);
-int __pthread_condattr_getpshared(const pthread_condattr_t *, int *);
-int __pthread_condattr_init(pthread_condattr_t *);
-int __pthread_condattr_setpshared(pthread_condattr_t *, int);
-int __pthread_create(pthread_t *,
- const pthread_attr_t *,
- void *(*)(void *),
- void *);
-int __pthread_detach(pthread_t);
-int __pthread_equal(pthread_t, pthread_t);
-void __pthread_exit(void *);
-int __pthread_getattr_np(pthread_t, pthread_attr_t *);
-int __pthread_getconcurrency(void);
-int __pthread_getschedparam(pthread_t, int *, struct sched_param *);
-void *__pthread_getspecific(pthread_key_t);
-int __pthread_join(pthread_t, void **);
-int __pthread_key_create(pthread_key_t *, void (*) (void *));
-int __pthread_key_delete(pthread_key_t);
-int __pthread_kill(pthread_t, int);
-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_timedlock(pthread_mutex_t *, const struct timespec *);
-int __pthread_mutex_trylock(pthread_mutex_t *);
-int __pthread_mutex_unlock(pthread_mutex_t *);
-int __pthread_mutexattr_destroy(pthread_mutexattr_t *);
-int __pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
-int __pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *);
-int __pthread_mutexattr_init(pthread_mutexattr_t *);
-int __pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
-int __pthread_mutexattr_settype(pthread_mutexattr_t *, int);
-int __pthread_rwlock_destroy(pthread_rwlock_t *);
-int __pthread_rwlock_init(pthread_rwlock_t *,
- const pthread_rwlockattr_t *);
-int __pthread_rwlock_rdlock(pthread_rwlock_t *);
-int __pthread_rwlock_timedrdlock(pthread_rwlock_t *,
- const struct timespec *);
-int __pthread_rwlock_timedwrlock(pthread_rwlock_t *,
- const struct timespec *);
-int __pthread_rwlock_tryrdlock(pthread_rwlock_t *);
-int __pthread_rwlock_trywrlock(pthread_rwlock_t *);
-int __pthread_rwlock_unlock(pthread_rwlock_t *);
-int __pthread_rwlock_wrlock(pthread_rwlock_t *);
-int __pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
-int __pthread_rwlockattr_init(pthread_rwlockattr_t *);
-int __pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, int *);
-int __pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
-pthread_t __pthread_self(void);
-int __pthread_setcancelstate(int, int *);
-int __pthread_setcanceltype(int, int *);
-int __pthread_setconcurrency(int);
-int __pthread_setschedparam(pthread_t, int, const struct sched_param *);
-int __pthread_setspecific(pthread_key_t, const void *);
-int __pthread_sigmask(int, const sigset_t *, sigset_t *);
-void __pthread_testcancel(void);
-
-extern int pthread_attr_get_np(pthread_t, pthread_attr_t *)
- __attribute__ ((weak, alias("_pthread_attr_get_np")));
-
-
-static pthread_mutex_t allocmutexlock = PTHREAD_MUTEX_INITIALIZER;
-enum uthread_mutextype {
- UTHREAD_PTHREAD_MUTEX_ERRORCHECK = 1, /* Default POSIX mutex */
- UTHREAD_PTHREAD_MUTEX_RECURSIVE = 2, /* Recursive mutex */
- UTHREAD_PTHREAD_MUTEX_NORMAL = 3, /* No error checking */
- MUTEX_TYPE_MAX
-};
-
-enum {
- UTHREAD_PTHREAD_CREATE_JOINABLE = 0,
- UTHREAD_PTHREAD_CREATE_DETACHED = 1
-};
-
-enum {
- UTHREAD_PTHREAD_INHERIT_SCHED = 4,
- UTHREAD_PTHREAD_EXPLICIT_SCHED = 0
-};
-
-
-enum {
- UTHREAD_PTHREAD_SCOPE_SYSTEM = 2,
- UTHREAD_PTHREAD_SCOPE_PROCESS = 0
-};
-
-enum {
- UTHREAD_PTHREAD_PROCESS_PRIVATE = 0,
- UTHREAD_PTHREAD_PROCESS_SHARED = 1
-};
-
-
-enum {
- UTHREAD_PTHREAD_CANCEL_ENABLE = 0,
- UTHREAD_PTHREAD_CANCEL_DISABLE = 1,
- UTHREAD_PTHREAD_CANCEL_DEFERRED = 0,
- UTHREAD_PTHREAD_CANCEL_ASYNCHRONOUS = 2
-};
-
-#define UTHREAD_PTHREAD_CANCELED ((void *) 1)
-
-enum {
- UTHREAD_PTHREAD_PRIO_NONE = 0,
- UTHREAD_PTHREAD_PRIO_INHERIT = 1,
- UTHREAD_PTHREAD_PRIO_PROTECT = 2
-};
-
-
-struct uthread_pthread_once {
- int state;
- pthread_mutex_t *mutex;
-};
-
-typedef struct uthread_pthread_once uthread_pthread_once_t;
-
-/*
- * Flags for once initialization.
- */
-#define UTHREAD_PTHREAD_NEEDS_INIT 0
-#define UTHREAD_PTHREAD_DONE_INIT 1
-
-
-static int allocbarrier(pthread_barrier_t **barrier);
-static int alloccond(pthread_cond_t **cond);
-static int allocmutex(pthread_mutex_t **mutex);
-static int allocrwlock(pthread_rwlock_t **rwlock);
-
-static int
-allocbarrier(pthread_barrier_t **barrier)
-{
- pthread_barrier_t *b;
- int ret;
-
- b = malloc(sizeof(pthread_barrier_t));
- if (b == NULL)
- return ENOMEM;
- ret = __pthread_barrier_init(b, NULL, 1);
- if (ret != 0) {
- free(b);
- return ret;
- }
- __pthread_mutex_lock(&allocmutexlock);
- if (*barrier != NULL) {
- __pthread_mutex_unlock(&allocmutexlock);
- __pthread_barrier_destroy(b);
- free(b);
- return 0;
- }
- *barrier = b;
- __pthread_mutex_unlock(&allocmutexlock);
- return 0;
-}
-
-static int
-alloccond(pthread_cond_t **cond)
-{
- pthread_cond_t *c;
- int ret;
-
- c = malloc(sizeof(pthread_cond_t));
- if (c == NULL)
- return ENOMEM;
- ret = __pthread_cond_init(c, NULL);
- if (ret != 0) {
- free(c);
- return ret;
- }
- __pthread_mutex_lock(&allocmutexlock);
- if (*cond != NULL) {
- __pthread_mutex_unlock(&allocmutexlock);
- __pthread_cond_destroy(c);
- free(c);
- return 0;
- }
- *cond = c;
- __pthread_mutex_unlock(&allocmutexlock);
- return 0;
-}
-
-static int
-allocmutex(pthread_mutex_t **mutex)
-{
- pthread_mutex_t *m;
- int ret;
-
- m = malloc(sizeof(pthread_mutex_t));
- if (m == NULL)
- return ENOMEM;
- ret = __pthread_mutex_init(m, NULL);
- if (ret != 0) {
- free(m);
- return ret;
- }
- __pthread_mutex_lock(&allocmutexlock);
- if (*mutex != NULL) {
- __pthread_mutex_unlock(&allocmutexlock);
- __pthread_mutex_destroy(m);
- free(m);
- return 0;
- }
- *mutex = m;
- __pthread_mutex_unlock(&allocmutexlock);
- return 0;
-}
-
-static int
-allocrwlock(pthread_rwlock_t **rwlock)
-{
- pthread_rwlock_t *rw;
- int ret;
-
- rw = malloc(sizeof(pthread_rwlock_t));
- if (rw == NULL)
- return ENOMEM;
- ret = __pthread_rwlock_init(rw, NULL);
- if (ret != 0) {
- free(rw);
- return ret;
- }
- __pthread_mutex_lock(&allocmutexlock);
- if (*rwlock != NULL) {
- __pthread_mutex_unlock(&allocmutexlock);
- __pthread_rwlock_destroy(rw);
- free(rw);
- return 0;
- }
- *rwlock = rw;
- __pthread_mutex_unlock(&allocmutexlock);
- return 0;
-}
-
-int
-_pthread_atfork(void (*prepare)(void),
- void (*parent)(void),
- void (*child)(void))
-{
- return __pthread_atfork(prepare, parent, child);
-}
-
-int
-_pthread_attr_destroy(pthread_attr_t **attr)
-{
- int ret;
-
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- ret = __pthread_attr_destroy(*attr);
- if (ret == 0) {
- free(*attr);
- *attr = NULL;
- }
- return ret;
-}
-
-
-int
-_pthread_attr_getdetachstate(const pthread_attr_t **attr, int *detachstate)
-{
- int ret;
- int lstate;
-
- if (attr == NULL || *attr == NULL || detachstate == NULL)
- return EINVAL;
- ret = __pthread_attr_getdetachstate(*attr, &lstate);
- if (ret == 0) {
- switch (lstate) {
- case PTHREAD_CREATE_JOINABLE:
- *detachstate = UTHREAD_PTHREAD_CREATE_JOINABLE;
- break;
- case PTHREAD_CREATE_DETACHED:
- *detachstate = UTHREAD_PTHREAD_CREATE_DETACHED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_attr_getguardsize(const pthread_attr_t **attr, size_t *guardsize)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_getguardsize(*attr, guardsize);
-}
-
-int
-_pthread_attr_getinheritsched(const pthread_attr_t **attr, int *inherit)
-{
- int ret;
- int linherit;
-
- if (attr == NULL || *attr == NULL || inherit == NULL)
- return EINVAL;
- ret = __pthread_attr_getinheritsched(*attr, &linherit);
- if (ret == 0) {
- switch (linherit) {
- case PTHREAD_EXPLICIT_SCHED:
- *inherit = UTHREAD_PTHREAD_EXPLICIT_SCHED;
- break;
- case PTHREAD_INHERIT_SCHED:
- *inherit = UTHREAD_PTHREAD_INHERIT_SCHED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_attr_getschedparam(const pthread_attr_t **attr,
- struct sched_param *sparam)
-{
- if (attr == NULL || *attr == NULL || sparam == NULL)
- return EINVAL;
- return __pthread_attr_getschedparam(*attr, sparam);
-}
-
-int
-_pthread_attr_getschedpolicy(const pthread_attr_t **attr,
- int *policy)
-{
- if (attr == NULL || *attr == NULL || policy == NULL)
- return EINVAL;
- return __pthread_attr_getschedpolicy(*attr, policy);
-}
-
-int
-_pthread_attr_getscope(const pthread_attr_t **attr,
- int *scope)
-{
- int ret;
- int lscope;
-
- if (attr == NULL || *attr == NULL || scope == NULL)
- return EINVAL;
- ret = __pthread_attr_getscope(*attr, &lscope);
- if (ret == 0) {
- switch (lscope) {
- case PTHREAD_SCOPE_SYSTEM:
- *scope = UTHREAD_PTHREAD_SCOPE_SYSTEM;
- break;
- case PTHREAD_SCOPE_PROCESS:
- *scope = UTHREAD_PTHREAD_SCOPE_PROCESS;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_attr_getstack(const pthread_attr_t **attr,
- void **stackaddr,
- size_t *stacksize)
-{
- if (attr == NULL || *attr == NULL ||
- stackaddr == NULL || stacksize == NULL)
- return EINVAL;
- return __pthread_attr_getstack(*attr, stackaddr, stacksize);
-}
-
-int
-_pthread_attr_getstackaddr(const pthread_attr_t **attr,
- void **stackaddr)
-{
- size_t stacksize;
- if (attr == NULL || *attr == NULL || stackaddr == NULL)
- return EINVAL;
- return __pthread_attr_getstack(*attr, stackaddr, &stacksize);
-}
-
-int
-_pthread_attr_getstacksize(const pthread_attr_t **attr,
- size_t *stacksize)
-{
- if (attr == NULL || *attr == NULL || stacksize == NULL)
- return EINVAL;
- return __pthread_attr_getstacksize(*attr, stacksize);
-}
-
-int
-_pthread_attr_get_np(pthread_t tid, pthread_attr_t **dst)
-{
- if (dst == NULL || *dst == NULL)
- return EINVAL;
- return __pthread_getattr_np(tid, *dst);
-}
-
-int
-_pthread_attr_init(pthread_attr_t **attr)
-{
- int ret;
- pthread_attr_t *res;
-
- if (attr == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_attr_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_attr_init(res);
- if (ret == 0)
- *attr = res;
- else
- free(res);
- return ret;
-}
-int
-_pthread_attr_setdetachstate(pthread_attr_t **attr, int detachstate)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- switch (detachstate) {
- case UTHREAD_PTHREAD_CREATE_JOINABLE:
- return __pthread_attr_setdetachstate(*attr,
- PTHREAD_CREATE_JOINABLE);
- case UTHREAD_PTHREAD_CREATE_DETACHED:
- return __pthread_attr_setdetachstate(*attr,
- PTHREAD_CREATE_DETACHED);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_attr_setguardsize(pthread_attr_t **attr, size_t guardsize)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_setguardsize(*attr, guardsize);
-}
-
-int
-_pthread_attr_setinheritsched(pthread_attr_t **attr, int inherit)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- switch (inherit) {
- case UTHREAD_PTHREAD_EXPLICIT_SCHED:
- return __pthread_attr_setinheritsched(*attr,
- PTHREAD_EXPLICIT_SCHED);
- case UTHREAD_PTHREAD_INHERIT_SCHED:
- return __pthread_attr_setinheritsched(*attr,
- PTHREAD_INHERIT_SCHED);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_attr_setschedparam(pthread_attr_t **attr,
- struct sched_param *sparam)
-{
- if (attr == NULL || *attr == NULL || sparam == NULL)
- return EINVAL;
- return __pthread_attr_setschedparam(*attr, sparam);
-}
-
-int
-_pthread_attr_setschedpolicy(pthread_attr_t **attr,
- int policy)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_setschedpolicy(*attr, policy);
-}
-
-int
-_pthread_attr_setscope(pthread_attr_t **attr,
- int scope)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- switch (scope) {
- case UTHREAD_PTHREAD_SCOPE_SYSTEM:
- return __pthread_attr_setscope(*attr, PTHREAD_SCOPE_SYSTEM);
- case UTHREAD_PTHREAD_SCOPE_PROCESS:
- return __pthread_attr_setscope(*attr, PTHREAD_SCOPE_PROCESS);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_attr_setstack(pthread_attr_t **attr,
- void *stackaddr,
- size_t stacksize)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_setstack(*attr, stackaddr, stacksize);
-}
-
-int
-_pthread_attr_setstackaddr(pthread_attr_t **attr,
- void *stackaddr)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_setstackaddr(*attr, stackaddr);
-}
-
-int
-_pthread_attr_setstacksize(pthread_attr_t **attr,
- size_t stacksize)
-{
- if (attr == NULL || *attr == NULL)
- return EINVAL;
- return __pthread_attr_setstacksize(*attr, stacksize);
-}
-
-int
-_pthread_barrier_destroy(pthread_barrier_t **barrier)
-{
- int ret;
-
- if (barrier == NULL || *barrier == NULL)
- return EINVAL;
- ret = __pthread_barrier_destroy(*barrier);
- if (ret == 0) {
- free(*barrier);
- *barrier = NULL;
- }
- return ret;
-}
-
-int
-_pthread_barrier_init(pthread_barrier_t **barrier,
- pthread_barrierattr_t **battr,
- unsigned int count)
-{
- int ret;
- pthread_barrier_t *res;
-
- if (barrier == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_barrier_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_barrier_init(res, battr != NULL ? *battr : NULL,
- count);
- if (ret == 0)
- *barrier = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_barrier_wait(pthread_barrier_t **barrier)
-{
- int ret;
-
- if (barrier == NULL)
- return EINVAL;
- if (*barrier == NULL) {
- ret = allocbarrier(barrier);
- if (ret != 0)
- return ret;
- }
- return __pthread_barrier_wait(*barrier);
-}
-
-int
-_pthread_barrierattr_destroy(pthread_barrierattr_t **battr)
-{
- int ret;
-
- if (battr == NULL || *battr == NULL)
- return EINVAL;
- ret = __pthread_barrierattr_destroy(*battr);
- if (ret == 0) {
- free(*battr);
- *battr = NULL;
- }
- return ret;
-}
-
-int
-_pthread_barrierattr_getpshared(const pthread_barrierattr_t **battr,
- int *pshared)
-{
- int ret;
- int lshared;
-
- if (battr == NULL || *battr == NULL || pshared == NULL)
- return EINVAL;
- ret = __pthread_barrierattr_getpshared(*battr, &lshared);
- if (ret == 0) {
- switch (lshared) {
- case PTHREAD_PROCESS_PRIVATE:
- *pshared = UTHREAD_PTHREAD_PROCESS_PRIVATE;
- break;
- case PTHREAD_PROCESS_SHARED:
- *pshared = UTHREAD_PTHREAD_PROCESS_SHARED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_barrierattr_init(pthread_barrierattr_t **battr)
-{
- int ret;
- pthread_barrierattr_t *res;
-
- if (battr == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_barrierattr_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_barrierattr_init(res);
- if (ret == 0)
- *battr = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_barrierattr_setpshared(pthread_barrierattr_t **battr,
- int pshared)
-{
- if (battr == NULL || *battr == NULL)
- return EINVAL;
- switch (pshared) {
- case UTHREAD_PTHREAD_PROCESS_PRIVATE:
- return __pthread_barrierattr_setpshared(*battr,
- PTHREAD_PROCESS_PRIVATE);
- case UTHREAD_PTHREAD_PROCESS_SHARED:
- return __pthread_barrierattr_setpshared(*battr,
- PTHREAD_PROCESS_SHARED);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_cancel(pthread_t tid)
-{
- return __pthread_cancel(tid);
-}
-
-int
-_pthread_cond_broadcast(pthread_cond_t **cond)
-{
- int ret;
-
- if (cond == NULL)
- return EINVAL;
- if (*cond == NULL) {
- ret = alloccond(cond);
- if (ret != 0)
- return ret;
- }
- return __pthread_cond_broadcast(*cond);
-}
-
-int
-_pthread_cond_destroy(pthread_cond_t **cond)
-{
- int ret;
-
- if (cond == NULL || *cond == NULL)
- return EINVAL;
- ret = __pthread_cond_destroy(*cond);
- if (ret == 0) {
- free(*cond);
- *cond = NULL;
- }
- return ret;
-}
-
-int
-_pthread_cond_init(pthread_cond_t **cond,
- pthread_condattr_t **cattr)
-{
- int ret;
- pthread_cond_t *res;
-
- if (cond == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_cond_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_cond_init(res, cattr != NULL ? *cattr : NULL);
- if (ret == 0)
- *cond = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_cond_signal(pthread_cond_t **cond)
-{
- int ret;
-
- if (cond == NULL)
- return EINVAL;
- if (*cond == NULL) {
- ret = alloccond(cond);
- if (ret != 0)
- return ret;
- }
- return __pthread_cond_signal(*cond);
-}
-
-int
-_pthread_cond_timedwait(pthread_cond_t **cond,
- pthread_mutex_t **mutex,
- const struct timespec *timespec)
-{
- int ret;
-
- if (cond == NULL || mutex == NULL)
- return EINVAL;
- if (*cond == NULL) {
- ret = alloccond(cond);
- if (ret != 0)
- return ret;
- }
- if (*mutex == NULL) {
- ret = allocmutex(mutex);
- if (ret != 0)
- return ret;
- }
- return __pthread_cond_timedwait(*cond, *mutex, timespec);
-}
-
-int
-_pthread_cond_wait(pthread_cond_t **cond,
- pthread_mutex_t **mutex)
-{
- int ret;
-
- if (cond == NULL || mutex == NULL)
- return EINVAL;
- if (*cond == NULL) {
- ret = alloccond(cond);
- if (ret != 0)
- return ret;
- }
- if (*mutex == NULL) {
- ret = allocmutex(mutex);
- if (ret != 0)
- return ret;
- }
- return __pthread_cond_wait(*cond, *mutex);
-}
-
-int
-_pthread_condattr_destroy(pthread_condattr_t **cattr)
-{
- int ret;
-
- if (cattr == NULL || *cattr == NULL)
- return EINVAL;
- ret = __pthread_condattr_destroy(*cattr);
- if (ret == 0) {
- free(*cattr);
- *cattr = NULL;
- }
- return ret;
-}
-
-int
-_pthread_condattr_getpshared(const pthread_condattr_t **rwattr,
- int *pshared)
-{
- int ret;
- int lshared;
-
- if (rwattr == NULL || *rwattr == NULL || pshared == NULL)
- return EINVAL;
- ret = __pthread_condattr_getpshared(*rwattr, &lshared);
- if (ret == 0) {
- switch (lshared) {
- case PTHREAD_PROCESS_PRIVATE:
- *pshared = UTHREAD_PTHREAD_PROCESS_PRIVATE;
- break;
- case PTHREAD_PROCESS_SHARED:
- *pshared = UTHREAD_PTHREAD_PROCESS_SHARED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_condattr_init(pthread_condattr_t **cattr)
-{
- pthread_condattr_t *res;
- int ret;
-
- if (cattr == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_condattr_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_condattr_init(res);
- if (ret == 0)
- *cattr = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_condattr_setpshared(pthread_condattr_t **cattr,
- int pshared)
-{
- if (cattr == NULL || *cattr == NULL)
- return EINVAL;
- switch (pshared) {
- case UTHREAD_PTHREAD_PROCESS_PRIVATE:
- return __pthread_condattr_setpshared(*cattr,
- PTHREAD_PROCESS_PRIVATE);
- case UTHREAD_PTHREAD_PROCESS_SHARED:
- return __pthread_condattr_setpshared(*cattr,
- PTHREAD_PROCESS_SHARED);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_create(pthread_t *tid,
- const pthread_attr_t **attr,
- void *(*startfunc)(void *),
- void *arg)
-{
- return __pthread_create(tid,
- attr != NULL ? *attr : NULL,
- startfunc,
- arg);
-}
-
-int
-_pthread_detach(pthread_t tid)
-{
- return __pthread_detach(tid);
-}
-
-int
-_pthread_equal(pthread_t tid1, pthread_t tid2)
-{
- return __pthread_equal(tid1, tid2);
-}
-
-void
-_pthread_exit(void *retval)
-{
- __pthread_exit(retval);
-}
-
-int
-_pthread_getconcurrency(void)
-{
- return __pthread_getconcurrency();
-}
-
-int
-_pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
-{
- return EINVAL;
-}
-
-int
-_pthread_getschedparam(pthread_t tid, int *policy, struct sched_param *sparam)
-{
- if (sparam == NULL || policy == NULL)
- return EINVAL;
- return __pthread_getschedparam(tid, policy, sparam);
-}
-
-void *
-_pthread_getspecific(pthread_key_t key)
-{
- return __pthread_getspecific(key);
-}
-
-int
-_pthread_join(pthread_t tid, void **treturn)
-{
- return __pthread_join(tid, treturn);
-}
-
-int
-_pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
-{
- return __pthread_key_create(key, destructor);
-}
-
-int
-_pthread_key_delete(pthread_key_t key)
-{
- return __pthread_key_delete(key);
-}
-
-int
-_pthread_kill(pthread_t tid, int signo)
-{
- return __pthread_kill(tid, signo);
-}
-
-int
-_pthread_mutex_destroy(pthread_mutex_t **mutex)
-{
- int ret;
-
- if (mutex == NULL || *mutex == NULL)
- return EINVAL;
- ret = __pthread_mutex_destroy(*mutex);
- if (ret == 0) {
- free(*mutex);
- *mutex = NULL;
- }
- return ret;
-}
-
-int
-_pthread_mutex_init(pthread_mutex_t **mutex, const pthread_mutexattr_t **mattr)
-{
- int ret;
- pthread_mutex_t *res;
-
- if (mutex == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_mutex_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_mutex_init(res, mattr != NULL ? *mattr : NULL);
- if (ret == 0)
- *mutex = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_mutex_lock(pthread_mutex_t **mutex)
-{
- int ret;
-
- if (mutex == NULL)
- return EINVAL;
- if (*mutex == NULL) {
- ret = allocmutex(mutex);
- if (ret != 0)
- return ret;
- }
- return __pthread_mutex_lock(*mutex);
-}
-
-int
-_pthread_mutex_timedlock(pthread_mutex_t **mutex,
- const struct timespec *abstime)
-{
- int ret;
-
- if (mutex == NULL)
- return EINVAL;
- if (*mutex == NULL) {
- ret = allocmutex(mutex);
- if (ret != 0)
- return ret;
- }
- return __pthread_mutex_timedlock(*mutex, abstime);
-}
-
-int
-_pthread_mutex_trylock(pthread_mutex_t **mutex)
-{
- int ret;
-
- if (mutex == NULL)
- return EINVAL;
- if (*mutex == NULL) {
- ret = allocmutex(mutex);
- if (ret != 0)
- return ret;
- }
- return __pthread_mutex_trylock(*mutex);
-}
-
-int
-_pthread_mutex_unlock(pthread_mutex_t **mutex)
-{
- if (mutex == NULL || *mutex == NULL)
- return EINVAL;
- return __pthread_mutex_unlock(*mutex);
-}
-
-int
-_pthread_mutexattr_destroy(pthread_mutexattr_t **mattr)
-{
- int ret;
-
- if (mattr == NULL || *mattr == NULL)
- return EINVAL;
- ret = __pthread_mutexattr_destroy(*mattr);
- if (ret == 0) {
- free(*mattr);
- *mattr = NULL;
- }
- return ret;
-}
-
-int
-_pthread_mutexattr_getpshared(const pthread_mutexattr_t **mattr, int *pshared)
-{
- int ret;
- int lshared;
-
- if (mattr == NULL || *mattr == NULL || pshared == NULL)
- return EINVAL;
- ret = __pthread_mutexattr_getpshared(*mattr, &lshared);
- if (ret == 0) {
- switch (lshared) {
- case PTHREAD_PROCESS_PRIVATE:
- *pshared = UTHREAD_PTHREAD_PROCESS_PRIVATE;
- break;
- case PTHREAD_PROCESS_SHARED:
- *pshared = UTHREAD_PTHREAD_PROCESS_SHARED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_mutexattr_gettype(const pthread_mutexattr_t **mattr, int *type)
-{
- int ret;
- int ltype;
-
- if (mattr == NULL || *mattr == NULL || type == NULL)
- return EINVAL;
- ret = __pthread_mutexattr_gettype(*mattr, &ltype);
- if (ret == 0) {
- switch (ltype) {
- case PTHREAD_MUTEX_ERRORCHECK:
- *type = UTHREAD_PTHREAD_MUTEX_ERRORCHECK;
- break;
- case PTHREAD_MUTEX_RECURSIVE:
- *type = UTHREAD_PTHREAD_MUTEX_RECURSIVE;
- break;
- case PTHREAD_MUTEX_NORMAL:
- *type = UTHREAD_PTHREAD_MUTEX_NORMAL;
- break;
- default:
- return EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_mutexattr_init(pthread_mutexattr_t **mattr)
-{
- pthread_mutexattr_t *res;
- int ret;
-
- if (mattr == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_mutexattr_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_mutexattr_init(res);
- if (ret == 0)
- *mattr = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_mutexattr_setpshared(pthread_mutexattr_t **mattr,
- int pshared)
-{
- if (mattr == NULL || *mattr == NULL)
- return EINVAL;
- switch (pshared) {
- case UTHREAD_PTHREAD_PROCESS_PRIVATE:
- return __pthread_mutexattr_setpshared(*mattr,
- PTHREAD_PROCESS_PRIVATE);
- case UTHREAD_PTHREAD_PROCESS_SHARED:
- return __pthread_mutexattr_setpshared(*mattr,
- PTHREAD_PROCESS_SHARED);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_mutexattr_settype(pthread_mutexattr_t **mattr, int type)
-{
- if (mattr == NULL || *mattr == NULL)
- return EINVAL;
- switch (type) {
- case UTHREAD_PTHREAD_MUTEX_ERRORCHECK:
- return __pthread_mutexattr_settype(*mattr,
- PTHREAD_MUTEX_ERRORCHECK);
- case UTHREAD_PTHREAD_MUTEX_RECURSIVE:
- return __pthread_mutexattr_settype(*mattr,
- PTHREAD_MUTEX_RECURSIVE);
- case UTHREAD_PTHREAD_MUTEX_NORMAL:
- return __pthread_mutexattr_settype(*mattr,
- PTHREAD_MUTEX_NORMAL);
- default:
- return EINVAL;
- }
-}
-
-int
-_pthread_once(uthread_pthread_once_t *once_control,
- void (*init_routine) (void))
-{
- if (once_control->state == UTHREAD_PTHREAD_NEEDS_INIT) {
- _pthread_mutex_lock(&(once_control->mutex));
- if (once_control->state == UTHREAD_PTHREAD_NEEDS_INIT) {
- init_routine();
- once_control->state = UTHREAD_PTHREAD_DONE_INIT;
- }
- _pthread_mutex_unlock(&(once_control->mutex));
- }
- return (0);
-}
-
-int
-_pthread_rwlock_destroy(pthread_rwlock_t **rwlock)
-{
- int ret;
-
- if (rwlock == NULL || *rwlock == NULL)
- return EINVAL;
- ret = __pthread_rwlock_destroy(*rwlock);
- if (ret == 0) {
- free(*rwlock);
- *rwlock = NULL;
- }
- return ret;
-}
-
-int
-_pthread_rwlock_init(pthread_rwlock_t **rwlock,
- const pthread_rwlockattr_t **rwlockattr)
-{
- pthread_rwlock_t *res;
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_rwlock_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_rwlock_init(res,
- rwlockattr != NULL ? *rwlockattr : NULL);
- if (ret == 0)
- *rwlock = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_rwlock_rdlock(pthread_rwlock_t **rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_rdlock(*rwlock);
-}
-
-int
-_pthread_rwlock_timedrdlock(pthread_rwlock_t **rwlock,
- const struct timespec *abstime)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_timedrdlock(*rwlock, abstime);
-}
-
-int
-_pthread_rwlock_timedwrlock(pthread_rwlock_t **rwlock,
- const struct timespec *abstime)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_timedwrlock(*rwlock, abstime);
-}
-
-int
-_pthread_rwlock_tryrdlock(pthread_rwlock_t **rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_tryrdlock(*rwlock);
-}
-
-int
-_pthread_rwlock_trywrlock(pthread_rwlock_t **rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_trywrlock(*rwlock);
-}
-
-int
-_pthread_rwlock_unlock(pthread_rwlock_t **rwlock)
-{
- if (rwlock == NULL || *rwlock == NULL)
- return EINVAL;
- return __pthread_rwlock_unlock(*rwlock);
-}
-
-int
-_pthread_rwlock_wrlock(pthread_rwlock_t **rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- return EINVAL;
- if (*rwlock == NULL) {
- ret = allocrwlock(rwlock);
- if (ret != 0)
- return ret;
- }
- return __pthread_rwlock_wrlock(*rwlock);
-}
-
-int
-_pthread_rwlockattr_destroy(pthread_rwlockattr_t **rwattr)
-{
- int ret;
-
- if (rwattr == NULL || *rwattr == NULL)
- return EINVAL;
- ret = __pthread_rwlockattr_destroy(*rwattr);
- if (ret == 0) {
- free(*rwattr);
- *rwattr = NULL;
- }
- return ret;
-}
-
-int
-_pthread_rwlockattr_getpshared(const pthread_rwlockattr_t **rwattr,
- int *pshared)
-{
- int ret;
- int lshared;
-
- if (rwattr == NULL || *rwattr == NULL || pshared == NULL)
- return EINVAL;
- ret = __pthread_rwlockattr_getpshared(*rwattr, &lshared);
- if (ret == 0) {
- switch (lshared) {
- case PTHREAD_PROCESS_PRIVATE:
- *pshared = UTHREAD_PTHREAD_PROCESS_PRIVATE;
- break;
- case PTHREAD_PROCESS_SHARED:
- *pshared = UTHREAD_PTHREAD_PROCESS_SHARED;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_rwlockattr_init(pthread_rwlockattr_t **rwattr)
-{
- pthread_rwlockattr_t *res;
- int ret;
-
- if (rwattr == NULL)
- return EINVAL;
- res = malloc(sizeof(pthread_rwlockattr_t));
- if (res == NULL)
- return ENOMEM;
- ret = __pthread_rwlockattr_init(res);
- if (ret == 0)
- *rwattr = res;
- else
- free(res);
- return ret;
-}
-
-int
-_pthread_rwlockattr_setpshared(pthread_rwlockattr_t **rwattr,
- int pshared)
-{
- if (rwattr == NULL || *rwattr == NULL)
- return EINVAL;
- switch (pshared) {
- case UTHREAD_PTHREAD_PROCESS_PRIVATE:
- return __pthread_rwlockattr_setpshared(*rwattr,
- PTHREAD_PROCESS_PRIVATE);
- case UTHREAD_PTHREAD_PROCESS_SHARED:
- return __pthread_rwlockattr_setpshared(*rwattr,
- PTHREAD_PROCESS_SHARED);
- default:
- return EINVAL;
- }
-}
-
-pthread_t
-_pthread_self(void)
-{
- return __pthread_self();
-}
-
-int
-_pthread_setcancelstate(int newstate, int *oldstate)
-{
- int ret;
- int lold;
-
- switch (newstate) {
- case UTHREAD_PTHREAD_CANCEL_ENABLE:
- ret = __pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &lold);
- break;
- case UTHREAD_PTHREAD_CANCEL_DISABLE:
- ret = __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &lold);
- break;
- default:
- ret = EINVAL;
- }
- if (ret == 0 && oldstate != NULL) {
- switch (lold) {
- case PTHREAD_CANCEL_ENABLE:
- *oldstate = UTHREAD_PTHREAD_CANCEL_ENABLE;
- break;
- case PTHREAD_CANCEL_DISABLE:
- *oldstate = UTHREAD_PTHREAD_CANCEL_DISABLE;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_setcanceltype(int newtype, int *oldtype)
-{
- int ret;
- int lold;
-
- switch (newtype) {
- case UTHREAD_PTHREAD_CANCEL_DEFERRED:
- ret = __pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &lold);
- break;
- case UTHREAD_PTHREAD_CANCEL_ASYNCHRONOUS:
- ret = __pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &lold);
- break;
- default:
- ret = EINVAL;
- }
- if (ret == 0 && oldtype != NULL) {
- switch (lold) {
- case PTHREAD_CANCEL_DEFERRED:
- *oldtype = UTHREAD_PTHREAD_CANCEL_DEFERRED;
- break;
- case PTHREAD_CANCEL_ASYNCHRONOUS:
- *oldtype = UTHREAD_PTHREAD_CANCEL_ASYNCHRONOUS;
- break;
- default:
- ret = EINVAL;
- }
- }
- return ret;
-}
-
-int
-_pthread_setconcurrency(int level)
-{
- return __pthread_setconcurrency(level);
-}
-
-int
-_pthread_setschedparam(pthread_t tid, int policy,
- const struct sched_param *sparam)
-{
- return __pthread_setschedparam(tid, policy, sparam);
-}
-
-int
-_pthread_setspecific(pthread_key_t key, const void *value)
-{
- return __pthread_setspecific(key, value);
-}
-
-int
-_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
-{
- return __pthread_sigmask(how, set, oset);
-}
-
-void
-_pthread_testcancel(void)
-{
- __pthread_testcancel();
-}
-
-#ifdef LINUXTHREADS_WRAP_API
-
-#include "internals.h"
-
-void linuxthreads__pthread_cleanup_pop(struct _pthread_cleanup_buffer *buf,
- int execute);
-void linuxthreads__pthread_cleanup_push(struct _pthread_cleanup_buffer *buf,
- void (*)(void *),
- void *);
-
-void wrap_pthread_cleanup_pop(int) __asm__("_pthread_cleanup_pop");
-
-void wrap_pthread_cleanup_push(void (*)(void *), void *) __asm__("_pthread_cleanup_push");
-
-#undef pthread_cleanup_pop
-#undef pthread_cleanup_push
-
-extern int pthread_cleanup_pop(int) __attribute__ ((weak, alias("_pthread_cleanup_pop")));
-
-extern int pthread_cleanup_push(void (*)(void *), void *) __attribute__ ((weak, alias("_pthread_cleanup_push")));
-
-struct wrap_pthread_cleanup_buffer {
- struct _pthread_cleanup_buffer _buf;
- void (*func)(void *);
- void *arg;
- void *nextfree;
-};
-
-
-static pthread_mutex_t cleanup_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_key_t cleanup_key = (pthread_key_t) -1;
-static void free_cleanup_buffers(void *arg);
-
-static struct wrap_pthread_cleanup_buffer *
-alloc_cleanup_buffer(void)
-{
- struct wrap_pthread_cleanup_buffer *buf;
-
- if (cleanup_key == (pthread_key_t) -1) {
- __pthread_mutex_lock(&cleanup_mutex);
- if (cleanup_key == (pthread_key_t) -1) {
- if (__pthread_key_create(&cleanup_key,
- free_cleanup_buffers) < 0) {
- __pthread_mutex_unlock(&cleanup_mutex);
- abort();
- }
- }
- __pthread_mutex_unlock(&cleanup_mutex);
- }
- buf = __pthread_getspecific(cleanup_key);
- if (buf == NULL) {
- buf = (struct wrap_pthread_cleanup_buffer *)
- malloc(sizeof(struct wrap_pthread_cleanup_buffer));
- } else {
- __pthread_setspecific(cleanup_key, buf->nextfree);
- }
- if (buf != NULL) {
- buf->nextfree = NULL;
- }
- return buf;
-}
-
-
-static void
-stash_cleanup_buffer(struct wrap_pthread_cleanup_buffer *buf)
-{
- buf->nextfree = __pthread_getspecific(cleanup_key);
- __pthread_setspecific(cleanup_key, buf);
-}
-
-static void
-free_cleanup_buffers(void *arg)
-{
- struct wrap_pthread_cleanup_buffer *buf;
- struct wrap_pthread_cleanup_buffer *nbuf;
-
- buf = (struct wrap_pthread_cleanup_buffer *) arg;
- while (buf != NULL) {
- nbuf = buf->nextfree;
- free(buf);
- buf = nbuf;
- }
-}
-
-static void
-wrap_cleanup(void *arg)
-{
- struct wrap_pthread_cleanup_buffer *buf;
-
- buf = (struct wrap_pthread_cleanup_buffer *) arg;
- buf->func(buf->arg);
-
- /* Cannot free buffer yet ==> stash it on a thread specific freelist */
- stash_cleanup_buffer(buf);
-}
-
-void
-wrap_pthread_cleanup_pop(int execute)
-{
- pthread_descr self;
- struct _pthread_cleanup_buffer *buf;
-
- self = thread_self();
- buf = THREAD_GETMEM(self, p_cleanup);
-
- linuxthreads__pthread_cleanup_pop(buf, execute);
-}
-
-void
-wrap_pthread_cleanup_push(void (*func)(void *),
- void *arg)
-{
- struct wrap_pthread_cleanup_buffer *buf;
-
- buf = alloc_cleanup_buffer();
- buf->func = func;
- buf->arg = arg;
- linuxthreads__pthread_cleanup_push(&buf->_buf,
- wrap_cleanup,
- buf);
-}
-#endif
diff --git a/devel/linuxthreads/pkg-descr b/devel/linuxthreads/pkg-descr
deleted file mode 100644
index 5af7e0a3fd91..000000000000
--- a/devel/linuxthreads/pkg-descr
+++ /dev/null
@@ -1,15 +0,0 @@
-LinuxThreads is an POSIX pthreads implementation using "kernel threads". In
-this FreeBSD port, a kernel thread is started using rfork (whereas in the
-original Linux implementation a kernel thread is started using the Linux clone
-call).
-This implementation provides a so-called one-to-one mapping of threads to
-kernel schedulable entities. For more information see about the original
-LinuxThreads implementation see:
-
-WWW: http://pauillac.inria.fr/~xleroy/linuxthreads/
-
-Note that LinuxThreads has been integrated with the GNU C library (glibc) since
-version 2.0, so the above URL points to dated information.
-
-The complete FreeBSD source code matching the installed userland
-must be installed in /usr/src before building linuxthreads.
diff --git a/devel/linuxthreads/pkg-message b/devel/linuxthreads/pkg-message
deleted file mode 100644
index 04c2689e0b24..000000000000
--- a/devel/linuxthreads/pkg-message
+++ /dev/null
@@ -1,3 +0,0 @@
-Please see the README.FreeBSD file in the work directory for
-instructions on how to compile with linuxthreads, and for other
-issues and problems.
diff --git a/devel/linuxthreads/pkg-plist b/devel/linuxthreads/pkg-plist
deleted file mode 100644
index db10b3ad484b..000000000000
--- a/devel/linuxthreads/pkg-plist
+++ /dev/null
@@ -1,38 +0,0 @@
-lib/liblthread.a
-%%PROFILE:%%lib/liblthread_p.a
-%%LIBLTHREADPICARCHIVE:%%lib/liblthread_pic.a
-%%PIC:%%lib/liblthread.so
-%%PIC:%%lib/liblthread.so.%%LTHREADSHMAJOR:%%
-lib/liblgcc_r.a
-lib/liblgcc_r_pic.a
-%%GCC4ONLY:%%lib/liblgcc_r_eh.a
-%%GCC4ONLY:%%lib/liblgcc_r_eh_p.a
-%%PROFILE:%%lib/liblgcc_r_p.a
-%%GCC4ONLY:%%lib/liblgcc_s.so
-%%GCC4ONLY:%%lib/liblgcc_s.so.1
-%%LIBLGCC_R_PICARCHIVE:%%lib/liblgcc_r_pic.a
-%%GCC3OR4ONLY:%%lib/liblstdc++.a
-%%GCC3OR4ONLY:%%%%PROFILE:%%lib/liblstdc++_p.a
-%%GCC3OR4ONLY:%%%%PICARCHIVE:%%lib/liblstdc++_pic.a
-%%GCC3OR4ONLY:%%%%PIC:%%lib/liblstdc++.so
-%%GCC3OR4ONLY:%%%%PIC:%%lib/liblstdc++.so.%%LIBSTDCPPMAJOR:%%
-%%GCC3OR4ONLY:%%lib/liblsupc++.a
-%%GCC3OR4ONLY:%%%%PROFILE:%%lib/liblsupc++_p.a
-%%GCC3OR4ONLY:%%%%PICARCHIVE:%%lib/liblsupc++_pic.a
-include/pthread/linuxthreads/pthread.h
-include/pthread/linuxthreads/semaphore.h
-include/pthread/linuxthreads/pt-machine.h
-include/pthread/linuxthreads/useldt.h
-include/pthread/linuxthreads/bits/initspin.h
-include/pthread/linuxthreads/bits/libc-lock.h
-include/pthread/linuxthreads/bits/libc-tsd.h
-include/pthread/linuxthreads/bits/pthreadtypes.h
-include/pthread/linuxthreads/bits/stdio-lock.h
-include/pthread/linuxthreads/bits/local_lim.h
-include/pthread/linuxthreads/bits/posix_opt.h
-include/pthread/linuxthreads/bits/sigthread.h
-include/pthread/linuxthreads/sys/_pthreadtypes.h
-@dirrm include/pthread/linuxthreads/sys
-@dirrm include/pthread/linuxthreads/bits
-@dirrm include/pthread/linuxthreads
-@dirrm include/pthread