mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] cpu.h: use standard types instead of glib's
Date: Fri,  7 Oct 2016 12:47:09 -0400	[thread overview]
Message-ID: <1475858831-32687-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1475858831-32687-1-git-send-email-lcapitulino@redhat.com>

Future commits will introduce standard C code that
wants to use cpu.h. Let's convert cpu.h to standard
types.

I'm choosing not to change the gui code that uses
cpu.h though. I think that in all platforms where
glib is supported, guint64 should always be uint64_t
and guint should always be unsigned int.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 cpu.h | 47 +++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/cpu.h b/cpu.h
index 05c7f17..fc0b3c4 100644
--- a/cpu.h
+++ b/cpu.h
@@ -20,45 +20,48 @@
 #ifndef _CPU_H
 #define _CPU_H
 
-static inline int cpu_isset(guint64 *cpu_mask, gint cpu)
+#include <stdint.h>
+#include <stdbool.h>
+
+static inline int cpu_isset(uint64_t *cpu_mask, int cpu)
 {
-	guint64 mask;
+	uint64_t mask;
 
 	mask = *(cpu_mask + (cpu >> 6));
 
 	return mask & (1ULL << (cpu & ((1ULL << 6) - 1)));
 }
 
-static inline gboolean cpu_allset(guint64 *cpu_mask, gint max_cpus)
+static inline bool cpu_allset(uint64_t *cpu_mask, int max_cpus)
 {
-	gint cpu;
+	int cpu;
 
 	for (cpu = 0; cpu < max_cpus; cpu++) {
 		if (!cpu_isset(cpu_mask, cpu))
-			return FALSE;
+			return false;
 	}
-	return TRUE;
+	return true;
 }
 
-static inline void cpu_set(guint64 *cpu_mask, gint cpu)
+static inline void cpu_set(uint64_t *cpu_mask, int cpu)
 {
-	guint64 *mask;
+	uint64_t *mask;
 
 	mask = cpu_mask + (cpu >> 6);
 	*mask |= (1ULL << (cpu & ((1ULL << 6) - 1)));
 }
 
-static inline void cpu_clear(guint64 *cpu_mask, gint cpu)
+static inline void cpu_clear(uint64_t *cpu_mask, int cpu)
 {
-	guint64 *mask;
+	uint64_t *mask;
 
 	mask = cpu_mask + (cpu >> 6);
 	*mask &= ~(1ULL << (cpu & ((1ULL << 6) - 1)));
 }
 
-static inline void set_cpus(guint64 *cpu_mask, gint cpus)
+static inline void set_cpus(uint64_t *cpu_mask, int cpus)
 {
-	gint idx;
+	int idx;
 
 	for (idx = 0; idx < (cpus >> 6); idx++) {
 		*(cpu_mask + idx) = -1ULL;
@@ -67,22 +70,22 @@ static inline void set_cpus(guint64 *cpu_mask, gint cpus)
 	*(cpu_mask) = (1ULL << (cpus & ((1ULL << 6) - 1))) - 1;
 }
 
-static inline gboolean cpus_equal(guint64 *a_mask, guint64 *b_mask,
-				  gint cpus)
+static inline bool cpus_equal(uint64_t *a_mask, uint64_t *b_mask,
+				  int cpus)
 {
-	gint idx;
+	int idx;
 
 	for (idx = 0; idx < (cpus >> 6) + 1; idx++) {
 		if (*(a_mask + idx) != *(b_mask + idx))
-			return FALSE;
+			return false;
 	}
-	return TRUE;
+	return true;
 }
 
 /* Hamming weight */
-static inline guint hweight(guint mask)
+static inline unsigned int hweight(unsigned int mask)
 {
-	guint64 w = mask;
+	uint64_t w = mask;
 
 	w -= (w >> 1) & 0x5555555555555555ul;
 	w =  (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
@@ -90,10 +93,10 @@ static inline guint hweight(guint mask)
 	return (w * 0x0101010101010101ul) >> 56;
 }
 
-static inline guint cpu_weight(guint64 *cpu_mask, guint cpus)
+static inline unsigned int cpu_weight(uint64_t *cpu_mask, unsigned int cpus)
 {
-	guint weight = 0;
-	gint idx;
+	unsigned int weight = 0;
+	int idx;
 
 	for (idx = 0; idx < (cpus >> 6) + 1; idx++)
 		weight += hweight(*(cpu_mask + idx));
-- 
2.5.5

  reply	other threads:[~2016-10-07 16:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07 16:47 [PATCH 0/3] trace-cmd record: add --cpu-list option Luiz Capitulino
2016-10-07 16:47 ` Luiz Capitulino [this message]
2016-10-07 16:47 ` [PATCH 2/3] trace-cmd record: refactor set_mask() Luiz Capitulino
2016-10-07 16:47 ` [PATCH 3/3] trace-cmd record: add --cpu-list option Luiz Capitulino
2016-10-28 19:49   ` Steven Rostedt
2016-10-28 19:50     ` Steven Rostedt
2016-10-28 21:15       ` Luiz Capitulino
2016-10-28 21:39         ` Steven Rostedt
2016-10-28 21:14     ` Luiz Capitulino
2016-11-15 21:38       ` Steven Rostedt
2016-11-16 14:09         ` Luiz Capitulino
2016-10-19 13:30 ` [PATCH 0/3] " Luiz Capitulino
2016-10-19 13:55   ` Steven Rostedt
2016-10-19 13:58     ` Luiz Capitulino

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=1475858831-32687-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®