Sarathy's patch
[p5sagit/p5-mst-13.2.git] / win32 / win32.c
index a01ff6f..dcdda53 100644 (file)
 #include "XSUB.h"
 #include <fcntl.h>
 #include <sys/stat.h>
+#ifndef __GNUC__
+/* assert.h conflicts with #define of assert in perl.h */
 #include <assert.h>
+#endif
 #include <string.h>
 #include <stdarg.h>
 #include <float.h>
 
+#ifdef __GNUC__
+/* Mingw32 defaults to globing command line 
+ * So we turn it off like this:
+ */
+int _CRT_glob = 0;
+#endif
+
 #define EXECF_EXEC 1
 #define EXECF_SPAWN 2
 #define EXECF_SPAWN_NOWAIT 3
@@ -535,15 +545,15 @@ getegid(void)
 }
 
 int
-setuid(uid_t uid)
+setuid(uid_t auid)
 { 
-    return (uid == ROOT_UID ? 0 : -1);
+    return (auid == ROOT_UID ? 0 : -1);
 }
 
 int
-setgid(gid_t gid)
+setgid(gid_t agid)
 {
-    return (gid == ROOT_GID ? 0 : -1);
+    return (agid == ROOT_GID ? 0 : -1);
 }
 
 /*
@@ -926,7 +936,15 @@ win32_feof(FILE *fp)
  * we have to roll our own.
  */
 
+#ifdef USE_THREADS
+#ifdef USE_DECLSPEC_THREAD
 __declspec(thread) char        strerror_buffer[512];
+#else
+#define strerror_buffer (thr->i.Wstrerror_buffer)
+#endif
+#else
+char   strerror_buffer[512];
+#endif
 
 DllExport char *
 win32_strerror(int e) 
@@ -937,6 +955,7 @@ win32_strerror(int e)
     DWORD source = 0;
 
     if(e < 0 || e > sys_nerr) {
+        dTHR;
        if(e < 0)
            e = GetLastError();
 
@@ -1112,9 +1131,9 @@ win32_abort(void)
 }
 
 DllExport int
-win32_fstat(int fd,struct stat *bufptr)
+win32_fstat(int fd,struct stat *sbufptr)
 {
-    return fstat(fd,bufptr);
+    return fstat(fd,sbufptr);
 }
 
 DllExport int
@@ -1126,21 +1145,13 @@ win32_pipe(int *pfd, unsigned int size, int mode)
 DllExport FILE*
 win32_popen(const char *command, const char *mode)
 {
-#ifdef __GNUC__
-    return NULL;
-#else
     return _popen(command, mode);
-#endif
 }
 
 DllExport int
 win32_pclose(FILE *pf)
 {
-#ifdef __GNUC__
-    return fclose(pf);
-#else
     return _pclose(pf);
-#endif
 }
 
 DllExport int
@@ -1263,17 +1274,13 @@ win32_setvbuf(FILE *pf, char *buf, int type, size_t size)
 DllExport int
 win32_flushall(void)
 {
-#ifndef __GNUC__
     return flushall();
-#endif
 }
 
 DllExport int
 win32_fcloseall(void)
 {
-#ifndef __GNUC__
     return fcloseall();
-#endif
 }
 
 DllExport char*
@@ -1738,6 +1745,7 @@ Perl_win32_init(int *argcp, char ***argvp)
 #if !defined(_ALPHA_) && !defined(__GNUC__)
     _control87(MCW_EM, MCW_EM);
 #endif
+    MALLOC_INIT; 
 }
 
 #ifdef USE_BINMODE_SCRIPTS
@@ -1771,3 +1779,4 @@ win32_strip_return(SV *sv)
 
 
 
+