aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorgrischka <grischka>2009-05-11 18:45:44 +0200
committergrischka <grischka>2009-05-11 18:45:44 +0200
commitf9181416f604c1c0715fc538316948a9f957a3c3 (patch)
tree44b516fd9c79bd470322480540feda94acb2c6d9 /tcc.c
parent5c6509578e78db8978b19ab81c4f26398f13c82d (diff)
downloadtinycc-f9181416f604c1c0715fc538316948a9f957a3c3.tar.gz
tinycc-f9181416f604c1c0715fc538316948a9f957a3c3.tar.bz2
move some global variables into TCCState
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/tcc.c b/tcc.c
index 32dc66c..a82b8a1 100644
--- a/tcc.c
+++ b/tcc.c
@@ -303,12 +303,12 @@ int parse_args(TCCState *s, int argc, char **argv)
#endif
#ifdef CONFIG_TCC_BCHECK
case TCC_OPTION_b:
- do_bounds_check = 1;
- do_debug = 1;
+ s->do_bounds_check = 1;
+ s->do_debug = 1;
break;
#endif
case TCC_OPTION_g:
- do_debug = 1;
+ s->do_debug = 1;
break;
case TCC_OPTION_c:
multiple_files = 1;
@@ -355,7 +355,7 @@ int parse_args(TCCState *s, int argc, char **argv)
break;
case TCC_OPTION_v:
do {
- if (0 == verbose++)
+ if (0 == s->verbose++)
printf("tcc version %s\n", TCC_VERSION);
} while (*optarg++ == 'v');
break;
@@ -439,11 +439,11 @@ int main(int argc, char **argv)
optind = parse_args(s, argc - 1, argv + 1);
if (print_search_dirs) {
/* enough for Linux kernel */
- printf("install: %s/\n", tcc_lib_path);
+ printf("install: %s/\n", s->tcc_lib_path);
return 0;
}
if (optind == 0 || nb_files == 0) {
- if (optind && verbose)
+ if (optind && s->verbose)
return 0;
help();
return 1;
@@ -517,7 +517,7 @@ int main(int argc, char **argv)
if (tcc_add_library(s, filename + 2) < 0)
error("cannot find %s", filename);
} else {
- if (1 == verbose)
+ if (1 == s->verbose)
printf("-> %s\n", filename);
if (tcc_add_file(s, filename) < 0)
ret = 1;
@@ -530,18 +530,8 @@ int main(int argc, char **argv)
if (ret)
goto the_end;
- if (do_bench) {
- double total_time;
- total_time = (double)(getclock_us() - start_time) / 1000000.0;
- if (total_time < 0.001)
- total_time = 0.001;
- if (total_bytes < 1)
- total_bytes = 1;
- printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n",
- tok_ident - TOK_IDENT, total_lines, total_bytes,
- total_time, (int)(total_lines / total_time),
- total_bytes / total_time / 1000000.0);
- }
+ if (do_bench)
+ print_stats(s, getclock_us() - start_time);
if (s->output_type == TCC_OUTPUT_PREPROCESS) {
if (outfile)
@@ -552,7 +542,7 @@ int main(int argc, char **argv)
ret = tcc_output_file(s, outfile) ? 1 : 0;
the_end:
/* XXX: cannot do it with bound checking because of the malloc hooks */
- if (!do_bounds_check)
+ if (!s->do_bounds_check)
tcc_delete(s);
#ifdef MEM_DEBUG