X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=include%2FHsBase.h;h=41281979528b7c09a497de05a7135a10533844b0;hb=4aef249a45d1db6b300baa0b8d24179802062928;hp=39acf82e06a5178a46bd2eeb1e5a3f03b58513de;hpb=7d86914e22df09da3a1d4aa8ab331209a994d22d;p=ghc-base.git diff --git a/include/HsBase.h b/include/HsBase.h index 39acf82..4128197 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -125,12 +125,9 @@ #if HAVE_VFORK_H #include #endif -#include "lockFile.h" #include "dirUtils.h" #include "WCsubst.h" -#include "runProcess.h" - #if defined(__MINGW32__) /* in Win32Utils.c */ extern void maperrno (void); @@ -140,7 +137,6 @@ extern HsWord64 getUSecOfDay(void); #if defined(__MINGW32__) #include #include -#include "timeUtils.h" #include #include #endif @@ -150,67 +146,61 @@ extern HsWord64 getUSecOfDay(void); #endif /* in inputReady.c */ -int inputReady(int fd, int msecs, int isSock); +extern int fdReady(int fd, int write, int msecs, int isSock); /* in Signals.c */ extern HsInt nocldstop; -#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32) -/* in execvpe.c */ -extern int execvpe(char *name, char *const argv[], char **envp); -extern void pPrPr_disableITimers (void); -#endif - /* ----------------------------------------------------------------------------- 64-bit operations, defined in longlong.c -------------------------------------------------------------------------- */ #ifdef SUPPORT_LONG_LONGS -StgBool stg_gtWord64 (StgWord64, StgWord64); -StgBool stg_geWord64 (StgWord64, StgWord64); -StgBool stg_eqWord64 (StgWord64, StgWord64); -StgBool stg_neWord64 (StgWord64, StgWord64); -StgBool stg_ltWord64 (StgWord64, StgWord64); -StgBool stg_leWord64 (StgWord64, StgWord64); - -StgBool stg_gtInt64 (StgInt64, StgInt64); -StgBool stg_geInt64 (StgInt64, StgInt64); -StgBool stg_eqInt64 (StgInt64, StgInt64); -StgBool stg_neInt64 (StgInt64, StgInt64); -StgBool stg_ltInt64 (StgInt64, StgInt64); -StgBool stg_leInt64 (StgInt64, StgInt64); - -StgWord64 stg_remWord64 (StgWord64, StgWord64); -StgWord64 stg_quotWord64 (StgWord64, StgWord64); - -StgInt64 stg_remInt64 (StgInt64, StgInt64); -StgInt64 stg_quotInt64 (StgInt64, StgInt64); -StgInt64 stg_negateInt64 (StgInt64); -StgInt64 stg_plusInt64 (StgInt64, StgInt64); -StgInt64 stg_minusInt64 (StgInt64, StgInt64); -StgInt64 stg_timesInt64 (StgInt64, StgInt64); - -StgWord64 stg_and64 (StgWord64, StgWord64); -StgWord64 stg_or64 (StgWord64, StgWord64); -StgWord64 stg_xor64 (StgWord64, StgWord64); -StgWord64 stg_not64 (StgWord64); - -StgWord64 stg_uncheckedShiftL64 (StgWord64, StgInt); -StgWord64 stg_uncheckedShiftRL64 (StgWord64, StgInt); -StgInt64 stg_uncheckedIShiftL64 (StgInt64, StgInt); -StgInt64 stg_uncheckedIShiftRA64 (StgInt64, StgInt); -StgInt64 stg_uncheckedIShiftRL64 (StgInt64, StgInt); - -StgInt64 stg_intToInt64 (StgInt); -StgInt stg_int64ToInt (StgInt64); -StgWord64 stg_int64ToWord64 (StgInt64); -StgWord64 stg_wordToWord64 (StgWord); -StgWord stg_word64ToWord (StgWord64); -StgInt64 stg_word64ToInt64 (StgWord64); - -StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da); -StgInt64 stg_integerToInt64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da); +HsBool hs_gtWord64 (HsWord64, HsWord64); +HsBool hs_geWord64 (HsWord64, HsWord64); +HsBool hs_eqWord64 (HsWord64, HsWord64); +HsBool hs_neWord64 (HsWord64, HsWord64); +HsBool hs_ltWord64 (HsWord64, HsWord64); +HsBool hs_leWord64 (HsWord64, HsWord64); + +HsBool hs_gtInt64 (HsInt64, HsInt64); +HsBool hs_geInt64 (HsInt64, HsInt64); +HsBool hs_eqInt64 (HsInt64, HsInt64); +HsBool hs_neInt64 (HsInt64, HsInt64); +HsBool hs_ltInt64 (HsInt64, HsInt64); +HsBool hs_leInt64 (HsInt64, HsInt64); + +HsWord64 hs_remWord64 (HsWord64, HsWord64); +HsWord64 hs_quotWord64 (HsWord64, HsWord64); + +HsInt64 hs_remInt64 (HsInt64, HsInt64); +HsInt64 hs_quotInt64 (HsInt64, HsInt64); +HsInt64 hs_negateInt64 (HsInt64); +HsInt64 hs_plusInt64 (HsInt64, HsInt64); +HsInt64 hs_minusInt64 (HsInt64, HsInt64); +HsInt64 hs_timesInt64 (HsInt64, HsInt64); + +HsWord64 hs_and64 (HsWord64, HsWord64); +HsWord64 hs_or64 (HsWord64, HsWord64); +HsWord64 hs_xor64 (HsWord64, HsWord64); +HsWord64 hs_not64 (HsWord64); + +HsWord64 hs_uncheckedShiftL64 (HsWord64, HsInt); +HsWord64 hs_uncheckedShiftRL64 (HsWord64, HsInt); +HsInt64 hs_uncheckedIShiftL64 (HsInt64, HsInt); +HsInt64 hs_uncheckedIShiftRA64 (HsInt64, HsInt); +HsInt64 hs_uncheckedIShiftRL64 (HsInt64, HsInt); + +HsInt64 hs_intToInt64 (HsInt); +HsInt hs_int64ToInt (HsInt64); +HsWord64 hs_int64ToWord64 (HsInt64); +HsWord64 hs_wordToWord64 (HsWord); +HsWord hs_word64ToWord (HsWord64); +HsInt64 hs_word64ToInt64 (HsWord64); + +HsWord64 hs_integerToWord64 (HsInt sa, StgByteArray /* Really: mp_limb_t* */ da); +HsInt64 hs_integerToInt64 (HsInt sa, StgByteArray /* Really: mp_limb_t* */ da); #endif /* SUPPORT_LONG_LONGS */ @@ -416,6 +406,9 @@ __hscore_ftruncate( int fd, off_t where ) #elif defined(HAVE__CHSIZE) return _chsize(fd,where); #else +// ToDo: we should use _chsize_s() on Windows which allows a 64-bit +// offset, but it doesn't seem to be available from mingw at this time +// --SDM (01/2008) #error at least ftruncate or _chsize functions are required to build #endif } @@ -481,36 +474,6 @@ __hscore_lstat( const char *fname, struct stat *st ) #endif } -#ifdef PATH_MAX -/* A size that will contain many path names, but not necessarily all - * (PATH_MAX is not defined on systems with unlimited path length, - * e.g. the Hurd). - */ -INLINE HsInt __hscore_long_path_size() { return PATH_MAX; } -#else -INLINE HsInt __hscore_long_path_size() { return 4096; } -#endif - -#ifdef R_OK -INLINE mode_t __hscore_R_OK() { return R_OK; } -#endif -#ifdef W_OK -INLINE mode_t __hscore_W_OK() { return W_OK; } -#endif -#ifdef X_OK -INLINE mode_t __hscore_X_OK() { return X_OK; } -#endif - -#ifdef S_IRUSR -INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; } -#endif -#ifdef S_IWUSR -INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; } -#endif -#ifdef S_IXUSR -INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; } -#endif - INLINE char * __hscore_d_name( struct dirent* d ) { @@ -531,16 +494,32 @@ __hscore_free_dirent(struct dirent *dEnt) #endif } +#if defined(__MINGW32__) +// We want the versions of stat/fstat/lseek that use 64-bit offsets, +// and you have to ask for those explicitly. Unfortunately there +// doesn't seem to be a 64-bit version of truncate/ftruncate, so while +// hFileSize and hSeek will work with large files, hSetFileSize will not. +#define stat(file,buf) _stati64(file,buf) +#define fstat(fd,buf) _fstati64(fd,buf) +typedef struct _stati64 struct_stat; +typedef off64_t stsize_t; +#else +typedef struct stat struct_stat; +typedef off_t stsize_t; +#endif + INLINE HsInt __hscore_sizeof_stat( void ) { - return sizeof(struct stat); + return sizeof(struct_stat); } -INLINE time_t __hscore_st_mtime ( struct stat* st ) { return st->st_mtime; } -INLINE off_t __hscore_st_size ( struct stat* st ) { return st->st_size; } +INLINE time_t __hscore_st_mtime ( struct_stat* st ) { return st->st_mtime; } +INLINE stsize_t __hscore_st_size ( struct_stat* st ) { return st->st_size; } #if !defined(_MSC_VER) -INLINE mode_t __hscore_st_mode ( struct stat* st ) { return st->st_mode; } +INLINE mode_t __hscore_st_mode ( struct_stat* st ) { return st->st_mode; } +INLINE mode_t __hscore_st_dev ( struct_stat* st ) { return st->st_dev; } +INLINE mode_t __hscore_st_ino ( struct_stat* st ) { return st->st_ino; } #endif #if HAVE_TERMIOS_H @@ -690,15 +669,21 @@ INLINE int __hscore_open(char *file, int how, mode_t mode) { // macros which redirect to the 64-bit-off_t versions when large file // support is enabled. // +#if defined(__MINGW32__) +INLINE off64_t __hscore_lseek(int fd, off64_t off, int whence) { + return (_lseeki64(fd,off,whence)); +} +#else INLINE off_t __hscore_lseek(int fd, off_t off, int whence) { return (lseek(fd,off,whence)); } +#endif -INLINE int __hscore_stat(char *file, struct stat *buf) { +INLINE int __hscore_stat(char *file, struct_stat *buf) { return (stat(file,buf)); } -INLINE int __hscore_fstat(int fd, struct stat *buf) { +INLINE int __hscore_fstat(int fd, struct_stat *buf) { return (fstat(fd,buf)); } @@ -736,36 +721,6 @@ INLINE void setTimevalTicks(struct timeval *p, HsWord64 usecs) } #endif /* !defined(__MINGW32__) */ -// Directory-related - -#if defined(__MINGW32__) - -/* Make sure we've got the reqd CSIDL_ constants in scope; - * w32api header files are lagging a bit in defining the full set. - */ -#if !defined(CSIDL_APPDATA) -#define CSIDL_APPDATA 0x001a -#endif -#if !defined(CSIDL_PERSONAL) -#define CSIDL_PERSONAL 0x0005 -#endif -#if !defined(CSIDL_PROFILE) -#define CSIDL_PROFILE 0x0028 -#endif -#if !defined(CSIDL_WINDOWS) -#define CSIDL_WINDOWS 0x0024 -#endif - -INLINE int __hscore_CSIDL_PROFILE() { return CSIDL_PROFILE; } -INLINE int __hscore_CSIDL_APPDATA() { return CSIDL_APPDATA; } -INLINE int __hscore_CSIDL_WINDOWS() { return CSIDL_WINDOWS; } -INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; } -#endif - -#if defined(__MINGW32__) -INLINE unsigned int __hscore_get_osver(void) { return _osver; } -#endif - /* ToDo: write a feature test that doesn't assume 'environ' to * be in scope at link-time. */ extern char** environ;