From 201a7c0d0f0ead1da225bb92ab375f90ca61ebc5 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 31 Oct 2016 13:58:14 -0600
Subject: [PATCH 11/16] Put g_precise, g_ncpus and g_sortkey into numatop.h
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

g_precise, g_ncpus and g_sortkey belong to numatop.c so it makes
sense to add their extern declarations into numatop.h and remove the
duplication of these from node.c, os_util.c, win.c

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 common/cmd.c                  |  1 +
 common/include/cmd.h          |  2 --
 common/include/numatop.h      | 48 +++++++++++++++++++++++++++++++++++++++++++
 common/include/os/pfwrapper.h |  3 +--
 common/include/perf.h         |  2 --
 common/include/util.h         |  1 -
 common/include/win.h          |  6 ------
 common/os/node.c              |  1 +
 common/os/os_util.c           |  3 ++-
 common/win.c                  |  1 +
 10 files changed, 54 insertions(+), 14 deletions(-)
 create mode 100644 common/include/numatop.h

diff --git a/common/cmd.c b/common/cmd.c
index beb6f13..bba8515 100644
--- a/common/cmd.c
+++ b/common/cmd.c
@@ -36,6 +36,7 @@
 #include <ctype.h>
 #include <strings.h>
 #include "include/types.h"
+#include "include/numatop.h"
 #include "include/cmd.h"
 #include "include/page.h"
 #include "include/win.h"
diff --git a/common/include/cmd.h b/common/include/cmd.h
index 1ca09ce..960a022 100644
--- a/common/include/cmd.h
+++ b/common/include/cmd.h
@@ -227,8 +227,6 @@ typedef struct _switch {
 #define	CMD_UNCOREQPI(cmd) \
 	((cmd_uncoreqpi_t *)(cmd))
 
-extern int g_sortkey;
-
 extern void switch_table_init(void);
 extern int cmd_id_get(char);
 extern void cmd_execute(cmd_t *, boolean_t *);
diff --git a/common/include/numatop.h b/common/include/numatop.h
new file mode 100644
index 0000000..2b0512b
--- /dev/null
+++ b/common/include/numatop.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *   * Neither the name of Intel Corporation nor the names of its contributors
+ *     may be used to endorse or promote products derived from this software
+ *     without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NUMATOP_H
+#define	_NUMATOP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern precise_type_t g_precise;
+
+/* Number of online CPUs */
+extern int g_ncpus;
+
+/* The sorting key */
+extern int g_sortkey;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _NUMATOP_H */
diff --git a/common/include/os/pfwrapper.h b/common/include/os/pfwrapper.h
index 738927d..5654dd3 100644
--- a/common/include/os/pfwrapper.h
+++ b/common/include/os/pfwrapper.h
@@ -33,6 +33,7 @@
 #include <pthread.h>
 #include "linux/perf_event.h"
 #include "../types.h"
+#include "../numatop.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -107,8 +108,6 @@ typedef struct _pf_ll_rbrec {
 	unsigned int ip_num;
 } pf_ll_rbrec_t;
 
-extern precise_type_t g_precise;
-
 struct _perf_cpu;
 struct _perf_pqos;
 struct _node;
diff --git a/common/include/perf.h b/common/include/perf.h
index f621db5..72f9e67 100644
--- a/common/include/perf.h
+++ b/common/include/perf.h
@@ -181,8 +181,6 @@ typedef struct _perf_ctl {
 	uint64_t last_ms_pqos;
 } perf_ctl_t;
 
-extern precise_type_t g_precise;
-
 extern int perf_init(void);
 extern void perf_fini(void);
 extern int perf_allstop(void);
diff --git a/common/include/util.h b/common/include/util.h
index cfa5f58..feecb44 100644
--- a/common/include/util.h
+++ b/common/include/util.h
@@ -86,7 +86,6 @@ typedef struct _dump_ctl {
 
 extern pid_t g_numatop_pid;
 extern struct timeval g_tvbase;
-extern int g_ncpus;
 extern int g_pagesize;
 extern double g_nsofclk;
 
diff --git a/common/include/win.h b/common/include/win.h
index 2835fa0..39bf7f2 100644
--- a/common/include/win.h
+++ b/common/include/win.h
@@ -419,12 +419,6 @@ typedef struct _dyn_warn {
 /* CPU unhalted cycles in a second */
 extern uint64_t g_clkofsec;
 
-/* Number of online CPUs */
-extern int g_ncpus;
-
-/* The sorting key */
-extern int g_sortkey;
-
 extern void win_fix_init(void);
 extern void win_fix_fini(void);
 extern void win_warn_msg(warn_type_t);
diff --git a/common/os/node.c b/common/os/node.c
index d705bf5..8327fc1 100644
--- a/common/os/node.c
+++ b/common/os/node.c
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <assert.h>
 #include "../include/types.h"
+#include "../include/numatop.h"
 #include "../include/util.h"
 #include "../include/os/os_util.h"
 #include "../include/os/pfwrapper.h"
diff --git a/common/os/os_util.c b/common/os/os_util.c
index 71e449c..8013036 100644
--- a/common/os/os_util.c
+++ b/common/os/os_util.c
@@ -41,6 +41,7 @@
 #include <limits.h>
 #include <locale.h>
 #include "../include/types.h"
+#include "../include/numatop.h"
 #include "../include/util.h"
 #include "../include/os/os_util.h"
 
@@ -702,4 +703,4 @@ os_sysfs_uncore_imc_init(imc_info_t *imc, int num)
 	}
 
 	return imc_num;
-}
\ No newline at end of file
+}
diff --git a/common/win.c b/common/win.c
index bd76118..617192a 100644
--- a/common/win.c
+++ b/common/win.c
@@ -39,6 +39,7 @@
 #include <signal.h>
 #include <curses.h>
 #include "include/types.h"
+#include "include/numatop.h"
 #include "include/util.h"
 #include "include/disp.h"
 #include "include/reg.h"
-- 
2.10.2

