[project @ 2001-09-14 11:25:57 by simonmar]
[haskell-directory.git] / include / HsCore.h
1 /* -----------------------------------------------------------------------------
2  * $Id: HsCore.h,v 1.4 2001/09/14 11:25:57 simonmar Exp $
3  *
4  * Definitions for package `core' which are visible in Haskell land.
5  *
6  * ---------------------------------------------------------------------------*/
7
8 #ifndef HSCORE_H
9 #define HSCORE_H
10
11 #include "config.h"
12 #include "HsFFI.h"
13
14 #ifdef HAVE_SYS_TYPES_H
15 #include <sys/types.h>
16 #endif
17 #ifdef HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20 #ifdef HAVE_SYS_STAT_H
21 #include <sys/stat.h>
22 #endif
23 #ifdef HAVE_FCNTL_H
24 # include <fcntl.h>
25 #endif
26 #ifdef HAVE_TERMIOS_H
27 #include <termios.h>
28 #endif
29 #ifdef HAVE_SIGNAL_H
30 #include <signal.h>
31 #endif
32 #ifdef HAVE_ERRNO_H
33 #include <errno.h>
34 #endif
35 #ifdef HAVE_STRING_H
36 #include <string.h>
37 #endif
38 #ifdef HAVE_DIRENT_H
39 #include <dirent.h>
40 #endif
41 #ifdef HAVE_UTIME_H
42 #include <utime.h>
43 #endif
44 #if defined(HAVE_GETTIMEOFDAY)
45 #  ifdef HAVE_SYS_TIME_H
46 #   include <sys/time.h>
47 #  endif
48 #elif defined(HAVE_GETCLOCK)
49 # ifdef HAVE_SYS_TIMERS_H
50 #  define POSIX_4D9 1
51 #  include <sys/timers.h>
52 # endif
53 #endif
54 #if defined(HAVE_TIME_H)
55 # include <time.h>
56 #endif
57 #ifdef HAVE_SYS_TIMEB_H
58 #include <sys/timeb.h>
59 #endif
60 #ifdef HAVE_WINDOWS_H
61 #include <windows.h>
62 #endif
63 #ifdef HAVE_SYS_TIMES_H
64 #include <sys/times.h>
65 #endif
66
67 #if !defined(mingw32_TARGET_OS) && !defined(irix_TARGET_OS)
68 # if defined(HAVE_SYS_RESOURCE_H)
69 #  include <sys/resource.h>
70 # endif
71 #endif
72
73 #ifdef hpux_TARGET_OS
74 #include <sys/syscall.h>
75 #define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
76 #define HAVE_GETRUSAGE
77 #endif
78
79 /* For System */
80 #ifdef HAVE_SYS_WAIT_H
81 #include <sys/wait.h>
82 #endif
83 #ifdef HAVE_VFORK_H
84 #include <vfork.h>
85 #endif
86
87 extern inline int s_isreg_wrap(m)  { return S_ISREG(m);  }
88 extern inline int s_isdir_wrap(m)  { return S_ISDIR(m);  }
89 extern inline int s_isfifo_wrap(m) { return S_ISFIFO(m); }
90 extern inline int s_isblk_wrap(m)  { return S_ISBLK(m);  }
91 extern inline int s_ischr_wrap(m)  { return S_ISCHR(m);  }
92 #ifdef S_ISSOCK
93 extern inline int s_issock_wrap(m) { return S_ISSOCK(m); }
94 #endif
95
96 extern inline void *
97 memcpy_wrap_dst_off(char *dst, int dst_off, char *src, size_t sz)
98 { return memcpy(dst+dst_off, src, sz); }
99
100 extern inline void *
101 memcpy_wrap_src_off(char *dst, char *src, int src_off, size_t sz)
102 { return memcpy(dst, src+src_off, sz); }
103
104 extern inline int
105 read_ba_wrap(int fd, void *ptr, HsInt off, int size)
106 { return read(fd, ptr + off, size); }
107
108 extern inline int
109 write_wrap(int fd, void *ptr, HsInt off, int size)
110 { return write(fd, ptr + off, size); }
111
112 extern inline int
113 read_wrap(int fd, void *ptr, HsInt off, int size)
114 { return read(fd, ptr + off, size); }
115
116 #include "lockFile.h"
117
118 #include "HsFFI.h"
119
120 /* in ghc_errno.c */
121 int *ghcErrno(void);
122
123 /* in system.c */
124 HsInt systemCmd(HsAddr cmd);
125
126 /* in inputReady.c */
127 int inputReady(int fd, int msecs);
128
129 #endif