get_regset: define iff PTRACE_GETREGSET is used

* syscall.c [AARCH64, X86_64, X32] (ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET): New macros.
(get_regset): Define iff ARCH_REGS_FOR_GETREGSET is defined; change
return type to long, return ptrace() return code instead of assigning it
to get_regs_error; do not list individual architectures, implement
constant and variable iovec cases depending on ARCH_IOVEC_FOR_GETREGSET.
(get_regs): Assign get_regset() return code to get_regs_error.
diff --git a/syscall.c b/syscall.c
index 85a8d28..3b2dcf8 100644
--- a/syscall.c
+++ b/syscall.c
@@ -699,6 +699,8 @@
 static struct iovec x86_io = {
 	.iov_base = &x86_regs_union
 };
+# define ARCH_REGS_FOR_GETREGSET x86_regs_union
+# define ARCH_IOVEC_FOR_GETREGSET x86_io
 #elif defined(IA64)
 bool ia64_ia32mode = 0; /* not static */
 static long ia64_r8, ia64_r10;
@@ -741,6 +743,8 @@
 static struct iovec aarch64_io = {
 	.iov_base = &arm_regs_union
 };
+# define ARCH_REGS_FOR_GETREGSET arm_regs_union
+# define ARCH_IOVEC_FOR_GETREGSET aarch64_io
 #elif defined(ALPHA)
 static long alpha_r0;
 static long alpha_a3;
@@ -1010,38 +1014,33 @@
 #ifndef get_regs
 long get_regs_error;
 
-static void get_regset(pid_t pid)
+#if defined ARCH_REGS_FOR_GETREGSET
+static long
+get_regset(pid_t pid)
 {
-/* constant iovec */
-# if defined(METAG) \
-  || defined(OR1K) \
-  || defined(ARC)
+# ifdef ARCH_IOVEC_FOR_GETREGSET
+	/* variable iovec */
+	ARCH_IOVEC_FOR_GETREGSET.iov_len = sizeof(ARCH_REGS_FOR_GETREGSET);
+	return ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS,
+		      &ARCH_IOVEC_FOR_GETREGSET);
+# else
+	/* constant iovec */
 	static struct iovec io = {
 		.iov_base = &ARCH_REGS_FOR_GETREGSET,
 		.iov_len = sizeof(ARCH_REGS_FOR_GETREGSET)
 	};
-	get_regs_error = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &io);
+	return ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &io);
 
-/* variable iovec */
-# elif defined(X86_64) || defined(X32)
-	/* x86_io.iov_base = &x86_regs_union; - already is */
-	x86_io.iov_len = sizeof(x86_regs_union);
-	get_regs_error = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &x86_io);
-# elif defined(AARCH64)
-	/* aarch64_io.iov_base = &arm_regs_union; - already is */
-	aarch64_io.iov_len = sizeof(arm_regs_union);
-	get_regs_error = ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &aarch64_io);
-# else
-#  warning both PTRACE_GETREGSET and NT_PRSTATUS are available but not yet used
 # endif
 }
+#endif /* ARCH_REGS_FOR_GETREGSET */
 
 void
 get_regs(pid_t pid)
 {
 /* PTRACE_GETREGSET only */
 # if defined(METAG) || defined(OR1K) || defined(X32) || defined(AARCH64) || defined(ARC)
-	get_regset(pid);
+	get_regs_error = get_regset(pid);
 
 /* PTRACE_GETREGS only */
 # elif defined(ARM)
@@ -1070,7 +1069,7 @@
 	static int getregset_support;
 
 	if (getregset_support >= 0) {
-		get_regset(pid);
+		get_regs_error = get_regset(pid);
 		if (getregset_support > 0)
 			return;
 		if (get_regs_error >= 0) {