summaryrefslogtreecommitdiff
path: root/devel/linuxthreads/files
diff options
context:
space:
mode:
authorTor Egge <tegge@FreeBSD.org>2005-07-22 22:20:21 +0000
committerTor Egge <tegge@FreeBSD.org>2005-07-22 22:20:21 +0000
commit20fa307449d9fa0d99a080cc66a5b037f8ca0b78 (patch)
treea25a5a9e4e6e2741431b6712a2713d885f958a84 /devel/linuxthreads/files
parent- Update to 2.2.5 (diff)
Check for NO_PIC and NO_PROFILE on FreeBSD >= 6.0.
Add sys/_pthreadtypes.h to allow compilation on FreeBSD >= 6.0. Initialize signal trampoline variables earlier to avoid race in wrapper around sigaction. Fix known API wrapper bugs. Port compile time options: Add option for using an alternate restart signal instead of SIGUSR2. Add options for adjustment of maximum thread stack size and maximum number of threads. Make all options start with LINUXTHREADS_ Note that complete FreeBSD source matching userland must be installed in /usr/src when compiling this port.
Notes
Notes: svn path=/head/; revision=139916
Diffstat (limited to 'devel/linuxthreads/files')
-rw-r--r--devel/linuxthreads/files/README.FreeBSD21
-rw-r--r--devel/linuxthreads/files/_pthreadtypes.h45
-rw-r--r--devel/linuxthreads/files/patch-aa67
-rw-r--r--devel/linuxthreads/files/wraputhread.c14
4 files changed, 135 insertions, 12 deletions
diff --git a/devel/linuxthreads/files/README.FreeBSD b/devel/linuxthreads/files/README.FreeBSD
index d59a697de9d1..7aacaa3b5190 100644
--- a/devel/linuxthreads/files/README.FreeBSD
+++ b/devel/linuxthreads/files/README.FreeBSD
@@ -138,3 +138,24 @@ set at 20 + 16 * MAXUSERS.
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
new file mode 100644
index 000000000000..7b485dc568de
--- /dev/null
+++ b/devel/linuxthreads/files/_pthreadtypes.h
@@ -0,0 +1,45 @@
+/*-
+ * 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/patch-aa b/devel/linuxthreads/files/patch-aa
index 58e262ed0b75..31cb50737af6 100644
--- a/devel/linuxthreads/files/patch-aa
+++ b/devel/linuxthreads/files/patch-aa
@@ -13,7 +13,7 @@ diff -ru ../../work/linuxthreads-2.2.3/Examples/Makefile ./Examples/Makefile
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,126 @@
+@@ -1,128 +1,143 @@
-# Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
-# This file is part of the GNU C Library.
+LIB=lthread
@@ -65,6 +65,12 @@ diff -ru ../../work/linuxthreads-2.2.3/Makefile ./Makefile
+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
@@ -78,6 +84,10 @@ diff -ru ../../work/linuxthreads-2.2.3/Makefile ./Makefile
+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.
@@ -115,6 +125,13 @@ diff -ru ../../work/linuxthreads-2.2.3/Makefile ./Makefile
+ ${.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) \
@@ -749,13 +766,17 @@ diff -ru ../../work/linuxthreads-2.2.3/pthread.c ./pthread.c
static void pthread_handle_sigcancel(int sig);
static void pthread_handle_sigrestart(int sig);
static void pthread_handle_sigdebug(int sig);
-@@ -238,8 +246,8 @@
+@@ -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
@@ -1105,7 +1126,15 @@ diff -ru ../../work/linuxthreads-2.2.3/signals.c ./signals.c
{
pthread_descr self;
char * in_sighandler;
-@@ -145,9 +144,9 @@
+@@ -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)
@@ -1117,12 +1146,30 @@ diff -ru ../../work/linuxthreads-2.2.3/signals.c ./signals.c
}
newactp = &newact;
}
-@@ -158,7 +157,7 @@
+ 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 *) 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. */
@@ -1225,6 +1272,16 @@ diff -ru ../../work/linuxthreads-2.2.3/sysdeps/unix/sysv/linux/bits/local_lim.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
diff --git a/devel/linuxthreads/files/wraputhread.c b/devel/linuxthreads/files/wraputhread.c
index 0394f53ba07f..b59c2cae4a82 100644
--- a/devel/linuxthreads/files/wraputhread.c
+++ b/devel/linuxthreads/files/wraputhread.c
@@ -1,4 +1,6 @@
/*
+ * 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.
*
@@ -23,7 +25,7 @@
* 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.3 2003-06-09 03:48:31 tegge Exp $
+ * $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/wraputhread.c,v 1.4 2005-07-22 22:20:21 tegge Exp $
*/
#ifdef LINUXTHREADS_WRAP_API
@@ -242,14 +244,14 @@ enum {
};
enum {
- UTHREAD_PTHREAD_INHERIT_SCHED = 0,
- UTHREAD_PTHREAD_EXPLICIT_SCHED = 1
+ UTHREAD_PTHREAD_INHERIT_SCHED = 4,
+ UTHREAD_PTHREAD_EXPLICIT_SCHED = 0
};
enum {
- UTHREAD_PTHREAD_SCOPE_SYSTEM = 0,
- UTHREAD_PTHREAD_SCOPE_PROCESS = 1
+ UTHREAD_PTHREAD_SCOPE_SYSTEM = 2,
+ UTHREAD_PTHREAD_SCOPE_PROCESS = 0
};
enum {
@@ -1050,8 +1052,6 @@ _pthread_getspecific(pthread_key_t key)
int
_pthread_join(pthread_t tid, void **treturn)
{
- if (treturn == NULL)
- return EINVAL;
return __pthread_join(tid, treturn);
}