]> granicus.if.org Git - strace/commitdiff
A better handling of current_wordsize
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 15 Feb 2013 13:55:14 +0000 (14:55 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 15 Feb 2013 13:55:14 +0000 (14:55 +0100)
On x86_64:
  text    data     bss     dec     hex filename
435661   26628   47424  509713   7c711 strace_old
435501   26612   47440  509553   7c671 strace_new_clever_wordsize

On x32 and arm it should be even better, current_wordsize becomes
a constant there.

* defs.h: Declare current_wordsize as a variable if needed,
else declare as a constant define.
Remove declatation of personality_wordsize[].
* syscall.c: Make personality_wordsize[] static.
Declare current_wordsize as a variable if needed.
(set_personality): Set current_wordsize only if non-constant.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
defs.h
syscall.c

diff --git a/defs.h b/defs.h
index 82ffd848a81cfe10c3b3e96300ba7e511d455e0e..7702aaed29d5aee2c6a75cdf674a022144b45117 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -707,13 +707,20 @@ extern void tprints(const char *str);
 
 #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])
+extern unsigned current_personality;
 #else
 # define set_personality(personality) ((void)0)
 # define current_personality 0
-# define current_wordsize    PERSONALITY0_WORDSIZE
+#endif
+
+#if SUPPORTED_PERSONALITIES == 1
+# define current_wordsize PERSONALITY0_WORDSIZE
+#else
+# if SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_WORDSIZE == PERSONALITY1_WORDSIZE
+#  define current_wordsize PERSONALITY0_WORDSIZE
+# else
+extern unsigned current_wordsize;
+# endif
 #endif
 
 struct sysent {
index 433ee724ae15a6163d68a93fb1ff64b11837d6f4..7ed0bdcdb98c5377ea1744e70571fdbbbf90c346 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -214,15 +214,18 @@ unsigned nioctlents = nioctlents0;
 int *qual_flags = qual_flags0;
 
 #if SUPPORTED_PERSONALITIES > 1
-int current_personality;
+unsigned current_personality;
 
-const int personality_wordsize[SUPPORTED_PERSONALITIES] = {
+# ifndef current_wordsize
+unsigned current_wordsize;
+static const int personality_wordsize[SUPPORTED_PERSONALITIES] = {
        PERSONALITY0_WORDSIZE,
        PERSONALITY1_WORDSIZE,
 # if SUPPORTED_PERSONALITIES > 2
        PERSONALITY2_WORDSIZE,
 # endif
 };
+# endif
 
 void
 set_personality(int personality)
@@ -268,6 +271,9 @@ set_personality(int personality)
        }
 
        current_personality = personality;
+# ifndef current_wordsize
+       current_wordsize = personality_wordsize[personality];
+# endif
 }
 
 static void