Remove _WIN32 bullshit (msys2 exist uU)
This commit is contained in:
parent
ef94f0cf60
commit
94b74d446f
9 changed files with 21 additions and 86 deletions
|
@ -33,41 +33,17 @@
|
||||||
# undef __attribute__
|
# undef __attribute__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#include <unistd.h>
|
||||||
# include <unistd.h>
|
#include <sys/time.h>
|
||||||
# include <sys/time.h>
|
|
||||||
/* XXX: need to define this to use them in non ISOC99 context */
|
/* XXX: need to define this to use them in non ISOC99 context */
|
||||||
extern float strtof (const char *__nptr, char **__endptr);
|
extern float strtof (const char *__nptr, char **__endptr);
|
||||||
extern long double strtold (const char *__nptr, char **__endptr);
|
extern long double strtold (const char *__nptr, char **__endptr);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define WIN32_LEAN_AND_MEAN 1
|
|
||||||
# include <windows.h>
|
|
||||||
# include <io.h> /* open, close etc. */
|
|
||||||
# include <direct.h> /* getcwd */
|
|
||||||
# include <malloc.h> /* alloca */
|
|
||||||
# ifdef __GNUC__
|
|
||||||
# include <stdint.h>
|
|
||||||
# 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
|
#ifndef O_BINARY
|
||||||
# define O_BINARY 0
|
# define O_BINARY 0
|
||||||
|
@ -92,7 +68,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||||
#ifndef CONFIG_SYSROOT
|
#ifndef CONFIG_SYSROOT
|
||||||
# define CONFIG_SYSROOT ""
|
# define CONFIG_SYSROOT ""
|
||||||
#endif
|
#endif
|
||||||
#if !defined CONFIG_TCCDIR && !defined _WIN32
|
#if !defined CONFIG_TCCDIR
|
||||||
# define CONFIG_TCCDIR "/usr/local/lib/tcc"
|
# define CONFIG_TCCDIR "/usr/local/lib/tcc"
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_LDDIR
|
#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 int tcc_add_library_err(TCCState *s, const char *f);
|
||||||
PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time);
|
PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time);
|
||||||
char *tcc_load_text(int fd);
|
char *tcc_load_text(int fd);
|
||||||
#ifdef _WIN32
|
|
||||||
char *normalize_slashes(char *path);
|
|
||||||
#endif
|
|
||||||
/* for #pragma once */
|
/* for #pragma once */
|
||||||
int normalized_PATHCMP(const char *f1, const char *f2);
|
int normalized_PATHCMP(const char *f1, const char *f2);
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
#ifndef TCC_PATH_H
|
#ifndef TCC_PATH_H
|
||||||
# define TCC_PATH_H 1
|
# 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_DIRSEP(c) (c == '/')
|
||||||
# define IS_ABSPATH(p) IS_DIRSEP(p[0])
|
# define IS_ABSPATH(p) IS_DIRSEP(p[0])
|
||||||
# define PATHCMP strcmp
|
# define PATHCMP strcmp
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define PATHSEP ";"
|
||||||
|
#else
|
||||||
# define PATHSEP ":"
|
# define PATHSEP ":"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <tcc.h>
|
#include <tcc.h>
|
||||||
#include <tcc/path.h>
|
#include <tcc/path.h>
|
||||||
#include <tcc/memory.h>
|
#include <tcc/memory.h>
|
||||||
|
@ -37,36 +39,6 @@ struct TCCState *tcc_state;
|
||||||
void** stk_data;
|
void** stk_data;
|
||||||
int nb_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)
|
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 = bf->buffer + initlen;
|
||||||
bf->buf_end[0] = CH_EOB; /* put eob symbol */
|
bf->buf_end[0] = CH_EOB; /* put eob symbol */
|
||||||
pstrcpy(bf->filename, sizeof(bf->filename), filename);
|
pstrcpy(bf->filename, sizeof(bf->filename), filename);
|
||||||
#ifdef _WIN32
|
|
||||||
normalize_slashes(bf->filename);
|
|
||||||
#endif
|
|
||||||
bf->true_filename = bf->filename;
|
bf->true_filename = bf->filename;
|
||||||
bf->line_num = 1;
|
bf->line_num = 1;
|
||||||
bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;
|
bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define USING_GLOBALS
|
#define USING_GLOBALS
|
||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
#include "utils/string.h"
|
#include "utils/string.h"
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <tcc.h>
|
#include <tcc.h>
|
||||||
#include <tcc/path.h>
|
#include <tcc/path.h>
|
||||||
#include <tcc/memory.h>
|
#include <tcc/memory.h>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define USING_GLOBALS
|
#define USING_GLOBALS
|
||||||
#include <tcc.h>
|
#include <tcc.h>
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define USING_GLOBALS
|
#define USING_GLOBALS
|
||||||
#include <tcc.h>
|
#include <tcc.h>
|
||||||
#include <tcc/path.h>
|
#include <tcc/path.h>
|
||||||
|
@ -551,12 +553,7 @@ const char *get_tok_str(int v, CValue *cv)
|
||||||
case TOK_CULONG:
|
case TOK_CULONG:
|
||||||
case TOK_CLLONG:
|
case TOK_CLLONG:
|
||||||
case TOK_CULLONG:
|
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);
|
sprintf(p, "%llu", (unsigned long long)cv->i);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case TOK_LCHAR:
|
case TOK_LCHAR:
|
||||||
cstr_ccat(&cstr_buf, 'L');
|
cstr_ccat(&cstr_buf, 'L');
|
||||||
|
@ -1622,11 +1619,7 @@ static CachedInclude *search_cached_include(TCCState *s1, const char *filename,
|
||||||
s = basename = tcc_basename(filename);
|
s = basename = tcc_basename(filename);
|
||||||
h = TOK_HASH_INIT;
|
h = TOK_HASH_INIT;
|
||||||
while ((c = (unsigned char)*s) != 0) {
|
while ((c = (unsigned char)*s) != 0) {
|
||||||
#ifdef _WIN32
|
|
||||||
h = TOK_HASH_FUNC(h, toup(c));
|
|
||||||
#else
|
|
||||||
h = TOK_HASH_FUNC(h, c);
|
h = TOK_HASH_FUNC(h, c);
|
||||||
#endif
|
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
h &= (CACHED_INCLUDES_HASH_SIZE - 1);
|
h &= (CACHED_INCLUDES_HASH_SIZE - 1);
|
||||||
|
@ -1786,9 +1779,6 @@ void tccpp_putfile(const char *filename)
|
||||||
*tcc_basename(buf) = 0;
|
*tcc_basename(buf) = 0;
|
||||||
}
|
}
|
||||||
pstrcat(buf, sizeof buf, filename);
|
pstrcat(buf, sizeof buf, filename);
|
||||||
#ifdef _WIN32
|
|
||||||
normalize_slashes(buf);
|
|
||||||
#endif
|
|
||||||
if (0 == strcmp(file->filename, buf))
|
if (0 == strcmp(file->filename, buf))
|
||||||
return;
|
return;
|
||||||
//printf("new file '%s'\n", buf);
|
//printf("new file '%s'\n", buf);
|
||||||
|
|
|
@ -174,13 +174,9 @@ static char
|
||||||
static unsigned
|
static unsigned
|
||||||
getclock_ms(void)
|
getclock_ms(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
return GetTickCount();
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
return tv.tv_sec*1000 + (tv.tv_usec+500)/1000;
|
return tv.tv_sec*1000 + (tv.tv_usec+500)/1000;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <tcc.h>
|
#include <tcc.h>
|
||||||
#include <tcc/path.h>
|
#include <tcc/path.h>
|
||||||
#include <tcc/object/archive.h>
|
#include <tcc/object/archive.h>
|
||||||
|
|
Loading…
Reference in a new issue