summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-01-14 13:25:33 -0500
committerTavian Barnes <tavianator@gmail.com>2010-01-14 13:25:33 -0500
commitb252ea0b251963c753b0c48a47e8d1ff7f274137 (patch)
tree3265c656d17495ead26ac3508c3bef87d4039667 /dimension
parenta8b7936b17a2270e6b19cb02f25dedc33a1a076e (diff)
downloaddimension-b252ea0b251963c753b0c48a47e8d1ff7f274137.tar.xz
New --threads cmdline option.
Diffstat (limited to 'dimension')
-rw-r--r--dimension/main.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/dimension/main.c b/dimension/main.c
index 9083a07..d66ee04 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -28,6 +28,7 @@
static const char *output = NULL, *input = NULL;
static unsigned int width = 640, height = 480;
+static unsigned int nthreads = 0;
static int tokenize = 0, parse = 0;
int
@@ -36,15 +37,21 @@ main(int argc, char **argv) {
* Parse the command-line options
*/
+ static enum {
+ DMNSN_NTHREADS = 256
+ };
+
static struct option long_options[] = {
- { "output", required_argument, NULL, 'o' },
- { "input", required_argument, NULL, 'i' },
- { "width", required_argument, NULL, 'w' },
- { "height", required_argument, NULL, 'h' },
- { "tokenize", no_argument, &tokenize, 1 },
- { "parse", no_argument, &parse, 1 },
- { 0, 0, 0, 0 }
+ { "output", required_argument, NULL, 'o' },
+ { "input", required_argument, NULL, 'i' },
+ { "width", required_argument, NULL, 'w' },
+ { "height", required_argument, NULL, 'h' },
+ { "threads", required_argument, NULL, DMNSN_NTHREADS },
+ { "tokenize", no_argument, &tokenize, 1 },
+ { "parse", no_argument, &parse, 1 },
+ { 0, 0, 0, 0 }
};
+
int opt, opt_index;
while (1) {
@@ -97,6 +104,17 @@ main(int argc, char **argv) {
break;
}
+ case DMNSN_NTHREADS:
+ {
+ char *endptr;
+ nthreads = strtoul(optarg, &endptr, 10);
+ if (*endptr != '\0' || endptr == optarg) {
+ fprintf(stderr, "Invalid argument to --nthreads!\n");
+ return EXIT_FAILURE;
+ }
+ break;
+ }
+
default:
fprintf(stderr, "Invalid command line option!\n");
return EXIT_FAILURE;
@@ -197,6 +215,8 @@ main(int argc, char **argv) {
return EXIT_FAILURE;
}
+ scene->nthreads = nthreads;
+
/*
* Now we render the scene
*/