History

Add input files/libs and reloc_output switch to TCCState

files[0], and reloc_outpu will be needed for (upcoming in the next patch) "compute default outfile name" refactored into libtcc function. Also, since for symmetry and from libification point of view, it makes some sense to also put all information about what was given as input to compilation into TCCState, let's not only put files[0], but all files and all libraries given explicitely by user. One point: I've used bitfield for reloc_output & trimmed down output_type to 8 bits so that TCCState stays the same in size, and also access to output_type is (hopefully) is not slower. By the way -- as of today, sizeof(TCCState) on i686-pc-linux-gnu is 2884 bytes...

Kirill Smelkov committed 16 years ago

Commit a919a371 parent 66b54af4 files · +24 −1Browse files

Unified · Split

4 files
  1. libtcc.c +8 −0
  2. libtcc.h +7 −0
  3. tcc.c +1 −0
  4. tcc.h +8 −1
libtcc.c+8−0
@@ -1038,6 +1038,10 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 1037 unmodified lines
10381038 dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
10391039
10401040 tcc_free(s1->tcc_lib_path);
1041+
1042+ dynarray_reset(&s1->input_files, &s1->nb_input_files);
1043+ dynarray_reset(&s1->input_libs, &s1->nb_input_libs);
1044+
10411045 #ifdef HAVE_SELINUX
10421046 munmap (s1->write_mem, s1->mem_size);
10431047 munmap (s1->runtime_mem, s1->mem_size);
@@ -1184,6 +1188,8 @@ the_end: · 140 unmodified lines
11841188
11851189 LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)
11861190 {
1191+ dynarray_add((void ***)&s->input_files, &s->nb_input_files, tcc_strdup(filename));
1192+
11871193 if (s->output_type == TCC_OUTPUT_PREPROCESS)
11881194 return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);
11891195 else
@@ -1220,6 +1226,8 @@ LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname) · 30 unmodified lines
12201226 {
12211227 char buf[1024];
12221228 int i;
1229+
1230+ dynarray_add((void ***)&s->input_libs, &s->nb_input_libs, tcc_strdup(libraryname));
12231231
12241232 /* first we look for the dynamic library if not static linking */
12251233 if (!s->static_link) {
libtcc.h+7−0
@@ -103,6 +103,13 @@ LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name); · 102 unmodified lines
103103 /* set CONFIG_TCCDIR at runtime */
104104 LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
105105
106+
107+/*****************************/
108+/* Miscellaneous */
109+
110+/* Get default target filename for this compilation */
111+LIBTCCAPI const char *tcc_default_target(TCCState *s);
112+
106113 #ifdef __cplusplus
107114 }
108115 #endif
tcc.c+1−0
@@ -475,6 +475,7 @@ int main(int argc, char **argv) · 474 unmodified lines
475475 }
476476
477477 tcc_set_output_type(s, output_type);
478+ s->reloc_output = reloc_output;
478479
479480 /* compile or add each files or library */
480481 for(i = 0; i < nb_files && ret == 0; i++) {
tcc.h+8−1
@@ -397,7 +397,8 @@ typedef struct ASMOperand { · 396 unmodified lines
397397 #endif
398398
399399 struct TCCState {
400− int output_type;
400+ unsigned output_type : 8;
401+ unsigned reloc_output : 1;
401402
402403 BufferedFile **include_stack_ptr;
403404 int *ifdef_stack_ptr;
@@ -518,6 +519,12 @@ struct TCCState { · 114 unmodified lines
518519 /* output file for preprocessing */
519520 FILE *outfile;
520521
522+ /* input files and libraries for this compilation */
523+ char **input_files;
524+ int nb_input_files;
525+ char **input_libs;
526+ int nb_input_libs;
527+
521528 /* for tcc_relocate */
522529 int runtime_added;
523530 void *runtime_mem;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t