Remove _WIN32 bullshit (msys2 exist uU)

This commit is contained in:
d0p1 🏳️‍⚧️ 2025-02-11 20:40:33 +01:00
parent ef94f0cf60
commit 94b74d446f
9 changed files with 21 additions and 86 deletions

View file

@ -33,41 +33,17 @@
# undef __attribute__
#endif
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <setjmp.h>
#include <time.h>
#ifndef _WIN32
# include <unistd.h>
# include <sys/time.h>
#include <unistd.h>
#include <sys/time.h>
/* 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 <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
# 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);

View file

@ -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

View file

@ -22,6 +22,8 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <tcc.h>
#include <tcc/path.h>
#include <tcc/memory.h>
@ -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;

View file

@ -20,6 +20,9 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#define USING_GLOBALS
#include "tcc.h"
#include "utils/string.h"

View file

@ -22,6 +22,8 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <tcc.h>
#include <tcc/path.h>
#include <tcc/memory.h>

View file

@ -22,6 +22,7 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#define USING_GLOBALS
#include <tcc.h>

View file

@ -22,6 +22,8 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#define USING_GLOBALS
#include <tcc.h>
#include <tcc/path.h>
@ -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);

View file

@ -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

View file

@ -28,6 +28,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdlib.h>
#include <tcc.h>
#include <tcc/path.h>
#include <tcc/object/archive.h>