1 /* -----------------------------------------------------------------------------
2 * $Id: HsCore.h,v 1.6 2002/01/02 14:40:11 simonmar Exp $
4 * (c) The University of Glasgow 2001-2002
6 * Definitions for package `core' which are visible in Haskell land.
8 * ---------------------------------------------------------------------------*/
18 #ifdef HAVE_SYS_TYPES_H
19 #include <sys/types.h>
24 #ifdef HAVE_SYS_STAT_H
48 #if defined(HAVE_GETTIMEOFDAY)
49 # ifdef HAVE_SYS_TIME_H
50 # include <sys/time.h>
52 #elif defined(HAVE_GETCLOCK)
53 # ifdef HAVE_SYS_TIMERS_H
55 # include <sys/timers.h>
58 #if defined(HAVE_TIME_H)
61 #ifdef HAVE_SYS_TIMEB_H
62 #include <sys/timeb.h>
67 #ifdef HAVE_SYS_TIMES_H
68 #include <sys/times.h>
74 #if !defined(mingw32_TARGET_OS) && !defined(irix_TARGET_OS)
75 # if defined(HAVE_SYS_RESOURCE_H)
76 # include <sys/resource.h>
81 #include <sys/syscall.h>
82 #define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
83 #define HAVE_GETRUSAGE
87 #ifdef HAVE_SYS_WAIT_H
106 HsInt systemCmd(HsAddr cmd);
108 /* in inputReady.c */
109 int inputReady(int fd, int msecs, int isSock);
111 /* -----------------------------------------------------------------------------
114 These functions are given as inlines here for when compiling via C,
115 but we also generate static versions into the cbits library for
116 when compiling to native code.
117 -------------------------------------------------------------------------- */
120 #define INLINE extern inline
123 INLINE int __hscore_s_isreg(m) { return S_ISREG(m); }
124 INLINE int __hscore_s_isdir(m) { return S_ISDIR(m); }
125 INLINE int __hscore_s_isfifo(m) { return S_ISFIFO(m); }
126 INLINE int __hscore_s_isblk(m) { return S_ISBLK(m); }
127 INLINE int __hscore_s_ischr(m) { return S_ISCHR(m); }
129 INLINE int __hscore_s_issock(m) { return S_ISSOCK(m); }
132 #ifndef mingw32_TARGET_OS
134 __hscore_sigemptyset( sigset_t *set )
135 { sigemptyset(set); }
139 __hscore_memcpy_dst_off( char *dst, int dst_off, char *src, size_t sz )
140 { return memcpy(dst+dst_off, src, sz); }
143 __hscore_memcpy_src_off( char *dst, char *src, int src_off, size_t sz )
144 { return memcpy(dst, src+src_off, sz); }
147 __hscore_supportsTextMode()
149 #if defined(mingw32_TARGET_OS)
150 return HS_BOOL_FALSE;
191 __hscore_setmode( HsInt fd, HsBool toBin )
194 return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
201 __hscore_PrelHandle_write( HsInt fd, HsBool isSock, HsAddr ptr,
206 return send(fd,ptr + off, sz, 0);
209 return write(fd,ptr + off, sz);
213 __hscore_PrelHandle_read( HsInt fd, HsBool isSock, HsAddr ptr,
218 return recv(fd,ptr + off, sz, 0);
221 return read(fd,ptr + off, sz);