Optimize code if we have only one personality

On i386:
   text	   data	    bss	    dec	    hex	filename
 238025	    672	  18980	 257677	  3ee8d	strace.before
 237389	    704	  18944	 257037	  3ec0d	strace

* defs.h: Define PERSONALITY0_WORDSIZE as sizeof(long) if not defined.
Introduce new define, current_wordsize as
(personality_wordsize[current_personality]).
Make set_personality() no-op, current_personality constant zero,
current_wordsize as PERSONALITY0_WORDSIZE if we have only one personality.
* count.c (call_summary): Use current_wordsize instead of
personality_wordsize[current_personality].
* desc.c (printflock): Likewise.
* file.c (sys_utime): Likewise.
* io.c (tprint_iov): Likewise.
* process.c (printargv): Likewise.
* resource.c (decode_rlimit): Likewise.
* signal.c (sys_kill): Likewise.
(sys_rt_sigaction): Likewise.
* time.c (sprinttv): Likewise.
(sprint_timespec): Likewise.
(printitv_bitness): Likewise.
(tprint_timex): Likewise.
(printsigevent): Likewise.
* util.c (dumpiov): Likewise.
(umoven): Likewise.
(umovestr): Likewise.
* syscall.c: Initialize sysent to sysent0 etc.
Make current_personality, personality_wordsize[], set_personality()
conditional on SUPPORTED_PERSONALITIES > 1.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/count.c b/count.c
index 2977353..d05ec60 100644
--- a/count.c
+++ b/count.c
@@ -220,7 +220,7 @@
 		if (i)
 			fprintf(outf,
 				"System call usage summary for %u bit mode:\n",
-				personality_wordsize[current_personality] * 8);
+				current_wordsize * 8);
 		call_summary_pers(outf);
 	}
 
diff --git a/defs.h b/defs.h
index 8750322..d327128 100644
--- a/defs.h
+++ b/defs.h
@@ -228,6 +228,10 @@
 # define PERSONALITY1_WORDSIZE 4
 #endif
 
+#ifndef PERSONALITY0_WORDSIZE
+# define PERSONALITY0_WORDSIZE sizeof(long)
+#endif
+
 #if !HAVE_DECL_PTRACE_SETOPTIONS
 # define PTRACE_SETOPTIONS	0x4200
 #endif
@@ -450,7 +454,6 @@
 void perror_msg_and_die(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
 void die_out_of_memory(void) __attribute__ ((noreturn));
 
-extern void set_personality(int personality);
 extern const char *xlookup(const struct xlat *, int);
 
 extern void set_sortby(const char *);
@@ -570,8 +573,16 @@
 #define printtv_special(tcp, addr)	\
 	printtv_bitness((tcp), (addr), BITNESS_CURRENT, 1)
 
+#if SUPPORTED_PERSONALITIES > 1
+extern void set_personality(int personality);
 extern int current_personality;
 extern const int personality_wordsize[];
+# define current_wordsize (personality_wordsize[current_personality])
+#else
+# define set_personality(personality) ((void)0)
+# define current_personality 0
+# define current_wordsize    PERSONALITY0_WORDSIZE
+#endif
 
 struct sysent {
 	unsigned nargs;
diff --git a/desc.c b/desc.c
index be4d2a9..884f143 100644
--- a/desc.c
+++ b/desc.c
@@ -230,8 +230,8 @@
 	struct flock fl;
 
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] != sizeof(fl.l_start)) {
-		if (personality_wordsize[current_personality] == 4) {
+	if (current_wordsize != sizeof(fl.l_start)) {
+		if (current_wordsize == 4) {
 			/* 32-bit x86 app on x86_64 and similar cases */
 			struct {
 				short int l_type;
@@ -252,7 +252,7 @@
 		} else {
 			/* let people know we have a problem here */
 			tprintf("{ <decode error: unsupported wordsize %d> }",
-				personality_wordsize[current_personality]);
+				current_wordsize);
 			return;
 		}
 	} else
diff --git a/file.c b/file.c
index 32d2122..1a448cd 100644
--- a/file.c
+++ b/file.c
@@ -2059,7 +2059,7 @@
 		long utl[2];
 		int uti[2];
 	} u;
-	unsigned wordsize = personality_wordsize[current_personality];
+	unsigned wordsize = current_wordsize;
 
 	if (entering(tcp)) {
 		printpath(tcp, tcp->u_arg[0]);
diff --git a/io.c b/io.c
index b483c49..a7f6c29 100644
--- a/io.c
+++ b/io.c
@@ -72,14 +72,11 @@
 		struct { u_int64_t base; u_int64_t len; } iov64;
 	} iov;
 #define sizeof_iov \
-  (personality_wordsize[current_personality] == 4 \
-   ? sizeof(iov.iov32) : sizeof(iov.iov64))
+	(current_wordsize == 4 ? sizeof(iov.iov32) : sizeof(iov.iov64))
 #define iov_iov_base \
-  (personality_wordsize[current_personality] == 4 \
-   ? (u_int64_t) iov.iov32.base : iov.iov64.base)
+	(current_wordsize == 4 ? (uint64_t) iov.iov32.base : iov.iov64.base)
 #define iov_iov_len \
-  (personality_wordsize[current_personality] == 4 \
-   ? (u_int64_t) iov.iov32.len : iov.iov64.len)
+	(current_wordsize == 4 ? (uint64_t) iov.iov32.len : iov.iov64.len)
 #else
 	struct iovec iov;
 #define sizeof_iov sizeof(iov)
diff --git a/process.c b/process.c
index 2239d4a..7035c2e 100644
--- a/process.c
+++ b/process.c
@@ -858,7 +858,7 @@
 	} cp;
 	const char *sep;
 	int n = 0;
-	unsigned wordsize = personality_wordsize[current_personality];
+	unsigned wordsize = current_wordsize;
 
 	cp.p64 = 1;
 	for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
diff --git a/resource.c b/resource.c
index 77a94a2..d7a34ef 100644
--- a/resource.c
+++ b/resource.c
@@ -180,7 +180,7 @@
 # if SIZEOF_RLIM_T == 4
 		print_rlimit32(tcp, addr);
 # else
-		if (personality_wordsize[current_personality] == 4)
+		if (current_wordsize == 4)
 			print_rlimit32(tcp, addr);
 		else
 			print_rlimit64(tcp, addr);
diff --git a/signal.c b/signal.c
index 11b133d..ab7ae56 100644
--- a/signal.c
+++ b/signal.c
@@ -1226,7 +1226,7 @@
 		long pid = tcp->u_arg[0];
 #if SUPPORTED_PERSONALITIES > 1
 		/* Sign-extend a 32-bit value when that's what it is. */
-		if (personality_wordsize[current_personality] < sizeof pid)
+		if (current_wordsize < sizeof pid)
 			pid = (long) (int) pid;
 #endif
 		tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
@@ -1335,8 +1335,7 @@
 	}
 #if SUPPORTED_PERSONALITIES > 1
 #if SIZEOF_LONG > 4
-	if (personality_wordsize[current_personality] != sizeof(sa.sa_flags)
-	    && personality_wordsize[current_personality] == 4) {
+	if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
 		struct new_sigaction32 sa32;
 		r = umove(tcp, addr, &sa32);
 		if (r >= 0) {
diff --git a/syscall.c b/syscall.c
index 3f157b2..3ee4417 100644
--- a/syscall.c
+++ b/syscall.c
@@ -183,29 +183,25 @@
 int qual_flags2[MAX_QUALS];
 #endif
 
-const struct sysent *sysent;
-const char *const *errnoent;
-const char *const *signalent;
-const struct ioctlent *ioctlent;
-unsigned nsyscalls;
-unsigned nerrnos;
-unsigned nsignals;
-unsigned nioctlents;
-int *qual_flags;
+const struct sysent *sysent = sysent0;
+const char *const *errnoent = errnoent0;
+const char *const *signalent = signalent0;
+const struct ioctlent *ioctlent = ioctlent0;
+unsigned nsyscalls = nsyscalls0;
+unsigned nerrnos = nerrnos0;
+unsigned nsignals = nsignals0;
+unsigned nioctlents = nioctlents0;
+int *qual_flags = qual_flags0;
 
+#if SUPPORTED_PERSONALITIES > 1
 int current_personality;
 
-#ifndef PERSONALITY0_WORDSIZE
-# define PERSONALITY0_WORDSIZE sizeof(long)
-#endif
 const int personality_wordsize[SUPPORTED_PERSONALITIES] = {
 	PERSONALITY0_WORDSIZE,
-#if SUPPORTED_PERSONALITIES > 1
 	PERSONALITY1_WORDSIZE,
-#endif
-#if SUPPORTED_PERSONALITIES > 2
+# if SUPPORTED_PERSONALITIES > 2
 	PERSONALITY2_WORDSIZE,
-#endif
+# endif
 };
 
 void
@@ -224,7 +220,6 @@
 		qual_flags = qual_flags0;
 		break;
 
-#if SUPPORTED_PERSONALITIES >= 2
 	case 1:
 		errnoent = errnoent1;
 		nerrnos = nerrnos1;
@@ -236,9 +231,8 @@
 		nsignals = nsignals1;
 		qual_flags = qual_flags1;
 		break;
-#endif
 
-#if SUPPORTED_PERSONALITIES >= 3
+# if SUPPORTED_PERSONALITIES >= 3
 	case 2:
 		errnoent = errnoent2;
 		nerrnos = nerrnos2;
@@ -250,13 +244,12 @@
 		nsignals = nsignals2;
 		qual_flags = qual_flags2;
 		break;
-#endif
+# endif
 	}
 
 	current_personality = personality;
 }
 
-#if SUPPORTED_PERSONALITIES > 1
 static void
 update_personality(struct tcb *tcp, int personality)
 {
@@ -521,7 +514,7 @@
 	tcp->scno = SYS_socket_subcall + tcp->u_arg[0];
 	addr = tcp->u_arg[1];
 	tcp->u_nargs = sysent[tcp->scno].nargs;
-	size = personality_wordsize[current_personality];
+	size = current_wordsize;
 	for (i = 0; i < tcp->u_nargs; ++i) {
 		if (size == sizeof(int)) {
 			unsigned int arg;
@@ -685,8 +678,7 @@
  * other: error, trace_syscall() should print error indicator
  *    ("????" etc) and bail out.
  */
-static
-int
+static int
 get_scno(struct tcb *tcp)
 {
 	long scno = 0;
@@ -1682,7 +1674,7 @@
 {
 	unsigned long int max = -(long int) nerrnos;
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] < sizeof(val)) {
+	if (current_wordsize < sizeof(val)) {
 		val = (unsigned int) val;
 		max = (unsigned int) max;
 	}
diff --git a/time.c b/time.c
index 09d0f07..537265e 100644
--- a/time.c
+++ b/time.c
@@ -79,7 +79,7 @@
 
 	if (bitness == BITNESS_32
 #if SUPPORTED_PERSONALITIES > 1
-	    || personality_wordsize[current_personality] == 4
+	    || current_wordsize == 4
 #endif
 		)
 	{
@@ -135,7 +135,7 @@
 		int rc;
 
 #if SUPPORTED_PERSONALITIES > 1
-		if (personality_wordsize[current_personality] == 4) {
+		if (current_wordsize == 4) {
 			struct timeval32 tv;
 
 			rc = umove(tcp, addr, &tv);
@@ -288,7 +288,7 @@
 
 		if (bitness == BITNESS_32
 #if SUPPORTED_PERSONALITIES > 1
-		    || personality_wordsize[current_personality] == 4
+		    || current_wordsize == 4
 #endif
 			)
 		{
@@ -542,7 +542,7 @@
 	struct timex tx;
 
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] == 4)
+	if (current_wordsize == 4)
 		return tprint_timex32(tcp, addr);
 #endif
 	if (umove(tcp, addr, &tx) < 0)
@@ -746,7 +746,7 @@
 	struct sigevent sev;
 
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] == 4) {
+	if (current_wordsize == 4) {
 		printsigevent32(tcp, arg);
 		return;
 	}
diff --git a/util.c b/util.c
index 4066bcb..9a77705 100644
--- a/util.c
+++ b/util.c
@@ -631,14 +631,11 @@
 	} iovu;
 #define iov iovu.iov64
 #define sizeof_iov \
-  (personality_wordsize[current_personality] == 4 \
-   ? sizeof(*iovu.iov32) : sizeof(*iovu.iov64))
+	(current_wordsize == 4 ? sizeof(*iovu.iov32) : sizeof(*iovu.iov64))
 #define iov_iov_base(i) \
-  (personality_wordsize[current_personality] == 4 \
-   ? (u_int64_t) iovu.iov32[i].base : iovu.iov64[i].base)
+	(current_wordsize == 4 ? (uint64_t) iovu.iov32[i].base : iovu.iov64[i].base)
 #define iov_iov_len(i) \
-  (personality_wordsize[current_personality] == 4 \
-   ? (u_int64_t) iovu.iov32[i].len : iovu.iov64[i].len)
+	(current_wordsize == 4 ? (uint64_t) iovu.iov32[i].len : iovu.iov64[i].len)
 #else
 	struct iovec *iov;
 #define sizeof_iov sizeof(*iov)
@@ -783,8 +780,8 @@
 	} u;
 
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] < sizeof(addr))
-		addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
+	if (current_wordsize < sizeof(addr))
+		addr &= (1ul << 8 * current_wordsize) - 1;
 #endif
 
 	if (!process_vm_readv_not_supported) {
@@ -874,8 +871,8 @@
 	} u;
 
 #if SUPPORTED_PERSONALITIES > 1
-	if (personality_wordsize[current_personality] < sizeof(addr))
-		addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
+	if (current_wordsize < sizeof(addr))
+		addr &= (1ul << 8 * current_wordsize) - 1;
 #endif
 
 	if (!process_vm_readv_not_supported) {