Merge to stable, checking for interface changes.
let avail = w - r
copied <- if (count >= avail)
then do
- memcpy_ba_baoff ptr raw r (fromIntegral avail)
+ memcpy_ba_baoff ptr raw (fromIntegral r) (fromIntegral avail)
writeIORef ref buf{ bufWPtr=0, bufRPtr=0 }
return avail
else do
- memcpy_ba_baoff ptr raw r (fromIntegral count)
+ memcpy_ba_baoff ptr raw (fromIntegral r) (fromIntegral count)
writeIORef ref buf{ bufRPtr = r + count }
return count
if (size - w > count)
-- There's enough room in the buffer:
-- just copy the data in and update bufWPtr.
- then do memcpy_baoff_ba old_raw w raw (fromIntegral count)
+ then do memcpy_baoff_ba old_raw (fromIntegral w) raw (fromIntegral count)
writeIORef ref old_buf{ bufWPtr = w + count }
return ()
-- Internal Utils
foreign import ccall unsafe "__hscore_memcpy_dst_off"
- memcpy_baoff_ba :: RawBuffer -> Int -> RawBuffer -> CSize -> IO (Ptr ())
+ memcpy_baoff_ba :: RawBuffer -> CInt -> RawBuffer -> CSize -> IO (Ptr ())
foreign import ccall unsafe "__hscore_memcpy_src_off"
- memcpy_ba_baoff :: RawBuffer -> RawBuffer -> Int -> CSize -> IO (Ptr ())
+ memcpy_ba_baoff :: RawBuffer -> RawBuffer -> CInt -> CSize -> IO (Ptr ())
illegalBufferSize :: Handle -> String -> Int -> IO a
illegalBufferSize handle fn sz =
writeIORef ref buf'
return True
else do r <- throwErrnoIfMinus1Retry "hWaitForInput" $
- inputReady (haFD handle_)
- (fromIntegral msecs) (haIsStream handle_)
+ inputReady (haFD handle_)
+ (fromIntegral msecs)
+ (fromIntegral $ fromEnum $ haIsStream handle_)
return (r /= 0)
foreign import ccall safe "inputReady"
- inputReady :: CInt -> CInt -> Bool -> IO CInt
+ inputReady :: CInt -> CInt -> CInt -> IO CInt
-- ---------------------------------------------------------------------------
-- hGetChar
-- not flushing, and there's enough room in the buffer:
-- just copy the data in and update bufWPtr.
- then do memcpy_baoff_ba old_raw w raw (fromIntegral count)
+ then do memcpy_baoff_ba old_raw (fromIntegral w) raw (fromIntegral count)
writeIORef ref old_buf{ bufWPtr = w + count }
return (newEmptyBuffer raw WriteBuffer sz)
if (size - w > count)
-- There's enough room in the buffer:
-- just copy the data in and update bufWPtr.
- then do memcpy_baoff_ptr old_raw w ptr (fromIntegral count)
+ then do memcpy_baoff_ptr old_raw (fromIntegral w) ptr (fromIntegral count)
writeIORef ref old_buf{ bufWPtr = w + count }
return count
let avail = w - r
if (count == avail)
then do
- memcpy_ptr_baoff ptr raw r (fromIntegral count)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral count)
writeIORef ref buf{ bufWPtr=0, bufRPtr=0 }
return (so_far + count)
else do
if (count < avail)
then do
- memcpy_ptr_baoff ptr raw r (fromIntegral count)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral count)
writeIORef ref buf{ bufRPtr = r + count }
return (so_far + count)
else do
- memcpy_ptr_baoff ptr raw r (fromIntegral avail)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral avail)
writeIORef ref buf{ bufWPtr=0, bufRPtr=0 }
let remaining = count - avail
so_far' = so_far + avail
let avail = w - r
if (count == avail)
then do
- memcpy_ptr_baoff ptr raw r (fromIntegral count)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral count)
writeIORef ref buf{ bufWPtr=0, bufRPtr=0 }
return (so_far + count)
else do
if (count < avail)
then do
- memcpy_ptr_baoff ptr raw r (fromIntegral count)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral count)
writeIORef ref buf{ bufRPtr = r + count }
return (so_far + count)
else do
- memcpy_ptr_baoff ptr raw r (fromIntegral avail)
+ memcpy_ptr_baoff ptr raw (fromIntegral r) (fromIntegral avail)
writeIORef ref buf{ bufWPtr=0, bufRPtr=0 }
let remaining = count - avail
so_far' = so_far + avail
-- memcpy wrappers
foreign import ccall unsafe "__hscore_memcpy_src_off"
- memcpy_ba_baoff :: RawBuffer -> RawBuffer -> Int -> CSize -> IO (Ptr ())
+ memcpy_ba_baoff :: RawBuffer -> RawBuffer -> CInt -> CSize -> IO (Ptr ())
foreign import ccall unsafe "__hscore_memcpy_src_off"
- memcpy_ptr_baoff :: Ptr a -> RawBuffer -> Int -> CSize -> IO (Ptr ())
+ memcpy_ptr_baoff :: Ptr a -> RawBuffer -> CInt -> CSize -> IO (Ptr ())
foreign import ccall unsafe "__hscore_memcpy_dst_off"
- memcpy_baoff_ba :: RawBuffer -> Int -> RawBuffer -> CSize -> IO (Ptr ())
+ memcpy_baoff_ba :: RawBuffer -> CInt -> RawBuffer -> CSize -> IO (Ptr ())
foreign import ccall unsafe "__hscore_memcpy_dst_off"
- memcpy_baoff_ptr :: RawBuffer -> Int -> Ptr a -> CSize -> IO (Ptr ())
+ memcpy_baoff_ptr :: RawBuffer -> CInt -> Ptr a -> CSize -> IO (Ptr ())
-----------------------------------------------------------------------------
-- Internal Utils
foreign import ccall unsafe "HsBase.h __hscore_o_nonblock" o_NONBLOCK :: CInt
foreign import ccall unsafe "HsBase.h __hscore_o_binary" o_BINARY :: CInt
-foreign import ccall unsafe "HsBase.h __hscore_s_isreg" s_isreg :: CMode -> Bool
-foreign import ccall unsafe "HsBase.h __hscore_s_ischr" s_ischr :: CMode -> Bool
-foreign import ccall unsafe "HsBase.h __hscore_s_isblk" s_isblk :: CMode -> Bool
-foreign import ccall unsafe "HsBase.h __hscore_s_isdir" s_isdir :: CMode -> Bool
-foreign import ccall unsafe "HsBase.h __hscore_s_isfifo" s_isfifo :: CMode -> Bool
+foreign import ccall unsafe "HsBase.h __hscore_s_isreg" c_s_isreg :: CMode -> CInt
+foreign import ccall unsafe "HsBase.h __hscore_s_ischr" c_s_ischr :: CMode -> CInt
+foreign import ccall unsafe "HsBase.h __hscore_s_isblk" c_s_isblk :: CMode -> CInt
+foreign import ccall unsafe "HsBase.h __hscore_s_isdir" c_s_isdir :: CMode -> CInt
+foreign import ccall unsafe "HsBase.h __hscore_s_isfifo" c_s_isfifo :: CMode -> CInt
+
+s_isreg :: CMode -> Bool
+s_isreg cm = c_s_isreg cm /= 0
+s_ischr :: CMode -> Bool
+s_ischr cm = c_s_ischr cm /= 0
+s_isblk :: CMode -> Bool
+s_isblk cm = c_s_isblk cm /= 0
+s_isdir :: CMode -> Bool
+s_isdir cm = c_s_isdir cm /= 0
+s_isfifo :: CMode -> Bool
+s_isfifo cm = c_s_isfifo cm /= 0
foreign import ccall unsafe "HsBase.h __hscore_sizeof_stat" sizeof_stat :: Int
foreign import ccall unsafe "HsBase.h __hscore_st_mtime" st_mtime :: Ptr CStat -> IO CTime
#endif
#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
-foreign import ccall unsafe "HsBase.h __hscore_s_issock" s_issock :: CMode -> Bool
+foreign import ccall unsafe "HsBase.h __hscore_s_issock" c_s_issock :: CMode -> CInt
+s_issock :: CMode -> Bool
+s_issock cmode = c_s_issock cmode /= 0
#else
s_issock :: CMode -> Bool
s_issock cmode = False
StgWord64 stg_remWord64 (StgWord64 a, StgWord64 b) {return a % b;}
StgWord64 stg_quotWord64 (StgWord64 a, StgWord64 b) {return a / b;}
+
StgInt64 stg_remInt64 (StgInt64 a, StgInt64 b) {return a % b;}
StgInt64 stg_quotInt64 (StgInt64 a, StgInt64 b) {return a / b;}
StgInt64 stg_negateInt64 (StgInt64 a) {return -a;}
StgWord64 stg_or64 (StgWord64 a, StgWord64 b) {return a | b;}
StgWord64 stg_xor64 (StgWord64 a, StgWord64 b) {return a ^ b;}
StgWord64 stg_not64 (StgWord64 a) {return ~a;}
+
StgWord64 stg_uncheckedShiftL64 (StgWord64 a, StgInt b) {return a << b;}
StgWord64 stg_uncheckedShiftRL64 (StgWord64 a, StgInt b) {return a >> b;}
/* Right shifting of signed quantities is not portable in C, so
StgInt64 stg_uncheckedIShiftL64 (StgInt64 a, StgInt b) {return a << b;}
StgInt64 stg_uncheckedIShiftRA64 (StgInt64 a, StgInt b) {return a >> b;}
StgInt64 stg_uncheckedIShiftRL64 (StgInt64 a, StgInt b)
-{return (StgInt64) ((StgWord64) a >> b);}
+ {return (StgInt64) ((StgWord64) a >> b);}
/* Casting between longs and longer longs.
(the primops that cast from long longs to Integers
StgWord stg_word64ToWord (StgWord64 w) {return (StgWord) w;}
StgInt64 stg_word64ToInt64 (StgWord64 w) {return (StgInt64) w;}
-StgWord64 stg_integerToWord64 (I_ sa, StgByteArray /* Really: mp_limb_t* */ da)
+StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da)
{
mp_limb_t* d;
- I_ s;
+ StgInt s;
StgWord64 res;
d = (mp_limb_t *)da;
s = sa;
StgInt64 stg_integerToInt64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da)
{
mp_limb_t* d;
- I_ s;
+ StgInt s;
StgInt64 res;
d = (mp_limb_t *)da;
s = (sa);
#ifdef SUPPORT_LONG_LONGS
-StgInt stg_gtWord64 (StgWord64, StgWord64);
-StgInt stg_geWord64 (StgWord64, StgWord64);
-StgInt stg_eqWord64 (StgWord64, StgWord64);
-StgInt stg_neWord64 (StgWord64, StgWord64);
-StgInt stg_ltWord64 (StgWord64, StgWord64);
-StgInt stg_leWord64 (StgWord64, StgWord64);
-
-StgInt stg_gtInt64 (StgInt64, StgInt64);
-StgInt stg_geInt64 (StgInt64, StgInt64);
-StgInt stg_eqInt64 (StgInt64, StgInt64);
-StgInt stg_neInt64 (StgInt64, StgInt64);
-StgInt stg_ltInt64 (StgInt64, StgInt64);
-StgInt stg_leInt64 (StgInt64, StgInt64);
+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);
StgWord64 stg_uncheckedShiftL64 (StgWord64, StgInt);
StgWord64 stg_uncheckedShiftRL64 (StgWord64, StgInt);
StgInt64 stg_uncheckedIShiftL64 (StgInt64, StgInt);
-StgInt64 stg_uncheckedIShiftRL64 (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);
-StgInt64 stg_integerToInt64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da);
StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da);
+StgInt64 stg_integerToInt64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da);
#endif /* SUPPORT_LONG_LONGS */
INLINE void __hscore_set_errno(int e) { errno = e; }
#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); }
-INLINE int __hscore_s_isblk(m) { return S_ISBLK(m); }
-INLINE int __hscore_s_ischr(m) { return S_ISCHR(m); }
+INLINE int __hscore_s_isreg(mode_t m) { return S_ISREG(m); }
+INLINE int __hscore_s_isdir(mode_t m) { return S_ISDIR(m); }
+INLINE int __hscore_s_isfifo(mode_t m) { return S_ISFIFO(m); }
+INLINE int __hscore_s_isblk(mode_t m) { return S_ISBLK(m); }
+INLINE int __hscore_s_ischr(mode_t m) { return S_ISCHR(m); }
#ifdef S_ISSOCK
-INLINE int __hscore_s_issock(m) { return S_ISSOCK(m); }
+INLINE int __hscore_s_issock(mode_t m) { return S_ISSOCK(m); }
#endif
#endif
return BUFSIZ;
}
-INLINE HsInt
+INLINE int
__hscore_seek_cur()
{
return SEEK_CUR;
}
-INLINE HsInt
+INLINE int
__hscore_o_binary()
{
#if defined(_MSC_VER)
#endif
}
-INLINE HsInt
+INLINE int
__hscore_seek_set( void )
{
return SEEK_SET;
}
-INLINE HsInt
+INLINE int
__hscore_seek_end( void )
{
return SEEK_END;
#endif
}
-INLINE HsInt
-__hscore_setmode( HsInt fd, HsBool toBin )
+INLINE int
+__hscore_setmode( int fd, HsBool toBin )
{
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
#if __GLASGOW_HASKELL__
-INLINE HsInt
-__hscore_PrelHandle_write( HsInt fd, HsAddr ptr, HsInt off, int sz )
+INLINE int
+__hscore_PrelHandle_write( int fd, void *ptr, HsInt off, int sz )
{
return write(fd,(char *)ptr + off, sz);
}
-INLINE HsInt
-__hscore_PrelHandle_read( HsInt fd, HsAddr ptr, HsInt off, int sz )
+INLINE int
+__hscore_PrelHandle_read( int fd, void *ptr, HsInt off, int sz )
{
return read(fd,(char *)ptr + off, sz);
}
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-INLINE HsInt
-__hscore_PrelHandle_send( HsInt fd, HsAddr ptr, HsInt off, int sz )
+INLINE int
+__hscore_PrelHandle_send( int fd, void *ptr, HsInt off, int sz )
{
return send(fd,(char *)ptr + off, sz, 0);
}
-INLINE HsInt
-__hscore_PrelHandle_recv( HsInt fd, HsAddr ptr, HsInt off, int sz )
+INLINE int
+__hscore_PrelHandle_recv( int fd, void *ptr, HsInt off, int sz )
{
return recv(fd,(char *)ptr + off, sz, 0);
}
#endif /* __GLASGOW_HASKELL__ */
-INLINE HsInt
-__hscore_mkdir( HsAddr pathName, HsInt mode )
+INLINE int
+__hscore_mkdir( char *pathName, int mode )
{
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
return mkdir(pathName);
#endif
}
-INLINE HsInt
-__hscore_lstat( HsAddr fname, HsAddr st )
+INLINE int
+__hscore_lstat( const char *fname, struct stat *st )
{
#if HAVE_LSTAT
- return lstat((const char*)fname, (struct stat*)st);
+ return lstat(fname, st);
#else
- return stat((const char*)fname, (struct stat*)st);
+ return stat(fname, st);
#endif
}
INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
#endif
-INLINE HsAddr
+INLINE char *
__hscore_d_name( struct dirent* d )
{
- return (HsAddr)(d->d_name);
+ return (d->d_name);
}
-INLINE HsInt
+INLINE int
__hscore_end_of_dir( void )
{
return READDIR_ERRNO_EOF;
}
INLINE void
-__hscore_free_dirent(HsAddr dEnt)
+__hscore_free_dirent(struct dirent *dEnt)
{
#if HAVE_READDIR_R
free(dEnt);
INLINE void hsFD_CLR(int fd, fd_set *fds) { FD_CLR(fd, fds); }
INLINE int hsFD_ISSET(int fd, fd_set *fds) { return FD_ISSET(fd, fds); }
INLINE void hsFD_SET(int fd, fd_set *fds) { FD_SET(fd, fds); }
-INLINE int sizeof_fd_set(void) { return sizeof(fd_set); }
+INLINE HsInt sizeof_fd_set(void) { return sizeof(fd_set); }
extern void hsFD_ZERO(fd_set *fds);
#endif