summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Kacur <jkacur@redhat.com>2013-11-14 17:40:03 +0100
committerJohn Kacur <jkacur@redhat.com>2013-11-14 17:40:03 +0100
commit1b46049fb5eab8fb8eb52184c362b28b3e20c083 (patch)
treeb36887d6da860fa2118014f353b5601c37040868
parent77d109dbea9b2ae39b87af0f0fbbe343cfea3d09 (diff)
downloadrt-tests-1b46049fb5eab8fb8eb52184c362b28b3e20c083.tar.gz
cyclictest: Align option fixes
These changes make the align option truly optional as claimed. 1. Rename disaligned to offset for readability. 2. Fix the aligned option so that if no optional argument is given, the offset defaults to 0 3. Fix some white space problems as reported by checkpatch.pl in the kernel Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index bbdcf93..7ca621b 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -185,7 +185,7 @@ static int ct_debug;
static int use_fifo = 0;
static pthread_t fifo_threadid;
static int aligned = 0;
-static int disaligned = 0;
+static int offset = 0;
static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -777,13 +777,12 @@ void *timerthread(void *param)
/* Get current time */
if(aligned){
pthread_barrier_wait(&globalt_barr);
- if(par->tnum==0){
+ if(par->tnum==0)
clock_gettime(par->clock, &globalt);
- }
pthread_barrier_wait(&align_barr);
now = globalt;
- if(disaligned){
- now.tv_nsec += disaligned * par->tnum;
+ if(offset) {
+ now.tv_nsec += offset * par->tnum;
tsnorm(&now);
}
}
@@ -1177,7 +1176,7 @@ static void process_options (int argc, char *argv[])
{"help", no_argument, NULL, OPT_HELP },
{NULL, 0, NULL, 0}
};
- int c = getopt_long(argc, argv, "a::A:b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+ int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
long_options, &option_index);
if (c == -1)
break;
@@ -1201,7 +1200,11 @@ static void process_options (int argc, char *argv[])
case OPT_ALIGNED:
aligned=1;
if (optarg != NULL)
- disaligned = atoi(optarg);
+ offset = atoi(optarg);
+ else if (optind<argc && atoi(argv[optind]))
+ offset = atoi(argv[optind]);
+ else
+ offset = 0;
break;
case 'b':
case OPT_BREAKTRACE:
@@ -1443,8 +1446,8 @@ static void process_options (int argc, char *argv[])
error = 1;
if (aligned) {
- pthread_barrier_init (&globalt_barr, NULL, num_threads);
- pthread_barrier_init (&align_barr, NULL, num_threads);
+ pthread_barrier_init(&globalt_barr, NULL, num_threads);
+ pthread_barrier_init(&align_barr, NULL, num_threads);
}
if (error)