]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / makecontext.c
index 94760e0c2bbeac92c7bbd5231a17c59062604eaa..42cdb1e948fa96b41d9bbdb25c776e7181739b2b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
@@ -13,9 +13,8 @@
    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.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <libintl.h>
 #include <stdarg.h>
    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,52 +53,44 @@ 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.  */
   sp -= 24;
   *sp = 0;
 
-  /* Pass (*func) to __start_context in %r7.  */
-  ucp->uc_mcontext.gregs[7] = (long) func;
+  /* Pass (*func) to __makecontext_ret in %r7.  */
+  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;
+  /* Pass ucp->uc_link to __makecontext_ret in %r8.  */
+  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");
-
 weak_alias (__makecontext, makecontext)