Add API implementation to get CPU core info
diff --git a/cpu-core-info/cpu_core_info.cpp b/cpu-core-info/cpu_core_info.cpp
index 3bba4ab..0a7fd84 100644
--- a/cpu-core-info/cpu_core_info.cpp
+++ b/cpu-core-info/cpu_core_info.cpp
@@ -65,6 +65,13 @@
return number_of_clusters;
}
+int get_number_of_cores() {
+ if(init()) {
+ return ERR_CODE;
+ }
+ return number_of_cores;
+}
+
int get_cluster(int core) {
if(init()) {
return ERR_CODE;
@@ -76,15 +83,16 @@
return core_cluster_map[core];
}
-int get_cores(int *cores) {
+uint32_t get_cores() {
+ uint32_t core_info = 0;
if(init()) {
return ERR_CODE;
}
int i;
for (i = 0; i < number_of_cores; i++) {
- cores[i] = i;
+ core_info = (!cores[i] ? (core_info | (1 << i)) : core_info);
}
- return number_of_cores;
+ return core_info;
}
int get_cores_within_cluster(int cluster, int *cores) {
diff --git a/cpu-core-info/cpu_core_info.h b/cpu-core-info/cpu_core_info.h
index 4e10e68..29b3918 100644
--- a/cpu-core-info/cpu_core_info.h
+++ b/cpu-core-info/cpu_core_info.h
@@ -44,11 +44,14 @@
//return total number of clusters
int get_number_of_clusters();
+//return total number of cores
+int get_number_of_cores();
+
//return cluster number to which the core belongs
int get_cluster(int core);
//return all the cores available
-int get_cores(int *cores);
+uint32_t get_cores();
//return the cores available within given cluster
int get_cores_within_cluster(int cluster, int *cores);