aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-30 13:34:07 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-30 14:32:47 -0500
commit41a33285f270f284aa44250e79d70372f68bce80 (patch)
tree6d8da5fb1082c293efa7a84e19499f88ab021ebe
parent708b9e195cbaebdbea5bfccb751c7fce0a25b9f7 (diff)
trace-view: Move cpu mask functions into cpu.h
Move the cpu mask alorithms out into cpu.h for other files to use them. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--cpu.h40
-rw-r--r--trace-view-store.c26
2 files changed, 46 insertions, 20 deletions
diff --git a/cpu.h b/cpu.h
new file mode 100644
index 0000000..86cab77
--- /dev/null
+++ b/cpu.h
@@ -0,0 +1,40 @@
1#ifndef _CPU_H
2#define _CPU_H
3
4static inline int cpu_isset(guint64 *cpu_mask, gint cpu)
5{
6 guint64 mask;
7
8 mask = *(cpu_mask + (cpu >> 6));
9
10 return mask & (1ULL << (cpu & ((1ULL << 6) - 1)));
11}
12
13static inline void cpu_set(guint64 *cpu_mask, gint cpu)
14{
15 guint64 *mask;
16
17 mask = cpu_mask + (cpu >> 6);
18 *mask |= (1ULL << (cpu & ((1ULL << 6) - 1)));
19}
20
21static inline void cpu_clear(guint64 *cpu_mask, gint cpu)
22{
23 guint64 *mask;
24
25 mask = cpu_mask + (cpu >> 6);
26 *mask &= ~(1ULL << (cpu & ((1ULL << 6) - 1)));
27}
28
29static inline void set_cpus(guint64 *cpu_mask, gint cpus)
30{
31 gint idx;
32
33 for (idx = 0; idx < (cpus >> 6); idx++) {
34 *(cpu_mask + idx) = -1ULL;
35 }
36
37 *(cpu_mask) = (1ULL << (cpus & ((1ULL << 6) - 1))) - 1;
38}
39
40#endif /* _CPU_H */
diff --git a/trace-view-store.c b/trace-view-store.c
index 2c4467a..6f7a46a 100644
--- a/trace-view-store.c
+++ b/trace-view-store.c
@@ -1,6 +1,8 @@
1#include "trace-view-store.h" 1#include "trace-view-store.h"
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "cpu.h"
5
4/* boring declarations of local functions */ 6/* boring declarations of local functions */
5 7
6static void trace_view_store_init (TraceViewStore *pkg_tree); 8static void trace_view_store_init (TraceViewStore *pkg_tree);
@@ -703,38 +705,22 @@ trace_view_store_iter_parent (GtkTreeModel *tree_model,
703 705
704static int mask_cpu_isset(TraceViewStore *store, gint cpu) 706static int mask_cpu_isset(TraceViewStore *store, gint cpu)
705{ 707{
706 guint64 mask; 708 return cpu_isset(store->cpu_mask, cpu);
707
708 mask = *(store->cpu_mask + (cpu >> 6));
709
710 return mask & (1ULL << (cpu & ((1ULL << 6) - 1)));
711} 709}
712 710
713static void mask_cpu_set(TraceViewStore *store, gint cpu) 711static void mask_cpu_set(TraceViewStore *store, gint cpu)
714{ 712{
715 guint64 *mask; 713 cpu_set(store->cpu_mask, cpu);
716
717 mask = store->cpu_mask + (cpu >> 6);
718 *mask |= (1ULL << (cpu & ((1ULL << 6) - 1)));
719} 714}
720 715
721static void mask_cpu_clear(TraceViewStore *store, gint cpu) 716static void mask_cpu_clear(TraceViewStore *store, gint cpu)
722{ 717{
723 guint64 *mask; 718 cpu_clear(store->cpu_mask, cpu);
724
725 mask = store->cpu_mask + (cpu >> 6);
726 *mask &= ~(1ULL << (cpu & ((1ULL << 6) - 1)));
727} 719}
728 720
729static void mask_set_cpus(TraceViewStore *store, gint cpus) 721static void mask_set_cpus(TraceViewStore *store, gint cpus)
730{ 722{
731 gint idx; 723 set_cpus(store->cpu_mask, cpus);
732
733 for (idx = 0; idx < (cpus >> 6); idx++) {
734 *(store->cpu_mask + idx) = -1ULL;
735 }
736
737 *(store->cpu_mask) = (1ULL << (cpus & ((1ULL << 6) - 1))) - 1;
738} 724}
739 725
740static void update_page(TraceViewStore *store) 726static void update_page(TraceViewStore *store)