2003-01-14  Roland McGrath  <roland@redhat.com>

	* configure.ac: Match powerpc* (includes powerpc64), and don't match
	ppc (never comes out of config.sub).
	* process.c (sys_ptrace): Use #lx format for address argument.
	[POWERPC]: Use sizeof(unsigned long) in place of 4 for multipliers.
	* process.c [POWERPC]: Likewise.
	* signal.c (sys_sigreturn) [POWERPC]: Likewise.
	* syscall.c (get_scno) [POWERPC]: Likewise.
	* util.c [POWERPC]: Likewise.
	(printnum): Use long for NUM.
	From Anton Blanchard <anton@samba.org>.
diff --git a/configure.ac b/configure.ac
index f78a428..6d83bbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,7 +67,7 @@
 	arch=alpha
 	AC_DEFINE([ALPHA], 1, [Define for the Alpha architecture.])
 	;;
-ppc|powerpc)
+powerpc*)
 	arch=powerpc
 	AC_DEFINE([POWERPC], 1, [Define for the PowerPC architecture.])
 	;;
diff --git a/process.c b/process.c
index c66e7c2..633a582 100644
--- a/process.c
+++ b/process.c
@@ -609,7 +609,8 @@
 		return -1;
 	return 0;
 #elif defined(POWERPC)
-	if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0)
+	if (ptrace(PTRACE_POKEUSER, tcp->pid,
+		   (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
 		return -1;
        return 0;
 #elif defined(S390) || defined(S390X)
@@ -693,7 +694,7 @@
 #endif
 	{
 		ptrace(PTRACE_POKEUSER, tcp->pid,
-		       (char*)((argnum==0 ? PT_ORIG_R3 : argnum+PT_R3)*4),
+		       (char*)((argnum==0 ? PT_ORIG_R3 : argnum+PT_R3)*sizeof(unsigned long)),
 		       tcp->u_arg[argnum]);
 		if (errno)
 			return -1;
@@ -2126,46 +2127,48 @@
 #ifndef PT_ORIG_R3
 #define PT_ORIG_R3 34
 #endif
-	{ 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"				},
+#define REGSIZE (sizeof(unsigned long))
+	{ REGSIZE*PT_R0,		"r0"				},
+	{ REGSIZE*PT_R1,		"r1"				},
+	{ REGSIZE*PT_R2,		"r2"				},
+	{ REGSIZE*PT_R3,		"r3"				},
+	{ REGSIZE*PT_R4,		"r4"				},
+	{ REGSIZE*PT_R5,		"r5"				},
+	{ REGSIZE*PT_R6,		"r6"				},
+	{ REGSIZE*PT_R7,		"r7"				},
+	{ REGSIZE*PT_R8,		"r8"				},
+	{ REGSIZE*PT_R9,		"r9"				},
+	{ REGSIZE*PT_R10,		"r10"				},
+	{ REGSIZE*PT_R11,		"r11"				},
+	{ REGSIZE*PT_R12,		"r12"				},
+	{ REGSIZE*PT_R13,		"r13"				},
+	{ REGSIZE*PT_R14,		"r14"				},
+	{ REGSIZE*PT_R15,		"r15"				},
+	{ REGSIZE*PT_R16,		"r16"				},
+	{ REGSIZE*PT_R17,		"r17"				},
+	{ REGSIZE*PT_R18,		"r18"				},
+	{ REGSIZE*PT_R19,		"r19"				},
+	{ REGSIZE*PT_R20,		"r20"				},
+	{ REGSIZE*PT_R21,		"r21"				},
+	{ REGSIZE*PT_R22,		"r22"				},
+	{ REGSIZE*PT_R23,		"r23"				},
+	{ REGSIZE*PT_R24,		"r24"				},
+	{ REGSIZE*PT_R25,		"r25"				},
+	{ REGSIZE*PT_R26,		"r26"				},
+	{ REGSIZE*PT_R27,		"r27"				},
+	{ REGSIZE*PT_R28,		"r28"				},
+	{ REGSIZE*PT_R29,		"r29"				},
+	{ REGSIZE*PT_R30,		"r30"				},
+	{ REGSIZE*PT_R31,		"r31"				},
+	{ REGSIZE*PT_NIP,		"NIP"				},
+	{ REGSIZE*PT_MSR,		"MSR"				},
+	{ REGSIZE*PT_ORIG_R3,		"ORIG_R3"			},
+	{ REGSIZE*PT_CTR,		"CTR"				},
+	{ REGSIZE*PT_LNK,		"LNK"				},
+	{ REGSIZE*PT_XER,		"XER"				},
+	{ REGSIZE*PT_CCR,		"CCR"				},
+	{ REGSIZE*PT_FPR0,		"FPR0"				},
+#undef REGSIZE
 #else
 #ifdef ALPHA
 	{ 0,			"r0"					},
@@ -2569,7 +2572,7 @@
 		case PTRACE_PEEKDATA:
 		case PTRACE_PEEKTEXT:
 		case PTRACE_PEEKUSER:
-			printnum(tcp, tcp->u_arg[3], "%#x");
+			printnum(tcp, tcp->u_arg[3], "%#lx");
 			break;
 		}
 	}
diff --git a/signal.c b/signal.c
index e2cb8d0..ad9e616 100644
--- a/signal.c
+++ b/signal.c
@@ -1253,7 +1253,7 @@
 
        if (entering(tcp)) {
 		   tcp->u_arg[0] = 0;
-		   if (upeek(tcp->pid, 4*PT_R1, &esp) < 0)
+		   if (upeek(tcp->pid, sizeof(unsigned long)*PT_R1, &esp) < 0)
 			   return 0;
 		   if (umove(tcp, esp, &sc) < 0)
 			   return 0;
diff --git a/syscall.c b/syscall.c
index b2ecd7a..f9e39d4 100644
--- a/syscall.c
+++ b/syscall.c
@@ -806,7 +806,7 @@
 		}
 	}
 #elif defined (POWERPC)
-	if (upeek(pid, 4*PT_R0, &scno) < 0)
+	if (upeek(pid, sizeof(unsigned long)*PT_R0, &scno) < 0)
 		return -1;
 	if (!(tcp->flags & TCB_INSYSCALL)) {
 		/* Check if we return from execve. */
@@ -1204,9 +1204,9 @@
 	}
 #elif defined (POWERPC)
 # define SO_MASK 0x10000000
-	if (upeek(pid, 4*PT_CCR, &flags) < 0)
+	if (upeek(pid, sizeof(unsigned long)*PT_CCR, &flags) < 0)
 		return -1;
-	if (upeek(pid, 4*PT_R3, &result) < 0)
+	if (upeek(pid, sizeof(unsigned long)*PT_R3, &result) < 0)
 		return -1;
 	if (flags & SO_MASK)
 		result = -result;
@@ -1528,7 +1528,7 @@
 	    	return -1;
 #else
 #ifdef POWERPC
-	if (upeek(tcp->pid, 4*PT_CCR, &flags) < 0)
+	if (upeek(tcp->pid, sizeof(unsigned long)*PT_CCR, &flags) < 0)
 		return -1;
 	if (error) {
 		flags |= SO_MASK;
@@ -1538,8 +1538,8 @@
 		flags &= ~SO_MASK;
 		result = rval;
 	}
-	if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_CCR), flags) < 0 ||
-	    ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R3), result) < 0)
+	if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_CCR), flags) < 0 ||
+	    ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(sizeof(unsigned long)*PT_R3), result) < 0)
 		return -1;
 #else /* !POWERPC */
 #ifdef M68K
@@ -1762,7 +1762,10 @@
 		else
      	        	tcp->u_nargs = MAX_ARGS;
 		for (i = 0; i < tcp->u_nargs; i++) {
-			if (upeek(pid, (i==0) ? (4*PT_ORIG_R3) : ((i+PT_R3)*4), &tcp->u_arg[i]) < 0)
+			if (upeek(pid, (i==0) ?
+				(sizeof(unsigned long)*PT_ORIG_R3) :
+				((i+PT_R3)*sizeof(unsigned long)),
+					&tcp->u_arg[i]) < 0)
 				return -1;
 		}
 	}
diff --git a/util.c b/util.c
index d3cec2d..d01b1d8 100644
--- a/util.c
+++ b/util.c
@@ -292,7 +292,7 @@
 long addr;
 char *fmt;
 {
-	int num;
+	long num;
 
 	if (!addr) {
 		tprintf("NULL");
@@ -942,7 +942,7 @@
 	if (upeek(tcp->pid, 4*15, &pc) < 0)
 		return -1;
 #elif defined(POWERPC)
-	if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0)
+	if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0)
 		return -1;
 #elif defined(M68k)
 	if (upeek(tcp->pid, 4*PT_PC, &pc) < 0)
@@ -1030,7 +1030,7 @@
 #elif defined(POWERPC)
 	long pc;
 
-	if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0) {
+	if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0) {
 		tprintf ("[????????] ");
 		return;
 	}
@@ -1203,8 +1203,8 @@
 #  define arg0_offset	REG_A0
 #  define arg1_offset	(REG_A0+1)
 # elif defined (POWERPC)
-#  define arg0_offset	(4*PT_R3)
-#  define arg1_offset	(4*PT_R4)
+#  define arg0_offset	(sizeof(unsigned long)*PT_R3)
+#  define arg1_offset	(sizeof(unsigned long)*PT_R4)
 #  define restore_arg0(tcp, state, val) 0
 # elif defined (HPPA)
 #  define arg0_offset	 PT_GR26
@@ -1483,7 +1483,7 @@
 #elif defined (MIPS)
 	return -1;		/* FIXME: I do not know what i do - Flo */
 #elif defined (POWERPC)
-	if (upeek(tcp->pid, 4*PT_NIP, &tcp->baddr) < 0)
+	if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &tcp->baddr) < 0)
 		return -1;
 #elif defined(S390) || defined(S390X)
 	if (upeek(tcp->pid,PT_PSWADDR, &tcp->baddr) < 0)
@@ -1707,7 +1707,7 @@
 		return 0;
 	}
 #elif defined(POWERPC)
-	if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0)
+	if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0)
 		return -1;
 	if (pc != tcp->baddr) {
 		/* The breakpoint has not been reached yet.  */