#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
#include "common.h"
#include <ctype.h>
-#ifdef __BORLANDC__
+#if NATIVE_WIN32
#include <process.h>
#else
#include "spawn.h"
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])
{
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)
{
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
#include <stdlib.h>
#endif
+#ifdef __MINGW32__
+#include <time.h>
+#else
#ifdef __BORLANDC__
#include <time.h>
#else
#endif /* USG */
#endif /* not VMS */
#endif
+#endif
/* This defines "errno" properly for VMS, and gives us EACCES. */
#include <errno.h>
--- /dev/null
+/* 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
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