[Xenomai-git] Philippe Gerum : boilerplate: introduce get_static_cpu_count()
Module: xenomai-forge Branch: next Commit: 06c690f8db5f13dbae3b7ec81dabde74b3884ae5 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=06c690f8db5f13dbae3b7ec81dabde74b3884ae5 Author: Philippe Gerum r...@xenomai.org 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 Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: introduce get_static_cpu_count()
Module: xenomai-forge Branch: next Commit: 366460e3e9e114d46755f8c87e49e0069f7baa9c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=366460e3e9e114d46755f8c87e49e0069f7baa9c Author: Philippe Gerum r...@xenomai.org 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 Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: introduce get_static_cpu_count()
Module: xenomai-forge Branch: rtdm-api-waitqueues Commit: 9579ce404325fffc35f8df2097cf3f7ecc09074a URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9579ce404325fffc35f8df2097cf3f7ecc09074a Author: Philippe Gerum r...@xenomai.org 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 Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: introduce get_static_cpu_count()
Module: xenomai-forge Branch: next Commit: 9579ce404325fffc35f8df2097cf3f7ecc09074a URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9579ce404325fffc35f8df2097cf3f7ecc09074a Author: Philippe Gerum r...@xenomai.org 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 Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git