Porting GHC to Barrelfish: base.patch

File base.patch, 25.6 KB (added by rmcilroy, 5 years ago)

Patch for base library

  • base.cabal

    Wed Aug 11 10:56:14 BST 2010  [email protected]
      * Checkpoint GHC on Barrelfish work 
      
      Now at the stage where we can build and run a helloword Haskell application on Barrelfish.
      
    Mon Aug  9 13:43:09 BST 2010  [email protected]
      * missing files from previous checkpoint of barrelfish port
    Mon Aug  9 10:49:44 BST 2010  [email protected]
      * Checkpoint barrelfish compatability changes
    Thu Jul 29 14:55:54 BST 2010  [email protected]
      * Changes to get ghc building against Barrelfish
    diff -rN -u old-base/base.cabal new-base/base.cabal
    old new  
    204204        cbits/inputReady.c 
    205205        cbits/selectUtils.c 
    206206        cbits/primFloat.c 
     207        cbits/BFishUtils.c 
    207208    include-dirs: include 
    208209    includes:    HsBase.h 
    209210    install-includes:    HsBase.h HsBaseConfig.h WCsubst.h consUtils.h Typeable.h 
  • cbits/BFishUtils.c

    diff -rN -u old-base/cbits/BFishUtils.c new-base/cbits/BFishUtils.c
    old new  
     1/* ---------------------------------------------------------------------------- 
     2   (c) The University of Glasgow 2006 
     3    
     4   Useful Barrelfish bits 
     5   ------------------------------------------------------------------------- */ 
     6 
     7#include "HsBase.h" 
     8 
     9#ifdef barrelfish_HOST_OS 
     10 
     11HsWord64 getUSecOfDay(void) 
     12{ 
     13    printf("NYI getUSecOfDay\n"); 
     14    return 0; 
     15} 
     16 
     17#endif 
  • cbits/iconv.c

    diff -rN -u old-base/cbits/iconv.c new-base/cbits/iconv.c
    old new  
    1 #ifndef __MINGW32__ 
     1#if !defined(__MINGW32__) && !defined(BARRELFISH) 
    22 
    33#include <stdlib.h> 
    44#include <iconv.h> 
  • cbits/inputReady.c

    diff -rN -u old-base/cbits/inputReady.c new-base/cbits/inputReady.c
    old new  
    1616int 
    1717fdReady(int fd, int write, int msecs, int isSock) 
    1818{ 
     19 
     20#ifdef BARRELFISH 
     21    return 1;   // Currently just return 1, look into this in the future 
     22#else 
     23 
    1924    if  
    2025#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) 
    2126    ( isSock ) { 
     
    165170        } 
    166171    } 
    167172#endif 
     173#endif 
    168174}     
  • cbits/PrelIOUtils.c

    diff -rN -u old-base/cbits/PrelIOUtils.c new-base/cbits/PrelIOUtils.c
    old new  
    3030#  include <langinfo.h> 
    3131#endif 
    3232 
    33 #if !defined(mingw32_HOST_OS) 
     33#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    3434const char* localeEncoding(void) 
    3535{ 
    3636#if defined(HAVE_LIBCHARSET) 
  • cbits/WCsubst.c

    diff -rN -u old-base/cbits/WCsubst.c new-base/cbits/WCsubst.c
    old new  
    40664066        int numblocks, 
    40674067        int unichar) 
    40684068{ 
     4069#ifdef BARRELFISH 
     4070        return NULL; 
     4071#else 
    40694072        struct _charblock_ key={unichar,1,(void *)0}; 
    40704073        struct _charblock_ *cb=bsearch(&key,blocks,numblocks,sizeof(key),blkcmp); 
    40714074        if(cb==(void *)0) return &nullrule; 
    40724075        return cb->rule; 
     4076#endif 
    40734077} 
    40744078         
    40754079 
  • config.sub

    diff -rN -u old-base/config.sub new-base/config.sub
    old new  
    44#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, 
    55#   Inc. 
    66 
    7 timestamp='2006-07-02' 
     7timestamp='2010-08-10' 
    88 
    99# This file is (in principle) common to ALL GNU software. 
    1010# The presence of a machine in this file suggests that SOME GNU software 
     
    13441344        -zvmoe) 
    13451345                os=-zvmoe 
    13461346                ;; 
     1347        -barrelfish) 
     1348                os=-barrelfish 
     1349                ;; 
    13471350        -none) 
    13481351                ;; 
    13491352        *) 
  • configure.ac

    diff -rN -u old-base/configure.ac new-base/configure.ac
    old new  
    5252AC_SUBST(ICONV_LIB_DIRS) 
    5353 
    5454# map standard C types and ISO types to Haskell types 
    55 FPTOOLS_CHECK_HTYPE(char) 
    56 FPTOOLS_CHECK_HTYPE(signed char) 
    57 FPTOOLS_CHECK_HTYPE(unsigned char) 
    58 FPTOOLS_CHECK_HTYPE(short) 
    59 FPTOOLS_CHECK_HTYPE(unsigned short) 
    60 FPTOOLS_CHECK_HTYPE(int) 
    61 FPTOOLS_CHECK_HTYPE(unsigned int) 
    62 FPTOOLS_CHECK_HTYPE(long) 
    63 FPTOOLS_CHECK_HTYPE(unsigned long) 
     55FPTOOLS_CHECK_HTYPE(char, , Int8) 
     56FPTOOLS_CHECK_HTYPE(signed char, , Int8) 
     57FPTOOLS_CHECK_HTYPE(unsigned char, , Word8) 
     58FPTOOLS_CHECK_HTYPE(short, , Int16) 
     59FPTOOLS_CHECK_HTYPE(unsigned short, , Word16) 
     60FPTOOLS_CHECK_HTYPE(int, , Int32) 
     61FPTOOLS_CHECK_HTYPE(unsigned int, , Word32) 
     62FPTOOLS_CHECK_HTYPE(long, , Int64) 
     63FPTOOLS_CHECK_HTYPE(unsigned long, , Word64) 
    6464if test "$ac_cv_type_long_long" = yes; then 
    65 FPTOOLS_CHECK_HTYPE(long long) 
    66 FPTOOLS_CHECK_HTYPE(unsigned long long) 
     65FPTOOLS_CHECK_HTYPE(long long, , Int64) 
     66FPTOOLS_CHECK_HTYPE(unsigned long long, , Word64) 
    6767fi 
    68 FPTOOLS_CHECK_HTYPE(float) 
    69 FPTOOLS_CHECK_HTYPE(double) 
    70 FPTOOLS_CHECK_HTYPE(ptrdiff_t) 
    71 FPTOOLS_CHECK_HTYPE(size_t) 
    72 FPTOOLS_CHECK_HTYPE(wchar_t) 
     68FPTOOLS_CHECK_HTYPE(float, , Float) 
     69FPTOOLS_CHECK_HTYPE(double, , Double) 
     70FPTOOLS_CHECK_HTYPE(ptrdiff_t, , Int64) 
     71FPTOOLS_CHECK_HTYPE(size_t, , Word64) 
     72FPTOOLS_CHECK_HTYPE(wchar_t, , Int32) 
    7373# Int32 is a HACK for non-ISO C compilers 
    74 FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32) 
    75 FPTOOLS_CHECK_HTYPE(clock_t) 
    76 FPTOOLS_CHECK_HTYPE(time_t) 
    77 FPTOOLS_CHECK_HTYPE(dev_t, Word32) 
    78 FPTOOLS_CHECK_HTYPE(ino_t) 
    79 FPTOOLS_CHECK_HTYPE(mode_t) 
    80 FPTOOLS_CHECK_HTYPE(off_t) 
    81 FPTOOLS_CHECK_HTYPE(pid_t) 
    82 FPTOOLS_CHECK_HTYPE(gid_t) 
    83 FPTOOLS_CHECK_HTYPE(uid_t) 
    84 FPTOOLS_CHECK_HTYPE(cc_t) 
    85 FPTOOLS_CHECK_HTYPE(speed_t) 
     74FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32, Int32) 
     75FPTOOLS_CHECK_HTYPE(clock_t, , Int64) 
     76FPTOOLS_CHECK_HTYPE(time_t, , Int64) 
     77FPTOOLS_CHECK_HTYPE(dev_t, Word32, Int64) 
     78FPTOOLS_CHECK_HTYPE(ino_t, , Int64) 
     79FPTOOLS_CHECK_HTYPE(mode_t, , Int32) 
     80FPTOOLS_CHECK_HTYPE(off_t, , Word64) 
     81FPTOOLS_CHECK_HTYPE(pid_t, , Word32) 
     82FPTOOLS_CHECK_HTYPE(gid_t, , Word32) 
     83FPTOOLS_CHECK_HTYPE(uid_t, , Word32) 
     84FPTOOLS_CHECK_HTYPE(cc_t, , Word32) 
     85FPTOOLS_CHECK_HTYPE(speed_t, , Word32) 
    8686FPTOOLS_CHECK_HTYPE(tcflag_t) 
    87 FPTOOLS_CHECK_HTYPE(nlink_t) 
    88 FPTOOLS_CHECK_HTYPE(ssize_t) 
     87FPTOOLS_CHECK_HTYPE(nlink_t, , Word32) 
     88FPTOOLS_CHECK_HTYPE(ssize_t, , Word32) 
    8989FPTOOLS_CHECK_HTYPE(rlim_t) 
    9090FPTOOLS_CHECK_HTYPE(wint_t) 
    9191 
    92 FPTOOLS_CHECK_HTYPE(intptr_t) 
    93 FPTOOLS_CHECK_HTYPE(uintptr_t) 
     92FPTOOLS_CHECK_HTYPE(intptr_t, , Int64) 
     93FPTOOLS_CHECK_HTYPE(uintptr_t, , Word64) 
    9494# Workaround for OSes that don't have intmax_t and uintmax_t, e.g. OpenBSD. 
    9595if test "$ac_cv_type_long_long" = yes; then 
    9696  fptools_cv_default_htype_intmax=$fptools_cv_htype_long_long 
     
    9999  fptools_cv_default_htype_intmax=$fptools_cv_htype_long 
    100100  fptools_cv_default_htype_uintmax=$fptools_cv_htype_unsigned_long 
    101101fi 
    102 FPTOOLS_CHECK_HTYPE(intmax_t, $fptools_cv_default_htype_intmax) 
    103 FPTOOLS_CHECK_HTYPE(uintmax_t, $fptools_cv_default_htype_uintmax) 
     102FPTOOLS_CHECK_HTYPE(intmax_t, $fptools_cv_default_htype_intmax, Int64) 
     103FPTOOLS_CHECK_HTYPE(uintmax_t, $fptools_cv_default_htype_uintmax, Word64) 
    104104 
    105105# test errno values 
    106106FP_CHECK_CONSTS([E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EADV EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBADRPC EBUSY ECHILD ECOMM ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDIRTY EDOM EDQUOT EEXIST EFAULT EFBIG EFTYPE EHOSTDOWN EHOSTUNREACH EIDRM EILSEQ EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENONET ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE EPROCLIM EPROCUNAVAIL EPROGMISMATCH EPROGUNAVAIL EPROTO EPROTONOSUPPORT EPROTOTYPE ERANGE EREMCHG EREMOTE EROFS ERPCMISMATCH ERREMOTE ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESRMNT ESTALE ETIME ETIMEDOUT ETOOMANYREFS ETXTBSY EUSERS EWOULDBLOCK EXDEV ENOCIGAR], [#include <stdio.h> 
     
    121121# to give prototype text. 
    122122FP_SEARCH_LIBS_PROTO(iconv, 
    123123                     [ 
     124#ifndef BARRELFISH 
    124125#include <stddef.h> 
    125126#include <iconv.h> 
     127#endif 
    126128                      ], 
    127                      [iconv_t cd; 
     129                     [#ifndef BARRELFISH 
     130                      iconv_t cd; 
    128131                      cd = iconv_open("", ""); 
    129132                      iconv(cd,NULL,NULL,NULL,NULL); 
    130                       iconv_close(cd);], 
     133                      iconv_close(cd); 
     134                      #endif 
     135                      ], 
    131136                     iconv, 
    132137                     [EXTRA_LIBS="$EXTRA_LIBS $ac_lib"], 
    133138                     [case `uname -s` in 
  • GHC/Conc.lhs

    diff -rN -u old-base/GHC/Conc.lhs new-base/GHC/Conc.lhs
    old new  
    8080        , asyncWriteBA  -- :: Int -> Int -> Int -> Int -> MutableByteArray# RealWorld -> IO (Int, Int) 
    8181#endif 
    8282 
    83 #ifndef mingw32_HOST_OS 
    84         , Signal, HandlerFun, setHandler, runHandlers 
     83#if !defined(mingw32_HOST_OS) 
     84        , Signal 
     85#endif 
     86#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
     87        , HandlerFun, setHandler, runHandlers 
    8588#endif 
    8689 
    8790        , ensureIOManagerIsRunning 
    88 #ifndef mingw32_HOST_OS 
     91#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    8992        , syncIOManager 
    9093#endif 
    9194 
     
    101104        ) where 
    102105 
    103106import System.Posix.Types 
    104 #ifndef mingw32_HOST_OS 
     107#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS)  
    105108import System.Posix.Internals 
    106109#endif 
    107110import Foreign 
    108111import Foreign.C 
    109112 
    110 #ifdef mingw32_HOST_OS 
     113#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    111114import Data.Typeable 
    112115#endif 
    113116 
    114 #ifndef mingw32_HOST_OS 
     117#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    115118import Data.Dynamic 
    116119#endif 
    117120import Control.Monad 
    118121import Data.Maybe 
    119122 
    120123import GHC.Base 
    121 #ifndef mingw32_HOST_OS 
     124#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    122125import GHC.Debug 
    123126#endif 
    124127import {-# SOURCE #-} GHC.IO.Handle ( hFlush ) 
     
    130133import GHC.MVar 
    131134import GHC.Num          ( Num(..) ) 
    132135import GHC.Real         ( fromIntegral ) 
    133 #ifndef mingw32_HOST_OS 
     136#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    134137import GHC.IOArray 
    135138import GHC.Arr          ( inRange ) 
    136139#endif 
    137 #ifdef mingw32_HOST_OS 
     140#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    138141import GHC.Real         ( div ) 
    139142import GHC.Ptr 
    140143#endif 
    141 #ifdef mingw32_HOST_OS 
     144#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    142145import GHC.Read         ( Read ) 
    143146import GHC.Enum         ( Enum ) 
    144147#endif 
     
    696699-- given file descriptor (GHC only). 
    697700threadWaitRead :: Fd -> IO () 
    698701threadWaitRead fd 
    699 #ifndef mingw32_HOST_OS 
     702#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    700703  | threaded  = waitForReadEvent fd 
    701704#endif 
    702705  | otherwise = IO $ \s ->  
     
    708711-- given file descriptor (GHC only). 
    709712threadWaitWrite :: Fd -> IO () 
    710713threadWaitWrite fd 
    711 #ifndef mingw32_HOST_OS 
     714#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    712715  | threaded  = waitForWriteEvent fd 
    713716#endif 
    714717  | otherwise = IO $ \s ->  
     
    780783-- around the scheduler loop.  Furthermore, the scheduler can be simplified 
    781784-- by not having to check for completed IO requests. 
    782785 
    783 #ifndef mingw32_HOST_OS 
     786#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    784787data IOReq 
    785788  = Read   {-# UNPACK #-} !Fd {-# UNPACK #-} !(MVar ()) 
    786789  | Write  {-# UNPACK #-} !Fd {-# UNPACK #-} !(MVar ()) 
     
    790793  = Delay    {-# UNPACK #-} !USecs {-# UNPACK #-} !(MVar ()) 
    791794  | DelaySTM {-# UNPACK #-} !USecs {-# UNPACK #-} !(TVar Bool) 
    792795 
    793 #ifndef mingw32_HOST_OS 
     796#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    794797{-# NOINLINE pendingEvents #-} 
    795798pendingEvents :: IORef [IOReq] 
    796799pendingEvents = unsafePerformIO $ do 
     
    10101013foreign import stdcall "WaitForSingleObject" 
    10111014   c_WaitForSingleObject :: HANDLE -> DWORD -> IO DWORD 
    10121015 
     1016#elif defined(barrelfish_HOST_OS) 
     1017-- ---------------------------------------------------------------------------- 
     1018-- Barrelfish IO manager thread 
     1019 
     1020ioManager :: IO () 
     1021ioManager = do 
     1022  return () 
     1023 
     1024wakeupIOManager :: IO () 
     1025wakeupIOManager = do 
     1026  return () 
     1027 
     1028type Signal = CInt 
     1029 
    10131030#else 
    10141031-- ---------------------------------------------------------------------------- 
    10151032-- Unix IO manager thread, using select() 
  • GHC/IO/Encoding/CodePage.hs

    diff -rN -u old-base/GHC/IO/Encoding/CodePage.hs new-base/GHC/IO/Encoding/CodePage.hs
    old new  
    11{-# LANGUAGE BangPatterns #-} 
    22module GHC.IO.Encoding.CodePage( 
    3 #if !defined(mingw32_HOST_OS) 
     3#if !defined(mingw32_HOST_OS)  
    44 ) where 
    55#else 
    66                        codePageEncoding, 
  • GHC/IO/Encoding/Iconv.hs

    diff -rN -u old-base/GHC/IO/Encoding/Iconv.hs new-base/GHC/IO/Encoding/Iconv.hs
    old new  
    1515 
    1616-- #hide 
    1717module GHC.IO.Encoding.Iconv ( 
    18 #if !defined(mingw32_HOST_OS) 
     18#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    1919   mkTextEncoding, 
    2020   latin1, 
    2121   utf8,  
     
    2828#include "MachDeps.h" 
    2929#include "HsBaseConfig.h" 
    3030 
    31 #if !defined(mingw32_HOST_OS) 
     31#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    3232 
    3333import Foreign 
    3434import Foreign.C 
  • GHC/IO/Encoding.hs

    diff -rN -u old-base/GHC/IO/Encoding.hs new-base/GHC/IO/Encoding.hs
    old new  
    3939import qualified GHC.IO.Encoding.UTF16  as UTF16 
    4040import qualified GHC.IO.Encoding.UTF32  as UTF32 
    4141 
    42 #if defined(mingw32_HOST_OS) 
     42#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    4343import Data.Maybe 
    4444import GHC.IO.Exception 
    4545#endif 
     
    9696 
    9797-- | The Unicode encoding of the current locale 
    9898localeEncoding  :: TextEncoding 
    99 #if !defined(mingw32_HOST_OS) 
     99#if defined(barrelfish_HOST_OS) 
     100localeEncoding  = UTF8.utf8 
     101#elif !defined(mingw32_HOST_OS)  
    100102localeEncoding = Iconv.localeEncoding 
    101103#else 
    102104localeEncoding = CodePage.localeEncoding 
     
    129131-- @CP@; for example, @\"CP1250\"@. 
    130132-- 
    131133mkTextEncoding :: String -> IO TextEncoding 
    132 #if !defined(mingw32_HOST_OS) 
     134#if defined(barrelfish_HOST_OS) 
     135mkTextEncoding e = ioException 
     136     (IOError Nothing NoSuchThing "mkTextEncoding" 
     137          ("unknown encoding:" ++ e)  Nothing Nothing) 
     138#elif !defined(mingw32_HOST_OS) 
    133139mkTextEncoding = Iconv.mkTextEncoding 
    134140#else 
    135141mkTextEncoding "UTF-8"    = return utf8 
  • GHC/IO/FD.hs

    diff -rN -u old-base/GHC/IO/FD.hs new-base/GHC/IO/FD.hs
    old new  
    224224           ioException (IOError Nothing InappropriateType "openFile" 
    225225                           "is a directory" Nothing Nothing) 
    226226 
    227 #ifndef mingw32_HOST_OS 
     227#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    228228        -- regular files need to be locked 
    229229        RegularFile -> do 
    230230           -- On Windows we use explicit exclusion via sopen() to implement 
     
    289289       c_close (fdFD fd) 
    290290 
    291291release :: FD -> IO () 
    292 #ifdef mingw32_HOST_OS 
     292#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    293293release _ = return () 
    294294#else 
    295295release fd = do _ <- unlockFile (fdFD fd) 
     
    614614-- ----------------------------------------------------------------------------- 
    615615-- Locking/unlocking 
    616616 
    617 #ifndef mingw32_HOST_OS 
     617#if !defined(mingw32_HOST_OS) && !defined(barrelfish_HOST_OS) 
    618618foreign import ccall unsafe "lockFile" 
    619619  lockFile :: CInt -> CDev -> CIno -> CInt -> IO CInt 
    620620 
  • GHC/TopHandler.lhs

    diff -rN -u old-base/GHC/TopHandler.lhs new-base/GHC/TopHandler.lhs
    old new  
    6767      topHandler 
    6868 
    6969install_interrupt_handler :: IO () -> IO () 
    70 #ifdef mingw32_HOST_OS 
     70#ifdef barrelfish_HOST_OS 
     71install_interrupt_handler handler = do 
     72  return () 
     73#elif defined(mingw32_HOST_OS) 
    7174install_interrupt_handler handler = do 
    7275  _ <- GHC.ConsoleHandler.installHandler $ 
    7376     Catch $ \event ->  
     
    188191 
    189192exitInterrupted :: IO a 
    190193exitInterrupted =  
    191 #ifdef mingw32_HOST_OS 
     194#if defined(mingw32_HOST_OS) || defined(barrelfish_HOST_OS) 
    192195  safeExit 252 
    193196#else 
    194197  -- we must exit via the default action for SIGINT, so that the 
  • include/HsBase.h

    diff -rN -u old-base/include/HsBase.h new-base/include/HsBase.h
    old new  
    99#ifndef __HSBASE_H__ 
    1010#define __HSBASE_H__ 
    1111 
     12 
    1213#ifdef __NHC__ 
    1314# include "Nhc98BaseConfig.h" 
    1415#else 
     
    170171INLINE int __hscore_get_errno(void) { return errno; } 
    171172INLINE void __hscore_set_errno(int e) { errno = e; } 
    172173 
    173 #if !defined(_MSC_VER) 
     174#ifdef barrelfish_HOST_OS 
     175INLINE int __hscore_s_isreg(mode_t m)  { return 0;  } 
     176INLINE int __hscore_s_isdir(mode_t m)  { return 0;  } 
     177INLINE int __hscore_s_isfifo(mode_t m) { return 0; } 
     178INLINE int __hscore_s_isblk(mode_t m)  { return 0;  } 
     179INLINE int __hscore_s_ischr(mode_t m)  { return 0;  } 
     180INLINE int __hscore_s_issock(mode_t m) { return 0; } 
     181#elif !defined(_MSC_VER) 
    174182INLINE int __hscore_s_isreg(mode_t m)  { return S_ISREG(m);  } 
    175183INLINE int __hscore_s_isdir(mode_t m)  { return S_ISDIR(m);  } 
    176184INLINE int __hscore_s_isfifo(mode_t m) { return S_ISFIFO(m); } 
    177185INLINE int __hscore_s_isblk(mode_t m)  { return S_ISBLK(m);  } 
    178186INLINE int __hscore_s_ischr(mode_t m)  { return S_ISCHR(m);  } 
    179 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     187#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)  
    180188INLINE int __hscore_s_issock(mode_t m) { return S_ISSOCK(m); } 
    181189#endif 
    182190#endif 
    183191 
    184 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32) 
     192#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32) && !defined(barrelfish_HOST_OS) 
    185193INLINE int 
    186194__hscore_sigemptyset( sigset_t *set ) 
    187195{ return sigemptyset(set); } 
     
    389397 
    390398INLINE time_t __hscore_st_mtime ( struct_stat* st ) { return st->st_mtime; } 
    391399INLINE stsize_t __hscore_st_size  ( struct_stat* st ) { return st->st_size; } 
    392 #if !defined(_MSC_VER) 
     400#if !defined(_MSC_VER)  
    393401INLINE mode_t __hscore_st_mode  ( struct_stat* st ) { return st->st_mode; } 
    394402INLINE dev_t  __hscore_st_dev  ( struct_stat* st ) { return st->st_dev; } 
    395403INLINE ino_t  __hscore_st_ino  ( struct_stat* st ) { return st->st_ino; } 
     
    447455} 
    448456#endif 
    449457 
    450 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32) 
     458#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32) && !defined(barrelfish_HOST_OS) 
    451459INLINE HsInt 
    452460__hscore_sizeof_sigset_t( void ) 
    453461{ 
     
    532540#endif 
    533541} 
    534542 
    535 #ifndef __MINGW32__ 
     543#if !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    536544INLINE size_t __hscore_sizeof_siginfo_t (void) 
    537545{ 
    538546    return sizeof(siginfo_t); 
     
    585593 
    586594INLINE int __hscore_hs_fileno (FILE *f) { return fileno (f); } 
    587595 
     596#ifdef barrelfish_HOST_OS 
     597INLINE int __hscore_open(char *file, int how, mode_t mode) { 
     598        return open(file,how); 
     599} 
     600#else 
    588601#ifdef __MINGW32__ 
    589602INLINE int __hscore_open(wchar_t *file, int how, mode_t mode) { 
    590603        if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND)) 
     
    599612        return open(file,how,mode); 
    600613} 
    601614#endif 
     615#endif 
    602616 
    603617// These are wrapped because on some OSs (eg. Linux) they are 
    604618// macros which redirect to the 64-bit-off_t versions when large file 
     
    616630 
    617631// select-related stuff 
    618632 
    619 #if !defined(__MINGW32__) 
     633#if !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    620634INLINE int  hsFD_SETSIZE(void) { return FD_SETSIZE; } 
    621635INLINE int  hsFD_ISSET(int fd, fd_set *fds) { return FD_ISSET(fd, fds); } 
    622636INLINE void hsFD_SET(int fd, fd_set *fds) { FD_SET(fd, fds); } 
     
    624638extern void hsFD_ZERO(fd_set *fds); 
    625639#endif 
    626640 
     641#if defined(barrelfish_HOST_OS) 
     642INLINE int __hscore_select(int nfds, fd_set *readfds, fd_set *writefds, 
     643                           fd_set *exceptfds, struct timeval *timeout) { 
     644        printf("NYI __hscore_select"); 
     645        return -1; 
     646} 
     647#else 
    627648INLINE int __hscore_select(int nfds, fd_set *readfds, fd_set *writefds, 
    628649                           fd_set *exceptfds, struct timeval *timeout) { 
    629650        return (select(nfds,readfds,writefds,exceptfds,timeout)); 
    630651} 
     652#endif 
    631653 
    632654// gettimeofday()-related 
    633655 
    634 #if !defined(__MINGW32__) 
     656#if !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    635657 
    636658INLINE HsInt sizeofTimeVal(void) { return sizeof(struct timeval); } 
    637659 
     
    654676 
    655677/* ToDo: write a feature test that doesn't assume 'environ' to 
    656678 *    be in scope at link-time. */ 
     679#ifdef barrelfish_HOST_OS 
     680INLINE char **__hscore_environ() {  
     681    printf("environ NYI\n"); 
     682    return NULL;  
     683} 
     684#else 
    657685extern char** environ; 
    658686INLINE char **__hscore_environ() { return environ; } 
     687#endif  
    659688 
    660689/* lossless conversions between pointers and integral types */ 
    661690INLINE void *    __hscore_from_uintptr(uintptr_t n) { return (void *)n; } 
     
    666695void errorBelch2(const char*s, char *t); 
    667696void debugBelch2(const char*s, char *t); 
    668697 
    669 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     698#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    670699 
    671700INLINE int fcntl_read(int fd, int cmd) { 
    672701    return fcntl(fd, cmd); 
  • System/CPUTime.hsc

    diff -rN -u old-base/System/CPUTime.hsc new-base/System/CPUTime.hsc
    old new  
    1919        ) where 
    2020 
    2121import Prelude 
     22import GHC.IO.Exception 
    2223 
    2324import Data.Ratio 
    2425 
     
    8990-- 
    9091-- Avoid the problem by resorting to times() instead. 
    9192-- 
    92 #if defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS 
     93#if defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS && ! barrelfish_HOST_OS 
    9394    allocaBytes (#const sizeof(struct rusage)) $ \ p_rusage -> do 
    9495    throwErrnoIfMinus1_ "getrusage" $ getrusage (#const RUSAGE_SELF) p_rusage 
    9596 
     
    106107type CRUsage = () 
    107108foreign import ccall unsafe getrusage :: CInt -> Ptr CRUsage -> IO CInt 
    108109#else 
    109 # if defined(HAVE_TIMES) 
     110# if defined(HAVE_TIMES) && ! barrelfish_HOST_OS 
    110111    allocaBytes (#const sizeof(struct tms)) $ \ p_tms -> do 
    111112    _ <- times p_tms 
    112113    u_ticks  <- (#peek struct tms,tms_utime) p_tms :: IO CClock 
     
    120121    ioException (IOError Nothing UnsupportedOperation  
    121122                         "getCPUTime" 
    122123                         "can't get CPU time" 
    123                          Nothing) 
     124                         Nothing Nothing) 
    124125# endif 
    125126#endif 
    126127 
     
    170171 
    171172#ifdef __GLASGOW_HASKELL__ 
    172173clockTicks :: Int 
    173 clockTicks = 
    174 #if defined(CLK_TCK) 
    175     (#const CLK_TCK) 
     174#ifdef barrelfish_HOST_OS 
     175clockTicks = 60 
     176#elif defined(CLK_TCK) 
     177clockTicks = (#const CLK_TCK) 
    176178#else 
    177     unsafePerformIO (sysconf (#const _SC_CLK_TCK) >>= return . fromIntegral) 
     179clockTicks = unsafePerformIO (sysconf (#const _SC_CLK_TCK) >>= return . fromIntegral) 
    178180foreign import ccall unsafe sysconf :: CInt -> IO CLong 
    179181#endif 
    180182#endif /* __GLASGOW_HASKELL__ */ 
  • System/Posix/Internals.hs

    diff -rN -u old-base/System/Posix/Internals.hs new-base/System/Posix/Internals.hs
    old new  
    147147#endif 
    148148 
    149149fdGetMode :: FD -> IO IOMode 
    150 #if defined(mingw32_HOST_OS) || defined(__MINGW32__) 
     150#if defined(mingw32_HOST_OS) || defined(__MINGW32__) ||  defined(barrelfish_HOST_OS) 
    151151fdGetMode _ = do 
    152152    -- We don't have a way of finding out which flags are set on FDs 
    153153    -- on Windows, so make a handle that thinks that anything goes. 
     
    181181-- --------------------------------------------------------------------------- 
    182182-- Terminal-related stuff 
    183183 
    184 #if defined(HTYPE_TCFLAG_T) 
     184#if defined(HTYPE_TCFLAG_T)  
    185185 
    186186setEcho :: FD -> Bool -> IO () 
    187187setEcho fd on = do 
     
    261261   set_saved_termios :: CInt -> (Ptr CTermios) -> IO () 
    262262#endif 
    263263 
     264#elif defined(barrelfish_HOST_OS) 
     265 
     266setCooked :: FD -> Bool -> IO () 
     267setCooked fd cooked = do 
     268   return () 
     269 
     270 
     271setEcho :: FD -> Bool -> IO () 
     272setEcho fd on = do 
     273   return () 
     274 
     275getEcho :: FD -> IO Bool 
     276getEcho fd = do 
     277   return True 
     278 
    264279#else 
    265280 
    266281-- 'raw' mode for Win32 means turn off 'line input' (=> buffering and 
     
    317332-- Turning on non-blocking for a file descriptor 
    318333 
    319334setNonBlockingFD :: FD -> Bool -> IO () 
    320 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     335#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    321336setNonBlockingFD fd set = do 
    322337  flags <- throwErrnoIfMinus1Retry "setNonBlockingFD" 
    323338                 (c_fcntl_read fd const_f_getfl) 
     
    339354-- ----------------------------------------------------------------------------- 
    340355-- Set close-on-exec for a file descriptor 
    341356 
    342 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     357#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    343358setCloseOnExec :: FD -> IO () 
    344359setCloseOnExec fd = do 
    345360  throwErrnoIfMinus1_ "setCloseOnExec" $ 
     
    420435foreign import ccall unsafe "HsBase.h getpid" 
    421436   c_getpid :: IO CPid 
    422437 
    423 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     438#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    424439foreign import ccall unsafe "HsBase.h fcntl_read" 
    425440   c_fcntl_read  :: CInt -> CInt -> IO CInt 
    426441 
     
    529544#endif 
    530545 
    531546s_issock :: CMode -> Bool 
    532 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) 
     547#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__) && !defined(barrelfish_HOST_OS) 
    533548s_issock cmode = c_s_issock cmode /= 0 
    534549foreign import ccall unsafe "HsBase.h __hscore_s_issock" c_s_issock :: CMode -> CInt 
    535550#else