summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-04-13 10:23:22 -0700
committerUlrich Drepper <drepper@redhat.com>2010-04-13 10:23:22 -0700
commit0dabf204ef2efaff8fa01a8d5d0f17eb8c0db796 (patch)
tree0b25d33e639cbd1405f3e034df27398f4251074c
parentef634a94c7126bcd6ac02de495b598fb99ac544d (diff)
downloadglibc-0dabf204ef2efaff8fa01a8d5d0f17eb8c0db796.tar.gz
glibc-0dabf204ef2efaff8fa01a8d5d0f17eb8c0db796.tar.xz
glibc-0dabf204ef2efaff8fa01a8d5d0f17eb8c0db796.zip
Fix makecontext on s390/s390x
-rw-r--r--ChangeLog6
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c64
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c62
3 files changed, 69 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog
index be0dd16054..60391d622b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-13  Andreas Schwab  <schwab@redhat.com>
+
+	* sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c: Fix setup of
+	overflow area.
+	* sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c: Likewise.
+
 2010-04-12  Andreas Schwab  <schwab@redhat.com>
 
 	* stdlib/tst-makecontext3.c (main): Initialize ucontext_t objects
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c b/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c
index 94760e0c2b..0e309c3e29 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
@@ -28,15 +28,15 @@
    double, complex and structure with sizes 0, 2, 4 or 8
    won't work.
    makecontext sets up a stack and the registers for the
-   context. The stack looks like this:
-           size                         offset
+   user context. The stack looks like this:
+	   size                         offset
     %r15 ->    +-----------------------+
-             4 | back chain (zero)     |  0
-             4 | reserved              |  4
-            88 | save area for (*func) |  8
-               +-----------------------+
-             n | overflow parameters   | 96
-               +-----------------------+
+	     4 | back chain (zero)     |  0
+	     4 | reserved              |  4
+	    88 | save area for (*func) |  8
+	       +-----------------------+
+	     n | overflow parameters   | 96
+	       +-----------------------+
    The registers are set up like this:
      %r2-%r6: parameters 1 to 5
      %r7    : (*func) pointer
@@ -54,27 +54,27 @@ void
 __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
 {
   extern void __makecontext_ret (void);
-  unsigned long *sp;
+  unsigned long int *sp;
   va_list ap;
-  int i;
 
-  sp = (unsigned long *) (((unsigned long) ucp->uc_stack.ss_sp
-			   + ucp->uc_stack.ss_size) & -8L);
+  sp = (unsigned long int *) (((unsigned long int) ucp->uc_stack.ss_sp
+			       + ucp->uc_stack.ss_size) & -8L);
 
   /* Set the return address to trampoline.  */
-  ucp->uc_mcontext.gregs[14] = (long) __makecontext_ret;
+  ucp->uc_mcontext.gregs[14] = (long int) __makecontext_ret;
 
   /* Set register parameters.  */
   va_start (ap, argc);
-  for (i = 0; (i < argc) && (i < 5); i++)
-    ucp->uc_mcontext.gregs[2+i] = va_arg (ap, long);
+  for (int i = 0; i < argc && i < 5; ++i)
+    ucp->uc_mcontext.gregs[2 + i] = va_arg (ap, long int);
 
   /* The remaining arguments go to the overflow area.  */
-  if (argc > 5) {
-    sp -= argc - 5;
-    for (i = 5; i < argc; i++)
-      sp[i] = va_arg(ap, long);
-  }
+  if (argc > 5)
+    {
+      sp -= argc - 5;
+      for (int i = 5; i < argc; ++i)
+	sp[i - 5] = va_arg (ap, long int);
+    }
   va_end (ap);
 
   /* Make room for the save area and set the backchain.  */
@@ -82,24 +82,24 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
   *sp = 0;
 
   /* Pass (*func) to __start_context in %r7.  */
-  ucp->uc_mcontext.gregs[7] = (long) func;
+  ucp->uc_mcontext.gregs[7] = (long int) func;
 
   /* Pass ucp->uc_link to __start_context in %r8.  */
-  ucp->uc_mcontext.gregs[8] = (long) ucp->uc_link;
+  ucp->uc_mcontext.gregs[8] = (long int) ucp->uc_link;
 
   /* Pass address of setcontext in %r9.  */
-  ucp->uc_mcontext.gregs[9] = (long) &setcontext;
+  ucp->uc_mcontext.gregs[9] = (long int) &setcontext;
 
   /* Set stack pointer.  */
-  ucp->uc_mcontext.gregs[15] = (long) sp;
+  ucp->uc_mcontext.gregs[15] = (long int) sp;
 }
 
-asm(".text\n"
-    ".type __makecontext_ret,@function\n"
-    "__makecontext_ret:\n"
-    "      basr  %r14,%r7\n"
-    "      lr    %r2,%r8\n"
-    "      br    %r9\n"
-    ".size __makecontext_ret, .-__makecontext_ret");
+asm (".text\n"
+     ".type __makecontext_ret,@function\n"
+     "__makecontext_ret:\n"
+     "      basr  %r14,%r7\n"
+     "      lr    %r2,%r8\n"
+     "      br    %r9\n"
+     ".size __makecontext_ret, .-__makecontext_ret");
 
 weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c b/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c
index b08f1b4047..40ff3eefb4 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
@@ -29,14 +29,14 @@
    won't work.
    makecontext sets up a stack and the registers for the
    user context. The stack looks like this:
-           size                         offset
+	   size                         offset
     %r15 ->    +-----------------------+
-             8 | back chain (zero)     |  0
-             8 | reserved              |  8
-           144 | save area for (*func) | 16
-               +-----------------------+
-             n | overflow parameters   | 160
-               +-----------------------+
+	     8 | back chain (zero)     |  0
+	     8 | reserved              |  8
+	   144 | save area for (*func) | 16
+	       +-----------------------+
+	     n | overflow parameters   | 160
+	       +-----------------------+
    The registers are set up like this:
      %r2-%r6: parameters 1 to 5
      %r7    : (*func) pointer
@@ -54,27 +54,27 @@ void
 __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
 {
   extern void __makecontext_ret (void);
-  unsigned long *sp;
+  unsigned long int *sp;
   va_list ap;
-  int i;
 
-  sp = (unsigned long *) (((unsigned long) ucp->uc_stack.ss_sp
-			   + ucp->uc_stack.ss_size) & -8L);
+  sp = (unsigned long int *) (((unsigned long int) ucp->uc_stack.ss_sp
+			       + ucp->uc_stack.ss_size) & -8L);
 
   /* Set the return address to trampoline.  */
-  ucp->uc_mcontext.gregs[14] = (long) __makecontext_ret;
+  ucp->uc_mcontext.gregs[14] = (long int) __makecontext_ret;
 
   /* Set register parameters.  */
   va_start (ap, argc);
-  for (i = 0; (i < argc) && (i < 5); i++)
-    ucp->uc_mcontext.gregs[2+i] = va_arg (ap, long);
+  for (int i = 0; i < argc && i < 5; ++i)
+    ucp->uc_mcontext.gregs[2 + i] = va_arg (ap, long int);
 
   /* The remaining arguments go to the overflow area.  */
-  if (argc > 5) {
-    sp -= argc - 5;
-    for (i = 5; i < argc; i++)
-      sp[i] = va_arg(ap, long);
-  }
+  if (argc > 5)
+    {
+      sp -= argc - 5;
+      for (int i = 5; i < argc; ++i)
+	sp[i - 5] = va_arg (ap, long int);
+    }
   va_end (ap);
 
   /* Make room for the save area and set the backchain.  */
@@ -82,24 +82,24 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
   *sp = 0;
 
   /* Pass (*func) to __start_context in %r7.  */
-  ucp->uc_mcontext.gregs[7] = (long) func;
+  ucp->uc_mcontext.gregs[7] = (long int) func;
 
   /* Pass ucp->uc_link to __start_context in %r8.  */
-  ucp->uc_mcontext.gregs[8] = (long) ucp->uc_link;
+  ucp->uc_mcontext.gregs[8] = (long int) ucp->uc_link;
 
   /* Pass address of setcontext in %r9.  */
-  ucp->uc_mcontext.gregs[9] = (long) &setcontext;
+  ucp->uc_mcontext.gregs[9] = (long int) &setcontext;
 
   /* Set stack pointer.  */
-  ucp->uc_mcontext.gregs[15] = (long) sp;
+  ucp->uc_mcontext.gregs[15] = (long int) sp;
 }
 
-asm(".text\n"
-    ".type __makecontext_ret,@function\n"
-    "__makecontext_ret:\n"
-    "      basr  %r14,%r7\n"
-    "      lgr   %r2,%r8\n"
-    "      br    %r9\n"
-    ".size __makecontext_ret, .-__makecontext_ret");
+asm (".text\n"
+     ".type __makecontext_ret,@function\n"
+     "__makecontext_ret:\n"
+     "      basr  %r14,%r7\n"
+     "      lgr   %r2,%r8\n"
+     "      br    %r9\n"
+     ".size __makecontext_ret, .-__makecontext_ret");
 
 weak_alias (__makecontext, makecontext)