/* ----------------------------------------------------------------------------- * * (c) The University of Glasgow 2002 * * Definitions for package `unix' which are visible in Haskell land. * * ---------------------------------------------------------------------------*/ #ifndef HSUNIX_H #define HSUNIX_H #include "HsUnixConfig.h" /* ultra-evil... */ #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME #undef PACKAGE_STRING #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #ifdef solaris2_HOST_OS #define _POSIX_PTHREAD_SEMANTICS #endif #include #include #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_SYS_TIMES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_RESOURCE_H #include #endif #ifdef HAVE_SYS_WAIT_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_TIME_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_UTIME_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_TERMIOS_H #include #endif #ifdef HAVE_SYS_UTSNAME_H #include #endif #ifdef HAVE_PWD_H #include #endif #ifdef HAVE_GRP_H #include #endif #ifdef HAVE_DIRENT_H #include #endif #ifdef HAVE_LIBUTIL_H #include #endif #ifdef HAVE_PTY_H #include #endif #ifdef HAVE_UTMP_H #include #endif #include #ifdef HAVE_SIGNAL_H #include #endif extern char **environ; #ifndef INLINE # if defined(__GNUC__) # define INLINE extern inline # else # define INLINE inline # endif #endif INLINE int __hsunix_wifexited (int stat) { return WIFEXITED(stat); } INLINE int __hsunix_wexitstatus (int stat) { return WEXITSTATUS(stat); } INLINE int __hsunix_wifsignaled (int stat) { return WIFSIGNALED(stat); } INLINE int __hsunix_wtermsig (int stat) { return WTERMSIG(stat); } INLINE int __hsunix_wifstopped (int stat) { return WIFSTOPPED(stat); } INLINE int __hsunix_wstopsig (int stat) { return WSTOPSIG(stat); } #ifdef HAVE_RTLDNEXT INLINE void *__hsunix_rtldNext (void) {return RTLD_NEXT;} #endif #ifdef HAVE_RTLDDEFAULT INLINE void *__hsunix_rtldDefault (void) {return RTLD_DEFAULT;} #endif /* O_SYNC doesn't exist on Mac OS X and (at least some versions of) FreeBSD, fall back to O_FSYNC, which should be the same */ #ifndef O_SYNC #define O_SYNC O_FSYNC #endif #ifdef SIGINFO INLINE int __hsunix_SIGINFO() { return SIGINFO; } #endif #ifdef SIGWINCH INLINE int __hsunix_SIGWINCH() { return SIGWINCH; } #endif // lstat is a macro on some platforms, so we need a wrapper: INLINE int __hsunix_lstat(const char *path, struct stat *buf) { return lstat(path,buf); } // lstat is a macro on some platforms, so we need a wrapper: INLINE int __hsunix_mknod(const char *pathname, mode_t mode, dev_t dev) { return mknod(pathname,mode,dev); } #ifdef HAVE_PTSNAME // I cannot figure out how to make the definitions of the following // functions visible in on Linux. But these definitions // follow the POSIX specs, and everything links and runs. INLINE char *__hsunix_ptsname(int fd) { extern char *ptsname(int); return ptsname(fd); } INLINE int __hsunix_grantpt(int fd) { extern int grantpt(int); return grantpt(fd); } INLINE int __hsunix_unlockpt(int fd) { extern int unlockpt(int); return unlockpt(fd); } #endif // push a SVR4 STREAMS module; do nothing if STREAMS not available INLINE int __hsunix_push_module(int fd, const char *module) { #if defined(I_PUSH) && !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC) return ioctl(fd, I_PUSH, module); #else return 0; #endif } #endif