From: rrt Date: Thu, 1 Mar 2001 12:25:33 +0000 (+0000) Subject: [project @ 2001-03-01 12:25:32 by rrt] X-Git-Tag: Approximately_9120_patches~2510 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;ds=sidebyside;h=ae2fa137637637d21e3ca46b25b9325a77e77641;p=ghc-hetmet.git [project @ 2001-03-01 12:25:32 by rrt] Apply stat fix for mingw. It's ugly, it's implausible, but it seems to work. Unlike Cygwin...(missing no. 3). --- diff --git a/ghc/driver/PackageSrc.hs b/ghc/driver/PackageSrc.hs index 81b963b..2eb3e6d 100644 --- a/ghc/driver/PackageSrc.hs +++ b/ghc/driver/PackageSrc.hs @@ -113,7 +113,7 @@ package_details installing = hs_libraries = [ "HSstd" ], extra_libraries = [ "HSstd_cbits" ] ++ # ifdef mingw32_TARGET_OS - ["wsock32"] + ["wsock32", "msvcrt"] # else ["m"] -- libm, that is # endif diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h index 9e37b03..8908cf3 100644 --- a/ghc/includes/Stg.h +++ b/ghc/includes/Stg.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stg.h,v 1.35 2001/02/09 13:09:17 simonmar Exp $ + * $Id: Stg.h,v 1.36 2001/03/01 12:25:32 rrt Exp $ * * (c) The GHC Team, 1998-1999 * @@ -41,6 +41,11 @@ /* Some macros to handle DLLing (Win32 only at the moment). */ #include "StgDLL.h" +/* Fix for mingw stat problem (done here so it's early enough) */ +#ifdef mingw32_TARGET_OS +#define __MSVCRT__ 1 +#endif + /* Turn lazy blackholing and eager blackholing on/off. * * Using eager blackholing makes things easier to debug because diff --git a/ghc/lib/std/Directory.hsc b/ghc/lib/std/Directory.hsc index 99d1e39..d04d3db 100644 --- a/ghc/lib/std/Directory.hsc +++ b/ghc/lib/std/Directory.hsc @@ -1,5 +1,5 @@ -- ----------------------------------------------------------------------------- --- $Id: Directory.hsc,v 1.7 2001/02/14 12:37:10 rrt Exp $ +-- $Id: Directory.hsc,v 1.8 2001/03/01 12:25:33 rrt Exp $ -- -- (c) The University of Glasgow, 1994-2000 -- @@ -65,6 +65,8 @@ import PrelPtr import PrelIOBase import PrelBase +-- Fix mingw stat problem +#include "../includes/Stg.h" #include #include #include @@ -498,24 +500,40 @@ setPermissions name (Permissions r w e s) = do withFileStatus :: FilePath -> (Ptr CStat -> IO a) -> IO a withFileStatus name f = do +#ifndef mingw32_TARGET_OS allocaBytes (#const sizeof(struct stat)) $ \p -> +#else + allocaBytes (#const sizeof(struct _stati64)) $ \p -> +#endif withUnsafeCString name $ \s -> do throwErrnoIfMinus1Retry_ "withFileStatus" (stat s p) f p modificationTime :: Ptr CStat -> IO ClockTime modificationTime stat = do +#ifndef mingw32_TARGET_OS mtime <- (#peek struct stat, st_mtime) stat +#else + mtime <- (#peek struct _stati64, st_mtime) stat +#endif return (TOD (toInteger (mtime :: CTime)) 0) isDirectory :: Ptr CStat -> IO Bool isDirectory stat = do +#ifndef mingw32_TARGET_OS mode <- (#peek struct stat, st_mode) stat +#else + mode <- (#peek struct _stati64, st_mode) stat +#endif return (s_ISDIR mode /= 0) isRegularFile :: Ptr CStat -> IO Bool isRegularFile stat = do +#ifndef mingw32_TARGET_OS mode <- (#peek struct stat, st_mode) stat +#else + mode <- (#peek struct _stati64, st_mode) stat +#endif return (s_ISREG mode /= 0) foreign import ccall unsafe s_ISDIR :: CMode -> Int diff --git a/ghc/lib/std/cbits/Makefile b/ghc/lib/std/cbits/Makefile index 16ec304..d3c75a4 100644 --- a/ghc/lib/std/cbits/Makefile +++ b/ghc/lib/std/cbits/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.24 2000/11/07 10:42:57 simonmar Exp $ +# $Id: Makefile,v 1.25 2001/03/01 12:25:33 rrt Exp $ TOP = ../../.. include $(TOP)/mk/boilerplate.mk @@ -13,8 +13,8 @@ C_SRCS= $(wildcard *.c) C_OBJS = $(C_SRCS:.c=.$(way_)o) LIBOBJS = $(C_OBJS) SRC_CC_OPTS += -O $(GhcLibCcOpts) -Wall -optc-DCOMPILING_STDLIB -ifneq "$(DLLized)" "YES" -SRC_CC_OPTS += -static +ifeq "$(DLLized)" "YES" +SRC_CC_OPTS += -dynamic endif # diff --git a/ghc/lib/std/cbits/fileSize.c b/ghc/lib/std/cbits/fileSize.c index cbba594..86c55d9 100644 --- a/ghc/lib/std/cbits/fileSize.c +++ b/ghc/lib/std/cbits/fileSize.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: fileSize.c,v 1.5 2001/01/16 11:27:45 simonmar Exp $ + * $Id: fileSize.c,v 1.6 2001/03/01 12:25:33 rrt Exp $ * * hClose Runtime Support */ @@ -21,14 +21,14 @@ StgInt fileSize(StgForeignPtr ptr, StgByteArray result) { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; int rc = 0; /* Flush buffer in order to get as an accurate size as poss. */ rc = flushFile(ptr); if (rc < 0) return rc; - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); @@ -55,14 +55,14 @@ StgInt fileSize_int64(StgForeignPtr ptr, StgByteArray result) { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; int rc = 0; /* Flush buffer in order to get as an accurate size as poss. */ rc = flushFile(ptr); if (rc < 0) return rc; - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); diff --git a/ghc/lib/std/cbits/getBufferMode.c b/ghc/lib/std/cbits/getBufferMode.c index 8e3c09b..c802909 100644 --- a/ghc/lib/std/cbits/getBufferMode.c +++ b/ghc/lib/std/cbits/getBufferMode.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: getBufferMode.c,v 1.3 1998/12/02 13:27:35 simonm Exp $ + * $Id: getBufferMode.c,v 1.4 2001/03/01 12:25:33 rrt Exp $ * * hIs...Buffered Runtime Support */ @@ -32,11 +32,11 @@ getBufferMode(ptr) StgForeignPtr ptr; { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; int fd = fo->fd; /* Try to find out the file type */ - while (fstat(fd, &sb) < 0) { + while (Fstat(fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); diff --git a/ghc/lib/std/cbits/getLock.c b/ghc/lib/std/cbits/getLock.c index 748ff65..143da77 100644 --- a/ghc/lib/std/cbits/getLock.c +++ b/ghc/lib/std/cbits/getLock.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: getLock.c,v 1.7 1999/12/08 15:47:07 simonmar Exp $ + * $Id: getLock.c,v 1.8 2001/03/01 12:25:33 rrt Exp $ * * stdin/stout/stderr Runtime Support */ @@ -48,9 +48,9 @@ int for_writing; int exclusive; { int i; - struct stat sb; + struct Stat sb; - while (fstat(fd, &sb) < 0) { + while (Fstat(fd, &sb) < 0) { if (errno != EINTR) { #ifndef _WIN32 return -1; diff --git a/ghc/lib/std/cbits/openFile.c b/ghc/lib/std/cbits/openFile.c index 66f7eab..5ce3340 100644 --- a/ghc/lib/std/cbits/openFile.c +++ b/ghc/lib/std/cbits/openFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: openFile.c,v 1.18 2000/05/15 09:20:11 simonmar Exp $ + * $Id: openFile.c,v 1.19 2001/03/01 12:25:33 rrt Exp $ * * openFile Runtime Support */ @@ -79,7 +79,7 @@ openFile(StgByteArray file, StgInt how, StgInt binary) int oflags; int for_writing; int created = 0; - struct stat sb; + struct Stat sb; IOFileObject* fo; int flags = 0; @@ -136,7 +136,7 @@ openFile(StgByteArray file, StgInt how, StgInt binary) } else { /* If it is a dangling symlink, break off now, too. */ #ifndef mingw32_TARGET_OS - struct stat st; + struct Stat st; if ( lstat(file,&st) == 0) { ghc_errtype = ERR_NOSUCHTHING; ghc_errstr = "dangling symlink"; @@ -193,7 +193,7 @@ openFile(StgByteArray file, StgInt how, StgInt binary) /* Make sure that we aren't looking at a directory */ - while (fstat(fd, &sb) < 0) { + while (Fstat(fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); diff --git a/ghc/lib/std/cbits/seekFile.c b/ghc/lib/std/cbits/seekFile.c index 9193484..16f7618 100644 --- a/ghc/lib/std/cbits/seekFile.c +++ b/ghc/lib/std/cbits/seekFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: seekFile.c,v 1.5 2000/01/17 12:30:07 simonmar Exp $ + * $Id: seekFile.c,v 1.6 2001/03/01 12:25:33 rrt Exp $ * * hSeek and hIsSeekable Runtime Support */ @@ -22,7 +22,7 @@ StgInt seekFile(StgForeignPtr ptr, StgInt whence, StgInt size, StgByteArray d) { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; off_t offset; int posn_delta =0; int rc = 0; @@ -84,7 +84,7 @@ seekFile(StgForeignPtr ptr, StgInt whence, StgInt size, StgByteArray d) if (rc < 0) return rc; /* Try to find out the file type */ - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); @@ -114,7 +114,7 @@ StgInt seekFile_int64(StgForeignPtr ptr, StgInt whence, StgInt64 d) { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; off_t offset = d; int posn_delta =0; int rc = 0; @@ -154,7 +154,7 @@ seekFile_int64(StgForeignPtr ptr, StgInt whence, StgInt64 d) if (rc < 0) return rc; /* Try to find out the file type & size for a physical file */ - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); @@ -183,10 +183,10 @@ StgInt seekFileP(StgForeignPtr ptr) { IOFileObject* fo = (IOFileObject*)ptr; - struct stat sb; + struct Stat sb; /* Try to find out the file type */ - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* highly unlikely */ if (errno != EINTR) { cvtErrno(); diff --git a/ghc/lib/std/cbits/setBuffering.c b/ghc/lib/std/cbits/setBuffering.c index 4a8c5bf..6bc943a 100644 --- a/ghc/lib/std/cbits/setBuffering.c +++ b/ghc/lib/std/cbits/setBuffering.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: setBuffering.c,v 1.10 2001/02/19 16:10:23 rrt Exp $ + * $Id: setBuffering.c,v 1.11 2001/03/01 12:25:33 rrt Exp $ * * hSetBuffering Runtime Support */ @@ -38,7 +38,7 @@ setBuffering(StgForeignPtr ptr, StgInt size) #ifndef mingw32_TARGET_OS struct termios tio; #endif - struct stat sb; + struct Stat sb; /* First off, flush old buffer.. */ if ( (fo->flags & FILEOBJ_WRITE) ) { @@ -100,7 +100,7 @@ setBuffering(StgForeignPtr ptr, StgInt size) case SB_BB: #ifdef HAVE_ST_BLKSIZE - while (fstat(fo->fd, &sb) < 0) { + while (Fstat(fo->fd, &sb) < 0) { /* not very likely.. */ if ( errno != EINTR ) { cvtErrno(); diff --git a/ghc/lib/std/cbits/stgio.h b/ghc/lib/std/cbits/stgio.h index 14da211..64cf6a2 100644 --- a/ghc/lib/std/cbits/stgio.h +++ b/ghc/lib/std/cbits/stgio.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: stgio.h,v 1.26 2001/02/28 14:24:46 sewardj Exp $ + * $Id: stgio.h,v 1.27 2001/03/01 12:25:33 rrt Exp $ * * (c) The GRASP/AQUA Project, Glasgow University, 1994-1999 * @@ -15,6 +15,17 @@ #include "stgerror.h" #include "fileObject.h" +/* Fix for mingwin stat */ +#ifdef mingw32_TARGET_OS +/* Need to #define __MSVCRT__ to get these versions, but in order to do this + early enough it's done in Stg.h (included by Rts.h) */ +#define Stat _stati64 +#define Fstat _fstati64 +#else +#define Stat stat +#define Fstat fstat +#endif + /* Function prototypes for the I/O subsytem... */