diff --git a/libtcc/include/tcc.h b/libtcc/include/tcc.h index 60545069..7cc68146 100644 --- a/libtcc/include/tcc.h +++ b/libtcc/include/tcc.h @@ -33,41 +33,17 @@ # undef __attribute__ #endif +#include #include #include #include #include -#ifndef _WIN32 -# include -# include +#include +#include /* XXX: need to define this to use them in non ISOC99 context */ extern float strtof (const char *__nptr, char **__endptr); extern long double strtold (const char *__nptr, char **__endptr); -#endif - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include -# include /* open, close etc. */ -# include /* getcwd */ -# include /* alloca */ -# ifdef __GNUC__ -# include -# endif -# define inline __inline -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# ifndef __GNUC__ -# define strtold (long double)strtod -# define strtof (float)strtod -# define strtoll _strtoi64 -# define strtoull _strtoui64 -# endif -# ifndef va_copy -# define va_copy(a,b) a = b -# endif -#endif #ifndef O_BINARY # define O_BINARY 0 @@ -92,7 +68,7 @@ extern long double strtold (const char *__nptr, char **__endptr); #ifndef CONFIG_SYSROOT # define CONFIG_SYSROOT "" #endif -#if !defined CONFIG_TCCDIR && !defined _WIN32 +#if !defined CONFIG_TCCDIR # define CONFIG_TCCDIR "/usr/local/lib/tcc" #endif #ifndef CONFIG_LDDIR @@ -793,9 +769,6 @@ void tcc_add_pragma_libs(TCCState *s1); PUB_FUNC int tcc_add_library_err(TCCState *s, const char *f); PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time); char *tcc_load_text(int fd); -#ifdef _WIN32 -char *normalize_slashes(char *path); -#endif /* for #pragma once */ int normalized_PATHCMP(const char *f1, const char *f2); diff --git a/libtcc/include/tcc/path.h b/libtcc/include/tcc/path.h index 1152cc0e..0c0657c4 100644 --- a/libtcc/include/tcc/path.h +++ b/libtcc/include/tcc/path.h @@ -1,15 +1,13 @@ #ifndef TCC_PATH_H # define TCC_PATH_H 1 -#ifdef _WIN32 -# define IS_DIRSEP(c) (c == '/' || c == '\\') -# define IS_ABSPATH(p) (IS_DIRSEP(p[0]) || (p[0] && p[1] == ':' && IS_DIRSEP(p[2]))) -# define PATHCMP stricmp -# define PATHSEP ";" -#else # define IS_DIRSEP(c) (c == '/') # define IS_ABSPATH(p) IS_DIRSEP(p[0]) # define PATHCMP strcmp + +#ifdef _WIN32 +# define PATHSEP ";" +#else # define PATHSEP ":" #endif diff --git a/libtcc/libtcc.c b/libtcc/libtcc.c index d135b5d5..8a8ac9ea 100644 --- a/libtcc/libtcc.c +++ b/libtcc/libtcc.c @@ -22,6 +22,8 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include + #include #include #include @@ -37,36 +39,6 @@ struct TCCState *tcc_state; void** stk_data; int nb_stk_data; -/********************************************************/ -#ifdef _WIN32 -char *normalize_slashes(char *path) -{ - char *p; - for (p = path; *p; ++p) - if (*p == '\\') - *p = '/'; - return path; -} - -#define tcc_module NULL /* NULL means executable itself */ - -#ifndef CONFIG_TCCDIR -/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */ -static inline char *config_tccdir_w32(char *path) -{ - char *p; - GetModuleFileNameA(tcc_module, path, MAX_PATH); - p = tcc_basename(normalize_slashes(strlwr(path))); - if (p > path) - --p; - *p = 0; - return path; -} -#define CONFIG_TCCDIR config_tccdir_w32(alloca(MAX_PATH)) -#endif - -#endif - /********************************************************/ PUB_FUNC void tcc_enter_state(TCCState *s1) @@ -316,9 +288,7 @@ void tcc_open_bf(TCCState *s1, const char *filename, int initlen) bf->buf_end = bf->buffer + initlen; bf->buf_end[0] = CH_EOB; /* put eob symbol */ pstrcpy(bf->filename, sizeof(bf->filename), filename); -#ifdef _WIN32 - normalize_slashes(bf->filename); -#endif + bf->true_filename = bf->filename; bf->line_num = 1; bf->ifdef_stack_ptr = s1->ifdef_stack_ptr; diff --git a/libtcc/tccasm.c b/libtcc/tccasm.c index c3ed7e91..245697a3 100644 --- a/libtcc/tccasm.c +++ b/libtcc/tccasm.c @@ -20,6 +20,9 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif /* HAVE_CONFIG_H */ + +#include + #define USING_GLOBALS #include "tcc.h" #include "utils/string.h" diff --git a/libtcc/tccelf.c b/libtcc/tccelf.c index 9c7da476..a4b0ff1f 100644 --- a/libtcc/tccelf.c +++ b/libtcc/tccelf.c @@ -22,6 +22,8 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include + #include #include #include diff --git a/libtcc/tccgen.c b/libtcc/tccgen.c index d6fae0f2..16b975c1 100644 --- a/libtcc/tccgen.c +++ b/libtcc/tccgen.c @@ -22,6 +22,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #define USING_GLOBALS #include diff --git a/libtcc/tccpp.c b/libtcc/tccpp.c index e1ef80be..31a9a4db 100644 --- a/libtcc/tccpp.c +++ b/libtcc/tccpp.c @@ -22,6 +22,8 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include + #define USING_GLOBALS #include #include @@ -551,12 +553,7 @@ const char *get_tok_str(int v, CValue *cv) case TOK_CULONG: case TOK_CLLONG: case TOK_CULLONG: - /* XXX: not quite exact, but only useful for testing */ -#ifdef _WIN32 - sprintf(p, "%u", (unsigned)cv->i); -#else sprintf(p, "%llu", (unsigned long long)cv->i); -#endif break; case TOK_LCHAR: cstr_ccat(&cstr_buf, 'L'); @@ -1622,11 +1619,7 @@ static CachedInclude *search_cached_include(TCCState *s1, const char *filename, s = basename = tcc_basename(filename); h = TOK_HASH_INIT; while ((c = (unsigned char)*s) != 0) { -#ifdef _WIN32 - h = TOK_HASH_FUNC(h, toup(c)); -#else h = TOK_HASH_FUNC(h, c); -#endif s++; } h &= (CACHED_INCLUDES_HASH_SIZE - 1); @@ -1786,9 +1779,6 @@ void tccpp_putfile(const char *filename) *tcc_basename(buf) = 0; } pstrcat(buf, sizeof buf, filename); -#ifdef _WIN32 - normalize_slashes(buf); -#endif if (0 == strcmp(file->filename, buf)) return; //printf("new file '%s'\n", buf); diff --git a/tcc/tcc.c b/tcc/tcc.c index c6481f9d..c60eb955 100644 --- a/tcc/tcc.c +++ b/tcc/tcc.c @@ -174,13 +174,9 @@ static char static unsigned getclock_ms(void) { -#ifdef _WIN32 - return GetTickCount(); -#else struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec*1000 + (tv.tv_usec+500)/1000; -#endif } int diff --git a/tcc/tcctools.c b/tcc/tcctools.c index c87f38e7..620f6e8b 100644 --- a/tcc/tcctools.c +++ b/tcc/tcctools.c @@ -28,6 +28,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + #include #include #include