]> granicus.if.org Git - strace/commitdiff
Introduce current_klongsize in addition to current_wordsize
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 11 Dec 2016 13:30:30 +0000 (16:30 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Dec 2016 14:39:48 +0000 (14:39 +0000)
Subsequent commits are going to use current_klongsize
as the tracee's size of kernel_ulong_t type.

* defs.h (PERSONALITY0_KLONGSIZE): New macro.
[X86_64] (PERSONALITY2_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES > 1] (PERSONALITY1_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES == 1] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE ==
PERSONALITY1_KLONGSIZE] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES != 1 && (SUPPORTED_PERSONALITIES != 2 ||
PERSONALITY0_KLONGSIZE != PERSONALITY1_KLONGSIZE)] (current_klongsize):
New variable prototype.
* syscall.c [!current_klongsize] (current_klongsize): New variable.
[!current_klongsize] (personality_klongsize): New array.
(set_personality) [!current_klongsize]: Update current_klongsize
with the appropriate value from personality_klongsize.

defs.h
syscall.c

diff --git a/defs.h b/defs.h
index f5d0ecbe757c32d4310a9f4eb0107a068ffe2131..758f2e707142765b78f0825e4e538716ed9ac7dc 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -150,7 +150,8 @@ extern char *stpcpy(char *dst, const char *src);
 
 #if defined X86_64
 # define SUPPORTED_PERSONALITIES 3
-# define PERSONALITY2_WORDSIZE 4
+# define PERSONALITY2_WORDSIZE  4
+# define PERSONALITY2_KLONGSIZE PERSONALITY0_KLONGSIZE
 #elif defined AARCH64 \
    || defined POWERPC64 \
    || defined RISCV \
@@ -168,12 +169,14 @@ extern char *stpcpy(char *dst, const char *src);
 # define DEFAULT_PERSONALITY 0
 #endif
 
-#define PERSONALITY0_WORDSIZE SIZEOF_LONG
+#define PERSONALITY0_WORDSIZE  SIZEOF_LONG
+#define PERSONALITY0_KLONGSIZE SIZEOF_KERNEL_LONG_T
 #define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
 #define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
 
 #if SUPPORTED_PERSONALITIES > 1
-# define PERSONALITY1_WORDSIZE 4
+# define PERSONALITY1_WORDSIZE  4
+# define PERSONALITY1_KLONGSIZE PERSONALITY1_WORDSIZE
 #endif
 
 #if SUPPORTED_PERSONALITIES > 1 && defined HAVE_M32_MPERS
@@ -792,12 +795,18 @@ extern unsigned current_personality;
 
 #if SUPPORTED_PERSONALITIES == 1
 # define current_wordsize PERSONALITY0_WORDSIZE
+# define current_klongsize PERSONALITY0_KLONGSIZE
 #else
 # if SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_WORDSIZE == PERSONALITY1_WORDSIZE
 #  define current_wordsize PERSONALITY0_WORDSIZE
 # else
 extern unsigned current_wordsize;
 # endif
+# if SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE == PERSONALITY1_KLONGSIZE
+#  define current_klongsize PERSONALITY0_KLONGSIZE
+# else
+extern unsigned current_klongsize;
+# endif
 #endif
 
 /* In many, many places we play fast and loose and use
index 81489af7dbe87b1ac4bfe2ce0e06396f3a4acb0b..e346958c6f9bc960a4d840c4d47d6f3cbc6fc619 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -257,6 +257,17 @@ static const int personality_wordsize[SUPPORTED_PERSONALITIES] = {
 };
 # endif
 
+# ifndef current_klongsize
+unsigned current_klongsize;
+static const int personality_klongsize[SUPPORTED_PERSONALITIES] = {
+       PERSONALITY0_KLONGSIZE,
+       PERSONALITY1_KLONGSIZE,
+#  if SUPPORTED_PERSONALITIES > 2
+       PERSONALITY2_KLONGSIZE,
+#  endif
+};
+# endif
+
 void
 set_personality(int personality)
 {
@@ -301,6 +312,9 @@ set_personality(int personality)
 # ifndef current_wordsize
        current_wordsize = personality_wordsize[personality];
 # endif
+# ifndef current_klongsize
+       current_klongsize = personality_klongsize[personality];
+# endif
 }
 
 static void