1 /* -----------------------------------------------------------------------------
2 * $Id: HsCore.h,v 1.5 2001/12/21 15:07:26 simonmar Exp $
4 * (c) The University of Glasgow 2001-2002
6 * Definitions for package `core' which are visible in Haskell land.
8 * ---------------------------------------------------------------------------*/
16 #ifdef HAVE_SYS_TYPES_H
17 #include <sys/types.h>
22 #ifdef HAVE_SYS_STAT_H
46 #if defined(HAVE_GETTIMEOFDAY)
47 # ifdef HAVE_SYS_TIME_H
48 # include <sys/time.h>
50 #elif defined(HAVE_GETCLOCK)
51 # ifdef HAVE_SYS_TIMERS_H
53 # include <sys/timers.h>
56 #if defined(HAVE_TIME_H)
59 #ifdef HAVE_SYS_TIMEB_H
60 #include <sys/timeb.h>
65 #ifdef HAVE_SYS_TIMES_H
66 #include <sys/times.h>
72 #if !defined(mingw32_TARGET_OS) && !defined(irix_TARGET_OS)
73 # if defined(HAVE_SYS_RESOURCE_H)
74 # include <sys/resource.h>
79 #include <sys/syscall.h>
80 #define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
81 #define HAVE_GETRUSAGE
85 #ifdef HAVE_SYS_WAIT_H
94 #include "PrelIOUtils.h"
105 HsInt systemCmd(HsAddr cmd);
107 /* in inputReady.c */
108 int inputReady(int fd, int msecs, int isSock);
110 /* -----------------------------------------------------------------------------
113 These functions are given as inlines here for when compiling via C,
114 but we also generate static versions into the cbits library for
115 when compiling to native code.
116 -------------------------------------------------------------------------- */
119 #define INLINE extern inline
122 INLINE int __hscore_s_isreg(m) { return S_ISREG(m); }
123 INLINE int __hscore_s_isdir(m) { return S_ISDIR(m); }
124 INLINE int __hscore_s_isfifo(m) { return S_ISFIFO(m); }
125 INLINE int __hscore_s_isblk(m) { return S_ISBLK(m); }
126 INLINE int __hscore_s_ischr(m) { return S_ISCHR(m); }
128 INLINE int __hscore_s_issock(m) { return S_ISSOCK(m); }
132 __hscore_sigemptyset( sigset_t *set )
133 { sigemptyset(set); }
136 __hscore_memcpy_dst_off( char *dst, int dst_off, char *src, size_t sz )
137 { return memcpy(dst+dst_off, src, sz); }
140 __hscore_memcpy_src_off( char *dst, char *src, int src_off, size_t sz )
141 { return memcpy(dst, src+src_off, sz); }
144 __hscore_supportsTextMode()
146 #if defined(mingw32_TARGET_OS)
147 return HS_BOOL_FALSE;
188 __hscore_setmode( HsInt fd, HsBool toBin )
191 return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
198 __hscore_PrelHandle_write( HsInt fd, HsBool isSock, HsAddr ptr,
203 return send(fd,ptr + off, sz, 0);
206 return write(fd,ptr + off, sz);
210 __hscore_PrelHandle_read( HsInt fd, HsBool isSock, HsAddr ptr,
215 return recv(fd,ptr + off, sz, 0);
218 return read(fd,ptr + off, sz);