From 95cfa9202c0e6152606d76ef38292d887d90d5da Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 9 Dec 2012 16:32:17 -0300 Subject: [PATCH] tornado/fw/sim/alg.c: take duration of simulation from command line --- tornado/fw/sim/alg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tornado/fw/sim/alg.c b/tornado/fw/sim/alg.c index 5a0a700..76682bd 100755 --- a/tornado/fw/sim/alg.c +++ b/tornado/fw/sim/alg.c @@ -67,11 +67,25 @@ static void process(unsigned v) } -int main(void) +static void usage(const char *name) { + fprintf(stderr, "usage: %s [seconds]\n", name); + exit(1); +} + + +int main(int argc, char **argv) +{ + double t; + char *end; int i; - for (i = 0; i != 10*S; i++) { + if (argc != 2) + usage(*argv); + t = strtod(argv[1], &end); + if (*end) + usage(*argv); + for (i = 0; i != t*S; i++) { unsigned v = sample((double) i/S); process(v);