]> granicus.if.org Git - strace/commitdiff
arm: rewrite shuffle_scno in a bit more readable way
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 11 Jan 2015 17:26:29 +0000 (17:26 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 12 Jan 2015 17:32:09 +0000 (17:32 +0000)
* linux/arm/syscallent.h: Define ARM_FIRST_SHUFFLED_SYSCALL instead of
ARM_LAST_ORDINARY_SYSCALL.
* syscall.c [ARM || AARCH64] (shuffle_scno): Update.

linux/arm/syscallent.h
syscall.c

index 5bde8bd9469de81d7b8cf4a53daf59f4223bad65..c93eaa4ca9b41712da0b86e5d80d3aba1137738f 100644 (file)
        { 4,    0,      sys_sched_getattr,      "sched_getattr" }, /* 381 */
        { 5,    TD|TF,  sys_renameat2,          "renameat2"     }, /* 382 */
 #ifdef __ARM_EABI__
-# define ARM_LAST_ORDINARY_SYSCALL 382
+# define ARM_FIRST_SHUFFLED_SYSCALL 383
 #else
        { 5,    0,      NULL,                   NULL            }, /* 383 */
        { 5,    0,      NULL,                   NULL            }, /* 384 */
        { 5,    0,      NULL,                   NULL            }, /* 399 */
 # define SYS_socket_subcall    400
 # include "subcall.h"
-# define ARM_LAST_ORDINARY_SYSCALL (SYS_socket_subcall + SYS_socket_nsubcalls + SYS_ipc_nsubcalls - 1)
-#endif /* !EABI */
+# define ARM_FIRST_SHUFFLED_SYSCALL (SYS_socket_subcall + SYS_socket_nsubcalls + SYS_ipc_nsubcalls)
+#endif /* !__ARM_EABI__ */
 
        /* __ARM_NR_cmpxchg (0x000ffff0).
         * Remapped by shuffle_scno() to be directly after ordinary syscalls
index 091626cec871899d28b0367da46276d67e564405..343fa308354134b8fbec20a495ccf1df8693f4ae 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -930,34 +930,35 @@ print_pc(struct tcb *tcp)
 #endif /* architecture */
 }
 
-/* Shuffle syscall numbers so that we don't have huge gaps in syscall table.
- * The shuffling should be reversible: shuffle_scno(shuffle_scno(n)) == n.
+/*
+ * Shuffle syscall numbers so that we don't have huge gaps in syscall table.
+ * The shuffling should be an involution: shuffle_scno(shuffle_scno(n)) == n.
  */
 #if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
 static long
 shuffle_scno(unsigned long scno)
 {
-       if (scno <= ARM_LAST_ORDINARY_SYSCALL)
+       if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
                return scno;
 
        /* __ARM_NR_cmpxchg? Swap with LAST_ORDINARY+1 */
-       if (scno == 0x000ffff0)
-               return ARM_LAST_ORDINARY_SYSCALL+1;
-       if (scno == ARM_LAST_ORDINARY_SYSCALL+1)
+       if (scno == ARM_FIRST_SHUFFLED_SYSCALL)
                return 0x000ffff0;
+       if (scno == 0x000ffff0)
+               return ARM_FIRST_SHUFFLED_SYSCALL;
 
-       /* Is it ARM specific syscall?
-        * Swap with [LAST_ORDINARY+2, LAST_ORDINARY+2 + LAST_SPECIAL] range.
+#define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
+       /*
+        * Is it ARM specific syscall?
+        * Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
+        * with [SECOND_SHUFFLED, SECOND_SHUFFLED + LAST_SPECIAL] range.
         */
-       if (scno >= 0x000f0000
-        && scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL
-       ) {
-               return scno - 0x000f0000 + (ARM_LAST_ORDINARY_SYSCALL+2);
+       if (scno >= 0x000f0000 &&
+           scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno - 0x000f0000 + ARM_SECOND_SHUFFLED_SYSCALL;
        }
-       if (/* scno >= ARM_LAST_ORDINARY_SYSCALL+2 - always true */ 1
-        && scno <= (ARM_LAST_ORDINARY_SYSCALL+2) + ARM_LAST_SPECIAL_SYSCALL
-       ) {
-               return scno + 0x000f0000 - (ARM_LAST_ORDINARY_SYSCALL+2);
+       if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
        }
 
        return scno;