[Xenomai-git] Philippe Gerum : psos: turn long names options into a standard tunable
Module: xenomai-3 Branch: master Commit: 053535d1ad648c744c39214d81a0b12ad8d1e041 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=053535d1ad648c744c39214d81a0b12ad8d1e041 Author: Philippe Gerum r...@xenomai.org Date: Tue May 19 11:31:28 2015 +0200 psos: turn long names options into a standard tunable --- include/boilerplate/setup.h |4 ++-- include/psos/psos.h | 13 - lib/psos/init.c | 31 +++ lib/psos/internal.h | 16 ++-- lib/psos/pt.c |4 ++-- lib/psos/queue.c|4 ++-- lib/psos/rn.c |4 ++-- lib/psos/sem.c |4 ++-- lib/psos/task.c |4 ++-- 9 files changed, 49 insertions(+), 35 deletions(-) diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h index 70b758d..bc8b3f6 100644 --- a/include/boilerplate/setup.h +++ b/include/boilerplate/setup.h @@ -35,11 +35,11 @@ struct option; struct setup_descriptor { const char *name; - int (*init)(void); int (*tune)(void); - const struct option *options; int (*parse_option)(int optnum, const char *optarg); void (*help)(void); + int (*init)(void); + const struct option *options; struct { int id; int opt_start; diff --git a/include/psos/psos.h b/include/psos/psos.h index 3359892..a6f1559 100644 --- a/include/psos/psos.h +++ b/include/psos/psos.h @@ -25,6 +25,7 @@ #define _XENOMAI_PSOS_PSOS_H #include sys/types.h +#include boilerplate/tunables.h #ifndef SUCCESS #define SUCCESS 0 @@ -369,7 +370,17 @@ int psos_task_normalize_priority(u_long psos_prio); u_long psos_task_denormalize_priority(int core_prio); -extern unsigned int psos_long_names; +extern int psos_long_names; + +static inline define_config_tunable(long_names, int, on) +{ + psos_long_names = on; +} + +static inline read_config_tunable(long_names, int) +{ + return psos_long_names; +} #ifdef __cplusplus } diff --git a/lib/psos/init.c b/lib/psos/init.c index be4e157..9e0b8fd 100644 --- a/lib/psos/init.c +++ b/lib/psos/init.c @@ -46,7 +46,7 @@ * - Tasks, Events, Queues, Semaphores * - Partitions, Regions, Timers */ -unsigned int psos_long_names; +int psos_long_names = 0; static unsigned int clock_resolution = 100; /* 1ms */ @@ -57,21 +57,20 @@ static const struct option psos_options[] = { #define clock_resolution_opt 0 .name = psos-clock-resolution, .has_arg = 1, - .flag = NULL, - .val = 0 }, { #define time_slice_opt 1 .name = psos-time-slice, .has_arg = 1, - .flag = NULL, - .val = 0 }, { - .name = NULL, - .has_arg = 0, - .flag = NULL, - .val = 0 +#define long_names_opt 2 + .name = psos-long-names, + .flag = psos_long_names, + .val = 1 + }, + { + /* sentinel */ } }; @@ -84,6 +83,8 @@ static int psos_parse_option(int optnum, const char *optarg) case time_slice_opt: time_slice_in_ticks = atoi(optarg); break; + case long_names_opt: + break; default: /* Paranoid, can't happen. */ return -EINVAL; @@ -96,6 +97,7 @@ static void psos_help(void) { fprintf(stderr, --psos-clock-resolution=ns tick value (default 1ms)\n); fprintf(stderr, --psos-time-slice=psos-ticksround-robin time slice\n); +fprintf(stderr, --psos-long-names enable long names for objects ( 4 characters)\n); } static int psos_init(void) @@ -129,17 +131,6 @@ static int psos_init(void) return 0; } -const char *__psos_maybe_short_name(char shrt[5], const char *lng) -{ - if (psos_long_names) - return lng; - - strncpy(shrt, lng, 5 - 1); - shrt[4] = '\0'; - - return (const char *)shrt; -} - static struct setup_descriptor psos_skin = { .name = psos, .init = psos_init, diff --git a/lib/psos/internal.h b/lib/psos/internal.h index 01432ba..0e5f108 100644 --- a/lib/psos/internal.h +++ b/lib/psos/internal.h @@ -18,7 +18,19 @@ #ifndef _PSOS_INTERNAL_H #define _PSOS_INTERNAL_H -const char *__psos_maybe_short_name(char shrt[5], - const char *lng); +#include string.h + +extern int psos_long_names; + +static inline +const char *psos_trunc_name(char dst[5], const char *src) +{ + if (psos_long_names) + return src; + + strncpy(dst, src, 4)[4] = '\0'; + + return dst; +} #endif /* !_PSOS_INTERNAL_H */ diff --git a/lib/psos/pt.c b/lib/psos/pt.c index 324ece6..afdda32 100644 --- a/lib/psos/pt.c +++ b/lib/psos/pt.c @@ -145,7 +145,7 @@ u_long pt_create(const char
[Xenomai-git] Philippe Gerum : psos: turn long names options into a standard tunable
Module: xenomai-3 Branch: next Commit: 309d1dd9e4dd8456102a3469658f26f5f24c00db URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=309d1dd9e4dd8456102a3469658f26f5f24c00db Author: Philippe Gerum r...@xenomai.org Date: Tue May 19 11:31:28 2015 +0200 psos: turn long names options into a standard tunable --- include/psos/psos.h | 13 - lib/psos/init.c | 21 + lib/psos/internal.h | 16 ++-- lib/psos/pt.c |4 ++-- lib/psos/queue.c|4 ++-- lib/psos/rn.c |4 ++-- lib/psos/sem.c |4 ++-- lib/psos/task.c |4 ++-- 8 files changed, 45 insertions(+), 25 deletions(-) diff --git a/include/psos/psos.h b/include/psos/psos.h index 3359892..a6f1559 100644 --- a/include/psos/psos.h +++ b/include/psos/psos.h @@ -25,6 +25,7 @@ #define _XENOMAI_PSOS_PSOS_H #include sys/types.h +#include boilerplate/tunables.h #ifndef SUCCESS #define SUCCESS 0 @@ -369,7 +370,17 @@ int psos_task_normalize_priority(u_long psos_prio); u_long psos_task_denormalize_priority(int core_prio); -extern unsigned int psos_long_names; +extern int psos_long_names; + +static inline define_config_tunable(long_names, int, on) +{ + psos_long_names = on; +} + +static inline read_config_tunable(long_names, int) +{ + return psos_long_names; +} #ifdef __cplusplus } diff --git a/lib/psos/init.c b/lib/psos/init.c index be4e157..81c09af 100644 --- a/lib/psos/init.c +++ b/lib/psos/init.c @@ -46,7 +46,7 @@ * - Tasks, Events, Queues, Semaphores * - Partitions, Regions, Timers */ -unsigned int psos_long_names; +int psos_long_names = 0; static unsigned int clock_resolution = 100; /* 1ms */ @@ -68,6 +68,12 @@ static const struct option psos_options[] = { .val = 0 }, { +#define long_names_opt 2 + .name = psos-long-names, + .flag = psos_long_names, + .val = 1 + }, + { .name = NULL, .has_arg = 0, .flag = NULL, @@ -84,6 +90,8 @@ static int psos_parse_option(int optnum, const char *optarg) case time_slice_opt: time_slice_in_ticks = atoi(optarg); break; + case long_names_opt: + break; default: /* Paranoid, can't happen. */ return -EINVAL; @@ -129,17 +137,6 @@ static int psos_init(void) return 0; } -const char *__psos_maybe_short_name(char shrt[5], const char *lng) -{ - if (psos_long_names) - return lng; - - strncpy(shrt, lng, 5 - 1); - shrt[4] = '\0'; - - return (const char *)shrt; -} - static struct setup_descriptor psos_skin = { .name = psos, .init = psos_init, diff --git a/lib/psos/internal.h b/lib/psos/internal.h index 01432ba..0e5f108 100644 --- a/lib/psos/internal.h +++ b/lib/psos/internal.h @@ -18,7 +18,19 @@ #ifndef _PSOS_INTERNAL_H #define _PSOS_INTERNAL_H -const char *__psos_maybe_short_name(char shrt[5], - const char *lng); +#include string.h + +extern int psos_long_names; + +static inline +const char *psos_trunc_name(char dst[5], const char *src) +{ + if (psos_long_names) + return src; + + strncpy(dst, src, 4)[4] = '\0'; + + return dst; +} #endif /* !_PSOS_INTERNAL_H */ diff --git a/lib/psos/pt.c b/lib/psos/pt.c index 324ece6..afdda32 100644 --- a/lib/psos/pt.c +++ b/lib/psos/pt.c @@ -145,7 +145,7 @@ u_long pt_create(const char *name, if (name == NULL || *name == '\0') sprintf(pt-name, pt%lu, ++anon_ptids); else { - name = __psos_maybe_short_name(short_name, name); + name = psos_trunc_name(short_name, name); namecpy(pt-name, name); } @@ -295,7 +295,7 @@ u_long pt_ident(const char *name, u_long node, u_long *ptid_r) if (node) return ERR_NODENO; - name = __psos_maybe_short_name(short_name, name); + name = psos_trunc_name(short_name, name); CANCEL_DEFER(svc); cobj = pvcluster_findobj(psos_pt_table, name); diff --git a/lib/psos/queue.c b/lib/psos/queue.c index fce091c..c3a27ae 100644 --- a/lib/psos/queue.c +++ b/lib/psos/queue.c @@ -97,7 +97,7 @@ static u_long __q_create(const char *name, u_long count, if (name == NULL || *name == '\0') sprintf(q-name, q%lu, ++anon_qids); else { - name = __psos_maybe_short_name(short_name, name); + name = psos_trunc_name(short_name, name); namecpy(q-name, name); } @@ -215,7 +215,7 @@ static u_long __q_ident(const char *name, if (node) return ERR_NODENO; - name = __psos_maybe_short_name(short_name, name); + name = psos_trunc_name(short_name, name); CANCEL_DEFER(svc); cobj = cluster_findobj(psos_queue_table, name); diff --git
[Xenomai-git] Philippe Gerum : psos: turn long names options into a standard tunable
Module: xenomai-3 Branch: next Commit: 053535d1ad648c744c39214d81a0b12ad8d1e041 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=053535d1ad648c744c39214d81a0b12ad8d1e041 Author: Philippe Gerum r...@xenomai.org Date: Tue May 19 11:31:28 2015 +0200 psos: turn long names options into a standard tunable --- include/boilerplate/setup.h |4 ++-- include/psos/psos.h | 13 - lib/psos/init.c | 31 +++ lib/psos/internal.h | 16 ++-- lib/psos/pt.c |4 ++-- lib/psos/queue.c|4 ++-- lib/psos/rn.c |4 ++-- lib/psos/sem.c |4 ++-- lib/psos/task.c |4 ++-- 9 files changed, 49 insertions(+), 35 deletions(-) diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h index 70b758d..bc8b3f6 100644 --- a/include/boilerplate/setup.h +++ b/include/boilerplate/setup.h @@ -35,11 +35,11 @@ struct option; struct setup_descriptor { const char *name; - int (*init)(void); int (*tune)(void); - const struct option *options; int (*parse_option)(int optnum, const char *optarg); void (*help)(void); + int (*init)(void); + const struct option *options; struct { int id; int opt_start; diff --git a/include/psos/psos.h b/include/psos/psos.h index 3359892..a6f1559 100644 --- a/include/psos/psos.h +++ b/include/psos/psos.h @@ -25,6 +25,7 @@ #define _XENOMAI_PSOS_PSOS_H #include sys/types.h +#include boilerplate/tunables.h #ifndef SUCCESS #define SUCCESS 0 @@ -369,7 +370,17 @@ int psos_task_normalize_priority(u_long psos_prio); u_long psos_task_denormalize_priority(int core_prio); -extern unsigned int psos_long_names; +extern int psos_long_names; + +static inline define_config_tunable(long_names, int, on) +{ + psos_long_names = on; +} + +static inline read_config_tunable(long_names, int) +{ + return psos_long_names; +} #ifdef __cplusplus } diff --git a/lib/psos/init.c b/lib/psos/init.c index be4e157..9e0b8fd 100644 --- a/lib/psos/init.c +++ b/lib/psos/init.c @@ -46,7 +46,7 @@ * - Tasks, Events, Queues, Semaphores * - Partitions, Regions, Timers */ -unsigned int psos_long_names; +int psos_long_names = 0; static unsigned int clock_resolution = 100; /* 1ms */ @@ -57,21 +57,20 @@ static const struct option psos_options[] = { #define clock_resolution_opt 0 .name = psos-clock-resolution, .has_arg = 1, - .flag = NULL, - .val = 0 }, { #define time_slice_opt 1 .name = psos-time-slice, .has_arg = 1, - .flag = NULL, - .val = 0 }, { - .name = NULL, - .has_arg = 0, - .flag = NULL, - .val = 0 +#define long_names_opt 2 + .name = psos-long-names, + .flag = psos_long_names, + .val = 1 + }, + { + /* sentinel */ } }; @@ -84,6 +83,8 @@ static int psos_parse_option(int optnum, const char *optarg) case time_slice_opt: time_slice_in_ticks = atoi(optarg); break; + case long_names_opt: + break; default: /* Paranoid, can't happen. */ return -EINVAL; @@ -96,6 +97,7 @@ static void psos_help(void) { fprintf(stderr, --psos-clock-resolution=ns tick value (default 1ms)\n); fprintf(stderr, --psos-time-slice=psos-ticksround-robin time slice\n); +fprintf(stderr, --psos-long-names enable long names for objects ( 4 characters)\n); } static int psos_init(void) @@ -129,17 +131,6 @@ static int psos_init(void) return 0; } -const char *__psos_maybe_short_name(char shrt[5], const char *lng) -{ - if (psos_long_names) - return lng; - - strncpy(shrt, lng, 5 - 1); - shrt[4] = '\0'; - - return (const char *)shrt; -} - static struct setup_descriptor psos_skin = { .name = psos, .init = psos_init, diff --git a/lib/psos/internal.h b/lib/psos/internal.h index 01432ba..0e5f108 100644 --- a/lib/psos/internal.h +++ b/lib/psos/internal.h @@ -18,7 +18,19 @@ #ifndef _PSOS_INTERNAL_H #define _PSOS_INTERNAL_H -const char *__psos_maybe_short_name(char shrt[5], - const char *lng); +#include string.h + +extern int psos_long_names; + +static inline +const char *psos_trunc_name(char dst[5], const char *src) +{ + if (psos_long_names) + return src; + + strncpy(dst, src, 4)[4] = '\0'; + + return dst; +} #endif /* !_PSOS_INTERNAL_H */ diff --git a/lib/psos/pt.c b/lib/psos/pt.c index 324ece6..afdda32 100644 --- a/lib/psos/pt.c +++ b/lib/psos/pt.c @@ -145,7 +145,7 @@ u_long pt_create(const char *name,