aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2009-05-11 18:46:02 +0200
committergrischka <grischka>2009-05-11 18:46:02 +0200
commit67aebdd5b733094bffbf23a87da14d2c53937a99 (patch)
tree17521833e98b73b06dd4b39960f30d24997f0971
parent0a35f9d66e15e7daadc329e7fc34b2fe5a8cbce1 (diff)
downloadtinycc-67aebdd5b733094bffbf23a87da14d2c53937a99.tar.gz
tinycc-67aebdd5b733094bffbf23a87da14d2c53937a99.tar.bz2
enable making tcc using libtcc
-rw-r--r--libtcc.c27
-rw-r--r--tcc.c10
-rw-r--r--tcc.h24
3 files changed, 32 insertions, 29 deletions
diff --git a/libtcc.c b/libtcc.c
index 6b7d956..bca1946 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -326,7 +326,7 @@ int ieee_finite(double d)
}
/* copy a string and truncate it. */
-static char *pstrcpy(char *buf, int buf_size, const char *s)
+char *pstrcpy(char *buf, int buf_size, const char *s)
{
char *q, *q_end;
int c;
@@ -346,7 +346,7 @@ static char *pstrcpy(char *buf, int buf_size, const char *s)
}
/* strcat and truncate. */
-static char *pstrcat(char *buf, int buf_size, const char *s)
+char *pstrcat(char *buf, int buf_size, const char *s)
{
int len;
len = strlen(buf);
@@ -356,7 +356,7 @@ static char *pstrcat(char *buf, int buf_size, const char *s)
}
/* extract the basename of a file */
-static char *tcc_basename(const char *name)
+char *tcc_basename(const char *name)
{
char *p = strchr(name, 0);
while (p > name && !IS_PATHSEP(p[-1]))
@@ -364,7 +364,7 @@ static char *tcc_basename(const char *name)
return p;
}
-static char *tcc_fileextension (const char *name)
+char *tcc_fileextension (const char *name)
{
char *b = tcc_basename(name);
char *e = strrchr(b, '.');
@@ -418,7 +418,7 @@ int mem_max_size;
unsigned malloc_usable_size(void*);
#endif
-static inline void tcc_free(void *ptr)
+void tcc_free(void *ptr)
{
#ifdef MEM_DEBUG
mem_cur_size -= malloc_usable_size(ptr);
@@ -426,7 +426,7 @@ static inline void tcc_free(void *ptr)
free(ptr);
}
-static void *tcc_malloc(unsigned long size)
+void *tcc_malloc(unsigned long size)
{
void *ptr;
ptr = malloc(size);
@@ -440,7 +440,7 @@ static void *tcc_malloc(unsigned long size)
return ptr;
}
-static void *tcc_mallocz(unsigned long size)
+void *tcc_mallocz(unsigned long size)
{
void *ptr;
ptr = tcc_malloc(size);
@@ -448,7 +448,7 @@ static void *tcc_mallocz(unsigned long size)
return ptr;
}
-static inline void *tcc_realloc(void *ptr, unsigned long size)
+void *tcc_realloc(void *ptr, unsigned long size)
{
void *ptr1;
#ifdef MEM_DEBUG
@@ -464,7 +464,7 @@ static inline void *tcc_realloc(void *ptr, unsigned long size)
return ptr1;
}
-static char *tcc_strdup(const char *str)
+char *tcc_strdup(const char *str)
{
char *ptr;
ptr = tcc_malloc(strlen(str) + 1);
@@ -476,7 +476,7 @@ static char *tcc_strdup(const char *str)
#define malloc(s) use_tcc_malloc(s)
#define realloc(p, s) use_tcc_realloc(p, s)
-static void dynarray_add(void ***ptab, int *nb_ptr, void *data)
+void dynarray_add(void ***ptab, int *nb_ptr, void *data)
{
int nb, nb_alloc;
void **pp;
@@ -498,7 +498,7 @@ static void dynarray_add(void ***ptab, int *nb_ptr, void *data)
*nb_ptr = nb;
}
-static void dynarray_reset(void *pp, int *n)
+void dynarray_reset(void *pp, int *n)
{
void **p;
for (p = *(void***)pp; *n; ++p, --*n)
@@ -2030,7 +2030,10 @@ static int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
int tcc_add_file(TCCState *s, const char *filename)
{
- return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
+ if (s->output_type == TCC_OUTPUT_PREPROCESS)
+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);
+ else
+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
}
int tcc_add_library_path(TCCState *s, const char *pathname)
diff --git a/tcc.c b/tcc.c
index 9cd88f3..3fce608 100644
--- a/tcc.c
+++ b/tcc.c
@@ -509,13 +509,11 @@ int main(int argc, char **argv)
const char *filename;
filename = files[i];
- if (output_type == TCC_OUTPUT_PREPROCESS) {
- if (tcc_add_file_internal(s, filename,
- AFF_PRINT_ERROR | AFF_PREPROCESS) < 0)
+ if (filename[0] == '-' && filename[1]) {
+ if (tcc_add_library(s, filename + 2) < 0) {
+ error_noabort("cannot find %s", filename);
ret = 1;
- } else if (filename[0] == '-' && filename[1]) {
- if (tcc_add_library(s, filename + 2) < 0)
- error("cannot find %s", filename);
+ }
} else {
if (1 == s->verbose)
printf("-> %s\n", filename);
diff --git a/tcc.h b/tcc.h
index 9fa9944..7ee5282 100644
--- a/tcc.h
+++ b/tcc.h
@@ -724,23 +724,25 @@ extern long double strtold (const char *__nptr, char **__endptr);
#endif
void error(const char *fmt, ...);
+void error_noabort(const char *fmt, ...);
void warning(const char *fmt, ...);
+
void tcc_set_lib_path_w32(TCCState *s);
int tcc_set_flag(TCCState *s, const char *flag_name, int value);
void tcc_print_stats(TCCState *s, int64_t total_time);
-static void tcc_free(void *ptr);
-static void *tcc_malloc(unsigned long size);
-static void *tcc_mallocz(unsigned long size);
-static void *tcc_realloc(void *ptr, unsigned long size);
-static char *tcc_strdup(const char *str);
+void tcc_free(void *ptr);
+void *tcc_malloc(unsigned long size);
+void *tcc_mallocz(unsigned long size);
+void *tcc_realloc(void *ptr, unsigned long size);
+char *tcc_strdup(const char *str);
-static char *tcc_basename(const char *name);
-static char *tcc_fileextension (const char *name);
-static char *pstrcpy(char *buf, int buf_size, const char *s);
-static char *pstrcat(char *buf, int buf_size, const char *s);
-static void dynarray_add(void ***ptab, int *nb_ptr, void *data);
-static void dynarray_reset(void *pp, int *n);
+char *tcc_basename(const char *name);
+char *tcc_fileextension (const char *name);
+char *pstrcpy(char *buf, int buf_size, const char *s);
+char *pstrcat(char *buf, int buf_size, const char *s);
+void dynarray_add(void ***ptab, int *nb_ptr, void *data);
+void dynarray_reset(void *pp, int *n);
#ifdef CONFIG_TCC_BACKTRACE
extern int num_callers;