From 4dc8a2aec63e4fb5ee2688544c4de323ed5de3ef Mon Sep 17 00:00:00 2001
From: Wichert Akkerman <wichert@deephackmode.org>
Date: Thu, 23 Dec 1999 14:20:14 +0000
Subject: [PATCH] Bunch of stuff

---
 CREDITS            |   1 +
 ChangeLog          |  13 ++
 NEWS               |   6 +
 bjm.c              |  31 +++++
 config.sub         |   7 +-
 configure.in       |   3 +
 desc.c             |   1 +
 file.c             |   1 +
 io.c               |   1 +
 ioctl.c            |   1 +
 ipc.c              |   1 +
 linux/syscall.h    |   2 +-
 linux/syscallent.h |  10 +-
 mem.c              |  41 ++++---
 net.c              |   3 +-
 process.c          | 297 ++++++++++++++++++++++++++++-----------------
 resource.c         |   1 +
 signal.c           |  26 ++++
 strace.1           |   2 +-
 strace.c           |   1 +
 stream.c           |   1 +
 syscall.c          |  27 ++++-
 system.c           |   1 +
 util.c             |  23 +++-
 24 files changed, 359 insertions(+), 142 deletions(-)

diff --git a/CREDITS b/CREDITS
index 7a59c7fb..e2f05229 100644
--- a/CREDITS
+++ b/CREDITS
@@ -37,3 +37,4 @@ porting to new systems:
 	John Hughes <john@Calva.COM>
 	Richard Braakman <dark@xs4all.nl>
 	Florian Lohoff <flo@rfc822.org>
+	D.J. Barrow <djbarrow@de.ibm.com>
diff --git a/ChangeLog b/ChangeLog
index 19aa8e8e..959068c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,20 @@
+Thu Dec 23 15:01:37 CET 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Merge patch from ftp://oss.software.ibm.com/linux390/ to add
+    support for Linux on the IBM S/390 architecture
+
+Mon Dec 20 00:27:50 CET 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Rewrite mmap-handling to support mmap2 on Linux
+
 Tue Dec 14 11:35:16 CET 1999 Wichert Akkerman <wakkerma@debian.org>
 
   * Note that Linux can handle sys_semop() as well
 
+Tue Nov 30 11:05:26 CET 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Include linux/in6.h for glibc2.0 and older
+
 Mon Nov 29 16:33:04 CET 1999 Wichert Akkerman <wakkerma@debian.org>
 
   * Merge patches from John Hughes to make configure support UnixWare
diff --git a/NEWS b/NEWS
index c7148f5b..d30d556d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Changes in 4.2
+==============
+* Compiles on glibc2.0 systems again
+* Linux/S390 port added
+* The usual Linux syscall updates 
+
 Changes in 4.1
 ================
 * Linux/MIPS port added
diff --git a/bjm.c b/bjm.c
index a26b61bf..8583bc06 100644
--- a/bjm.c
+++ b/bjm.c
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
+ * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
+ * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ *	$Id$
+ */
 #include "defs.h"
 
 #if defined(LINUX)
diff --git a/config.sub b/config.sub
index 9fbf9921..c3b2a987 100755
--- a/config.sub
+++ b/config.sub
@@ -155,7 +155,7 @@ case $basic_machine in
 		| alpha | alphaev5 | alphaev56 | alphapca56 | we32k | ns16k | clipper \
 		| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
 		| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
-		| mipstx39 | mipstx39el \
+		| mipstx39 | mipstx39el | s390 \
 		| sparc | sparclet | sparclite | sparc64 | v850)
 		basic_machine=$basic_machine-unknown
 		;;
@@ -182,7 +182,7 @@ case $basic_machine in
 	      | sparc64-* | mips64-* | mipsel-* \
 	      | mips64el-* | mips64orion-* | mips64orionel-*  \
 	      | mipstx39-* | mipstx39el-* \
-	      | f301-*)
+	      | f301-* | s390-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
@@ -511,6 +511,9 @@ case $basic_machine in
 	rtpc | rtpc-*)
 		basic_machine=romp-ibm
 		;;
+	s390)
+		basic_machine=s390-ibm
+		;;
 	sequent)
 		basic_machine=i386-sequent
 		;;
diff --git a/configure.in b/configure.in
index a389676a..05f270e6 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,9 @@ ppc|powerpc)
 arm)
 	arch=arm
 	;;
+s390)
+	arch=s390
+	;;
 *)
 	AC_MSG_ERROR(this architecture is not yet supported by strace)
 	;;
diff --git a/desc.c b/desc.c
index 3b76e7ea..9d46d144 100644
--- a/desc.c
+++ b/desc.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/file.c b/file.c
index 1ecf85bd..57122168 100644
--- a/file.c
+++ b/file.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/io.c b/io.c
index e42fba11..45c34135 100644
--- a/io.c
+++ b/io.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/ioctl.c b/ioctl.c
index 4e6a416b..f4bb784e 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/ipc.c b/ipc.c
index f01a9a91..e4dacabd 100644
--- a/ipc.c
+++ b/ipc.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/linux/syscall.h b/linux/syscall.h
index 84b3661f..c63e42de 100644
--- a/linux/syscall.h
+++ b/linux/syscall.h
@@ -81,7 +81,7 @@ int sys_getresuid(), sys_getresgid(), sys_pread(), sys_pwrite(), sys_getcwd();
 int sys_sigaltstack(), sys_rt_sigprocmask(), sys_rt_sigaction();
 int sys_rt_sigpending(), sys_rt_sigsuspend(), sys_rt_sigqueueinfo();
 int sys_rt_sigtimedwait(), sys_prctl(), sys_poll(), sys_vfork();
-int sys_sendfile();
+int sys_sendfile(), sys_old_mmap();
 
 
 /* sys_socketcall subcalls */
diff --git a/linux/syscallent.h b/linux/syscallent.h
index 3e74fa53..182b9e6f 100644
--- a/linux/syscallent.h
+++ b/linux/syscallent.h
@@ -122,7 +122,7 @@
 	{ 1,	TF,	sys_swapon,		"swapon"	}, /* 87 */
 	{ 3,	0,	sys_reboot,		"reboot"	}, /* 88 */
 	{ 3,	0,	sys_readdir,		"readdir"	}, /* 89 */
-	{ 6,	0,	sys_mmap,		"mmap"		}, /* 90 */
+	{ 6,	0,	sys_old_mmap,		"old_mmap"	}, /* 90 */
 	{ 2,	0,	sys_munmap,		"munmap"	}, /* 91 */
 	{ 2,	TF,	sys_truncate,		"truncate"	}, /* 92 */
 	{ 2,	0,	sys_ftruncate,		"ftruncate"	}, /* 93 */
@@ -236,10 +236,10 @@
 	{ 5,	0,	printargs,		"SYS_188"	}, /* 188 */
 	{ 5,	0,	printargs,		"SYS_189"	}, /* 189 */
 	{ 0,	TP,	sys_vfork,		"vfork"		}, /* 190 */
-	{ 5,	0,	printargs,		"SYS_191"	}, /* 191 */
-	{ 5,	0,	printargs,		"SYS_192"	}, /* 192 */
-	{ 5,	0,	printargs,		"SYS_193"	}, /* 193 */
-	{ 5,	0,	printargs,		"SYS_194"	}, /* 194 */
+	{ 5,	0,	printargs,		"getrlimit"	}, /* 191 */
+	{ 6,	0,	sys_mmap,		"mmap2"		}, /* 192 */
+	{ 5,	0,	printargs,		"truncate64"	}, /* 193 */
+	{ 5,	0,	printargs,		"ftruncate64"	}, /* 194 */
 	{ 5,	0,	printargs,		"SYS_195"	}, /* 195 */
 	{ 5,	0,	printargs,		"SYS_196"	}, /* 196 */
 	{ 5,	0,	printargs,		"SYS_197"	}, /* 197 */
diff --git a/mem.c b/mem.c
index 702c1228..b4e0e6c7 100644
--- a/mem.c
+++ b/mem.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -136,27 +137,13 @@ static struct xlat mmap_flags[] = {
 	{ 0,		NULL		},
 };
 
+static
 int
-sys_mmap(tcp)
+print_mmap(tcp,u_arg)
 struct tcb *tcp;
+long *u_arg;
 {
-#ifdef LINUX
-#  if defined(ALPHA) || defined(sparc) || defined(POWERPC) || defined(MIPS)
-	long *u_arg = tcp->u_arg;
-#  else /* !ALPHA */
-	long u_arg[6];
-#  endif /* !ALPHA */
-#else /* !LINUX */
-	long *u_arg = tcp->u_arg;
-#endif /* !LINUX */
-
 	if (entering(tcp)) {
-#if defined(LINUX) && !defined(ALPHA) && !defined(sparc) && !defined(POWERPC) && !defined(MIPS)
-		if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
-				(char *) u_arg) == -1)
-			return 0;
-#endif /* LINUX && !ALPHA && !sparc && !POWERPC */
-
 		/* addr */
 		if (!u_arg[0])
 			tprintf("NULL, ");
@@ -178,6 +165,26 @@ struct tcb *tcp;
 	return RVAL_HEX;
 }
 
+#ifdef LINUX
+int sys_old_mmap(tcp)
+struct tcb *tcp;
+{
+    long u_arg[6];
+
+    if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
+	    return 0;
+    return print_mmap(tcp, u_arg);
+   
+}
+#endif
+
+int
+sys_mmap(tcp)
+struct tcb *tcp;
+{
+    return print_mmap(tcp, tcp->u_arg);
+}
+
 int
 sys_munmap(tcp)
 struct tcb *tcp;
diff --git a/net.c b/net.c
index e685e308..a8c62d56 100644
--- a/net.c
+++ b/net.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -45,7 +46,7 @@
 #endif
 #endif /* LINUX */
 
-#if defined(LINUX) && defined(MIPS)
+#if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
 #if defined(HAVE_LINUX_IN6_H)
 #include <linux/in6.h>
 #endif
diff --git a/process.c b/process.c
index 44844edd..ea78824a 100644
--- a/process.c
+++ b/process.c
@@ -2,6 +2,11 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
+ * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *                     Linux for s390 port by D.J. Barrow
+ *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -166,7 +171,7 @@ struct tcb *tcp;
 #ifdef PR_GET_PDEATHSIG
 		case PR_GET_PDEATHSIG:
 			for (i=1; i<tcp->u_nargs; i++)
-				tprintf(", %@lx", tcp->u_arg[i]);
+				tprintf(", %#lx", tcp->u_arg[i]);
 			break;
 #endif
 		default:
@@ -1421,116 +1426,189 @@ static
 #endif /* !SUNOS4_KERNEL_ARCH_KLUDGE */
 struct xlat struct_user_offsets[] = {
 #ifdef LINUX
-#ifdef SPARC
+#ifdef S390
+	{ PT_PSWMASK,		"psw_mask"				},
+	{ PT_PSWADDR,		"psw_addr"				},
+	{ PT_GPR0,		"gpr0"					},
+	{ PT_GPR1,		"gpr1"					},
+	{ PT_GPR2,		"gpr2"					},
+	{ PT_GPR3,		"gpr3"					},
+	{ PT_GPR4,		"gpr4"					},
+	{ PT_GPR5,		"gpr5"					},
+	{ PT_GPR6,		"gpr6"					},
+	{ PT_GPR7,		"gpr7"					},
+	{ PT_GPR8,		"gpr8"					},
+	{ PT_GPR9,		"gpr9"					},
+	{ PT_GPR10,		"gpr10"					},
+	{ PT_GPR11,		"gpr11"					},
+	{ PT_GPR12,		"gpr12"					},
+	{ PT_GPR13,		"gpr13"					},
+	{ PT_GPR14,		"gpr14"					},
+	{ PT_GPR15,		"gpr15"					},
+	{ PT_ACR0,		"acr0"					},
+	{ PT_ACR1,		"acr1"					},
+	{ PT_ACR2,		"acr2"					},
+	{ PT_ACR3,		"acr3"					},
+	{ PT_ACR4,		"acr4"					},
+	{ PT_ACR5,		"acr5"					},
+	{ PT_ACR6,		"acr6"					},
+	{ PT_ACR7,		"acr7"					},
+	{ PT_ACR8,		"acr8"					},
+	{ PT_ACR9,		"acr9"					},
+	{ PT_ACR10,		"acr10"					},
+	{ PT_ACR11,		"acr11"					},
+	{ PT_ACR12,		"acr12"					},
+	{ PT_ACR13,		"acr13"					},
+	{ PT_ACR14,		"acr14"					},
+	{ PT_ACR15,		"acr15"					},
+	{ PT_ORIGGPR2,		"orig_gpr2"				},
+	{ PT_FPC,		"fpc"					},
+	{ PT_FPR0_HI,		"fpr0.hi"				},
+	{ PT_FPR0_LO,		"fpr0.lo"				},
+	{ PT_FPR1_HI,		"fpr1.hi"				},
+	{ PT_FPR1_LO,		"fpr1.lo"				},
+	{ PT_FPR2_HI,		"fpr2.hi"				},
+	{ PT_FPR2_LO,		"fpr2.lo"				},
+	{ PT_FPR3_HI,		"fpr3.hi"				},
+	{ PT_FPR3_LO,		"fpr3.lo"				},
+	{ PT_FPR4_HI,		"fpr4.hi"				},
+	{ PT_FPR4_LO,		"fpr4.lo"				},
+	{ PT_FPR5_HI,		"fpr5.hi"				},
+	{ PT_FPR5_LO,		"fpr5.lo"				},
+	{ PT_FPR6_HI,		"fpr6.hi"				},
+	{ PT_FPR6_LO,		"fpr6.lo"				},
+	{ PT_FPR7_HI,		"fpr7.hi"				},
+	{ PT_FPR7_LO,		"fpr7.lo"				},
+	{ PT_FPR8_HI,		"fpr8.hi"				},
+	{ PT_FPR8_LO,		"fpr8.lo"				},
+	{ PT_FPR9_HI,		"fpr9.hi"				},
+	{ PT_FPR9_LO,		"fpr9.lo"				},
+	{ PT_FPR10_HI,		"fpr10.hi"				},
+	{ PT_FPR10_LO,		"fpr10.lo"				},
+	{ PT_FPR11_HI,		"fpr11.hi"				},
+	{ PT_FPR11_LO,		"fpr11.lo"				},
+	{ PT_FPR12_HI,		"fpr12.hi"				},
+	{ PT_FPR12_LO,		"fpr12.lo"				},
+	{ PT_FPR13_HI,		"fpr13.hi"				},
+	{ PT_FPR13_LO,		"fpr13.lo"				},
+	{ PT_FPR14_HI,		"fpr14.hi"				},
+	{ PT_FPR14_LO,		"fpr14.lo"				},
+	{ PT_FPR15_HI,		"fpr15.hi"				},
+	{ PT_FPR15_LO,		"fpr15.lo"				},
+	{ PT_CR_9,		"cr9"					},
+	{ PT_CR_10,		"cr10"					},
+	{ PT_CR_11,		"cr11"					},
+#endif
+#if defined(SPARC)
 	/* XXX No support for these offsets yet. */
 #elif defined(POWERPC)
-	{ 4*PT_R0,		"4*PT_R0"	},
-	{ 4*PT_R1,		"4*PT_R1"	},
-	{ 4*PT_R2,		"4*PT_R2"	},
-	{ 4*PT_R3,		"4*PT_R3"	},
-	{ 4*PT_R4,		"4*PT_R4"	},
-	{ 4*PT_R5,		"4*PT_R5"	},
-	{ 4*PT_R6,		"4*PT_R6"	},
-	{ 4*PT_R7,		"4*PT_R7"	},
-	{ 4*PT_R8,		"4*PT_R8"	},
-	{ 4*PT_R9,		"4*PT_R9"	},
-	{ 4*PT_R10,		"4*PT_R10"	},
-	{ 4*PT_R11,		"4*PT_R11"	},
-	{ 4*PT_R12,		"4*PT_R12"	},
-	{ 4*PT_R13,		"4*PT_R13"	},
-	{ 4*PT_R14,		"4*PT_R14"	},
-	{ 4*PT_R15,		"4*PT_R15"	},
-	{ 4*PT_R16,		"4*PT_R16"	},
-	{ 4*PT_R17,		"4*PT_R17"	},
-	{ 4*PT_R18,		"4*PT_R18"	},
-	{ 4*PT_R19,		"4*PT_R19"	},
-	{ 4*PT_R20,		"4*PT_R20"	},
-	{ 4*PT_R21,		"4*PT_R21"	},
-	{ 4*PT_R22,		"4*PT_R22"	},
-	{ 4*PT_R23,		"4*PT_R23"	},
-	{ 4*PT_R24,		"4*PT_R24"	},
-	{ 4*PT_R25,		"4*PT_R25"	},
-	{ 4*PT_R26,		"4*PT_R26"	},
-	{ 4*PT_R27,		"4*PT_R27"	},
-	{ 4*PT_R28,		"4*PT_R28"	},
-	{ 4*PT_R29,		"4*PT_R29"	},
-	{ 4*PT_R30,		"4*PT_R30"	},
-	{ 4*PT_R31,		"4*PT_R31"	},
-	{ 4*PT_NIP,		"4*PT_NIP"	},
-	{ 4*PT_MSR,		"4*PT_MSR"	},
-	{ 4*PT_ORIG_R3,	 "4*PT_ORIG_R3"	},
-	{ 4*PT_CTR,		"4*PT_CTR"	},
-	{ 4*PT_LNK,		"4*PT_LNK"	},
-	{ 4*PT_XER,		"4*PT_XER"	},
-	{ 4*PT_CCR,		"4*PT_CCR"	},
-	{ 4*PT_FPR0,	"4*PT_FPR0"	},
+	{ 4*PT_R0,		"4*PT_R0"				},
+	{ 4*PT_R1,		"4*PT_R1"				},
+	{ 4*PT_R2,		"4*PT_R2"				},
+	{ 4*PT_R3,		"4*PT_R3"				},
+	{ 4*PT_R4,		"4*PT_R4"				},
+	{ 4*PT_R5,		"4*PT_R5"				},
+	{ 4*PT_R6,		"4*PT_R6"				},
+	{ 4*PT_R7,		"4*PT_R7"				},
+	{ 4*PT_R8,		"4*PT_R8"				},
+	{ 4*PT_R9,		"4*PT_R9"				},
+	{ 4*PT_R10,		"4*PT_R10"				},
+	{ 4*PT_R11,		"4*PT_R11"				},
+	{ 4*PT_R12,		"4*PT_R12"				},
+	{ 4*PT_R13,		"4*PT_R13"				},
+	{ 4*PT_R14,		"4*PT_R14"				},
+	{ 4*PT_R15,		"4*PT_R15"				},
+	{ 4*PT_R16,		"4*PT_R16"				},
+	{ 4*PT_R17,		"4*PT_R17"				},
+	{ 4*PT_R18,		"4*PT_R18"				},
+	{ 4*PT_R19,		"4*PT_R19"				},
+	{ 4*PT_R20,		"4*PT_R20"				},
+	{ 4*PT_R21,		"4*PT_R21"				},
+	{ 4*PT_R22,		"4*PT_R22"				},
+	{ 4*PT_R23,		"4*PT_R23"				},
+	{ 4*PT_R24,		"4*PT_R24"				},
+	{ 4*PT_R25,		"4*PT_R25"				},
+	{ 4*PT_R26,		"4*PT_R26"				},
+	{ 4*PT_R27,		"4*PT_R27"				},
+	{ 4*PT_R28,		"4*PT_R28"				},
+	{ 4*PT_R29,		"4*PT_R29"				},
+	{ 4*PT_R30,		"4*PT_R30"				},
+	{ 4*PT_R31,		"4*PT_R31"				},
+	{ 4*PT_NIP,		"4*PT_NIP"				},
+	{ 4*PT_MSR,		"4*PT_MSR"				},
+	{ 4*PT_ORIG_R3,		"4*PT_ORIG_R3"				},
+	{ 4*PT_CTR,		"4*PT_CTR"				},
+	{ 4*PT_LNK,		"4*PT_LNK"				},
+	{ 4*PT_XER,		"4*PT_XER"				},
+	{ 4*PT_CCR,		"4*PT_CCR"				},
+	{ 4*PT_FPR0,		"4*PT_FPR0"				},
 #else	
 #ifdef ALPHA
-	{ 0,		"r0"					},
-	{ 1,		"r1"					},
-	{ 2,		"r2"					},
-	{ 3,		"r3"					},
-	{ 4,		"r4"					},
-	{ 5,		"r5"					},
-	{ 6,		"r6"					},
-	{ 7,		"r7"					},
-	{ 8,		"r8"					},
-	{ 9,		"r9"					},
-	{ 10,		"r10"					},
-	{ 11,		"r11"					},
-	{ 12,		"r12"					},
-	{ 13,		"r13"					},
-	{ 14,		"r14"					},
-	{ 15,		"r15"					},
-	{ 16,		"r16"					},
-	{ 17,		"r17"					},
-	{ 18,		"r18"					},
-	{ 19,		"r19"					},
-	{ 20,		"r20"					},
-	{ 21,		"r21"					},
-	{ 22,		"r22"					},
-	{ 23,		"r23"					},
-	{ 24,		"r24"					},
-	{ 25,		"r25"					},
-	{ 26,		"r26"					},
-	{ 27,		"r27"					},
-	{ 28,		"r28"					},
-	{ 29,		"gp"					},
-	{ 30,		"fp"					},
-	{ 31,		"zero"					},
-	{ 32,		"fp0"					},
-	{ 33,		"fp"					},
-	{ 34,		"fp2"					},
-	{ 35,		"fp3"					},
-	{ 36,		"fp4"					},
-	{ 37,		"fp5"					},
-	{ 38,		"fp6"					},
-	{ 39,		"fp7"					},
-	{ 40,		"fp8"					},
-	{ 41,		"fp9"					},
-	{ 42,		"fp10"					},
-	{ 43,		"fp11"					},
-	{ 44,		"fp12"					},
-	{ 45,		"fp13"					},
-	{ 46,		"fp14"					},
-	{ 47,		"fp15"					},
-	{ 48,		"fp16"					},
-	{ 49,		"fp17"					},
-	{ 50,		"fp18"					},
-	{ 51,		"fp19"					},
-	{ 52,		"fp20"					},
-	{ 53,		"fp21"					},
-	{ 54,		"fp22"					},
-	{ 55,		"fp23"					},
-	{ 56,		"fp24"					},
-	{ 57,		"fp25"					},
-	{ 58,		"fp26"					},
-	{ 59,		"fp27"					},
-	{ 60,		"fp28"					},
-	{ 61,		"fp29"					},
-	{ 62,		"fp30"					},
-	{ 63,		"fp31"					},
-	{ 64,		"pc"					},
+	{ 0,			"r0"					},
+	{ 1,			"r1"					},
+	{ 2,			"r2"					},
+	{ 3,			"r3"					},
+	{ 4,			"r4"					},
+	{ 5,			"r5"					},
+	{ 6,			"r6"					},
+	{ 7,			"r7"					},
+	{ 8,			"r8"					},
+	{ 9,			"r9"					},
+	{ 10,			"r10"					},
+	{ 11,			"r11"					},
+	{ 12,			"r12"					},
+	{ 13,			"r13"					},
+	{ 14,			"r14"					},
+	{ 15,			"r15"					},
+	{ 16,			"r16"					},
+	{ 17,			"r17"					},
+	{ 18,			"r18"					},
+	{ 19,			"r19"					},
+	{ 20,			"r20"					},
+	{ 21,			"r21"					},
+	{ 22,			"r22"					},
+	{ 23,			"r23"					},
+	{ 24,			"r24"					},
+	{ 25,			"r25"					},
+	{ 26,			"r26"					},
+	{ 27,			"r27"					},
+	{ 28,			"r28"					},
+	{ 29,			"gp"					},
+	{ 30,			"fp"					},
+	{ 31,			"zero"					},
+	{ 32,			"fp0"					},
+	{ 33,			"fp"					},
+	{ 34,			"fp2"					},
+	{ 35,			"fp3"					},
+	{ 36,			"fp4"					},
+	{ 37,			"fp5"					},
+	{ 38,			"fp6"					},
+	{ 39,			"fp7"					},
+	{ 40,			"fp8"					},
+	{ 41,			"fp9"					},
+	{ 42,			"fp10"					},
+	{ 43,			"fp11"					},
+	{ 44,			"fp12"					},
+	{ 45,			"fp13"					},
+	{ 46,			"fp14"					},
+	{ 47,			"fp15"					},
+	{ 48,			"fp16"					},
+	{ 49,			"fp17"					},
+	{ 50,			"fp18"					},
+	{ 51,			"fp19"					},
+	{ 52,			"fp20"					},
+	{ 53,			"fp21"					},
+	{ 54,			"fp22"					},
+	{ 55,			"fp23"					},
+	{ 56,			"fp24"					},
+	{ 57,			"fp25"					},
+	{ 58,			"fp26"					},
+	{ 59,			"fp27"					},
+	{ 60,			"fp28"					},
+	{ 61,			"fp29"					},
+	{ 62,			"fp30"					},
+	{ 63,			"fp31"					},
+	{ 64,			"pc"					},
 #else /* !ALPHA */
 #ifdef I386
 	{ 4*EBX,		"4*EBX"					},
@@ -1573,6 +1651,9 @@ struct xlat struct_user_offsets[] = {
 	{ 4*PT_PC,		"4*PT_PC"				},
 #endif /* M68K */
 #endif /* !I386 */
+#ifdef S390
+	{ uoff(u_fpvalid),	"offsetof(struct user, u_fpvalid)"	},
+#endif
 #ifndef MIPS
 	{ uoff(u_fpvalid),	"offsetof(struct user, u_fpvalid)"	},
 #endif
@@ -1593,7 +1674,7 @@ struct xlat struct_user_offsets[] = {
 	{ uoff(reserved),	"offsetof(struct user, reserved)"	},
 #endif
 	{ uoff(u_ar0),		"offsetof(struct user, u_ar0)"		},
-#if !defined(ARM) && !defined(MIPS)
+#if !defined(ARM) && !defined(MIPS) && !defined(S390)
 	{ uoff(u_fpstate),	"offsetof(struct user, u_fpstate)"	},
 #endif
 	{ uoff(magic),		"offsetof(struct user, magic)"		},
diff --git a/resource.c b/resource.c
index bb93fb63..ea741b8f 100644
--- a/resource.c
+++ b/resource.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/signal.c b/signal.c
index edad17fa..c99598b1 100644
--- a/signal.c
+++ b/signal.c
@@ -2,6 +2,10 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
+ * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *                     Linux for s390 port by D.J. Barrow
+ *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -692,6 +696,27 @@ int
 sys_sigreturn(tcp)
 struct tcb *tcp;
 {
+#ifdef S390
+    long usp;
+    struct sigcontext_struct sc;
+
+    if (entering(tcp)) {
+	    tcp->u_arg[0] = 0;
+	    if (upeek(tcp->pid,PT_GPR15,&usp)<0)
+		    return 0;
+	    if (umove(tcp, usp+__SIGNAL_FRAMESIZE, &sc) < 0)
+		    return 0;
+	    tcp->u_arg[0] = 1;
+	    memcpy(&tcp->u_arg[1],&sc.oldmask[0],sizeof(sigset_t));
+    } else {
+	    tcp->u_rval = tcp->u_error = 0;
+	    if (tcp->u_arg[0] == 0)
+		    return 0;
+	    tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
+	    return RVAL_NONE | RVAL_STR;
+    }
+    return 0;
+#else
 #ifdef I386
 	long esp;
 	struct sigcontext_struct sc;
@@ -843,6 +868,7 @@ struct tcb *tcp;
 #endif /* !M68K */
 #endif /* !POWERPC */
 #endif /* !I386 */
+#endif /* S390 */
 }
 
 int
diff --git a/strace.1 b/strace.1
index 1ec9e44d..391c907a 100644
--- a/strace.1
+++ b/strace.1
@@ -306,7 +306,7 @@ Print all non-ASCII strings in hexadecimal string format.
 Print all strings in hexadecimal string format.
 .TP
 .BI "\-a " column
-Align return values in a secific column (default column 40).
+Align return values in a specific column (default column 40).
 .TP
 .BI "\-e " expr
 A qualifying expression which modifies which events to trace
diff --git a/strace.c b/strace.c
index 8288d2ab..31ccd697 100644
--- a/strace.c
+++ b/strace.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/stream.c b/stream.c
index 7f287c5d..1458c6a6 100644
--- a/stream.c
+++ b/stream.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/syscall.c b/syscall.c
index 3b3f7fe2..2b23471d 100644
--- a/syscall.c
+++ b/syscall.c
@@ -2,6 +2,10 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
+ * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *                     Linux for s390 port by D.J. Barrow
+ *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -590,6 +594,9 @@ struct tcb *tcp;
 #elif defined (SPARC)
 	struct regs regs;
 	unsigned long trap;
+#elif defined(S390)
+	long gpr2;
+	long pc;
 #endif 
 #endif /* LINUX */
 
@@ -601,7 +608,14 @@ struct tcb *tcp;
 	if (dtime && (tcp->flags & TCB_INSYSCALL))
 		gettimeofday(&tv, NULL);
 #ifdef LINUX
-#if defined (POWERPC)
+#if defined(S390)
+	if (upeek(tcp->pid,PT_PSWADDR,&pc) < 0)
+		return -1;
+	scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)(pc-4),0);
+	if (errno)
+		return -1;
+	scno&=0xFF;
+#elif defined (POWERPC)
 	if (upeek(pid, 4*PT_R0, &scno) < 0)
 		return -1;
 	if (!(tcp->flags & TCB_INSYSCALL)) {
@@ -1086,7 +1100,16 @@ struct tcb *tcp;
 	/* Entering system call */
 	tcp->scno = scno;
 #ifdef LINUX
-#if defined (ALPHA)
+#if defined(S390)
+	{
+		int i;
+		tcp->u_nargs = sysent[tcp->scno].nargs;
+		for (i = 0; i < tcp->u_nargs; i++) {
+			if (upeek(pid,i==0 ? PT_ORIGGPR2:PT_GPR2+(i<<2), &tcp->u_arg[i]) < 0)
+				return -1;
+		}
+	}
+#elif defined (ALPHA)
 	{
 		int i;
 		tcp->u_nargs = sysent[tcp->scno].nargs;
diff --git a/system.c b/system.c
index 1d0c1630..6472529a 100644
--- a/system.c
+++ b/system.c
@@ -2,6 +2,7 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/util.c b/util.c
index 32b3fef5..5c38e66b 100644
--- a/util.c
+++ b/util.c
@@ -2,6 +2,10 @@
  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
+ * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *                     Linux for s390 port by D.J. Barrow
+ *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -891,7 +895,11 @@ struct tcb *tcp;
 	if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)&regs,0) < 0)
 		return -1;
 	pc = regs.r_pc;
-#endif
+#elif defined(S390)
+	if(upeek(tcp->pid,PT_PSWADDR,&pc) < 0)
+		return -1;
+
+#else
 	return pc;
 #endif /* LINUX */
 
@@ -1045,13 +1053,15 @@ struct tcb *tcp;
 #elif defined (M68K)
 #define LOOP	0x60fe0000
 #elif defined (ALPHA)
-#define LOOP    0xc3ffffff
+#define LOOP	0xc3ffffff
 #elif defined (POWERPC)
-#define LOOP 0x0000feeb
+#define LOOP	0x0000feeb
 #elif defined(ARM)
-#define LOOP -1  /* almost certainly wrong, jws */
+#define LOOP	-1		/* almost certainly wrong, jws */
 #elif defined(MIPS)
-#define LOOP 0x1000ffff
+#define LOOP	0x1000ffff
+#elif defined(S390)
+#define LOOP	0xa7f40000	/* BRC 15,0 */
 #else
 #error unknown architecture
 #endif
@@ -1075,6 +1085,9 @@ struct tcb *tcp;
 #elif defined (POWERPC)
 	if (upeek(tcp->pid, 4*PT_NIP, &tcp->baddr) < 0)
 		return -1;
+#elif defined(S390)
+	if (upeek(tcp->pid,PT_PSWADDR, &tcp->baddr) < 0)
+		return -1;
 #else
 #error unknown architecture
 #endif