X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=include%2FHsBase.h;h=b92303a457b6e9e817c52dd762fa74954c6367cc;hb=f3dac5d39fabca642d74ebc321361960df7aa943;hp=7f2e63369142cc6df5855d2a1ca11aad06c2cb3e;hpb=040c3ce8ddfe84ff3f7a539bdc0f1f70e83ea5e3;p=haskell-directory.git diff --git a/include/HsBase.h b/include/HsBase.h index 7f2e633..b92303a 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -1,14 +1,14 @@ /* ----------------------------------------------------------------------------- - * $Id: HsBase.h,v 1.16 2002/10/03 13:04:58 panne Exp $ + * $Id: HsBase.h,v 1.32 2003/10/13 05:09:40 sof Exp $ * * (c) The University of Glasgow 2001-2002 * - * Definitions for package `core' which are visible in Haskell land. + * Definitions for package `base' which are visible in Haskell land. * * ---------------------------------------------------------------------------*/ -#ifndef HSCORE_H -#define HSCORE_H +#ifndef __HSBASE_H__ +#define __HSBASE_H__ #include "config.h" #include "HsFFI.h" @@ -78,6 +78,9 @@ #ifdef HAVE_LIMITS_H #include #endif +#ifdef HAVE_WCTYPE_H +#include +#endif #if !defined(mingw32_TARGET_OS) && !defined(irix_TARGET_OS) # if defined(HAVE_SYS_RESOURCE_H) @@ -114,7 +117,11 @@ int *ghcErrno(void); HsInt systemCmd(HsAddr cmd); /* in rawSystem.c */ -HsInt rawSystemCmd(HsAddr cmd); +#if defined(mingw32_TARGET_OS) +HsInt rawSystem(HsAddr cmd); +#else +HsInt rawSystem(HsAddr cmd, HsAddr args); +#endif /* in inputReady.c */ int inputReady(int fd, int msecs, int isSock); @@ -122,6 +129,9 @@ int inputReady(int fd, int msecs, int isSock); /* in writeError.c */ void writeErrString__(HsAddr msg_hdr, HsAddr msg, HsInt len); +/* in Signals.c */ +extern HsInt nocldstop; + /* ----------------------------------------------------------------------------- 64-bit operations, defined in longlong.c -------------------------------------------------------------------------- */ @@ -185,9 +195,14 @@ StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ -------------------------------------------------------------------------- */ #ifndef INLINE -#define INLINE extern inline +# if defined(_MSC_VER) +# define INLINE extern __inline +# else +# define INLINE extern inline +# endif #endif +#if !defined(_MSC_VER) INLINE int __hscore_s_isreg(m) { return S_ISREG(m); } INLINE int __hscore_s_isdir(m) { return S_ISDIR(m); } INLINE int __hscore_s_isfifo(m) { return S_ISFIFO(m); } @@ -196,8 +211,9 @@ INLINE int __hscore_s_ischr(m) { return S_ISCHR(m); } #ifdef S_ISSOCK INLINE int __hscore_s_issock(m) { return S_ISSOCK(m); } #endif +#endif -#ifndef mingw32_TARGET_OS +#if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER) && !defined(__MINGW32__) INLINE int __hscore_sigemptyset( sigset_t *set ) { return sigemptyset(set); } @@ -252,10 +268,10 @@ __hscore_seek_cur() INLINE HsInt __hscore_o_binary() { -#ifdef HAVE_O_BINARY +#if defined(_MSC_VER) return O_BINARY; #else - return 0; + return CONST_O_BINARY; #endif } @@ -377,10 +393,10 @@ __hscore_PrelHandle_write( HsInt fd, HsBool isSock, HsAddr ptr, { #if defined(__MINGW32__) if (isSock) { - return send(fd,ptr + off, sz, 0); + return send(fd,(char *)ptr + off, sz, 0); } #endif - return write(fd,ptr + off, sz); + return write(fd,(char *)ptr + off, sz); } INLINE HsInt @@ -389,10 +405,10 @@ __hscore_PrelHandle_read( HsInt fd, HsBool isSock, HsAddr ptr, { #if defined(__MINGW32__) if (isSock) { - return recv(fd,ptr + off, sz, 0); + return recv(fd,(char *)ptr + off, sz, 0); } #endif - return read(fd,ptr + off, sz); + return read(fd,(char *)ptr + off, sz); } @@ -424,25 +440,47 @@ __hscore_lstat( HsAddr fname, HsAddr st ) #endif } -INLINE HsInt __hscore_path_max() { return PATH_MAX; } +#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 +#if !defined(_MSC_VER) INLINE HsAddr __hscore_d_name( struct dirent* d ) { -#ifndef mingw32_TARGET_OS +#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__) return (HsAddr)(&d->d_name); #else return (HsAddr)(d->d_name); #endif } +#endif INLINE HsInt __hscore_end_of_dir( void ) @@ -470,7 +508,9 @@ __hscore_sizeof_stat( void ) 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; } +#if !defined(_MSC_VER) INLINE mode_t __hscore_st_mode ( struct stat* st ) { return st->st_mode; } +#endif #if HAVE_TERMIOS_H INLINE tcflag_t __hscore_lflag( struct termios* ts ) { return ts->c_lflag; } @@ -481,7 +521,6 @@ __hscore_poke_lflag( struct termios* ts, tcflag_t t ) { ts->c_lflag = t; } INLINE unsigned char* __hscore_ptr_c_cc( struct termios* ts ) { return (unsigned char*) &ts->c_cc; } -#endif INLINE HsInt __hscore_sizeof_termios( void ) @@ -492,7 +531,9 @@ __hscore_sizeof_termios( void ) return 0; #endif } +#endif +#if !defined(_MSC_VER) && !defined(__MINGW32__) INLINE HsInt __hscore_sizeof_sigset_t( void ) { @@ -502,6 +543,7 @@ __hscore_sizeof_sigset_t( void ) return 0; #endif } +#endif INLINE int __hscore_echo( void ) @@ -600,9 +642,13 @@ __hscore_f_setfl( void ) #endif } +// defined in rts/RtsStartup.c. +extern void* __hscore_get_saved_termios(int fd); +extern void __hscore_set_saved_termios(int fd, void* ts); + INLINE int __hscore_hs_fileno (FILE *f) { return fileno (f); } -#ifndef mingw32_TARGET_OS +#if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER) && !defined(__MINGW32__) INLINE int __hsposix_SIGABRT() { return SIGABRT; } INLINE int __hsposix_SIGALRM() { return SIGALRM; } INLINE int __hsposix_SIGBUS() { return SIGBUS; } @@ -623,7 +669,9 @@ INLINE int __hsposix_SIGTTIN() { return SIGTTIN; } INLINE int __hsposix_SIGTTOU() { return SIGTTOU; } INLINE int __hsposix_SIGUSR1() { return SIGUSR1; } INLINE int __hsposix_SIGUSR2() { return SIGUSR2; } +#if HAVE_SIGPOLL INLINE int __hsposix_SIGPOLL() { return SIGPOLL; } +#endif INLINE int __hsposix_SIGPROF() { return SIGPROF; } INLINE int __hsposix_SIGSYS() { return SIGSYS; } INLINE int __hsposix_SIGTRAP() { return SIGTRAP; } @@ -635,7 +683,7 @@ INLINE int __hsposix_SIGXFSZ() { return SIGXFSZ; } INLINE int __hsposix_SIG_BLOCK() { return SIG_BLOCK; } INLINE int __hsposix_SIG_UNBLOCK() { return SIG_SETMASK; } INLINE int __hsposix_SIG_SETMASK() { return SIG_UNBLOCK; } -#endif // mingw32_TARGET_OS +#endif /* mingw32_TARGET_OS */ -#endif +#endif /* __HSBASE_H__ */