diff options
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/ChangeLog | 8 | ||||
-rw-r--r-- | nptl/Makefile | 3 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S | 27 | ||||
-rw-r--r-- | nptl/tst-align3.c | 57 |
4 files changed, 87 insertions, 8 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index b4fe8e03a6..7059de65a6 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,11 @@ +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 e7cbbcb1f6..e3c16dd7c6 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 \ @@ -412,6 +412,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/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" |