[PATCH] lscpu: Add byte order and bogoMIPS information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The byte order and BogoMIPS of a CPU come naturally to a program like
lscpu. This patch adds this functionality to the readable output.

Thanks,
Davidlohr


Signed-off-by: Davidlohr Bueso <dave@xxxxxxx>
---
 sys-utils/lscpu.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 58cd869..c3727e6 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -77,6 +77,11 @@ enum {
 	MODE_LONG	= (1 << 3)
 };
 
+enum {
+	BENDIAN	= 0,
+	LENDIAN
+};
+
 /* cache(s) description */
 struct cpu_cache {
 	char		*name;
@@ -97,6 +102,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 +372,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;
 	}
@@ -402,6 +409,15 @@ read_basicinfo(struct lscpu_desc *desc)
 	desc->online = path_cpulist(_PATH_SYS_SYSTEM "/cpu/online");
 }
 
+static
+int get_byteorder(void)
+{
+	int x = 1;
+	if (*(char *)&x == LENDIAN)
+		return LENDIAN;
+	else return BENDIAN;
+}
+
 static int
 has_pci_device(int vendor, int device)
 {
@@ -858,6 +874,12 @@ print_readable(struct lscpu_desc *desc, int hex)
 		print_s(_("Stepping:"), desc->stepping);
 	if (desc->mhz)
 		print_s(_("CPU MHz:"), desc->mhz);
+	if(get_byteorder() == BENDIAN)
+		print_s(_("Byte Order"), "Big Endian");
+	else
+		print_s(_("Byte Order"), "Little Endian");
+	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


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux