[CRIU] [PATCH 8/8] compel: Split up cpu.h into uapi and priv parts
Pavel Emelyanov
xemul at virtuozzo.com
Mon Nov 14 05:06:30 PST 2016
The compel_foo_cpu_cap()-s and cpuid_bar()-s are not needed
(at least now) outside of compel.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
compel/arch/aarch64/src/lib/cpu.c | 2 +-
compel/arch/aarch64/src/lib/include/cpu.h | 0
compel/arch/arm/src/lib/cpu.c | 2 +-
compel/arch/arm/src/lib/include/cpu.h | 0
compel/arch/ppc64/src/lib/cpu.c | 2 +-
compel/arch/ppc64/src/lib/include/cpu.h | 0
compel/arch/x86/src/lib/cpu.c | 4 +-
compel/arch/x86/src/lib/include/cpu.h | 59 ++++++++++++++++++++++++++
compel/arch/x86/src/lib/include/uapi/asm/cpu.h | 55 ------------------------
compel/include/cpu.h | 10 +++++
compel/include/uapi/cpu.h | 3 --
11 files changed, 74 insertions(+), 63 deletions(-)
create mode 100644 compel/arch/aarch64/src/lib/include/cpu.h
create mode 100644 compel/arch/arm/src/lib/include/cpu.h
create mode 100644 compel/arch/ppc64/src/lib/include/cpu.h
create mode 100644 compel/arch/x86/src/lib/include/cpu.h
create mode 100644 compel/include/cpu.h
diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index 9e5d0d7..4965b45 100644
--- a/compel/arch/aarch64/src/lib/cpu.c
+++ b/compel/arch/aarch64/src/lib/cpu.c
@@ -1,7 +1,7 @@
#include <string.h>
#include <stdbool.h>
-#include "uapi/compel/cpu.h"
+#include "cpu.h"
#include "common/bitops.h"
diff --git a/compel/arch/aarch64/src/lib/include/cpu.h b/compel/arch/aarch64/src/lib/include/cpu.h
new file mode 100644
index 0000000..e69de29
diff --git a/compel/arch/arm/src/lib/cpu.c b/compel/arch/arm/src/lib/cpu.c
index 9e5d0d7..4965b45 100644
--- a/compel/arch/arm/src/lib/cpu.c
+++ b/compel/arch/arm/src/lib/cpu.c
@@ -1,7 +1,7 @@
#include <string.h>
#include <stdbool.h>
-#include "uapi/compel/cpu.h"
+#include "cpu.h"
#include "common/bitops.h"
diff --git a/compel/arch/arm/src/lib/include/cpu.h b/compel/arch/arm/src/lib/include/cpu.h
new file mode 100644
index 0000000..e69de29
diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c
index e324b80..0bfd490 100644
--- a/compel/arch/ppc64/src/lib/cpu.c
+++ b/compel/arch/ppc64/src/lib/cpu.c
@@ -3,7 +3,7 @@
#include <errno.h>
#include <stdbool.h>
-#include "uapi/compel/cpu.h"
+#include "cpu.h"
#include "common/bitops.h"
diff --git a/compel/arch/ppc64/src/lib/include/cpu.h b/compel/arch/ppc64/src/lib/include/cpu.h
new file mode 100644
index 0000000..e69de29
diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c
index 7962a61..76933f2 100644
--- a/compel/arch/x86/src/lib/cpu.c
+++ b/compel/arch/x86/src/lib/cpu.c
@@ -1,8 +1,8 @@
#include <string.h>
#include <stdbool.h>
-#include "uapi/compel/cpu.h"
-
+#include <compel/cpu.h>
+#include "asm/cpu.h"
#include "common/bitops.h"
#include "common/compiler.h"
diff --git a/compel/arch/x86/src/lib/include/cpu.h b/compel/arch/x86/src/lib/include/cpu.h
new file mode 100644
index 0000000..396fcfd
--- /dev/null
+++ b/compel/arch/x86/src/lib/include/cpu.h
@@ -0,0 +1,59 @@
+#ifndef __COMPEL_ASM_CPU_H__
+#define __COMPEL_ASM_CPU_H__
+
+static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ /* ecx is often an input as well as an output. */
+ asm volatile("cpuid"
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+ "=d" (*edx)
+ : "0" (*eax), "2" (*ecx)
+ : "memory");
+}
+
+static inline void cpuid(unsigned int op,
+ unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ *eax = op;
+ *ecx = 0;
+ native_cpuid(eax, ebx, ecx, edx);
+}
+
+static inline void cpuid_count(unsigned int op, int count,
+ unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ *eax = op;
+ *ecx = count;
+ native_cpuid(eax, ebx, ecx, edx);
+}
+
+static inline unsigned int cpuid_eax(unsigned int op)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ cpuid(op, &eax, &ebx, &ecx, &edx);
+ return eax;
+}
+
+static inline unsigned int cpuid_ecx(unsigned int op)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ cpuid(op, &eax, &ebx, &ecx, &edx);
+ return ecx;
+}
+
+static inline unsigned int cpuid_edx(unsigned int op)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ cpuid(op, &eax, &ebx, &ecx, &edx);
+ return edx;
+}
+
+#endif
diff --git a/compel/arch/x86/src/lib/include/uapi/asm/cpu.h b/compel/arch/x86/src/lib/include/uapi/asm/cpu.h
index f79ace1..90d7770 100644
--- a/compel/arch/x86/src/lib/include/uapi/asm/cpu.h
+++ b/compel/arch/x86/src/lib/include/uapi/asm/cpu.h
@@ -121,61 +121,6 @@
*/
#define X86_FEATURE_PREFETCHWT1 (11*32+0) /* The PREFETCHWT1 instruction */
-static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- /* ecx is often an input as well as an output. */
- asm volatile("cpuid"
- : "=a" (*eax),
- "=b" (*ebx),
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx)
- : "memory");
-}
-
-static inline void cpuid(unsigned int op,
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- *eax = op;
- *ecx = 0;
- native_cpuid(eax, ebx, ecx, edx);
-}
-
-static inline void cpuid_count(unsigned int op, int count,
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- *eax = op;
- *ecx = count;
- native_cpuid(eax, ebx, ecx, edx);
-}
-
-static inline unsigned int cpuid_eax(unsigned int op)
-{
- unsigned int eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
- return eax;
-}
-
-static inline unsigned int cpuid_ecx(unsigned int op)
-{
- unsigned int eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
- return ecx;
-}
-
-static inline unsigned int cpuid_edx(unsigned int op)
-{
- unsigned int eax, ebx, ecx, edx;
-
- cpuid(op, &eax, &ebx, &ecx, &edx);
- return edx;
-}
-
enum {
X86_VENDOR_INTEL = 0,
X86_VENDOR_AMD = 1,
diff --git a/compel/include/cpu.h b/compel/include/cpu.h
new file mode 100644
index 0000000..dd95e0a
--- /dev/null
+++ b/compel/include/cpu.h
@@ -0,0 +1,10 @@
+#ifndef __COMPEL_CPU_H__
+#define __COMPEL_CPU_H__
+
+#include <compel/cpu.h>
+
+extern void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
+extern void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
+extern int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
+
+#endif
diff --git a/compel/include/uapi/cpu.h b/compel/include/uapi/cpu.h
index 662883b..23438da 100644
--- a/compel/include/uapi/cpu.h
+++ b/compel/include/uapi/cpu.h
@@ -5,9 +5,6 @@
#include <compel/asm/cpu.h>
-extern void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
-extern void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
-extern int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature);
extern int compel_cpuid(compel_cpuinfo_t *info);
extern bool cpu_has_feature(unsigned int feature);
--
2.5.0
More information about the CRIU
mailing list