Module: xenomai-forge Branch: next Commit: 366460e3e9e114d46755f8c87e49e0069f7baa9c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=366460e3e9e114d46755f8c87e49e0069f7baa9c
Author: Philippe Gerum <[email protected]> Date: Mon Apr 21 11:21:25 2014 +0200 boilerplate: introduce get_static_cpu_count() --- include/boilerplate/ancillaries.h | 2 ++ lib/boilerplate/ancillaries.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/boilerplate/ancillaries.h b/include/boilerplate/ancillaries.h index b2c5b44..f1b4118 100644 --- a/include/boilerplate/ancillaries.h +++ b/include/boilerplate/ancillaries.h @@ -75,6 +75,8 @@ void error_hook(struct error_frame *ef); void boilerplate_init(void); +int get_static_cpu_count(void); + #ifdef __cplusplus } #endif diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c index 390369c..688aeee 100644 --- a/lib/boilerplate/ancillaries.c +++ b/lib/boilerplate/ancillaries.c @@ -224,6 +224,29 @@ int __check_cancel_type(const char *locktype) #endif /* CONFIG_XENO_DEBUG */ +int get_static_cpu_count(void) +{ + char buf[BUFSIZ]; + int count = 0; + FILE *fp; + + /* + * We want the maximum # of CPU the running kernel was + * configured for, not the current online/present/possible + * count of CPU devices. + */ + fp = fopen("/sys/devices/system/cpu/kernel_max", "r"); + if (fp == NULL) + return -1; + + if (fgets(buf, sizeof(buf), fp)) + count = atoi(buf); + + fclose(fp); + + return count; +} + static void __boilerplate_init(void) { __RT(clock_gettime(CLOCK_MONOTONIC, &__init_date)); _______________________________________________ Xenomai-git mailing list [email protected] http://www.xenomai.org/mailman/listinfo/xenomai-git
