diff options
author | Rob Landley <rob@landley.net> | 2007-06-01 14:31:45 -0400 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2007-06-01 14:31:45 -0400 |
commit | fc2224b26c73198d00eba714caf47bd2e3a5e63b (patch) | |
tree | a2f8915b753e07b567341e8d1d1e271ae32d8faa /main.c | |
parent | b841cd2f8c1b378c1e8d73f5915662b8e79aac80 (diff) | |
download | toybox-fc2224b26c73198d00eba714caf47bd2e3a5e63b.tar.gz |
Show the compiler how to optimize out the option parsing logic when nothing
is using it.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -50,6 +50,18 @@ struct toy_list *toy_find(char *name) } } +// Figure out whether or not anything is using the option parsing logic, +// because the compiler can't figure out whether or not to optimize it away +// on its' own. + +#undef NEWTOY +#undef OLDTOY +#define NEWTOY(name, opts, flags) opts || +#define OLDTOY(name, oldname, opts, flags) opts || +static const NEED_OPTIONS = +#include "toys/toylist.h" +0; // Ends the opts || opts || opts... + void toy_init(struct toy_list *which, char *argv[]) { // Free old toys contents here? @@ -57,7 +69,7 @@ void toy_init(struct toy_list *which, char *argv[]) toys.which = which; toys.argv = argv; toys.exitval = 1; - if (which->options) get_optflags(); + if (NEED_OPTIONS && which->options) get_optflags(); else toys.optargs = argv+1; } |