[CRIU] [PATCH 07/18] compel: fpu -- Add compel_fpu_has_feature helper

Cyrill Gorcunov gorcunov at gmail.com
Thu Jul 19 15:47:35 MSK 2018


Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 compel/arch/aarch64/src/lib/cpu.c |  9 +++++++++
 compel/arch/arm/src/lib/cpu.c     |  9 +++++++++
 compel/arch/ppc64/src/lib/cpu.c   |  9 +++++++++
 compel/arch/s390/src/lib/cpu.c    | 11 ++++++++++-
 compel/arch/x86/src/lib/cpu.c     |  9 +++++++++
 compel/include/uapi/cpu.h         |  1 +
 6 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index c7573f6adef9..38d9cbf4ef6d 100644
--- a/compel/arch/aarch64/src/lib/cpu.c
+++ b/compel/arch/aarch64/src/lib/cpu.c
@@ -28,6 +28,15 @@ bool compel_cpu_has_feature(unsigned int feature)
 	return compel_test_cpu_cap(&rt_info, feature);
 }
 
+bool compel_fpu_has_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_test_fpu_cap(&rt_info, feature);
+}
+
 void compel_cpu_clear_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
diff --git a/compel/arch/arm/src/lib/cpu.c b/compel/arch/arm/src/lib/cpu.c
index c7573f6adef9..38d9cbf4ef6d 100644
--- a/compel/arch/arm/src/lib/cpu.c
+++ b/compel/arch/arm/src/lib/cpu.c
@@ -28,6 +28,15 @@ bool compel_cpu_has_feature(unsigned int feature)
 	return compel_test_cpu_cap(&rt_info, feature);
 }
 
+bool compel_fpu_has_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_test_fpu_cap(&rt_info, feature);
+}
+
 void compel_cpu_clear_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c
index f6d163b89f45..27a21a53ad92 100644
--- a/compel/arch/ppc64/src/lib/cpu.c
+++ b/compel/arch/ppc64/src/lib/cpu.c
@@ -42,6 +42,15 @@ bool compel_cpu_has_feature(unsigned int feature)
 	return compel_test_cpu_cap(&rt_info, feature);
 }
 
+bool compel_fpu_has_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_test_fpu_cap(&rt_info, feature);
+}
+
 void compel_cpu_clear_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
diff --git a/compel/arch/s390/src/lib/cpu.c b/compel/arch/s390/src/lib/cpu.c
index 85a074a3bab7..97ab809b8ae4 100644
--- a/compel/arch/s390/src/lib/cpu.c
+++ b/compel/arch/s390/src/lib/cpu.c
@@ -33,7 +33,7 @@ int compel_cpuid(compel_cpuinfo_t *info)
 	return 0;
 }
 
-bool cpu_has_feature(unsigned int feature)
+bool compel_cpu_has_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
 		compel_cpuid(&rt_info);
@@ -42,6 +42,15 @@ bool cpu_has_feature(unsigned int feature)
 	return compel_test_cpu_cap(&rt_info, feature);
 }
 
+bool compel_fpu_has_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_test_fpu_cap(&rt_info, feature);
+}
+
 void compel_cpu_clear_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c
index 722c729e2a74..85a936299342 100644
--- a/compel/arch/x86/src/lib/cpu.c
+++ b/compel/arch/x86/src/lib/cpu.c
@@ -445,6 +445,15 @@ bool compel_cpu_has_feature(unsigned int feature)
 	return compel_test_cpu_cap(&rt_info, feature);
 }
 
+bool compel_fpu_has_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_test_fpu_cap(&rt_info, feature);
+}
+
 void compel_cpu_clear_feature(unsigned int feature)
 {
 	if (!rt_info_done) {
diff --git a/compel/include/uapi/cpu.h b/compel/include/uapi/cpu.h
index 3799595852b0..d858a0b467e6 100644
--- a/compel/include/uapi/cpu.h
+++ b/compel/include/uapi/cpu.h
@@ -7,6 +7,7 @@
 
 extern int compel_cpuid(compel_cpuinfo_t *info);
 extern bool compel_cpu_has_feature(unsigned int feature);
+extern bool compel_fpu_has_feature(unsigned int feature);
 extern void compel_cpu_clear_feature(unsigned int feature);
 extern void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c);
 
-- 
2.14.4



More information about the CRIU mailing list