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
326}326}
327 327
328/* copy a string and truncate it. */328/* copy a string and truncate it. */
329static char *pstrcpy(char *buf, int buf_size, const char *s)329char *pstrcpy(char *buf, int buf_size, const char *s)
330{330{
331 char *q, *q_end;331 char *q, *q_end;
332 int c;332 int c;
@@ -346,7 +346,7 @@ static char *pstrcpy(char *buf, int buf_size, const char *s) · 13 unmodified lines
346}346}
347 347
348/* strcat and truncate. */348/* strcat and truncate. */
349static char *pstrcat(char *buf, int buf_size, const char *s)349char *pstrcat(char *buf, int buf_size, const char *s)
350{350{
351 int len;351 int len;
352 len = strlen(buf);352 len = strlen(buf);
@@ -356,7 +356,7 @@ static char *pstrcat(char *buf, int buf_size, const char *s) · 3 unmodified lines
356}356}
357 357
358/* extract the basename of a file */358/* extract the basename of a file */
359static char *tcc_basename(const char *name)359char *tcc_basename(const char *name)
360{360{
361 char *p = strchr(name, 0);361 char *p = strchr(name, 0);
362 while (p > name && !IS_PATHSEP(p[-1]))362 while (p > name && !IS_PATHSEP(p[-1]))
@@ -364,7 +364,7 @@ static char *tcc_basename(const char *name) · 1 unmodified line
364 return p;364 return p;
365}365}
366 366
367static char *tcc_fileextension (const char *name)367char *tcc_fileextension (const char *name)
368{368{
369 char *b = tcc_basename(name);369 char *b = tcc_basename(name);
370 char *e = strrchr(b, '.');370 char *e = strrchr(b, '.');
@@ -418,7 +418,7 @@ int mem_max_size; · 47 unmodified lines
418unsigned malloc_usable_size(void*);418unsigned malloc_usable_size(void*);
419#endif419#endif
420 420
421static inline void tcc_free(void *ptr)421void tcc_free(void *ptr)
422{422{
423#ifdef MEM_DEBUG423#ifdef MEM_DEBUG
424 mem_cur_size -= malloc_usable_size(ptr);424 mem_cur_size -= malloc_usable_size(ptr);
@@ -426,7 +426,7 @@ static inline void tcc_free(void *ptr) · 1 unmodified line
426 free(ptr);426 free(ptr);
427}427}
428 428
429static void *tcc_malloc(unsigned long size)429void *tcc_malloc(unsigned long size)
430{430{
431 void *ptr;431 void *ptr;
432 ptr = malloc(size);432 ptr = malloc(size);
@@ -440,7 +440,7 @@ static void *tcc_malloc(unsigned long size) · 7 unmodified lines
440 return ptr;440 return ptr;
441}441}
442 442
443static void *tcc_mallocz(unsigned long size)443void *tcc_mallocz(unsigned long size)
444{444{
445 void *ptr;445 void *ptr;
446 ptr = tcc_malloc(size);446 ptr = tcc_malloc(size);
@@ -448,7 +448,7 @@ static void *tcc_mallocz(unsigned long size) · 1 unmodified line
448 return ptr;448 return ptr;
449}449}
450 450
451static inline void *tcc_realloc(void *ptr, unsigned long size)451void *tcc_realloc(void *ptr, unsigned long size)
452{452{
453 void *ptr1;453 void *ptr1;
454#ifdef MEM_DEBUG454#ifdef MEM_DEBUG
@@ -464,7 +464,7 @@ static inline void *tcc_realloc(void *ptr, unsigned long size) · 9 unmodified lines
464 return ptr1;464 return ptr1;
465}465}
466 466
467static char *tcc_strdup(const char *str)467char *tcc_strdup(const char *str)
468{468{
469 char *ptr;469 char *ptr;
470 ptr = tcc_malloc(strlen(str) + 1);470 ptr = tcc_malloc(strlen(str) + 1);
@@ -476,7 +476,7 @@ static char *tcc_strdup(const char *str) · 5 unmodified lines
476#define malloc(s) use_tcc_malloc(s)476#define malloc(s) use_tcc_malloc(s)
477#define realloc(p, s) use_tcc_realloc(p, s)477#define realloc(p, s) use_tcc_realloc(p, s)
478 478
479static void dynarray_add(void ***ptab, int *nb_ptr, void *data)479void dynarray_add(void ***ptab, int *nb_ptr, void *data)
480{480{
481 int nb, nb_alloc;481 int nb, nb_alloc;
482 void **pp;482 void **pp;
@@ -498,7 +498,7 @@ static void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 15 unmodified lines
498 *nb_ptr = nb;498 *nb_ptr = nb;
499}499}
500 500
501static void dynarray_reset(void *pp, int *n)501void dynarray_reset(void *pp, int *n)
502{502{
503 void **p;503 void **p;
504 for (p = *(void***)pp; *n; ++p, --*n)504 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
2030 2030
2031int tcc_add_file(TCCState *s, const char *filename)2031int tcc_add_file(TCCState *s, const char *filename)
2032{2032{
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);
2034}2037}
2035 2038
2036int tcc_add_library_path(TCCState *s, const char *pathname)2039int 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
509 const char *filename;509 const char *filename;
510 510
511 filename = files[i];511 filename = files[i];
512 if (output_type == TCC_OUTPUT_PREPROCESS) {512 if (filename[0] == '-' && filename[1]) {
513 if (tcc_add_file_internal(s, filename, 513 if (tcc_add_library(s, filename + 2) < 0) {
514 AFF_PRINT_ERROR | AFF_PREPROCESS) < 0)514 error_noabort("cannot find %s", filename);
515 ret = 1;515 ret = 1;
516 } else if (filename[0] == '-' && filename[1]) {516 }
517 if (tcc_add_library(s, filename + 2) < 0)
518 error("cannot find %s", filename);
519 } else {517 } else {
520 if (1 == s->verbose)518 if (1 == s->verbose)
521 printf("-> %s\n", filename);519 printf("-> %s\n", filename);
tcc.h+14−12
@@ -724,23 +724,25 @@ extern long double strtold (const char *__nptr, char **__endptr); · 723 unmodified lines
724#endif724#endif
725 725
726void error(const char *fmt, ...);726void error(const char *fmt, ...);
727void error_noabort(const char *fmt, ...);
727void warning(const char *fmt, ...);728void warning(const char *fmt, ...);
729
728void tcc_set_lib_path_w32(TCCState *s);730void tcc_set_lib_path_w32(TCCState *s);
729int tcc_set_flag(TCCState *s, const char *flag_name, int value);731int tcc_set_flag(TCCState *s, const char *flag_name, int value);
730void tcc_print_stats(TCCState *s, int64_t total_time);732void tcc_print_stats(TCCState *s, int64_t total_time);
731 733
732static void tcc_free(void *ptr);734void tcc_free(void *ptr);
733static void *tcc_malloc(unsigned long size);735void *tcc_malloc(unsigned long size);
734static void *tcc_mallocz(unsigned long size);736void *tcc_mallocz(unsigned long size);
735static void *tcc_realloc(void *ptr, unsigned long size);737void *tcc_realloc(void *ptr, unsigned long size);
736static char *tcc_strdup(const char *str);738char *tcc_strdup(const char *str);
737 739
738static char *tcc_basename(const char *name);740char *tcc_basename(const char *name);
739static char *tcc_fileextension (const char *name);741char *tcc_fileextension (const char *name);
740static char *pstrcpy(char *buf, int buf_size, const char *s);742char *pstrcpy(char *buf, int buf_size, const char *s);
741static char *pstrcat(char *buf, int buf_size, const char *s);743char *pstrcat(char *buf, int buf_size, const char *s);
742static void dynarray_add(void ***ptab, int *nb_ptr, void *data);744void dynarray_add(void ***ptab, int *nb_ptr, void *data);
743static void dynarray_reset(void *pp, int *n);745void dynarray_reset(void *pp, int *n);
744 746
745#ifdef CONFIG_TCC_BACKTRACE747#ifdef CONFIG_TCC_BACKTRACE
746extern int num_callers;748extern 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