History

enable making tcc using libtcc

grischka committed 17 years ago

Commit 67aebdd1 parent 0a35f9d3 files · +33 −30Browse files

Unified · Split

3 files
  1. libtcc.c +15 −12
  2. tcc.c +4 −6
  3. tcc.h +14 −12
libtcc.c+15−12
@@ -326,7 +326,7 @@ int ieee_finite(double d) · 325 unmodified lines
326326 }
327327
328328 /* copy a string and truncate it. */
329−static char *pstrcpy(char *buf, int buf_size, const char *s)
329+char *pstrcpy(char *buf, int buf_size, const char *s)
330330 {
331331 char *q, *q_end;
332332 int c;
@@ -346,7 +346,7 @@ static char *pstrcpy(char *buf, int buf_size, const char *s) · 13 unmodified lines
346346 }
347347
348348 /* strcat and truncate. */
349−static char *pstrcat(char *buf, int buf_size, const char *s)
349+char *pstrcat(char *buf, int buf_size, const char *s)
350350 {
351351 int len;
352352 len = strlen(buf);
@@ -356,7 +356,7 @@ static char *pstrcat(char *buf, int buf_size, const char *s) · 3 unmodified lines
356356 }
357357
358358 /* extract the basename of a file */
359−static char *tcc_basename(const char *name)
359+char *tcc_basename(const char *name)
360360 {
361361 char *p = strchr(name, 0);
362362 while (p > name && !IS_PATHSEP(p[-1]))
@@ -364,7 +364,7 @@ static char *tcc_basename(const char *name) · 1 unmodified line
364364 return p;
365365 }
366366
367−static char *tcc_fileextension (const char *name)
367+char *tcc_fileextension (const char *name)
368368 {
369369 char *b = tcc_basename(name);
370370 char *e = strrchr(b, '.');
@@ -418,7 +418,7 @@ int mem_max_size; · 47 unmodified lines
418418 unsigned malloc_usable_size(void*);
419419 #endif
420420
421−static inline void tcc_free(void *ptr)
421+void tcc_free(void *ptr)
422422 {
423423 #ifdef MEM_DEBUG
424424 mem_cur_size -= malloc_usable_size(ptr);
@@ -426,7 +426,7 @@ static inline void tcc_free(void *ptr) · 1 unmodified line
426426 free(ptr);
427427 }
428428
429−static void *tcc_malloc(unsigned long size)
429+void *tcc_malloc(unsigned long size)
430430 {
431431 void *ptr;
432432 ptr = malloc(size);
@@ -440,7 +440,7 @@ static void *tcc_malloc(unsigned long size) · 7 unmodified lines
440440 return ptr;
441441 }
442442
443−static void *tcc_mallocz(unsigned long size)
443+void *tcc_mallocz(unsigned long size)
444444 {
445445 void *ptr;
446446 ptr = tcc_malloc(size);
@@ -448,7 +448,7 @@ static void *tcc_mallocz(unsigned long size) · 1 unmodified line
448448 return ptr;
449449 }
450450
451−static inline void *tcc_realloc(void *ptr, unsigned long size)
451+void *tcc_realloc(void *ptr, unsigned long size)
452452 {
453453 void *ptr1;
454454 #ifdef MEM_DEBUG
@@ -464,7 +464,7 @@ static inline void *tcc_realloc(void *ptr, unsigned long size) · 9 unmodified lines
464464 return ptr1;
465465 }
466466
467−static char *tcc_strdup(const char *str)
467+char *tcc_strdup(const char *str)
468468 {
469469 char *ptr;
470470 ptr = tcc_malloc(strlen(str) + 1);
@@ -476,7 +476,7 @@ static char *tcc_strdup(const char *str) · 5 unmodified lines
476476 #define malloc(s) use_tcc_malloc(s)
477477 #define realloc(p, s) use_tcc_realloc(p, s)
478478
479−static void dynarray_add(void ***ptab, int *nb_ptr, void *data)
479+void dynarray_add(void ***ptab, int *nb_ptr, void *data)
480480 {
481481 int nb, nb_alloc;
482482 void **pp;
@@ -498,7 +498,7 @@ static void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 15 unmodified lines
498498 *nb_ptr = nb;
499499 }
500500
501−static void dynarray_reset(void *pp, int *n)
501+void dynarray_reset(void *pp, int *n)
502502 {
503503 void **p;
504504 for (p = *(void***)pp; *n; ++p, --*n)
@@ -2030,7 +2030,10 @@ static int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1525 unmodified lines
20302030
20312031 int tcc_add_file(TCCState *s, const char *filename)
20322032 {
2033− return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
2033+ if (s->output_type == TCC_OUTPUT_PREPROCESS)
2034+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);
2035+ else
2036+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
20342037 }
20352038
20362039 int tcc_add_library_path(TCCState *s, const char *pathname)
tcc.c+4−6
@@ -509,13 +509,11 @@ int main(int argc, char **argv) · 508 unmodified lines
509509 const char *filename;
510510
511511 filename = files[i];
512− if (output_type == TCC_OUTPUT_PREPROCESS) {
513− if (tcc_add_file_internal(s, filename,
514− AFF_PRINT_ERROR | AFF_PREPROCESS) < 0)
512+ if (filename[0] == '-' && filename[1]) {
513+ if (tcc_add_library(s, filename + 2) < 0) {
514+ error_noabort("cannot find %s", filename);
515515 ret = 1;
516− } else if (filename[0] == '-' && filename[1]) {
517− if (tcc_add_library(s, filename + 2) < 0)
518− error("cannot find %s", filename);
516+ }
519517 } else {
520518 if (1 == s->verbose)
521519 printf("-> %s\n", filename);
tcc.h+14−12
@@ -724,23 +724,25 @@ extern long double strtold (const char *__nptr, char **__endptr); · 723 unmodified lines
724724 #endif
725725
726726 void error(const char *fmt, ...);
727+void error_noabort(const char *fmt, ...);
727728 void warning(const char *fmt, ...);
729+
728730 void tcc_set_lib_path_w32(TCCState *s);
729731 int tcc_set_flag(TCCState *s, const char *flag_name, int value);
730732 void tcc_print_stats(TCCState *s, int64_t total_time);
731733
732−static void tcc_free(void *ptr);
733−static void *tcc_malloc(unsigned long size);
734−static void *tcc_mallocz(unsigned long size);
735−static void *tcc_realloc(void *ptr, unsigned long size);
736−static char *tcc_strdup(const char *str);
737−
738−static char *tcc_basename(const char *name);
739−static char *tcc_fileextension (const char *name);
740−static char *pstrcpy(char *buf, int buf_size, const char *s);
741−static char *pstrcat(char *buf, int buf_size, const char *s);
742−static void dynarray_add(void ***ptab, int *nb_ptr, void *data);
743−static void dynarray_reset(void *pp, int *n);
734+void tcc_free(void *ptr);
735+void *tcc_malloc(unsigned long size);
736+void *tcc_mallocz(unsigned long size);
737+void *tcc_realloc(void *ptr, unsigned long size);
738+char *tcc_strdup(const char *str);
739+
740+char *tcc_basename(const char *name);
741+char *tcc_fileextension (const char *name);
742+char *pstrcpy(char *buf, int buf_size, const char *s);
743+char *pstrcat(char *buf, int buf_size, const char *s);
744+void dynarray_add(void ***ptab, int *nb_ptr, void *data);
745+void dynarray_reset(void *pp, int *n);
744746
745747 #ifdef CONFIG_TCC_BACKTRACE
746748 extern int num_callers;

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