summaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-10-20 06:59:57 +0000
committerJakub Jelinek <jakub@redhat.com>2005-10-20 06:59:57 +0000
commitb7071f6fc41f4c20510de3683f39e5c8ea8a2e1e (patch)
tree852f4f1992a3c9ecbb44b822df6702c7e635fc5a /nptl
parentacfebba27b162b3064c616142883541eaef3f725 (diff)
Updated to fedora-glibc-20051020T0651
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog18
-rw-r--r--nptl/Makefile6
-rw-r--r--nptl/TODO4
-rw-r--r--nptl/init.c21
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S27
-rw-r--r--nptl/tst-align3.c57
6 files changed, 114 insertions, 19 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 815d4b5ebd..02da41dd82 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,21 @@
+2005-10-16 Roland McGrath <roland@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Even when using a
+ compile-time default stack size, apply the minimum that allocate_stack
+ will require, and round up to page size.
+
+2005-10-10 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * Makefile ($(test-modules)): Remove static pattern rule.
+
+2005-10-14 Jakub Jelinek <jakub@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Fix stack
+ alignment in callback function.
+ * Makefile: Add rules to build and run tst-align3.
+ * tst-align3.c: New file.
+
2005-10-03 Jakub Jelinek <jakub@redhat.com>
* allocatestack.c (setxid_signal_thread): Add
diff --git a/nptl/Makefile b/nptl/Makefile
index 1fbe464518..dbe84b1c4f 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -205,7 +205,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
tst-sem8 tst-sem9 \
tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
- tst-align tst-align2 \
+ tst-align tst-align2 tst-align3 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
tst-raise1 \
@@ -295,9 +295,6 @@ tst-tls5modd.so-no-z-defs = yes
tst-tls5mode.so-no-z-defs = yes
tst-tls5modf.so-no-z-defs = yes
-$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
- $(build-module)
-
ifeq ($(build-shared),yes)
# Build all the modules even when not actually running test programs.
tests: $(test-modules)
@@ -412,6 +409,7 @@ CFLAGS-tst-cleanupx4.c += -fexceptions
CFLAGS-tst-oncex3.c += -fexceptions
CFLAGS-tst-oncex4.c += -fexceptions
CFLAGS-tst-align.c += $(stack-align-test-flags)
+CFLAGS-tst-align3.c += $(stack-align-test-flags)
CFLAGS-tst-initializers1.c += -W -Wall -Werror
tst-cancel7-ARGS = --command "$(built-program-cmd)"
diff --git a/nptl/TODO b/nptl/TODO
index a4a1055f46..d597176512 100644
--- a/nptl/TODO
+++ b/nptl/TODO
@@ -6,6 +6,10 @@
- a new attribute for mutexes: number of times we spin before calling
sys_futex
+- for adaptive mutexes: when releasing, determine whether somebody spins.
+If yes, for a short time release lock. If someone else locks no wakeup
+syscall needed.
+
- test with threaded process terminating and semadj (?) being applied
diff --git a/nptl/init.c b/nptl/init.c
index de704122d1..6a7fff9959 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -297,17 +297,22 @@ __pthread_initialize_minimal_internal (void)
|| limit.rlim_cur == RLIM_INFINITY)
/* The system limit is not usable. Use an architecture-specific
default. */
- __default_stacksize = ARCH_STACK_DEFAULT_SIZE;
+ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
else if (limit.rlim_cur < PTHREAD_STACK_MIN)
/* The system limit is unusably small.
Use the minimal size acceptable. */
- __default_stacksize = PTHREAD_STACK_MIN;
- else
- {
- /* Round the resource limit up to page size. */
- const uintptr_t pagesz = __sysconf (_SC_PAGESIZE);
- __default_stacksize = (limit.rlim_cur + pagesz - 1) & -pagesz;
- }
+ limit.rlim_cur = PTHREAD_STACK_MIN;
+
+ /* Make sure it meets the minimum size that allocate_stack
+ (allocatestack.c) will demand, which depends on the page size. */
+ const uintptr_t pagesz = __sysconf (_SC_PAGESIZE);
+ const size_t minstack = pagesz * 2 + __static_tls_size + MINIMAL_REST_STACK;
+ if (limit.rlim_cur < minstack)
+ limit.rlim_cur = minstack;
+
+ /* Round the resource limit up to page size. */
+ limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
+ __default_stacksize = limit.rlim_cur;
/* Get the size of the static and alignment requirements for the TLS
block. */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
index 6bf8d095ba..9db5516913 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
@@ -86,9 +86,11 @@ __pthread_once:
/* Preserve the pointer to the control variable. */
3: pushq %rdi
.Lpush_rdi:
+ pushq %rdi
+.Lpush_rdi2:
.LcleanupSTART:
- callq *8(%rsp)
+ callq *16(%rsp)
.LcleanupEND:
/* Get the control variable address back. */
@@ -99,6 +101,9 @@ __pthread_once:
LOCK
incl (%rdi)
+ addq $8, %rsp
+.Ladd1:
+
/* Wake up all other threads. */
movl $0x7fffffff, %edx
movl $FUTEX_WAKE, %esi
@@ -106,7 +111,7 @@ __pthread_once:
syscall
4: addq $8, %rsp
-.Ladd:
+.Ladd2:
xorl %eax, %eax
retq
@@ -224,20 +229,28 @@ clear_once_control:
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 24
.byte 4 # DW_CFA_advance_loc4
- .long .Lpop_rdi-.Lpush_rdi
+ .long .Lpush_rdi2-.Lpush_rdi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 32
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpop_rdi-.Lpush_rdi2
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 24
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Ladd1-.Lpop_rdi
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 16
.byte 4 # DW_CFA_advance_loc4
- .long .Ladd-.Lpop_rdi
+ .long .Ladd2-.Ladd1
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 8
.byte 4 # DW_CFA_advance_loc4
- .long clear_once_control-.Ladd
+ .long clear_once_control-.Ladd2
.byte 14 # DW_CFA_def_cfa_offset
- .uleb128 24
+ .uleb128 32
#if 0
.byte 4 # DW_CFA_advance_loc4
- .long .Lpop_rdi2-clear_once_control
+ .long .Lpop_rdi3-clear_once_control
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 16
#endif
diff --git a/nptl/tst-align3.c b/nptl/tst-align3.c
new file mode 100644
index 0000000000..64df146131
--- /dev/null
+++ b/nptl/tst-align3.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <tst-stack-align.h>
+
+static bool ok = true;
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static void
+once_test (void)
+{
+ puts ("in once_test");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+}
+
+static int
+do_test (void)
+{
+ puts ("in main");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ if (pthread_once (&once, once_test))
+ {
+ puts ("pthread once failed");
+ return 1;
+ }
+
+ return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"