[Xenomai-git] Philippe Gerum : demo/posix: add cyclictest from stock rt-tests
Module: xenomai-3 Branch: master Commit: 790836f392dfd2acae4ddbfd926d43a7fabfda08 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=790836f392dfd2acae4ddbfd926d43a7fabfda08 Author: Philippe GerumDate: Wed Sep 30 16:13:39 2015 +0200 demo/posix: add cyclictest from stock rt-tests --- configure.ac |1 + demo/posix/Makefile.am |6 +- demo/posix/cyclictest/Makefile.am | 34 + demo/posix/cyclictest/README |5 + demo/posix/cyclictest/cyclictest.c | 2203 demo/posix/cyclictest/error.c | 96 ++ demo/posix/cyclictest/error.h | 19 + demo/posix/cyclictest/rt-sched.h | 76 ++ demo/posix/cyclictest/rt-utils.c | 319 ++ demo/posix/cyclictest/rt-utils.h | 27 + demo/posix/cyclictest/rt_numa.h| 277 + 11 files changed, 3061 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8f2136e..b613515 100644 --- a/configure.ac +++ b/configure.ac @@ -904,6 +904,7 @@ AC_CONFIG_FILES([ \ utils/net/Makefile \ demo/Makefile \ demo/posix/Makefile \ + demo/posix/cyclictest/Makefile \ demo/posix/cobalt/Makefile \ demo/alchemy/Makefile \ demo/alchemy/cobalt/Makefile \ diff --git a/demo/posix/Makefile.am b/demo/posix/Makefile.am index aa0f7f7..0dd66a5 100644 --- a/demo/posix/Makefile.am +++ b/demo/posix/Makefile.am @@ -1,6 +1,8 @@ +SUBDIRS = cyclictest + if XENO_COBALT -SUBDIRS = cobalt +SUBDIRS += cobalt endif -DIST_SUBDIRS = cobalt +DIST_SUBDIRS = cyclictest cobalt diff --git a/demo/posix/cyclictest/Makefile.am b/demo/posix/cyclictest/Makefile.am new file mode 100644 index 000..ff62b37 --- /dev/null +++ b/demo/posix/cyclictest/Makefile.am @@ -0,0 +1,34 @@ +demodir = @XENO_DEMO_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +VERSION_STRING = 0.92 + +demo_PROGRAMS = cyclictest + +cyclictest_CPPFLAGS = \ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include \ + -DVERSION_STRING=$(VERSION_STRING) \ + -Wno-strict-prototypes \ + -Wno-implicit-function-declaration \ + -Wno-missing-prototypes \ + -Wno-nonnull\ + -Wno-unused-function\ + -Wno-unused-result + +cyclictest_SOURCES = \ + cyclictest.c\ + error.c \ + error.h \ + rt_numa.h \ + rt-sched.h \ + rt-utils.c \ + rt-utils.h + +cyclictest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +cyclictest_LDADD = \ + ../../../lib/@XENO_CORE_LIB@\ +@XENO_USER_LDADD@ \ + -lpthread -lrt -lm diff --git a/demo/posix/cyclictest/README b/demo/posix/cyclictest/README new file mode 100644 index 000..8186b04 --- /dev/null +++ b/demo/posix/cyclictest/README @@ -0,0 +1,5 @@ + +This is the original cyclictest program from the PREEMPT-RT test +suite as of version 0.92. + +See git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git diff --git a/demo/posix/cyclictest/cyclictest.c b/demo/posix/cyclictest/cyclictest.c new file mode 100644 index 000..92c7043 --- /dev/null +++ b/demo/posix/cyclictest/cyclictest.c @@ -0,0 +1,2203 @@ +/* + * High resolution timer test software + * + * (C) 2013 Clark Williams + * (C) 2013 John Kacur + * (C) 2008-2012 Clark Williams + * (C) 2005-2007 Thomas Gleixner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License Version + * 2 as published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rt_numa.h" + +#include "rt-utils.h" + +#define DEFAULT_INTERVAL 1000 +#define DEFAULT_DISTANCE 500 + +#ifndef SCHED_IDLE +#define SCHED_IDLE 5 +#endif +#ifndef SCHED_NORMAL +#define SCHED_NORMAL SCHED_OTHER +#endif + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +/* Ugly, but */ +#define gettid() syscall(__NR_gettid) +#define sigev_notify_thread_id _sigev_un._tid + +#ifdef __UCLIBC__ +#define MAKE_PROCESS_CPUCLOCK(pid, clock) \ + ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) +#define CPUCLOCK_SCHED 2 + +static int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *req, + struct timespec *rem) +{ + if (clock_id == CLOCK_THREAD_CPUTIME_ID) + return -EINVAL; + if (clock_id == CLOCK_PROCESS_CPUTIME_ID) + clock_id = MAKE_PROCESS_CPUCLOCK
[Xenomai-git] Philippe Gerum : demo/posix: add cyclictest from stock rt-tests
Module: xenomai-3 Branch: next Commit: 790836f392dfd2acae4ddbfd926d43a7fabfda08 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=790836f392dfd2acae4ddbfd926d43a7fabfda08 Author: Philippe GerumDate: Wed Sep 30 16:13:39 2015 +0200 demo/posix: add cyclictest from stock rt-tests --- configure.ac |1 + demo/posix/Makefile.am |6 +- demo/posix/cyclictest/Makefile.am | 34 + demo/posix/cyclictest/README |5 + demo/posix/cyclictest/cyclictest.c | 2203 demo/posix/cyclictest/error.c | 96 ++ demo/posix/cyclictest/error.h | 19 + demo/posix/cyclictest/rt-sched.h | 76 ++ demo/posix/cyclictest/rt-utils.c | 319 ++ demo/posix/cyclictest/rt-utils.h | 27 + demo/posix/cyclictest/rt_numa.h| 277 + 11 files changed, 3061 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8f2136e..b613515 100644 --- a/configure.ac +++ b/configure.ac @@ -904,6 +904,7 @@ AC_CONFIG_FILES([ \ utils/net/Makefile \ demo/Makefile \ demo/posix/Makefile \ + demo/posix/cyclictest/Makefile \ demo/posix/cobalt/Makefile \ demo/alchemy/Makefile \ demo/alchemy/cobalt/Makefile \ diff --git a/demo/posix/Makefile.am b/demo/posix/Makefile.am index aa0f7f7..0dd66a5 100644 --- a/demo/posix/Makefile.am +++ b/demo/posix/Makefile.am @@ -1,6 +1,8 @@ +SUBDIRS = cyclictest + if XENO_COBALT -SUBDIRS = cobalt +SUBDIRS += cobalt endif -DIST_SUBDIRS = cobalt +DIST_SUBDIRS = cyclictest cobalt diff --git a/demo/posix/cyclictest/Makefile.am b/demo/posix/cyclictest/Makefile.am new file mode 100644 index 000..ff62b37 --- /dev/null +++ b/demo/posix/cyclictest/Makefile.am @@ -0,0 +1,34 @@ +demodir = @XENO_DEMO_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +VERSION_STRING = 0.92 + +demo_PROGRAMS = cyclictest + +cyclictest_CPPFLAGS = \ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include \ + -DVERSION_STRING=$(VERSION_STRING) \ + -Wno-strict-prototypes \ + -Wno-implicit-function-declaration \ + -Wno-missing-prototypes \ + -Wno-nonnull\ + -Wno-unused-function\ + -Wno-unused-result + +cyclictest_SOURCES = \ + cyclictest.c\ + error.c \ + error.h \ + rt_numa.h \ + rt-sched.h \ + rt-utils.c \ + rt-utils.h + +cyclictest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +cyclictest_LDADD = \ + ../../../lib/@XENO_CORE_LIB@\ +@XENO_USER_LDADD@ \ + -lpthread -lrt -lm diff --git a/demo/posix/cyclictest/README b/demo/posix/cyclictest/README new file mode 100644 index 000..8186b04 --- /dev/null +++ b/demo/posix/cyclictest/README @@ -0,0 +1,5 @@ + +This is the original cyclictest program from the PREEMPT-RT test +suite as of version 0.92. + +See git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git diff --git a/demo/posix/cyclictest/cyclictest.c b/demo/posix/cyclictest/cyclictest.c new file mode 100644 index 000..92c7043 --- /dev/null +++ b/demo/posix/cyclictest/cyclictest.c @@ -0,0 +1,2203 @@ +/* + * High resolution timer test software + * + * (C) 2013 Clark Williams + * (C) 2013 John Kacur + * (C) 2008-2012 Clark Williams + * (C) 2005-2007 Thomas Gleixner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License Version + * 2 as published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rt_numa.h" + +#include "rt-utils.h" + +#define DEFAULT_INTERVAL 1000 +#define DEFAULT_DISTANCE 500 + +#ifndef SCHED_IDLE +#define SCHED_IDLE 5 +#endif +#ifndef SCHED_NORMAL +#define SCHED_NORMAL SCHED_OTHER +#endif + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +/* Ugly, but */ +#define gettid() syscall(__NR_gettid) +#define sigev_notify_thread_id _sigev_un._tid + +#ifdef __UCLIBC__ +#define MAKE_PROCESS_CPUCLOCK(pid, clock) \ + ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) +#define CPUCLOCK_SCHED 2 + +static int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *req, + struct timespec *rem) +{ + if (clock_id == CLOCK_THREAD_CPUTIME_ID) + return -EINVAL; + if (clock_id == CLOCK_PROCESS_CPUTIME_ID) + clock_id = MAKE_PROCESS_CPUCLOCK (0,