All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Joe Korty <joe.korty@ccur.com>
Cc: "Luck, Tony" <tony.luck@intel.com>, linux-kernel@vger.kernel.org
Subject: Re: format_cpumask()
Date: Mon, 17 Nov 2003 16:26:47 -0800	[thread overview]
Message-ID: <20031118002647.GH22764@holomorphy.com> (raw)
In-Reply-To: <20031118002213.GA6272@tsunami.ccur.com>

On Mon, Nov 17, 2003 at 07:22:13PM -0500, Joe Korty wrote:
> How about this? (eye-checked only).
> static int format_cpumask(char *buf, cpumask_t cpus)
> {
> 	int i, d, len = 0;
> 	cpumask_t tmp;
> 
> 	for(i = (NR_CPUS - 1) & ~3; i >= 0; i -= 4) {
> 		cpus_shift_right(tmp, cpus, i);
> 		d = (int)cpus_coerce(tmp) & 0xf;
> 		buf[len++] = "0123456789abcdef"[d];
> 	}
> 	return len;
> }

I think Keith Owens had a much better suggestion: using '*' in the
format string.


===== include/linux/cpumask.h 1.1 vs edited =====
--- 1.1/include/linux/cpumask.h	Mon Aug 18 19:46:23 2003
+++ edited/include/linux/cpumask.h	Mon Nov 17 16:25:18 2003
@@ -68,4 +68,20 @@
 		cpu < NR_CPUS;						\
 		cpu = next_online_cpu(cpu,map))
 
+static inline int format_cpumask(char *buf, cpumask_t cpus)
+{
+	int k, len = 0;
+
+	for (k = sizeof(cpumask_t)/sizeof(long) - 1; k >= 0; --k) {
+		int m;
+		cpumask_t tmp;
+
+		cpus_shift_right(tmp, cpus, BITS_PER_LONG*k);
+		m = sprintf(buf, "%0*lx", 2*sizeof(long), cpus_coerce(tmp));
+		len += m;
+		buf += m;
+	}
+	return len;
+}
+
 #endif /* __LINUX_CPUMASK_H */

  parent reply	other threads:[~2003-11-18  0:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-17 23:56 format_cpumask() Luck, Tony
2003-11-18  0:00 ` format_cpumask() William Lee Irwin III
2003-11-18  0:03 ` format_cpumask() William Lee Irwin III
     [not found] ` <20031118002213.GA6272@tsunami.ccur.com>
2003-11-18  0:26   ` William Lee Irwin III [this message]
2003-11-18  0:34     ` format_cpumask() Keith Owens
2003-11-18  0:56       ` format_cpumask() William Lee Irwin III
2003-11-28 20:54         ` [PATCH] new /proc/irq cpumask format; consolidate cpumask display and input code Paul Jackson
2003-11-28 21:09           ` William Lee Irwin III
  -- strict thread matches above, loose matches on Subject: below --
2003-11-17 18:49 format_cpumask() Luck, Tony
2003-11-17 23:35 ` format_cpumask() William Lee Irwin III
2003-11-17  3:35 format_cpumask() William Lee Irwin III
2003-11-19  9:32 ` format_cpumask() Paul Jackson
2003-11-19 10:38   ` format_cpumask() William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031118002647.GH22764@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=joe.korty@ccur.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.