[CRIU] [PATCH] compel: Split cpu.h heander into uapi and priv parts
Pavel Emelyanov
xemul at virtuozzo.com
Mon Nov 21 00:48:27 PST 2016
https://travis-ci.org/xemul/criu/builds/177585567
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 | 3 +-
compel/arch/x86/src/lib/include/cpu.h | 59 ++++++++++++++++++++++++++
compel/arch/x86/src/lib/include/uapi/asm/cpu.h | 55 ------------------------
compel/include/compel-cpu.h | 11 +++++
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/compel-cpu.h
diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index 9e5d0d7..3fa5446 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 "compel-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..3fa5446 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 "compel-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..00a02ea 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 "compel-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..88df9f2 100644
--- a/compel/arch/x86/src/lib/cpu.c
+++ b/compel/arch/x86/src/lib/cpu.c
@@ -1,8 +1,7 @@
#include <string.h>
#include <stdbool.h>
-#include "uapi/compel/cpu.h"
-
+#include "compel-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/compel-cpu.h b/compel/include/compel-cpu.h
new file mode 100644
index 0000000..a06b2de
--- /dev/null
+++ b/compel/include/compel-cpu.h
@@ -0,0 +1,11 @@
+#ifndef __COMPEL_CPU_H__
+#define __COMPEL_CPU_H__
+
+#include <compel/cpu.h>
+#include "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);
+
+#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.1.4
More information about the CRIU
mailing list