From ef3a0a7fe79aaa41810708eaacd9e10dbb8548f0 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sun, 26 Mar 2000 07:18:33 +0000 Subject: [PATCH] * Added support for mingw32. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@203 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCglobl.h | 7 +++++++ src/SDCCmain.c | 32 ++++++++++++++++---------------- support/cpp/Makefile.in | 2 +- support/cpp/cpplib.c | 4 ++++ support/cpp/support.c | 30 ++++++++++++++++++++++++++++++ support/gc/mach_dep.c | 15 ++++++++++++++- 6 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 support/cpp/support.c diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 7290bbf5..c054ff95 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -9,6 +9,13 @@ #include "sdccconf.h" #include "SDCCerr.h" +#ifdef __BORLANDC__ +#define NATIVE_WIN32 1 +#endif +#ifdef __MINGW32__ +#define NATIVE_WIN32 1 +#endif + #ifdef _NO_GC #define GC_malloc malloc diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 03c6ef33..8f958818 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -25,7 +25,7 @@ #include "common.h" #include -#ifdef __BORLANDC__ +#if NATIVE_WIN32 #include #else #include "spawn.h" @@ -994,9 +994,6 @@ char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL}; int my_system (const char *cmd, char **cmd_argv) { char *dir, *got= NULL; int i= 0; - #ifdef __BORLANDC__ - char *r; - #endif while (!got && try_dir[i]) { @@ -1005,21 +1002,24 @@ int my_system (const char *cmd, char **cmd_argv) strcat(dir, "/"); strcat(dir, cmd); - #ifdef __BORLANDC__ +#if NATIVE_WIN32 strcat(dir, ".exe"); /* Mung slashes into backslashes to keep WIndoze happy. */ - r = dir; - - while (*r) - { - if (*r == '/') - { - *r = '\\'; - } - r++; - } - #endif + { + char *r; + r = dir; + + while (*r) + { + if (*r == '/') + { + *r = '\\'; + } + r++; + } + } +#endif if (access(dir, X_OK) == 0) { diff --git a/support/cpp/Makefile.in b/support/cpp/Makefile.in index 9bf1a000..5efe335b 100644 --- a/support/cpp/Makefile.in +++ b/support/cpp/Makefile.in @@ -32,7 +32,7 @@ CFLAGS = @CFLAGS@ M_OR_MM = @M_OR_MM@ LDFLAGS = @LDFLAGS@ -OBJECTS = cppalloc.o cpperror.o cppexp.o cpphash.o cpplib.o cppmain.o +OBJECTS = cppalloc.o cpperror.o cppexp.o cpphash.o cpplib.o cppmain.o support.o SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) TARGET = $(PRJDIR)/bin/sdcpp diff --git a/support/cpp/cpplib.c b/support/cpp/cpplib.c index cc0b5cb2..06d7e71f 100644 --- a/support/cpp/cpplib.c +++ b/support/cpp/cpplib.c @@ -78,6 +78,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif +#ifdef __MINGW32__ +#include +#else #ifdef __BORLANDC__ #include #else @@ -93,6 +96,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif /* USG */ #endif /* not VMS */ #endif +#endif /* This defines "errno" properly for VMS, and gives us EACCES. */ #include diff --git a/support/cpp/support.c b/support/cpp/support.c new file mode 100644 index 00000000..a8808f88 --- /dev/null +++ b/support/cpp/support.c @@ -0,0 +1,30 @@ +/* Support functions for mingw32 and probably Borland C + */ +#include + +#ifdef __MINGW32__ +void bzero(void *s, size_t n) +{ + memset(s, 0, n); +} + +void bcopy(const void *src, void *dest, size_t n) +{ + memcpy(dest, src, n); +} + +int bcmp(const void *s1, const void *s2, size_t n) +{ + return memcmp(s1, s2, n); +} + +char *index(const char *s, int c) +{ + return strchr(s, c); +} + +char *rindex(const char *s, int c) +{ + return strrchr(s, c); +} +#endif diff --git a/support/gc/mach_dep.c b/support/gc/mach_dep.c index 53698604..2919765b 100644 --- a/support/gc/mach_dep.c +++ b/support/gc/mach_dep.c @@ -224,7 +224,20 @@ void GC_push_regs() asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp"); # endif -# if defined(I386) && defined(MSWIN32) && !defined(USE_GENERIC) +# if defined(I386) && defined(__MINGW32__) + /* I386 code, generic code does not appear to work */ + /* It does appear to work under OS2, and asms dont */ + /* This is used for some 38g UNIX variants and for CYGWIN32 */ + asm("pushl %eax"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ecx"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edx"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebp"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %esi"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edi"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebx"); asm("call _GC_push_one"); asm("addl $4,%esp"); +# endif + +# if defined(I386) && defined(MSWIN32) && !defined(USE_GENERIC) && !defined(__MINGW32__) /* I386 code, Microsoft variant */ __asm push eax __asm call GC_push_one -- 2.30.2