* Added support for mingw32.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 26 Mar 2000 07:18:33 +0000 (07:18 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 26 Mar 2000 07:18:33 +0000 (07:18 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@203 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglobl.h
src/SDCCmain.c
support/cpp/Makefile.in
support/cpp/cpplib.c
support/cpp/support.c [new file with mode: 0644]
support/gc/mach_dep.c

index 7290bbf5696bc80428cdb34df6ed7716a5914219..c054ff9528ed2a4d1cd0bfb67a263ed025e1c441 100644 (file)
@@ -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
index 03c6ef338e093ab5e3b128bb0714ecd95c6a093f..8f958818ad1cd6700a46f17ce8a3f85cf7e221f3 100644 (file)
@@ -25,7 +25,7 @@
 #include "common.h"
 #include <ctype.h>
 
-#ifdef __BORLANDC__
+#if NATIVE_WIN32
 #include <process.h>
 #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)
         {
index 9bf1a00006e1ec1d655df6fb86beedc076601a47..5efe335bad2e623a44e4786d7eb539065acb4c71 100644 (file)
@@ -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
index cc0b5cb2ce637bdff7cd1882b2f907c8379849e8..06d7e71fa327d7a2b54c33fafe48c3c82b50400b 100644 (file)
@@ -78,6 +78,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #include <stdlib.h>
 #endif
 
+#ifdef __MINGW32__
+#include <time.h>
+#else
 #ifdef __BORLANDC__
 #include <time.h>
 #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 <errno.h>
diff --git a/support/cpp/support.c b/support/cpp/support.c
new file mode 100644 (file)
index 0000000..a8808f8
--- /dev/null
@@ -0,0 +1,30 @@
+/* Support functions for mingw32 and probably Borland C
+ */
+#include <string.h>
+
+#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
index 536986049985bab7bb04925c8529de6a8865afa7..2919765bf0fbf6eb533a6dd7da55370d7c9cc86c 100644 (file)
@@ -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