mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
enable making tcc using libtcc
This commit is contained in:
parent
0a35f9d66e
commit
67aebdd5b7
27
libtcc.c
27
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)
|
||||
|
10
tcc.c
10
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);
|
||||
|
24
tcc.h
24
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;
|
||||
|
Loading…
Reference in New Issue
Block a user