summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpus.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/cpus.h b/cpus.h
index d672daa..0626726 100644
--- a/cpus.h
+++ b/cpus.h
@@ -2,15 +2,27 @@
#define CPUS_H
#include <unistd.h>
+#include "built_in.h"
+#include "die.h"
-static inline int get_number_cpus(void)
+static inline unsigned int get_number_cpus(void)
{
- return sysconf(_SC_NPROCESSORS_CONF);
+ int ret = sysconf(_SC_NPROCESSORS_CONF);
+
+ if (unlikely(ret <= 0))
+ panic("get_number_cpus error!\n");
+
+ return ret;
}
-static inline int get_number_cpus_online(void)
+static inline unsigned int get_number_cpus_online(void)
{
- return sysconf(_SC_NPROCESSORS_ONLN);
+ int ret = sysconf(_SC_NPROCESSORS_ONLN);
+
+ if (unlikely(ret <= 0))
+ panic("get_number_cpus_online error!\n");
+
+ return ret;
}
#endif /* CPUS_H */