]> granicus.if.org Git - strace/commitdiff
Remove broken HAVE_LONG_LONG conditionals
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 17 Feb 2013 21:41:33 +0000 (22:41 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 17 Feb 2013 21:41:33 +0000 (22:41 +0100)
We use printllval without HAVE_LONG_LONG guards in many places,
but define it only if HAVE_LONG_LONG. This means that
on !HAVE_LONG_LONG systems we won't build for some time now.

* defs.h: Remove HAVE_LONG_LONG guard around LONG_LONG() macro
and printllval() function declaration.
* util.c: Remove HAVE_LONG_LONG guard around printllval()
function definition.
(printllval): Add compile-time error check for using wrong
if branch. Explain places where we deliberately use mismatched
types for printf formats.

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

diff --git a/defs.h b/defs.h
index a349036ad90dc35db1d257ae7b15fbb89ca1ff95..c9200fa01db1edfff1760074ce517438a70ed8d7 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -602,19 +602,18 @@ extern const char *xlookup(const struct xlat *, int);
 extern int string_to_uint(const char *str);
 extern int string_quote(const char *, char *, long, int);
 
-#if HAVE_LONG_LONG
-/* _l refers to the lower numbered u_arg,
- * _h refers to the higher numbered u_arg
+/* a refers to the lower numbered u_arg,
+ * b refers to the higher numbered u_arg
  */
-# if HAVE_LITTLE_ENDIAN_LONG_LONG
-#  define LONG_LONG(_l,_h) \
-       ((long long)((unsigned long long)(unsigned)(_l) | ((unsigned long long)(_h)<<32)))
-# else
-#  define LONG_LONG(_l,_h) \
-       ((long long)((unsigned long long)(unsigned)(_h) | ((unsigned long long)(_l)<<32)))
-# endif
-extern int printllval(struct tcb *, const char *, int);
+#if HAVE_LITTLE_ENDIAN_LONG_LONG
+# define LONG_LONG(a,b) \
+       ((long long)((unsigned long long)(unsigned)(a) | ((unsigned long long)(b)<<32)))
+#else
+# define LONG_LONG(a,b) \
+       ((long long)((unsigned long long)(unsigned)(b) | ((unsigned long long)(a)<<32)))
 #endif
+extern int printllval(struct tcb *, const char *, int);
+
 extern void printxval(const struct xlat *, int, const char *);
 extern int printargs(struct tcb *);
 extern int printargs_lu(struct tcb *);
diff --git a/util.c b/util.c
index 72873da59616ab19114b7b78fee7d9fa085f75a6..9199f261548e246af7a670cf489c40700291092e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -178,7 +178,6 @@ printxval(const struct xlat *xlat, int val, const char *dflt)
                tprintf("%#x /* %s */", val, dflt);
 }
 
-#if HAVE_LONG_LONG
 /*
  * Print 64bit argument at position llarg and return the index of the next
  * argument.
@@ -186,31 +185,41 @@ printxval(const struct xlat *xlat, int val, const char *dflt)
 int
 printllval(struct tcb *tcp, const char *format, int llarg)
 {
-# if defined(X86_64) || defined(POWERPC64)
+#if defined(X86_64) || defined(POWERPC64)
        if (current_personality == 0) {
+               /* Technically, format expects "long long",
+                * but we supply "long". We expect that
+                * on this arch, they are the same.
+                */
                tprintf(format, tcp->u_arg[llarg]);
                llarg++;
        } else {
-#  ifdef POWERPC64
+# ifdef POWERPC64
                /* Align 64bit argument to 64bit boundary.  */
                llarg = (llarg + 1) & 0x1e;
-#  endif
+# endif
                tprintf(format, LONG_LONG(tcp->u_arg[llarg], tcp->u_arg[llarg + 1]));
                llarg += 2;
        }
-# elif defined IA64 || defined ALPHA
+#elif defined IA64 || defined ALPHA
+       /* Technically, format expects "long long",
+        * but we supply "long". We expect that
+        * on this arch, they are the same.
+        */
        tprintf(format, tcp->u_arg[llarg]);
        llarg++;
-# elif defined LINUX_MIPSN32 || defined X32
+#elif defined LINUX_MIPSN32 || defined X32
        tprintf(format, tcp->ext_arg[llarg]);
        llarg++;
-# else
+#else
+# if SIZEOF_LONG > 4
+#  error BUG: must not combine two args for long long on this arch
+# endif
        tprintf(format, LONG_LONG(tcp->u_arg[llarg], tcp->u_arg[llarg + 1]));
        llarg += 2;
-# endif
+#endif
        return llarg;
 }
-#endif
 
 /*
  * Interpret `xlat' as an array of flags