From: Denys Vlasenko Date: Sun, 17 Feb 2013 21:41:33 +0000 (+0100) Subject: Remove broken HAVE_LONG_LONG conditionals X-Git-Tag: v4.8~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9d0fc0a63d5b425d6a4e9fedb4cb7a8e3129d6c;p=strace Remove broken HAVE_LONG_LONG conditionals 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 --- diff --git a/defs.h b/defs.h index a349036a..c9200fa0 100644 --- 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 72873da5..9199f261 100644 --- 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