On Tue, 2010-08-17 at 15:44 +0200, Karel Zak wrote: > On Tue, Aug 17, 2010 at 08:49:50AM -0400, Mike Frysinger wrote: > > On Tue, Aug 17, 2010 at 8:41 AM, Davidlohr Bueso wrote: > > > +static > > > +int get_byteorder(void) > > > +{ > > > + int x = 1; > > > + if (*(char *)&x == LENDIAN) > > > + return LENDIAN; > > > + else return BENDIAN; > > > +} > > > > this looks like aliasing violations. since util-linux is autotooled, > > use AC_C_BIGENDIAN and then WORDS_BIGENDIAN (assuming util-linux > > doesnt already provide something). > > $ grep ENDIAN ./configure.ac > AC_C_BIGENDIAN > > or include bitops.h and use #if (__BYTE_ORDER == __BIG_ENDIAN) or so. > That was dumb of me not to check previous code for this. Here's a new patch for printing the endianess, based on lib/md5.c. >From 0cf011e3eb66cec775996db0a1c3b6c94695cd8d Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso <dave@xxxxxxx> Date: Tue, 17 Aug 2010 09:58:57 -0400 Subject: [PATCH] lscpu: Add byte order and BogoMIPS information. Signed-off-by: Davidlohr Bueso <dave@xxxxxxx> --- sys-utils/lscpu.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 58cd869..b136118 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -30,6 +30,7 @@ #include <sys/utsname.h> #include <unistd.h> #include <stdarg.h> +#include <bitops.h> #include "cpuset.h" #include "nls.h" @@ -97,6 +98,7 @@ struct lscpu_desc { int virtype; /* VIRT_PARA|FULL|NONE ? */ char *mhz; char *stepping; + char *bogomips; char *flags; int mode; /* rm, lm or/and tm */ @@ -366,6 +368,7 @@ read_basicinfo(struct lscpu_desc *desc) else if (lookup(buf, "stepping", &desc->stepping)) ; else if (lookup(buf, "cpu MHz", &desc->mhz)) ; else if (lookup(buf, "flags", &desc->flags)) ; + else if (lookup(buf, "bogomips", &desc->bogomips)) ; else continue; } @@ -858,6 +861,15 @@ print_readable(struct lscpu_desc *desc, int hex) print_s(_("Stepping:"), desc->stepping); if (desc->mhz) print_s(_("CPU MHz:"), desc->mhz); +#ifdef __BYTE_ORDER +#if (__BYTE_ORDER == __LITTLE_ENDIAN) + print_s(_("Byte Order"), "Little Endian"); +#else + print_s(_("Byte Order"), "Big Endian"); +#endif +#endif + if (desc->bogomips) + print_s(_("BogoMIPS:"), desc->bogomips); if (desc->virtflag) { if (!strcmp(desc->virtflag, "svm")) print_s(_("Virtualization:"), "AMD-V"); -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html