diff options
| author | grischka <grischka> | 2017-02-13 18:23:43 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2017-02-13 18:23:43 +0100 |
| commit | a4a20360e9df90bb8a0ed23d113ed5564882de8a (patch) | |
| tree | 3115b2a0ce13f54bb56c0b19818623dfdca3bfc4 /libtcc.c | |
| parent | 9817204d8afa37e03035158502ec7b73c72cae50 (diff) | |
| download | tinycc-a4a20360e9df90bb8a0ed23d113ed5564882de8a.tar.gz tinycc-a4a20360e9df90bb8a0ed23d113ed5564882de8a.tar.bz2 | |
fixes & cleanups
- tccgen.c/tcc.h: allow function declaration after use:
int f() { return g(); }
int g() { return 1; }
may be a warning but not an error
see also 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6
- tccgen.c: redundant code related to inline functions removed
(functions used anywhere have sym->c set automatically)
- tccgen.c: make 32bit llop non-equal test portable
(probably not on C67)
- dynarray_add: change prototype to possibly avoid aliasing
problems or at least warnings
- lib/alloca*.S: ".section .note.GNU-stack,"",%progbits" removed
(has no effect)
- tccpe: set SizeOfCode field (for correct upx decompression)
- libtcc.c: fixed alternative -run invocation
tcc "-run -lxxx ..." file.c
(meant to load the library after file).
Also supported now:
tcc files ... options ... -run @ arguments ...
Diffstat (limited to 'libtcc.c')
| -rw-r--r-- | libtcc.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -403,13 +403,13 @@ PUB_FUNC void tcc_memstats(int bench) /********************************************************/ /* dynarrays */ -ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) +ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data) { int nb, nb_alloc; void **pp; nb = *nb_ptr; - pp = *ptab; + pp = *(void ***)ptab; /* every power of two we double array size */ if ((nb & (nb - 1)) == 0) { if (!nb) @@ -417,7 +417,7 @@ ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) else nb_alloc = nb * 2; pp = tcc_realloc(pp, nb_alloc * sizeof(void *)); - *ptab = pp; + *(void***)ptab = pp; } pp[nb++] = data; *nb_ptr = nb; @@ -1013,7 +1013,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) } /* update target deps */ - dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps, + dynarray_add(&s1->target_deps, &s1->nb_target_deps, tcc_strdup(filename)); parse_flags = 0; @@ -1586,7 +1586,7 @@ static void args_parser_add_file(TCCState *s, const char* filename, int filetype struct filespec *f = tcc_malloc(sizeof *f + strlen(filename)); f->type = filetype; strcpy(f->name, filename); - dynarray_add((void ***)&s->files, &s->nb_files, f); + dynarray_add(&s->files, &s->nb_files, f); } /* read list file */ @@ -1611,8 +1611,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) { const TCCOption *popt; const char *optarg, *r; + const char *run = NULL; int optind = 0; - int run = 0; int x; int last_o = -1; CString linker_arg; /* collect -Wl options */ @@ -1631,8 +1631,10 @@ reparse: } if (r[0] != '-' || r[1] == '\0') { - args_parser_add_file(s, r, s->filetype); + if (r[0] != '@') /* allow "tcc file(s) -run @ args ..." */ + args_parser_add_file(s, r, s->filetype); if (run) { + tcc_set_options(s, run); optind--; /* argv[0] will be this file */ break; @@ -1753,7 +1755,7 @@ reparse: tcc_add_sysinclude_path(s, buf); break; case TCC_OPTION_include: - dynarray_add((void ***)&s->cmd_include_files, + dynarray_add(&s->cmd_include_files, &s->nb_cmd_include_files, tcc_strdup(optarg)); break; case TCC_OPTION_nostdinc: @@ -1769,8 +1771,7 @@ reparse: #ifndef TCC_IS_NATIVE tcc_error("-run is not available in a cross compiler"); #endif - tcc_set_options(s, optarg); - run = 1; + run = optarg; x = TCC_OUTPUT_MEMORY; goto set_output_type; case TCC_OPTION_v: @@ -1903,7 +1904,7 @@ LIBTCCAPI int tcc_set_options(TCCState *s, const char *r) } cstr_ccat(&str, 0); //printf("<%s>\n", str.data), fflush(stdout); - dynarray_add((void ***)&argv, &argc, tcc_strdup(str.data)); + dynarray_add(&argv, &argc, tcc_strdup(str.data)); cstr_free(&str); } ret = tcc_parse_args(s, argc, argv); |
