{-# OPTIONS -W -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.68 2000/10/11 16:06:38 simonmar Exp $
+-- $Id: Main.hs,v 1.69 2000/11/07 10:42:55 simonmar Exp $
--
-- GHC Driver program
--
module Main (main) where
+import Utils
+
import GetImports
import Package
import Config
data WayName
= WayProf
| WayUnreg
- | WayDll
| WayTicky
| WayPar
| WayGran
GLOBAL_VAR(ways, [] ,[WayName])
--- ToDo: allow WayDll with any other allowed combination
-
-allowed_combinations =
- [ [WayProf,WayUnreg],
- [WayProf,WaySMP] -- works???
- ]
+allowed_combination ways = ways `elem` combs
+ where -- the sub-lists must be ordered according to WayName, because findBuildTag sorts them
+ combs = [ [WayProf,WayUnreg], [WayProf,WaySMP] ]
findBuildTag :: IO [String] -- new options
findBuildTag = do
writeIORef build_tag (wayTag details)
return (wayOpts details)
- ws -> if ws `notElem` allowed_combinations
+ ws -> if allowed_combination ws
then throwDyn (OtherError $
"combination not supported: " ++
foldr1 (\a b -> a ++ '/':b)
, "-funregisterised"
, "-fvia-C" ]),
- (WayDll, Way "dll" "DLLized"
- [ ]),
-
(WayPar, Way "mp" "Parallel"
[ "-fparallel"
, "-D__PARALLEL_HASKELL__"
-- the fp (%ebp) for our register maps.
= do n_regs <- readState stolen_x86_regs
sta <- readIORef static
- return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" ],
+ return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "",
+ if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" ],
[ "-fno-defer-pop", "-fomit-frame-pointer",
- "-DSTOLEN_X86_REGS="++show n_regs ]
+ "-DSTOLEN_X86_REGS="++show n_regs]
)
| prefixMatch "mips" cTARGETPLATFORM
-----------------------------------------------------------------------------
-- Which phase to stop at
-data ToDo = DoMkDependHS | DoMkDLL | StopBefore Phase | DoLink
+data ToDo = DoMkDependHS | StopBefore Phase | DoLink
deriving (Eq)
GLOBAL_VAR(v_todo, error "todo", ToDo)
-- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless.
do_recomp <- readIORef recomp
todo <- readIORef v_todo
- o_file <- odir_ify (basename ++ '.':phase_input_ext Ln)
+ o_file' <- odir_ify (basename ++ '.':phase_input_ext Ln)
+ o_file <- osuf_ify o_file'
source_unchanged <-
if not (do_recomp && ( todo == DoLink || todo == StopBefore Ln ))
then return ""
run_something "Copy stub .c file"
(unwords [
"rm -f", stub_c, "&&",
- "echo \'#include \""++stub_h++"\"\' >"++stub_c, " &&",
+ "echo \'#include \"Stg.h\"\n#include \""++stub_h++"\"\' >"++stub_c, " &&",
"cat", tmp_stub_c, ">> ", stub_c
])
++ [ verb, "-S", "-Wimplicit", opt_flag ]
++ [ "-D__GLASGOW_HASKELL__="++cProjectVersionInt ]
++ cc_opts
-#ifdef mingw32_TARGET_OS
- ++ [" -mno-cygwin"]
-#endif
++ (if excessPrecision then [] else [ "-ffloat-store" ])
++ include_paths
++ pkg_extra_cc_opts
-----------------------------------------------------------------------------
-- Linking
+GLOBAL_VAR(no_hs_main, False, Bool)
+
do_link :: [String] -> IO ()
do_link o_files = do
ln <- readIORef pgm_l
verb <- is_verbose
+ static <- readIORef static
+ let imp = if static then "" else "_imp"
+ no_hs_main <- readIORef no_hs_main
o_file <- readIORef output_file
let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
let lib_path_opts = map ("-L"++) lib_paths
pkg_libs <- getPackageLibraries
- let pkg_lib_opts = map (\lib -> "-l"++lib) pkg_libs
+ let pkg_lib_opts = map (\lib -> "-l" ++ lib ++ imp) pkg_libs
libs <- readIORef cmdline_libraries
let lib_opts = map ("-l"++) (reverse libs)
-- opts from -optl-<blah>
extra_ld_opts <- getOpts opt_l
+ rts_pkg <- getPackageDetails ["rts"]
+ std_pkg <- getPackageDetails ["std"]
+#ifdef mingw32_TARGET_OS
+ let extra_os = if static || no_hs_main
+ then []
+ else [ head (library_dirs (head rts_pkg)) ++ "/Main.dll_o",
+ head (library_dirs (head std_pkg)) ++ "/PrelMain.dll_o" ]
+#endif
+ (md_c_flags, _) <- machdepCCOpts
run_something "Linker"
- (unwords
+ (unwords
([ ln, verb, "-o", output_fn ]
+ ++ md_c_flags
++ o_files
+#ifdef mingw32_TARGET_OS
+ ++ extra_os
+#endif
++ extra_ld_inputs
++ lib_path_opts
++ lib_opts
++ pkg_lib_opts
++ pkg_extra_ld_opts
++ extra_ld_opts
+#ifdef mingw32_TARGET_OS
+ ++ if static then [ "-u _PrelMain_mainIO_closure" , "-u ___init_PrelMain"] else []
+#else
+ ++ [ "-u PrelMain_mainIO_closure" , "-u __init_PrelMain"]
+#endif
)
)
hPutStrLn h cmd
hClose h
exit_code <- system ("sh - " ++ tmp) `catchAllIO`
- (\e -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
+ (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
removeFile tmp
#endif
------- ways --------------------------------------------------------
, ( "prof" , NoArg (addNoDups ways WayProf) )
, ( "unreg" , NoArg (addNoDups ways WayUnreg) )
- , ( "dll" , NoArg (addNoDups ways WayDll) )
, ( "ticky" , NoArg (addNoDups ways WayTicky) )
, ( "parallel" , NoArg (addNoDups ways WayPar) )
, ( "gransim" , NoArg (addNoDups ways WayGran) )
, ( "cpp" , NoArg (updateState (\s -> s{ cpp_flag = True })) )
, ( "#include" , HasArg (addCmdlineHCInclude) )
, ( "no-link-chk" , NoArg (return ()) ) -- ignored for backwards compat
+ , ( "no-hs-main" , NoArg (writeIORef no_hs_main True) )
------- Output Redirection ------------------------------------------
, ( "odir" , HasArg (writeIORef output_dir . Just) )
----- Linker --------------------------------------------------------
, ( "static" , NoArg (writeIORef static True) )
+ , ( "rdynamic" , NoArg (return ()) ) -- ignored for compat w/ gcc
------ Compiler RTS options -----------------------------------------
, ( "H" , HasArg (newHeapSize . decodeSize) )
| p == r = my_prefix_match pat rest
| otherwise = Nothing
-prefixMatch :: Eq a => [a] -> [a] -> Bool
-prefixMatch [] _str = True
-prefixMatch _pat [] = False
-prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
- | otherwise = False
-
-postfixMatch :: String -> String -> Bool
-postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
-
later = flip finally
my_catchDyn = flip catchDyn
#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.44 2000/09/05 10:16:41 simonmar Exp $
+# $Id: Makefile,v 1.45 2000/11/07 10:42:56 simonmar Exp $
#
TOP=..
endif
HS_PROG = ghc-$(ProjectVersion)
-HS_SRCS = Config.hs Package.hs GetImports.hs Main.hs
-MKDEPENDHS_SRCS = Config.hs Main.hs GetImports.hs PackageSrc.hs
+HS_SRCS = Config.hs Package.hs GetImports.hs Main.hs Utils.hs
+MKDEPENDHS_SRCS = Config.hs Main.hs GetImports.hs PackageSrc.hs Utils.hs
LINK = ghc
SUBDIRS = mangler split stats
@echo "cGHC_SPLIT = \"$(GHC_SPLIT)\"" >> Config.hs
@echo "cGHC_STATS = \"$(GHC_STATS)\"" >> Config.hs
@echo "cGHC_SYSMAN = \"$(GHC_SYSMAN)\"" >> Config.hs
- @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> Config.hs
+ @echo "cDLLized = \"$(DLLized)\"" >> Config.hs
@echo "cCP = \"$(CP)\"" >> Config.hs
@echo "cRM = \"$(RM)\"" >> Config.hs
@echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> Config.hs
all :: package.conf package.conf.inplace
-pkgconf : Config.o Package.o PackageSrc.o
- $(HC) $(HC_OPTS) $(LD_OPTS) Config.o Package.o PackageSrc.o -o pkgconf
+pkgconf : Config.o Package.o PackageSrc.o Utils.o
+ $(HC) $(HC_OPTS) $(LD_OPTS) Config.o Package.o PackageSrc.o Utils.o -o pkgconf
package.conf.inplace : pkgconf
./pkgconf in-place >$@
include $(TOP)/mk/target.mk
-# we need the driver for generating dependencies...
-boot :: all
+# We need the driver for generating dependencies... so build it as
+# part of make boot. We need to do this using a recursive invocation
+# of $(MAKE), so that dependencies we just generated for the driver
+# itself are picked up.
+boot ::
+ $(MAKE) $(MFLAGS) all
# -----------------------------------------------------------------------------
# Create link to from ghc-x.xx to ghc...
+#include "../includes/config.h"
+
module Main (main) where
+import Utils
+
import IO
import System
import Config
extra_cc_opts = [],
-- the RTS forward-references to a bunch of stuff in the prelude,
-- so we force it to be included with special options to ld.
- extra_ld_opts = [
- "-u PrelMain_mainIO_closure"
- , "-u PrelBase_Izh_static_info"
- , "-u PrelBase_Czh_static_info"
- , "-u PrelFloat_Fzh_static_info"
- , "-u PrelFloat_Dzh_static_info"
- , "-u PrelAddr_Azh_static_info"
- , "-u PrelAddr_Wzh_static_info"
- , "-u PrelAddr_I64zh_static_info"
- , "-u PrelAddr_W64zh_static_info"
- , "-u PrelStable_StablePtr_static_info"
- , "-u PrelBase_Izh_con_info"
- , "-u PrelBase_Czh_con_info"
- , "-u PrelFloat_Fzh_con_info"
- , "-u PrelFloat_Dzh_con_info"
- , "-u PrelAddr_Azh_con_info"
- , "-u PrelAddr_Wzh_con_info"
- , "-u PrelAddr_I64zh_con_info"
- , "-u PrelAddr_W64zh_con_info"
- , "-u PrelStable_StablePtr_con_info"
- , "-u PrelBase_False_closure"
- , "-u PrelBase_True_closure"
- , "-u PrelPack_unpackCString_closure"
- , "-u PrelIOBase_stackOverflow_closure"
- , "-u PrelIOBase_heapOverflow_closure"
- , "-u PrelIOBase_NonTermination_closure"
- , "-u PrelIOBase_PutFullMVar_closure"
- , "-u PrelIOBase_BlockedOnDeadMVar_closure"
- , "-u PrelWeak_runFinalizzerBatch_closure"
- , "-u __init_Prelude"
- , "-u __init_PrelMain"
+ extra_ld_opts = map (
+#ifndef LEADING_UNDERSCORE
+ "-u "
+#else
+ "-u _"
+#endif
+ ++ ) [
+ "PrelBase_Izh_static_info"
+ , "PrelBase_Czh_static_info"
+ , "PrelFloat_Fzh_static_info"
+ , "PrelFloat_Dzh_static_info"
+ , "PrelAddr_Azh_static_info"
+ , "PrelAddr_Wzh_static_info"
+ , "PrelAddr_I64zh_static_info"
+ , "PrelAddr_W64zh_static_info"
+ , "PrelStable_StablePtr_static_info"
+ , "PrelBase_Izh_con_info"
+ , "PrelBase_Czh_con_info"
+ , "PrelFloat_Fzh_con_info"
+ , "PrelFloat_Dzh_con_info"
+ , "PrelAddr_Azh_con_info"
+ , "PrelAddr_Wzh_con_info"
+ , "PrelAddr_I64zh_con_info"
+ , "PrelAddr_W64zh_con_info"
+ , "PrelStable_StablePtr_con_info"
+ , "PrelBase_False_closure"
+ , "PrelBase_True_closure"
+ , "PrelPack_unpackCString_closure"
+ , "PrelIOBase_stackOverflow_closure"
+ , "PrelIOBase_heapOverflow_closure"
+ , "PrelIOBase_NonTermination_closure"
+ , "PrelIOBase_PutFullMVar_closure"
+ , "PrelIOBase_BlockedOnDeadMVar_closure"
+ , "PrelWeak_runFinalizzerBatch_closure"
+ , "__init_Prelude"
]
},
package_deps = [ "rts" ],
extra_ghc_opts = [],
extra_cc_opts = [],
- extra_ld_opts = [ "-lm" ]
+ extra_ld_opts = [ "-lm"
+#ifdef mingw32_TARGET_OS
+ , "-lwsock32"
+#endif
+ ]
},
Package {
package_deps = [ "lang", "text" ],
extra_ghc_opts = [],
extra_cc_opts = [],
- extra_ld_opts = if postfixMatch "solaris2" cTARGETPLATFORM
+ extra_ld_opts = if suffixMatch "solaris2" cTARGETPLATFORM
then [ "-lnsl", "-lsocket" ]
else []
},
then []
else [ cFPTOOLS_TOP_ABS ++ "/hslibs/util/cbits" ],
c_includes = [ "HsUtil.h" ],
- package_deps = [ "lang", "concurrent", "posix" ],
+ package_deps = [ "lang", "concurrent"
+#ifndef mingw32_TARGET_OS
+ , "posix"
+#endif
+ ],
extra_ghc_opts = [],
extra_cc_opts = [],
extra_ld_opts = []
ghc_src_dir :: String -> String
ghc_src_dir path = cFPTOOLS_TOP_ABS ++ '/':cCURRENT_DIR ++ '/':path
-
-prefixMatch :: Eq a => [a] -> [a] -> Bool
-prefixMatch [] _str = True
-prefixMatch _pat [] = False
-prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
- | otherwise = False
-
-postfixMatch :: String -> String -> Bool
-postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
--- /dev/null
+module Utils where
+
+prefixMatch :: Eq a => [a] -> [a] -> Bool
+prefixMatch [] _str = True
+prefixMatch _pat [] = False
+prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
+ | otherwise = False
+
+suffixMatch :: String -> String -> Bool
+suffixMatch pat str = prefixMatch (reverse pat) (reverse str)
Any other required tidying up.
\end{itemize}
+General note [chak]: Many regexps are very fragile because they rely on white
+space being in the right place. This caused trouble with gcc 2.95 (at least
+on Linux), where the use of white space in .s files generated by gcc suddenly
+changed. To guarantee compatibility across different versions of gcc, make
+sure (at least on i386-.*-linux) that regexps tolerate varying amounts of white
+space between an assembler statement and its arguments as well as after a the
+comma separating multiple arguments.
+
+\emph{For the time being, I have corrected the regexps for i386-.*-linux. I
+didn't touch all the regexps for other i386 platforms, as I don't have
+a box to test these changes.}
+
HPPA specific notes:
\begin{itemize}
\item
$T_POST_LBL = ':';
$T_X86_PRE_LLBL_PAT = '\.L';
$T_X86_PRE_LLBL = '.L';
- $T_X86_BADJMP = '^\tjmp [^\.\*]';
+ $T_X86_BADJMP = '^\tjmp\s+[^\.\*]';
- $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\t\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
+ $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,\s*0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\s*\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
$T_COPY_DIRVS = '\.(globl)';
if ( $TargetPlatform =~ /freebsd|netbsd_elf/ ) {
&init_TARGET_STUFF();
&init_FUNNY_THINGS();
- # perl4 on alphas SEGVs when give ${foo} substitutions in patterns.
- # To avoid them we declare some locals that allows to avoid using curlies.
- local($TUS) = ${T_US};
- local($TPOSTLBL) = ${T_POST_LBL};
- local($TMOVEDIRVS) = ${T_MOVE_DIRVS};
- local($TPREAPP) = ${T_PRE_APP};
- local($TCOPYDIRVS) = ${T_COPY_DIRVS};
- local($TDOTWORD) = ${T_DOT_WORD};
-
open(INASM, "< $in_asmf")
|| &tidy_up_and_die(1,"$Pgm: failed to open `$in_asmf' (to read)\n");
open(OUTASM,"> $out_asmf")
$i = 0; $chkcat[0] = 'misc'; $chk[0] = '';
while (<INASM>) {
- next if $T_STABBY && /^\.stab.*$TUS[@]?__stg_split_marker/o;
+ next if $T_STABBY && /^\.stab.*${T_US}__stg_split_marker/o;
next if $T_STABBY && /^\.stab.*ghc.*c_ID/;
next if /^\t\.def.*endef$/;
- next if /$TPREAPP(NO_)?APP/o;
+ next if /${T_PRE_APP}(NO_)?APP/o;
next if /^;/ && $TargetPlatform =~ /^hppa/;
next if /(^$|^\t\.file\t|^ # )/ && $TargetPlatform =~ /^(mips|powerpc|rs6000)-/;
$chkcat[$i] = 'literal';
$chksymb[$i] = $1;
- } elsif ( /^$TUS[@]?__stg_split_marker(\d*)$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}__stg_split_marker(\d*)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'splitmarker';
$chksymb[$i] = $1;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_info$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_info${T_POST_LBL}$/o ) {
$symb = $1;
$chk[++$i] = $_;
$chkcat[$i] = 'infotbl';
$infochk{$symb} = $i;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_(entry|ret)$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_(entry|ret)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'slow';
$chksymb[$i] = $1;
$slowchk{$1} = $i;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_fast\d*$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_fast\d*${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'fast';
$chksymb[$i] = $1;
$fastchk{$1} = $i;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_closure$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_closure${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'closure';
$chksymb[$i] = $1;
$closurechk{$1} = $i;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_srt$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_srt${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'srt';
$chksymb[$i] = $1;
$srtchk{$1} = $i;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_ct$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_ct${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'data';
$chksymb[$i] = '';
- } elsif ( /^$TUS[@]?ghc.*c_ID$TPOSTLBL/o ) {
+ } elsif ( /^${T_US}ghc.*c_ID${T_POST_LBL}/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'consist';
- } elsif ( /^($TUS[@]?__gnu_compiled_c|gcc2_compiled\.)$TPOSTLBL/o ) {
+ } elsif ( /^(${T_US}__gnu_compiled_c|gcc2_compiled\.)${T_POST_LBL}/o ) {
; # toss it
- } elsif ( /^$TUS[A-Za-z0-9_]+\.\d+$TPOSTLBL[@]?$/o
- || /^$TUS[@]?.*_CAT$TPOSTLBL[@]?$/o # PROF: _entryname_CAT
- || /^$TUS[@]?.*_done$TPOSTLBL[@]?$/o # PROF: _module_done
- || /^$TUS[@]?_module_registered$TPOSTLBL[@]?$/o # PROF: _module_registered
+ } elsif ( /^${T_US}[A-Za-z0-9_]+\.\d+${T_POST_LBL}$/o
+ || /^${T_US}.*_CAT${T_POST_LBL}$/o # PROF: _entryname_CAT
+ || /^${T_US}.*_done${T_POST_LBL}$/o # PROF: _module_done
+ || /^${T_US}_module_registered${T_POST_LBL}$/o # PROF: _module_registered
) {
$chk[++$i] = $_;
$chkcat[$i] = 'data';
$chkcat[$i] = 'toc';
$chksymb[$i] = $1;
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_cc(s)?$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_cc(s)?${T_POST_LBL}$/o ) {
# all CC_ symbols go in the data section...
$chk[++$i] = $_;
$chkcat[$i] = 'data';
$chksymb[$i] = '';
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_(alt|dflt)$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_(alt|dflt)${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
$chksymb[$i] = '';
#$symbtmp = $1;
#$chksymb[$i] = $symbtmp if ($TargetPlatform =~ /^powerpc-|^rs6000-/) ; #rm andre
- } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_vtbl$TPOSTLBL[@]?$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_vtbl${T_POST_LBL}$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'vector';
$chksymb[$i] = $1;
$chkcat[$i] = 'toss';
$chksymb[$i] = $1;
- } elsif ( /^$TUS[@]?[A-Za-z0-9_]/o
+ } elsif ( /^${T_US}[A-Za-z0-9_]/o
&& ( $TargetPlatform !~ /^hppa/ # need to avoid local labels in this case
|| ! /^L\$\d+$/ )
&& ( $TargetPlatform !~ /^powerpc|^rs6000/ # ditto
chop($thing = $_);
print "Funny global thing?: $_"
unless $KNOWN_FUNNY_THING{$thing}
- || /^$TUS[@]?stg_.*$TPOSTLBL[@]?$/o # RTS internals
- || /^$TUS[@]__fexp_.*$TPOSTLBL$/o # foreign export
- || /^$TUS[@]?__init.*$TPOSTLBL$/o # __init<module>
- || /^$TUS[@]?.*_btm$TPOSTLBL$/o # large bitmaps
- || /^$TUS[@]?.*_closure_tbl$TPOSTLBL$/o; # closure tables
+ || /^${T_US}stg_.*${T_POST_LBL}$/o # RTS internals
+ || /^${T_US}__fexp_.*${T_POST_LBL}$/o # foreign export
+ || /^${T_US}__init.*${T_POST_LBL}$/o # __init<module>
+ || /^${T_US}.*_btm${T_POST_LBL}$/o # large bitmaps
+ || /^${T_US}.*_closure_tbl${T_POST_LBL}$/o; # closure tables
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
if ($TargetPlatform =~ /^powerpc-|^rs6000-/)
if (($p, $r) = split(/--- BEGIN ---/, $c)) {
if ($TargetPlatform =~ /^i386-/) {
- $p =~ s/^\tpushl \%edi\n//;
- $p =~ s/^\tpushl \%esi\n//;
- $p =~ s/^\tpushl \%ebx\n//;
- $p =~ s/^\tsubl \$\d+,\%esp\n//;
- $p =~ s/^\tmovl \$\d+,\%eax\n\tcall __alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/);
+ $p =~ s/^\tpushl\s+\%edi\n//;
+ $p =~ s/^\tpushl\s+\%esi\n//;
+ $p =~ s/^\tpushl\s+\%ebx\n//;
+ $p =~ s/^\tsubl\s+\$\d+,\s*\%esp\n//;
+ $p =~ s/^\tmovl\s+\$\d+,\s*\%eax\n\tcall\s+__alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/);
} elsif ($TargetPlatform =~ /^m68k-/) {
$p =~ s/^\tlink a6,#-?\d.*\n//;
$p =~ s/^\tpea a6@\n\tmovel sp,a6\n//;
if (($r, $e) = split(/--- END ---/, $c)) {
if ($TargetPlatform =~ /^i386-/) {
$e =~ s/^\tret\n//;
- $e =~ s/^\tpopl \%edi\n//;
- $e =~ s/^\tpopl \%esi\n//;
- $e =~ s/^\tpopl \%edx\n//;
- $e =~ s/^\tpopl \%ecx\n//;
- $e =~ s/^\taddl \$\d+,\%esp\n//;
- $e =~ s/^\tsubl \$-\d+,\%esp\n//;
+ $e =~ s/^\tpopl\s+\%edi\n//;
+ $e =~ s/^\tpopl\s+\%esi\n//;
+ $e =~ s/^\tpopl\s+\%edx\n//;
+ $e =~ s/^\tpopl\s+\%ecx\n//;
+ $e =~ s/^\taddl\s+\$\d+,\s*\%esp\n//;
+ $e =~ s/^\tsubl\s+\$-\d+,\s*\%esp\n//;
} elsif ($TargetPlatform =~ /^m68k-/) {
$e =~ s/^\tunlk a6\n//;
$e =~ s/^\trts\n//;
# HWL HACK: dont die, just print a warning
#print stderr "HWL: this should die! Epilogue junk?: $e\n" if $e =~ /^\t[^\.]/
# && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
- die "Epilogue junk?: $e\n" if $e =~ /^\t[^\.\n]/
- && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
+
+ # ** FIXME:
+ # ** chak:
+ # Commented this out, because it complains about junk that
+ # is later removed in the FUNNY#END#THING loop - but as I am
+ # not sure how this could ever have worked, there may be a
+ # better solution...
+ #die "Epilogue junk?: $e\n" if $e =~ /^\t[^\.\n]/
+ # && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
# glue together what's left
$c = $r . $e;
# On Alphas, the prologue mangling is done a little later (below)
# toss all calls to __DISCARD__
- $c =~ s/^\t(call|jbsr|jal)\s+$TUS[@]?__DISCARD__\n//go;
+ $c =~ s/^\t(call|jbsr|jal)\s+${T_US}__DISCARD__\n//go;
# MIPS: that may leave some gratuitous asm macros around
# (no harm done; but we get rid of them to be tidier)
# pin a funny end-thing on (for easier matching):
$c .= 'FUNNY#END#THING';
- while ( $c =~ /$TMOVEDIRVS[@]?FUNNY#END#THING/o ) { # [@]? is a silly hack to avoid having to use curlies for T_PRE_APP
- # (this SEGVs perl4 on alphas, you see)
+ while ( $c =~ /${T_MOVE_DIRVS}FUNNY#END#THING/o ) {
$to_move = $1;
# blah_closure:
# ...
#
- if ( $TargetPlatform =~ /^(i386|sparc)/ && $to_move =~ /$TCOPYDIRVS/ ) {
+ if ( $TargetPlatform =~ /^(i386|sparc)/ && $to_move =~ /${T_COPY_DIRVS}/ ) {
$j = $i + 1;
while ( $j < $numchks && $chk[$j] =~ /$T_CONST_LBL/) {
$j++;
}
elsif ( $i < ($numchks - 1)
- && ( $to_move =~ /$TCOPYDIRVS/
+ && ( $to_move =~ /${T_COPY_DIRVS}/
|| ($TargetPlatform =~ /^hppa/ && $to_move =~ /align/ && $chkcat[$i+1] eq 'literal') )) {
$chk[$i + 1] = $to_move . $chk[$i + 1];
# otherwise they're tossed
}
- $c =~ s/$TMOVEDIRVS[@]?FUNNY#END#THING/FUNNY#END#THING/o; # [@]? is a hack (see above)
+ $c =~ s/${T_MOVE_DIRVS}FUNNY#END#THING/FUNNY#END#THING/o;
}
if ( $TargetPlatform =~ /^alpha-/ && $c =~ /^\t\.ent\s+(\S+)/ ) {
#
# -- 2/98 SOF
if ( $TargetPlatform =~ /^hppa/ ) {
- $chk[$i] =~ s/^$TUS[@]?ghc.*c_ID$TPOSTLBL/$consist/o;
+ $chk[$i] =~ s/^${T_US}ghc.*c_ID$TPOSTLBL/$consist/o;
$chk[$i] =~ s/\t$T_hsc_cc_PAT/$T_HDR_misc/o;
$consist = $chk[$i]; #clumsily
}
} elsif ( $TargetPlatform =~ /^i386-/ ) {
# Reg alloc depending, gcc generated code may jump to the fast entry point via
# a number of registers.
- $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%edx\n\tjmp \*\%edx\n//;
- $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%ecx\n\tjmp \*\%ecx\n//;
- $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%eax\n\tjmp \*\%eax\n//;
+ $c =~ s/^\tmovl\s+\$${T_US}${symb}_fast\d*,\s*\%edx\n\tjmp\s+\*\%edx\n//;
+ $c =~ s/^\tmovl\s+\$${T_US}${symb}_fast\d*,\s*\%ecx\n\tjmp\s+\*\%ecx\n//;
+ $c =~ s/^\tmovl\s+\$${T_US}${symb}_fast\d*,\s*\%eax\n\tjmp\s+\*\%eax\n//;
# The next two only apply if we're not stealing %esi or %edi.
- $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%esi\n\tjmp \*\%esi\n// if ($StolenX86Regs < 3);
- $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%edi\n\tjmp \*\%edi\n// if ($StolenX86Regs < 4);
+ $c =~ s/^\tmovl\s+\$${T_US}${symb}_fast\d*,\s*\%esi\n\tjmp\s+\*\%esi\n// if ($StolenX86Regs < 3);
+ $c =~ s/^\tmovl\s+\$${T_US}${symb}_fast\d*,\s*\%edi\n\tjmp\s+\*\%edi\n// if ($StolenX86Regs < 4);
} elsif ( $TargetPlatform =~ /^mips-/ ) {
$c =~ s/^\tjmp \$31,\(\$27\),0\n\t\.align 4\n\t\.end/\t.align 4\n\t.end/;
} elsif ( $TargetPlatform =~ /^m68k-/ ) {
# references to fast-entry point.
# (questionable re hppa and mips...)
print STDERR "still has jump to fast entry point:\n$c"
- if $c =~ /$TUS[@]?$symb[@]?_fast/; # NB: paranoia
+ if $c =~ /${T_US}${symb}_fast/;
}
print OUTASM $T_HDR_entry;
# jmp *<bad-reg>
#
-# the short form may tickle perl bug:
-# s/^\tmovl \$${T_US}(.*),(\%e[abcd]x)\n\tjmp \*$2/\tjmp $T_US$1/g;
- s/^\tmovl \$${T_US}(.*),\%eax\n\tjmp \*\%eax/\tjmp $T_US$1/g;
- s/^\tmovl \$${T_US}(.*),\%ebx\n\tjmp \*\%ebx/\tjmp $T_US$1/g;
- s/^\tmovl \$${T_US}(.*),\%ecx\n\tjmp \*\%ecx/\tjmp $T_US$1/g;
- s/^\tmovl \$${T_US}(.*),\%edx\n\tjmp \*\%edx/\tjmp $T_US$1/g;
+# Because of Perl bug, needed separate cases for eax, ebx, ecx, edx in the past
+ s/^\tmovl \$${T_US}(.*),(\%e[abcd]x)\n\tjmp \*$2/\tjmp $T_US$1/g;
if ($StolenX86Regs <= 2 ) { # YURGH! spurious uses of esi?
- s/^\tmovl (.*),\%esi\n\tjmp \*%esi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
- s/^\tjmp \*(-?\d*)\((.*\%esi.*)\)\n/\tmovl $2,\%eax\n\tjmp \*$1\(\%eax\)\n/g;
- s/^\tjmp \*\%esi\n/\tmovl \%esi,\%eax\n\tjmp \*\%eax\n/g;
+ s/^\tmovl\s+(.*),\s*\%esi\n\tjmp\s+\*%esi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
+ s/^\tjmp\s+\*(-?\d*)\((.*\%esi.*)\)\n/\tmovl $2,\%eax\n\tjmp \*$1\(\%eax\)\n/g;
+ s/^\tjmp\s+\*\%esi\n/\tmovl \%esi,\%eax\n\tjmp \*\%eax\n/g;
die "$Pgm: (mangler) still have jump involving \%esi!\n$_"
- if /(jmp|call) .*\%esi/;
+ if /(jmp|call)\s+.*\%esi/;
}
if ($StolenX86Regs <= 3 ) { # spurious uses of edi?
- s/^\tmovl (.*),\%edi\n\tjmp \*%edi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
- s/^\tjmp \*(-?\d*\(.*\%edi.*\))\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
- s/^\tjmp \*\%edi\n/\tmovl \%edi,\%eax\n\tjmp \*\%eax\n/g;
+ s/^\tmovl\s+(.*),\s*\%edi\n\tjmp\s+\*%edi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
+ s/^\tjmp\s+\*(-?\d*\(.*\%edi.*\))\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;
+ s/^\tjmp\s+\*\%edi\n/\tmovl \%edi,\%eax\n\tjmp \*\%eax\n/g;
die "$Pgm: (mangler) still have jump involving \%edi!\n$_"
- if /(jmp|call) .*\%edi/;
+ if /(jmp|call)\s+.*\%edi/;
}
# OK, now we can decide what our patch-up code is going to
# fix _all_ non-local jumps:
- s/^\tjmp \*${T_X86_PRE_LLBL_PAT}/\tJMP___SL/go;
- s/^\tjmp ${T_X86_PRE_LLBL_PAT}/\tJMP___L/go;
+ s/^\tjmp\s+\*${T_X86_PRE_LLBL_PAT}/\tJMP___SL/go;
+ s/^\tjmp\s+${T_X86_PRE_LLBL_PAT}/\tJMP___L/go;
- s/^(\tjmp .*\n)/$exit_patch$1/g; # here's the fix...
+ s/^(\tjmp\s+.*\n)/$exit_patch$1/g; # here's the fix...
s/^\tJMP___SL/\tjmp \*${T_X86_PRE_LLBL}/go;
s/^\tJMP___L/\tjmp ${T_X86_PRE_LLBL}/go;
if ($StolenX86Regs == 2 ) {
die "ARGH! Jump uses \%esi or \%edi with -monly-2-regs:\n$_"
- if /^\t(jmp|call) .*\%e(si|di)/;
+ if /^\t(jmp|call)\s+.*\%e(si|di)/;
} elsif ($StolenX86Regs == 3 ) {
die "ARGH! Jump uses \%edi with -monly-3-regs:\n$_"
- if /^\t(jmp|call) .*\%edi/;
+ if /^\t(jmp|call)\s+.*\%edi/;
}
# --------------------------------------------------------
local(@lines) = split(/\n/, $tbl);
local($i, $j); #local ($i, $extra, $words_to_pad, $j);
- # see comment in mangleAsm as to why this silliness is needed.
- local($TDOTWORD) = ${T_DOT_WORD};
- local($TDOTGLOBAL) = ${T_DOT_GLOBAL};
- local($TUS) = ${T_US};
- local($TPOSTLBL) = ${T_POST_LBL};
-
# Deal with the header...
- for ($i = 0; $i <= $#lines && $lines[$i] !~ /^\t?$TDOTWORD\s+/o; $i++) {
+ for ($i = 0; $i <= $#lines && $lines[$i] !~ /^\t?${T_DOT_WORD}\s+/o; $i++) {
$label .= $lines[$i] . "\n",
- next if $lines[$i] =~ /^[A-Za-z0-9_]+_info$TPOSTLBL[@]?$/o
- || $lines[$i] =~ /$TDOTGLOBAL/o
- || $lines[$i] =~ /^$TUS[@]?\S+_vtbl$TPOSTLBL[@]?$/o;
+ next if $lines[$i] =~ /^[A-Za-z0-9_]+_info${T_POST_LBL}$/o
+ || $lines[$i] =~ /${T_DOT_GLOBAL}/o
+ || $lines[$i] =~ /^${T_US}\S+_vtbl${T_POST_LBL}$/o;
$before .= $lines[$i] . "\n"; # otherwise...
}
# Grab the table data...
if ( $TargetPlatform !~ /^hppa/ ) {
- for ( ; $i <= $#lines && $lines[$i] =~ /^\t?$TDOTWORD\s+/o; $i++) {
+ for ( ; $i <= $#lines && $lines[$i] =~ /^\t?${T_DOT_WORD}\s+/o; $i++) {
push(@words, $lines[$i]);
}
} else { # hppa weirdness
- for ( ; $i <= $#lines && $lines[$i] =~ /^\s+($TDOTWORD|\.IMPORT)/; $i++) {
+ for ( ; $i <= $#lines && $lines[$i] =~ /^\s+(${T_DOT_WORD}|\.IMPORT)/; $i++) {
if ($lines[$i] =~ /^\s+\.IMPORT/) {
push(@imports, $lines[$i]);
} else {
# The .zero business is for Linux/ELF.
# The .skip business is for Sparc/Solaris/ELF.
# The .blockz business is for HPPA.
- if ($discard1 && $words[0] =~ /^\t?($TDOTWORD\s+0|\.zero\s+4|\.skip\s+4|\.blockz\s+4)/) {
+ if ($discard1 && $words[0] =~ /^\t?(${T_DOT_WORD}\s+0|\.zero\s+4|\.skip\s+4|\.blockz\s+4)/) {
shift(@words)
}
/* ----------------------------------------------------------------------------
- * $Id: ClosureMacros.h,v 1.26 2000/10/06 15:38:06 simonmar Exp $
+ * $Id: ClosureMacros.h,v 1.27 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#ifndef CLOSUREMACROS_H
#define CLOSUREMACROS_H
+/* Say whether the code comes before the heap; on mingwin this may not be the
+ case, not because of another random MS pathology, but because the static
+ program may reside in a DLL
+*/
+
+#undef TEXT_BEFORE_HEAP
+#ifndef mingw32_TARGET_OS
+#define TEXT_BEFORE_HEAP 1
+#endif
+
/* -----------------------------------------------------------------------------
Fixed Header Size
#endif
-#ifdef ENABLE_WIN32_DLL_SUPPORT /* needed for mingw DietHEP */
- extern int is_heap_alloced(const void* x);
-# define HEAP_ALLOCED(x) (is_heap_alloced(x))
+#ifdef TEXT_BEFORE_HEAP
+# define HEAP_ALLOCED(x) IS_USER_PTR(x)
#else
-# define HEAP_ALLOCED(x) IS_USER_PTR(x)
+extern int is_heap_alloced(const void* x);
+# define HEAP_ALLOCED(x) (is_heap_alloced(x))
#endif
/* When working with Win32 DLLs, static closures are identified by
# define IS_HUGS_CONSTR_INFO(info) 0 /* ToDo: more than mildly bogus */
#endif
-#ifdef ENABLE_WIN32_DLL_SUPPORT /* needed for mingw DietHEP */
+#ifdef TEXT_BEFORE_HEAP /* needed for mingw DietHEP */
+# define LOOKS_LIKE_GHC_INFO(info) IS_CODE_PTR(info)
+#else
# define LOOKS_LIKE_GHC_INFO(info) (!HEAP_ALLOCED(info) \
&& !LOOKS_LIKE_STATIC_CLOSURE(info))
-#else
-# define LOOKS_LIKE_GHC_INFO(info) IS_CODE_PTR(info)
#endif
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: PrimOps.h,v 1.64 2000/10/12 15:49:34 simonmar Exp $
+ * $Id: PrimOps.h,v 1.65 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
EXTFUN_RTS(decodeFloatzh_fast);
EXTFUN_RTS(decodeDoublezh_fast);
+/* Bit operations */
+EXTFUN_RTS(andIntegerzh_fast);
+EXTFUN_RTS(orIntegerzh_fast);
+EXTFUN_RTS(xorIntegerzh_fast);
+EXTFUN_RTS(complementIntegerzh_fast);
+
/* -----------------------------------------------------------------------------
Word64 PrimOps.
-------------------------------------------------------------------------- */
#ifdef COMPILING_RTS
#define DLL_IMPORT DLLIMPORT
#define DLL_IMPORT_RTS
-#define DLL_IMPORT_DATA
#define DLL_IMPORT_DATA_VAR(x) x
#else
#define DLL_IMPORT
#define DLL_IMPORT_RTS DLLIMPORT
-#define DLL_IMPORT_DATA DLLIMPORT
# ifdef ENABLE_WIN32_DLL_SUPPORT
# define DLL_IMPORT_DATA_VAR(x) _imp__##x
# else
/* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.34 2000/08/15 14:22:24 simonmar Exp $
+ * $Id: StgMacros.h,v 1.35 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
Catch frames
-------------------------------------------------------------------------- */
-extern DLL_IMPORT_DATA const StgPolyInfoTable catch_frame_info;
+extern DLL_IMPORT_RTS const StgPolyInfoTable catch_frame_info;
/* -----------------------------------------------------------------------------
Seq frames
an update...
-------------------------------------------------------------------------- */
-extern DLL_IMPORT_DATA const StgPolyInfoTable seq_frame_info;
+extern DLL_IMPORT_RTS const StgPolyInfoTable seq_frame_info;
#define PUSH_SEQ_FRAME(sp) \
{ \
-------------------------------------------------------------------------- */
#if defined(USE_SPLIT_MARKERS)
+#if defined(cygwin32_TARGET_OS) || defined(mingw32_TARGET_OS)
+#define __STG_SPLIT_MARKER __asm__("\n___stg_split_marker:");
+#else
#define __STG_SPLIT_MARKER __asm__("\n__stg_split_marker:");
+#endif
#else
#define __STG_SPLIT_MARKER /* nothing */
#endif
/* -----------------------------------------------------------------------------
- * $Id: StgMiscClosures.h,v 1.20 2000/10/12 15:50:14 simonmar Exp $
+ * $Id: StgMiscClosures.h,v 1.21 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
/* closures */
-extern DLL_IMPORT_DATA StgClosure END_TSO_QUEUE_closure;
-extern DLL_IMPORT_DATA StgClosure END_MUT_LIST_closure;
-extern DLL_IMPORT_DATA StgClosure NO_FINALIZER_closure;
-extern DLL_IMPORT_DATA StgClosure dummy_ret_closure;
-extern DLL_IMPORT_DATA StgClosure forceIO_closure;
+extern DLL_IMPORT_RTS StgClosure END_TSO_QUEUE_closure;
+extern DLL_IMPORT_RTS StgClosure END_MUT_LIST_closure;
+extern DLL_IMPORT_RTS StgClosure NO_FINALIZER_closure;
+extern DLL_IMPORT_RTS StgClosure dummy_ret_closure;
+extern DLL_IMPORT_RTS StgClosure forceIO_closure;
-extern DLL_IMPORT_DATA StgIntCharlikeClosure CHARLIKE_closure[];
-extern DLL_IMPORT_DATA StgIntCharlikeClosure INTLIKE_closure[];
+extern DLL_IMPORT_RTS StgIntCharlikeClosure CHARLIKE_closure[];
+extern DLL_IMPORT_RTS StgIntCharlikeClosure INTLIKE_closure[];
/* standard entry points */
/* -----------------------------------------------------------------------------
- * $Id: TailCalls.h,v 1.5 2000/04/05 14:26:31 panne Exp $
+ * $Id: TailCalls.h,v 1.6 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
stack that GCC hasn't popped yet. Also possibly to fool any
optimisations (a function call often acts as a barrier). Not sure
if any of this is necessary now -- SDM
+
+ Comment to above note: I don't think the __DISCARD__() in JMP_ is
+ necessary. Arguments should be popped from the C stack immediately
+ after returning from a function, as long as we pass -fno-defer-pop
+ to gcc. Moreover, a goto to a first-class label acts as a barrier
+ for optimisations in the same way a function call does.
+ -= chak
*/
/* The goto here seems to cause gcc -O2 to delete all the code after
function and these markers is shredded by the mangler.
-------------------------------------------------------------------------- */
+/* The following __DISCARD__() has become necessary with gcc 2.96 on x86.
+ * It prevents gcc from moving stack manipulation code from the function
+ * body (aka the Real Code) into the function prologue, ie, from moving it
+ * over the --- BEGIN --- marker. It should be noted that (like some
+ * other black magic in GHC's code), there is no essential reason why gcc
+ * could not move some stack manipulation code across the __DISCARD__() -
+ * it just doesn't choose to do it at the moment.
+ * -= chak
+ */
#ifndef FB_
-#define FB_ __asm__ volatile ("--- BEGIN ---");
+#define FB_ __asm__ volatile ("--- BEGIN ---"); __DISCARD__ ();
#endif
#ifndef FE_
/* -----------------------------------------------------------------------------
- * $Id: Updates.h,v 1.18 2000/05/15 14:38:11 simonmar Exp $
+ * $Id: Updates.h,v 1.19 2000/11/07 10:42:56 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#define PUSH_STD_CCCS(frame)
#endif
-extern DLL_IMPORT_DATA const StgPolyInfoTable upd_frame_info;
+extern DLL_IMPORT_RTS const StgPolyInfoTable upd_frame_info;
#define PUSH_UPD_FRAME(target, Sp_offset) \
{ \
DLL_IMPORT_RTS extern STGFUN(upd_frame_entry);
-extern DLL_IMPORT_DATA const StgInfoTable PAP_info;
+extern DLL_IMPORT_RTS const StgInfoTable PAP_info;
DLL_IMPORT_RTS STGFUN(PAP_entry);
EXTFUN_RTS(stg_update_PAP);
-extern DLL_IMPORT_DATA const StgInfoTable AP_UPD_info;
+extern DLL_IMPORT_RTS const StgInfoTable AP_UPD_info;
DLL_IMPORT_RTS STGFUN(AP_UPD_entry);
-extern DLL_IMPORT_DATA const StgInfoTable raise_info;
+extern DLL_IMPORT_RTS const StgInfoTable raise_info;
#endif /* UPDATES_H */
HC = $(GHC_INPLACE)
MKDEPENDHS = $(GHC_INPLACE)
-ifneq "$(way)" "dll"
+ifneq "$(DLLized)" "YES"
PACKAGE = -package-name std
else
# Hack by SPJ to delay if-then-else until the pattern rule when we have $*
PACKAGE = $(subst ~, ,$(word $(words dummy $(findstring $(notdir $*), PrelMain )), -package-name~std))
endif
-LIBRARY = libHSstd$(_way).a
-LIBOBJS = $(HS_OBJS)
+HSLIB = std
+
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
LIBOBJS = $(filter-out PrelHugs.$(way_)o,$(HS_OBJS))
endif
# Setting the GHC compile options
SRC_HC_OPTS += -recomp -cpp -fglasgow-exts-no-lang -fvia-C -Rghc-timing $(GhcLibHcOpts) $(PACKAGE)
-ifneq "$(way)" "dll"
+ifneq "$(DLLized)" "YES"
SRC_HC_OPTS += -static
endif
boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
-DLL_NAME = HSstd.dll
DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
-DLL_IMPLIB_NAME = libHSstd_imp.a
-SRC_BLD_DLL_OPTS += --export-all --output-def=HSstd.def DllVersionInfo.o
-SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHSstd_cbits_imp -lgmp_imp -L. -L../../rts/gmp -L../../rts -Lcbits
-ifeq "$(way)" "dll"
+ifeq "$(DLLized)" "YES"
HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
endif
# PrelMain.dll_o isn't to be included in the final .a,
# but it needs to be generated
-ifeq "$(way)" "dll"
-all :: PrelMain.dll_o DllVersionInfo.o
-
+ifeq "$(DLLized)" "YES"
+all :: PrelMain.dll_o
endif
CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
#
# Files to install from here
#
-INSTALL_LIBS += $(LIBRARY)
-ifeq "$(way)" "dll"
-INSTALL_PROGS += $(DLL_NAME)
+ifeq "$(DLLized)" "YES"
INSTALL_LIBS += PrelMain.dll_o
-else
-ifeq "$(EnableWin32Dlls)" "YES"
-$(patsubst %.a,%_imp.a, $(LIBRARY))
endif
-endif
-INSTALL_DATAS += $(HS_IFACES) PrelGHC.$(way_)hi
-ifeq "$(way)" "dll"
+
+INSTALL_DATAS += PrelGHC.$(way_)hi
+ifeq "$(DLLized)" "YES"
INSTALL_DATAS := $(filter-out PrelHugs.$(way_)hi,$(INSTALL_DATAS))
endif
% -----------------------------------------------------------------------------
-% $Id: PrelAddr.lhs,v 1.17 2000/06/30 13:39:35 simonmar Exp $
+% $Id: PrelAddr.lhs,v 1.18 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
module PrelAddr (
Addr(..)
- , AddrOff(..)
, nullAddr -- :: Addr
- , alignAddr -- :: Addr -> Int -> Addr
- , plusAddr -- :: Addr -> AddrOff -> Addr
- , minusAddr -- :: Addr -> Addr -> AddrOff
+ , alignAddr -- :: Addr -> Int -> Addr
+ , plusAddr -- :: Addr -> Int -> Addr
+ , minusAddr -- :: Addr -> Addr -> Int
, indexAddrOffAddr -- :: Addr -> Int -> Addr
data Addr = A# Addr# deriving (Eq, Ord)
data Word = W# Word# deriving (Eq, Ord)
-newtype AddrOff = AddrOff# Int
-
nullAddr :: Addr
nullAddr = A# (int2Addr# 0#)
0# -> addr;
n -> A# (int2Addr# (ai +# (i -# n))) }}
-plusAddr :: Addr -> AddrOff -> Addr
-plusAddr (A# addr) (AddrOff# (I# off)) = A# (int2Addr# (addr2Int# addr +# off))
+plusAddr :: Addr -> Int -> Addr
+plusAddr (A# addr) (I# off) = A# (int2Addr# (addr2Int# addr +# off))
-minusAddr :: Addr -> Addr -> AddrOff
-minusAddr (A# a1) (A# a2) = AddrOff# (I# (addr2Int# a1 -# addr2Int# a2))
+minusAddr :: Addr -> Addr -> Int
+minusAddr (A# a1) (A# a2) = I# (addr2Int# a1 -# addr2Int# a2)
instance CCallable Addr
instance CReturnable Addr
integerToWord64zh
int64ToIntegerzh
word64ToIntegerzh
-
+ andIntegerzh
+ orIntegerzh
+ xorIntegerzh
+ complementIntegerzh
+
Arrayzh
ByteArrayzh
MutableArrayzh
% ------------------------------------------------------------------------------
-% $Id: PrelHandle.lhs,v 1.62 2000/09/14 14:24:02 simonmar Exp $
+% $Id: PrelHandle.lhs,v 1.63 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The AQUA Project, Glasgow University, 1994-2000
%
case sz_in_bytes of
0 -> return nullAddr -- this has the effect of overwriting the pointer to the old buffer.
_ -> do
- chunk <- allocMemory__ sz_in_bytes
+ chunk <- malloc sz_in_bytes
if chunk == nullAddr
then ioException (IOError Nothing ResourceExhausted "mkBuffer__" "not enough virtual memory")
else return chunk
haFilePath__ = "closed file",
haBuffers__ = []
}
-
-mkErrorHandle__ :: IOException -> Handle__
-mkErrorHandle__ ioe =
- Handle__ { haFO__ = nullFile__,
- haType__ = (ErrorHandle ioe),
- haBufferMode__ = NoBuffering,
- haFilePath__ = "error handle",
- haBuffers__ = []
- }
\end{code}
%*********************************************************
#endif
return hdl
- _ -> do ioError <- constructError "stdout"
- newHandle (mkErrorHandle__ ioError)
+ _ -> constructErrorAndFail "stdout"
)
stdin = unsafePerformIO (do
#endif
hConnectTerms stdout hdl
return hdl
- _ -> do ioError <- constructError "stdin"
- newHandle (mkErrorHandle__ ioError)
+ _ -> constructErrorAndFail "stdin"
)
hConnectTo stdout hdl
return hdl
- _ -> do ioError <- constructError "stderr"
- newHandle (mkErrorHandle__ ioError)
+ _ -> constructErrorAndFail "stderr"
)
\end{code}
hClose handle =
withHandle__ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> return handle_
_ -> do
rc <- closeFile (haFO__ handle_)
hFileSize handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hFileSize" handle
SemiClosedHandle -> ioe_closedHandle "hFileSize" handle
#ifdef __HUGS__
_ ->
withHandle__ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hSetBuffering" handle
_ -> do
{- Note:
hIsOpen handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> return False
SemiClosedHandle -> return False
_ -> return True
hIsClosed handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> return True
_ -> return False
hIsReadable handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hIsReadable" handle
SemiClosedHandle -> ioe_closedHandle "hIsReadable" handle
htype -> return (isReadable htype)
hIsWritable handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hIsWritable" handle
SemiClosedHandle -> ioe_closedHandle "hIsWritable" handle
htype -> return (isWritable htype)
hGetBuffering handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hGetBuffering" handle
_ ->
{-
hIsSeekable handle =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hIsSeekable" handle
SemiClosedHandle -> ioe_closedHandle "hIsSeekable" handle
AppendHandle -> return False
else
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hSetEcho" handle
_ -> do
rc <- setTerminalEcho (haFO__ handle_) (if on then 1 else 0) -- ConcHask: SAFE, won't block
else
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hGetEcho" handle
_ -> do
rc <- getTerminalEcho (haFO__ handle_) -- ConcHask: SAFE, won't block
hIsTerminalDevice handle = do
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hIsTerminalDevice" handle
_ -> do
rc <- isTerminalDevice (haFO__ handle_) -- ConcHask: SAFE, won't block
ioError (userError "slurpFile: file too big")
else do
let sz_i = fromInteger sz
- chunk <- allocMemory__ sz_i
+ chunk <- malloc sz_i
if chunk == nullAddr
then do
hClose handle
getHandleFd handle =
withHandle_ handle $ \ handle_ -> do
case (haType__ handle_) of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "getHandleFd" handle
_ -> do
fd <- getFileFd (haFO__ handle_)
wantReadableHandle fun handle act =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle fun handle
SemiClosedHandle -> ioe_closedHandle fun handle
AppendHandle -> ioException not_readable_error
checkWriteableHandle fun handle handle_ act
= case haType__ handle_ of
- ErrorHandle theError -> ioError (IOException theError)
ClosedHandle -> ioe_closedHandle fun handle
SemiClosedHandle -> ioe_closedHandle fun handle
ReadHandle -> ioError not_writeable_error
wantRWHandle fun handle act =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle fun handle
SemiClosedHandle -> ioe_closedHandle fun handle
_ -> act handle_
wantSeekableHandle fun handle act =
withHandle_ handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle fun handle
SemiClosedHandle -> ioe_closedHandle fun handle
_ -> act handle_
% ------------------------------------------------------------------------------
-% $Id: PrelHugs.lhs,v 1.13 2000/06/30 13:39:35 simonmar Exp $
+% $Id: PrelHugs.lhs,v 1.14 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The University of Glasgow, 2000
%
import PrelFloat(Double)
import PrelReal(Fractional,fromRational,toRational)
import PrelAddr(Addr(..),nullAddr)
-import PrelStable(StablePtr,makeStablePtr)
+import PrelStable(StablePtr,newStablePtr)
import PrelErr(error)
import PrelPack(unpackCString)
import List(length)
:: Int -> IO Addr
hugsprimCreateAdjThunk :: (a -> b) -> String -> Char -> IO Addr
hugsprimCreateAdjThunk fun typestr callconv
- = do sp <- makeStablePtr fun
+ = do sp <- newStablePtr fun
p <- copy_String_to_cstring typestr -- is never freed
a <- hugsCreateAdjThunk sp p callconv
return a
% ------------------------------------------------------------------------------
-% $Id: PrelIO.lhs,v 1.15 2000/07/25 15:20:10 simonmar Exp $
+% $Id: PrelIO.lhs,v 1.16 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The University of Glasgow, 1992-2000
%
import PrelRead ( Read(..), readIO )
import PrelShow
import PrelMaybe ( Maybe(..) )
-import PrelAddr ( Addr(..), AddrOff(..), nullAddr, plusAddr )
+import PrelAddr ( Addr(..), nullAddr, plusAddr )
import PrelList ( concat, reverse, null )
import PrelPack ( unpackNBytesST, unpackNBytesAccST )
import PrelException ( ioError, catch, catchException, throw )
-- the handle.
withHandle handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hGetContents" handle
SemiClosedHandle -> ioe_closedHandle "hGetContents" handle
AppendHandle -> ioException not_readable_error
case mode of
NoBuffering -> return (handle_, (mode, nullAddr, 0))
_ -> case bufs of
- [] -> do buf <- allocMemory__ sz
+ [] -> do buf <- malloc sz
return (handle_, (mode, buf, sz))
(b:bs) -> return (handle_{ haBuffers__ = bs }, (mode, b, sz))
-- not flushing, and there's enough room in the buffer:
-- just copy the data in and update bufWPtr.
- else do memcpy (plusAddr fo_buf (AddrOff# fo_wptr)) buf count
+ else do memcpy (plusAddr fo_buf fo_wptr) buf count
setBufWPtr fo (fo_wptr + count)
handle_ <- freeBuffer handle_ buf sz
ok handle_
if (rc < 0) then constructErrorAndFail "commitBuffer"
else return ()
- else do memcpy (plusAddr fo_buf (AddrOff# new_wptr)) buf count
+ else do memcpy (plusAddr fo_buf new_wptr) buf count
setBufWPtr fo (new_wptr + count)
return ()
% ------------------------------------------------------------------------------
-% $Id: PrelIOBase.lhs,v 1.28 2000/09/25 12:58:39 simonpj Exp $
+% $Id: PrelIOBase.lhs,v 1.29 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
import PrelBase
import PrelNum ( fromInteger ) -- Integer literals
import PrelMaybe ( Maybe(..) )
-import PrelAddr ( Addr(..) )
+import PrelAddr ( Addr(..), nullAddr )
import PrelShow
import PrelList
import PrelDynamic
of the following:
-}
data Handle__Type
- = ErrorHandle IOException
- | ClosedHandle
+ = ClosedHandle
| SemiClosedHandle
| ReadHandle
| WriteHandle
instance Show Handle__Type where
showsPrec p t =
case t of
- ErrorHandle iot -> showString "error " . showsPrec p iot
ClosedHandle -> showString "closed"
SemiClosedHandle -> showString "semi-closed"
ReadHandle -> showString "readable"
showHdl ht cont =
case ht of
ClosedHandle -> showsPrec p ht . showString "}\n"
- ErrorHandle _ -> showsPrec p ht . showString "}\n"
_ -> cont
showBufMode :: FILE_OBJECT -> BufferMode -> ShowS
foreign import "libHS_cbits" "getErrStr__" unsafe getErrStr__ :: IO Addr
foreign import "libHS_cbits" "getErrNo__" unsafe getErrNo__ :: IO Int
foreign import "libHS_cbits" "getErrType__" unsafe getErrType__ :: IO Int
+
+malloc :: Int -> IO Addr
+malloc sz = do
+ a <- _malloc sz
+ if (a == nullAddr)
+ then ioException (IOError Nothing ResourceExhausted "malloc" "")
+ else return a
+
+foreign import "malloc" unsafe _malloc :: Int -> IO Addr
-foreign import "libHS_cbits" "allocMemory__" unsafe
- allocMemory__ :: Int -> IO Addr
foreign import "libHS_cbits" "getBufSize" unsafe
getBufSize :: FILE_OBJECT -> IO Int
foreign import "libHS_cbits" "setBuf" unsafe
% -----------------------------------------------------------------------------
-% $Id: PrelStable.lhs,v 1.7 2000/06/30 13:39:36 simonmar Exp $
+% $Id: PrelStable.lhs,v 1.8 2000/11/07 10:42:57 simonmar Exp $
%
% (c) The GHC Team, 1992-2000
%
module PrelStable
( StablePtr(..)
- , makeStablePtr -- :: a -> IO (StablePtr a)
+ , newStablePtr -- :: a -> IO (StablePtr a)
, deRefStablePtr -- :: StablePtr a -> a
, freeStablePtr -- :: StablePtr a -> IO ()
) where
instance CCallable (StablePtr a)
instance CReturnable (StablePtr a)
-makeStablePtr :: a -> IO (StablePtr a)
+newStablePtr :: a -> IO (StablePtr a)
deRefStablePtr :: StablePtr a -> IO a
-foreign import "freeStablePtr" unsafe freeStablePtr :: StablePtr a -> IO ()
+foreign import unsafe freeStablePtr :: StablePtr a -> IO ()
-makeStablePtr a = IO $ \ s ->
+newStablePtr a = IO $ \ s ->
case makeStablePtr# a s of (# s', sp #) -> (# s', StablePtr sp #)
deRefStablePtr (StablePtr sp) = IO $ \s -> deRefStablePtr# sp s
-# $Id: Makefile,v 1.23 2000/08/07 16:09:03 rrt Exp $
+# $Id: Makefile,v 1.24 2000/11/07 10:42:57 simonmar Exp $
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
-WAYS=$(GhcLibWays)
-
-ifeq "$(filter dll,$(WAYS))" "dll"
-override WAYS=dll
-else
override WAYS=
-endif
-LIBRARY=libHSstd_cbits$(_way).a
+HSLIB = std
+IS_CBITS_LIB = YES
C_SRCS= $(wildcard *.c)
C_OBJS = $(C_SRCS:.c=.$(way_)o)
LIBOBJS = $(C_OBJS)
-SRC_CC_OPTS += -O -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) $(GhcLibCcOpts) -Wall
-
-ifneq "$(way)" "dll"
+SRC_CC_OPTS += -O $(GhcLibCcOpts) -Wall -optc-DCOMPILING_STDLIB
+ifneq "$(DLLized)" "YES"
SRC_CC_OPTS += -static
endif
-ifeq "$(way)" "dll"
-all :: DllVersionInfo.o
-
-$(DLL_NAME) : DllVersionInfo.o
-endif
-
-DLL_NAME = HSstd_cbits.dll
-DLL_IMPLIB_NAME = libHSstd_cbits_imp.a
-DLL_DESCRIPTION = "Haskell Prelude helpers"
-SRC_BLD_DLL_OPTS += --export-all --output-def=HSstdcbits.def DllVersionInfo.o
-SRC_BLD_DLL_OPTS += -lwinmm -lwsock32 -lHSrts_imp -lgmp -L. -L../../../rts/gmp -L../../../rts
-SRC_CC_OPTS += -optc-DCOMPILING_STDLIB
-
#
# Compile the files using the Haskell compiler (ghc really).
#
# -----------------------------------------------------------------------------
# Installation
-INSTALL_LIBS+=$(LIBRARY)
-
-ifeq "$(EnableWin32DLLs)" "YES"
-INSTALL_PROGS += $(DLL_NAME)
-ifneq "$(way)" "dll"
-INSTALL_LIBS += $(patsubst %.a, %_imp.a, $(LIBRARY))
-endif
-endif
-
override datadir:=$(libdir)/includes
INSTALL_DATAS += HsStd.h stgio.h stgerror.h fileObject.h
+++ /dev/null
-/*
- * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
- *
- * $Id: allocMem.c,v 1.3 1999/11/25 16:54:14 simonmar Exp $
- *
- * malloc interface
- */
-
-#include "Rts.h"
-#include "stgio.h"
-
-StgAddr
-allocMemory__(StgInt sz/* bytes */)
-{
- StgAddr ptr;
-
- if ( (ptr = malloc(sz*sizeof(char))) == NULL) {
- ghc_errtype = ERR_RESOURCEEXHAUSTED;
- ghc_errstr = "malloc failed";
- return NULL;
- }
- return ptr;
-
-}
/* -----------------------------------------------------------------------------
- * $Id: stgio.h,v 1.23 2000/08/24 10:27:01 simonmar Exp $
+ * $Id: stgio.h,v 1.24 2000/11/07 10:42:57 simonmar Exp $
*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
*
#ifndef STGIO_H
#define STGIO_H
+#include "StgDLL.h" /* for DLL_IMPORT_STDLIB */
+
#include "stgerror.h"
#include "fileObject.h"
int delenv (char *);
/* errno.c */
-extern int ghc_errno;
-extern int ghc_errtype;
-extern char* ghc_errstr;
+DLL_IMPORT_STDLIB extern int ghc_errno;
+DLL_IMPORT_STDLIB extern int ghc_errtype;
+DLL_IMPORT_STDLIB extern char* ghc_errstr;
void cvtErrno(void);
void stdErrno(void);
#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.38 2000/11/01 11:41:47 simonmar Exp $
+# $Id: Makefile,v 1.39 2000/11/07 10:42:57 simonmar Exp $
#
# This is the Makefile for the runtime-system stuff.
# This stuff is written in C (and cannot be written in Haskell).
SRCS_RTS_S = $(wildcard *.S)
SRCS_RTS_HC = $(wildcard *.hc) $(wildcard parallel/*.hc)
-ifneq "$(way)" "dll"
+ifneq "$(DLLized)" "YES"
SRCS_RTS_C := $(filter-out RtsDllMain.c, $(SRCS_RTS_C))
else
SRCS_RTS_C := $(filter-out Main.c, $(SRCS_RTS_C))
#-----------------------------------------------------------------------------
# creating and installing libHSrts.a (in its many flavors)
#
-LIBRARY = libHSrts$(_way).a
LIBOBJS = $(patsubst %.c,%.$(way_)o,$(SRCS_RTS_C)) \
$(patsubst %.hc,%.$(way_)o,$(SRCS_RTS_HC)) \
$(patsubst %.S,%.$(way_)o,$(SRCS_RTS_S))
SRC_HC_OPTS += -I../includes -I. -Iparallel $(WARNING_OPTS) $(GhcRtsHcOpts) -optc-DCOMPILING_RTS
SRC_CC_OPTS = $(GhcRtsCcOpts)
-ifneq "$(way)" "dll"
+ifneq "$(DLLized)" "YES"
SRC_HC_OPTS += -static
endif
# SRC_HC_OPTS += -optc-fPIC
# -----------------------------------------------------------------------------
#
# Building DLLs is only supported on mingw32 at the moment.
-#
-DLL_NAME = HSrts.dll
-ifeq "$(way)" "dll"
-DLL_IMPLIB_NAME = libHSrts_imp.a
+#
+HSLIB = rts
-SRC_BLD_DLL_OPTS += --output-def=HSrts.def --export-all -L. -Lgmp -lwinmm \
- -lHS_imp_stub -lgmp_imp
+ifeq "$(DLLized)" "YES"
+SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp
+
+# It's not included in the DLL, but we need to compile it up separately.
+all :: Main.dll_o
-#
# Need an import library containing the symbols the RTS uses from the Prelude.
# So, to avoid bootstrapping trouble, we build one containing just the syms
# we need. Weirdly named to avoid clashing later on when compiling the contents
# Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
# below will need to be updated as well.
-$(DLL_PEN)/$(DLL_NAME) :: libHS_imp_stub.a
+$(DLL_PEN)/HSrts$(_way).dll :: libHS_imp_stub.a
libHS_imp_stub.a :
dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
-# It's not included in the DLL, but we need to compile it up separately.
-all :: Main.dll_o
-
endif
# -----------------------------------------------------------------------------
all :: gmp/libgmp.a
-ifeq "$(way)" "dll"
+ifeq "$(DLLized)" "YES"
all :: $(DLL_PEN)/gmp.dll
$(DLL_PEN)/gmp.dll:
# Just libHSrts is installed uniformly across ways
#
INSTALL_LIBS += $(LIBRARY)
-ifeq "$(EnableWin32DLLs)" "YES"
+ifeq "$(DLLized)" "YES"
INSTALL_PROGS += $(DLL_NAME) gmp/gmp.dll
-ifneq "$(way)" "dll"
-INSTALL_LIBS += $(patsubst %.a, %_imp.a, $(LIBARY))
-endif
+INSTALL_LIBS += $(patsubst %.a,%_imp.a,$(LIBARY))
INSTALL_LIBS += gmp/libgmp_imp.a Main.dll_o
endif
include $(TOP)/mk/target.mk
-
/* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.55 2000/09/26 16:45:35 simonpj Exp $
+ * $Id: PrimOps.hc,v 1.56 2000/11/07 10:42:57 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
FE_ \
}
+#define GMP_TAKE1_RET1(name,mp_fun) \
+FN_(name) \
+{ \
+ MP_INT arg1, result; \
+ I_ s1; \
+ StgArrWords* d1; \
+ FB_ \
+ \
+ /* call doYouWantToGC() */ \
+ MAYBE_GC(R2_PTR, name); \
+ \
+ d1 = (StgArrWords *)R2.p; \
+ s1 = R1.i; \
+ \
+ arg1._mp_alloc = d1->words; \
+ arg1._mp_size = (s1); \
+ arg1._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d1)); \
+ \
+ STGCALL1(mpz_init,&result); \
+ \
+ /* Perform the operation */ \
+ STGCALL2(mp_fun,&result,&arg1); \
+ \
+ TICK_RET_UNBOXED_TUP(2); \
+ RET_NP(result._mp_size, \
+ result._mp_d-sizeofW(StgArrWords)); \
+ FE_ \
+}
+
#define GMP_TAKE2_RET2(name,mp_fun) \
FN_(name) \
{ \
GMP_TAKE2_RET1(quotIntegerzh_fast, mpz_tdiv_q);
GMP_TAKE2_RET1(remIntegerzh_fast, mpz_tdiv_r);
GMP_TAKE2_RET1(divExactIntegerzh_fast, mpz_divexact);
+GMP_TAKE2_RET1(andIntegerzh_fast, mpz_and);
+GMP_TAKE2_RET1(orIntegerzh_fast, mpz_ior);
+GMP_TAKE2_RET1(xorIntegerzh_fast, mpz_xor);
+GMP_TAKE1_RET1(complementIntegerzh_fast, mpz_com);
GMP_TAKE2_RET2(quotRemIntegerzh_fast, mpz_tdiv_qr);
GMP_TAKE2_RET2(divModIntegerzh_fast, mpz_fdiv_qr);
/* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.79 2000/10/10 09:12:19 simonmar Exp $
+ * $Id: Schedule.c,v 1.80 2000/11/07 10:42:57 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
StgTSO *CurrentTSO;
#endif
+/* This is used in `TSO.h' and gcc 2.96 insists that this variable actually
+ * exists - earlier gccs apparently didn't.
+ * -= chak
+ */
+StgTSO dummy_tso;
+
rtsBool ready_to_gc;
/* All our current task ids, saved in case we need to kill them later.
testIntlike "Word8" (0::Word8)
testIntlike "Word16" (0::Word16)
testIntlike "Word32" (0::Word32)
+ testInteger
testIntlikeNoBits :: (Bounded a, Integral a, Ix a, Read a) => String -> a -> IO ()
testIntlikeNoBits name zero = do
testReal zero
testIntegral zero
+testInteger = do
+ let zero = 0 :: Integer
+ putStrLn $ "--------------------------------"
+ putStrLn $ "--Testing Integer
+ putStrLn $ "--------------------------------"
+ testEnum zero
+ testReadShow zero
+ testEq zero
+ testOrd zero
+ testNum zero
+ testReal zero
+ testIntegral zero
+ testBits zero False
testIntlike :: (Bounded a, Integral a, Ix a, Read a, Bits a) => String -> a -> IO ()
testIntlike name zero = do
testIntlikeNoBits name zero
- testBits zero
+ testBits zero True
-- In all these tests, zero is a dummy element used to get
where
(xs,ys) = samples zero
-testBits zero = do
+testBits zero do_bitsize = do
putStrLn "testBits"
table2 ".&. " (.&.) xs ys
table2 ".|. " (.|.) xs ys
table2 "`clearBit`" clearBit xs ([0..3] ++ [32])
table2 "`complementBit`" complementBit xs ([0..3] ++ [32])
table2 "`testBit`" testBit xs ([0..3] ++ [32])
- table1 "bitSize" bitSize xs
+ if do_bitsize then table1 "bitSize" bitSize xs else return ()
table1 "isSigned" isSigned xs
where
(xs,ys) = samples zero
isSigned 2 = False
isSigned 3 = False
#
+--------------------------------
+--Testing Integer
+ putStrLn $
+testEnum
+[0,1,2,3,4,5,6,7,8,9]
+[0,2,4,6,8,10,12,14,16,18]
+[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
+[0,2,4,6,8,10,12,14,16,18,20]
+testReadShow
+[-3,-2,-1,0,1,2,3]
+[-3,-2,-1,0,1,2,3]
+testEq
+-3 == -3 = True
+-3 == -2 = False
+-3 == -1 = False
+-3 == 0 = False
+-3 == 1 = False
+-3 == 2 = False
+-3 == 3 = False
+
+-2 == -3 = False
+-2 == -2 = True
+-2 == -1 = False
+-2 == 0 = False
+-2 == 1 = False
+-2 == 2 = False
+-2 == 3 = False
+
+-1 == -3 = False
+-1 == -2 = False
+-1 == -1 = True
+-1 == 0 = False
+-1 == 1 = False
+-1 == 2 = False
+-1 == 3 = False
+
+0 == -3 = False
+0 == -2 = False
+0 == -1 = False
+0 == 0 = True
+0 == 1 = False
+0 == 2 = False
+0 == 3 = False
+
+1 == -3 = False
+1 == -2 = False
+1 == -1 = False
+1 == 0 = False
+1 == 1 = True
+1 == 2 = False
+1 == 3 = False
+
+2 == -3 = False
+2 == -2 = False
+2 == -1 = False
+2 == 0 = False
+2 == 1 = False
+2 == 2 = True
+2 == 3 = False
+
+3 == -3 = False
+3 == -2 = False
+3 == -1 = False
+3 == 0 = False
+3 == 1 = False
+3 == 2 = False
+3 == 3 = True
+
+#
+-3 /= -3 = False
+-3 /= -2 = True
+-3 /= -1 = True
+-3 /= 0 = True
+-3 /= 1 = True
+-3 /= 2 = True
+-3 /= 3 = True
+
+-2 /= -3 = True
+-2 /= -2 = False
+-2 /= -1 = True
+-2 /= 0 = True
+-2 /= 1 = True
+-2 /= 2 = True
+-2 /= 3 = True
+
+-1 /= -3 = True
+-1 /= -2 = True
+-1 /= -1 = False
+-1 /= 0 = True
+-1 /= 1 = True
+-1 /= 2 = True
+-1 /= 3 = True
+
+0 /= -3 = True
+0 /= -2 = True
+0 /= -1 = True
+0 /= 0 = False
+0 /= 1 = True
+0 /= 2 = True
+0 /= 3 = True
+
+1 /= -3 = True
+1 /= -2 = True
+1 /= -1 = True
+1 /= 0 = True
+1 /= 1 = False
+1 /= 2 = True
+1 /= 3 = True
+
+2 /= -3 = True
+2 /= -2 = True
+2 /= -1 = True
+2 /= 0 = True
+2 /= 1 = True
+2 /= 2 = False
+2 /= 3 = True
+
+3 /= -3 = True
+3 /= -2 = True
+3 /= -1 = True
+3 /= 0 = True
+3 /= 1 = True
+3 /= 2 = True
+3 /= 3 = False
+
+#
+testOrd
+-3 <= -3 = True
+-3 <= -2 = True
+-3 <= -1 = True
+-3 <= 0 = True
+-3 <= 1 = True
+-3 <= 2 = True
+-3 <= 3 = True
+
+-2 <= -3 = False
+-2 <= -2 = True
+-2 <= -1 = True
+-2 <= 0 = True
+-2 <= 1 = True
+-2 <= 2 = True
+-2 <= 3 = True
+
+-1 <= -3 = False
+-1 <= -2 = False
+-1 <= -1 = True
+-1 <= 0 = True
+-1 <= 1 = True
+-1 <= 2 = True
+-1 <= 3 = True
+
+0 <= -3 = False
+0 <= -2 = False
+0 <= -1 = False
+0 <= 0 = True
+0 <= 1 = True
+0 <= 2 = True
+0 <= 3 = True
+
+1 <= -3 = False
+1 <= -2 = False
+1 <= -1 = False
+1 <= 0 = False
+1 <= 1 = True
+1 <= 2 = True
+1 <= 3 = True
+
+2 <= -3 = False
+2 <= -2 = False
+2 <= -1 = False
+2 <= 0 = False
+2 <= 1 = False
+2 <= 2 = True
+2 <= 3 = True
+
+3 <= -3 = False
+3 <= -2 = False
+3 <= -1 = False
+3 <= 0 = False
+3 <= 1 = False
+3 <= 2 = False
+3 <= 3 = True
+
+#
+-3 < -3 = False
+-3 < -2 = True
+-3 < -1 = True
+-3 < 0 = True
+-3 < 1 = True
+-3 < 2 = True
+-3 < 3 = True
+
+-2 < -3 = False
+-2 < -2 = False
+-2 < -1 = True
+-2 < 0 = True
+-2 < 1 = True
+-2 < 2 = True
+-2 < 3 = True
+
+-1 < -3 = False
+-1 < -2 = False
+-1 < -1 = False
+-1 < 0 = True
+-1 < 1 = True
+-1 < 2 = True
+-1 < 3 = True
+
+0 < -3 = False
+0 < -2 = False
+0 < -1 = False
+0 < 0 = False
+0 < 1 = True
+0 < 2 = True
+0 < 3 = True
+
+1 < -3 = False
+1 < -2 = False
+1 < -1 = False
+1 < 0 = False
+1 < 1 = False
+1 < 2 = True
+1 < 3 = True
+
+2 < -3 = False
+2 < -2 = False
+2 < -1 = False
+2 < 0 = False
+2 < 1 = False
+2 < 2 = False
+2 < 3 = True
+
+3 < -3 = False
+3 < -2 = False
+3 < -1 = False
+3 < 0 = False
+3 < 1 = False
+3 < 2 = False
+3 < 3 = False
+
+#
+-3 > -3 = False
+-3 > -2 = False
+-3 > -1 = False
+-3 > 0 = False
+-3 > 1 = False
+-3 > 2 = False
+-3 > 3 = False
+
+-2 > -3 = True
+-2 > -2 = False
+-2 > -1 = False
+-2 > 0 = False
+-2 > 1 = False
+-2 > 2 = False
+-2 > 3 = False
+
+-1 > -3 = True
+-1 > -2 = True
+-1 > -1 = False
+-1 > 0 = False
+-1 > 1 = False
+-1 > 2 = False
+-1 > 3 = False
+
+0 > -3 = True
+0 > -2 = True
+0 > -1 = True
+0 > 0 = False
+0 > 1 = False
+0 > 2 = False
+0 > 3 = False
+
+1 > -3 = True
+1 > -2 = True
+1 > -1 = True
+1 > 0 = True
+1 > 1 = False
+1 > 2 = False
+1 > 3 = False
+
+2 > -3 = True
+2 > -2 = True
+2 > -1 = True
+2 > 0 = True
+2 > 1 = True
+2 > 2 = False
+2 > 3 = False
+
+3 > -3 = True
+3 > -2 = True
+3 > -1 = True
+3 > 0 = True
+3 > 1 = True
+3 > 2 = True
+3 > 3 = False
+
+#
+-3 >= -3 = True
+-3 >= -2 = False
+-3 >= -1 = False
+-3 >= 0 = False
+-3 >= 1 = False
+-3 >= 2 = False
+-3 >= 3 = False
+
+-2 >= -3 = True
+-2 >= -2 = True
+-2 >= -1 = False
+-2 >= 0 = False
+-2 >= 1 = False
+-2 >= 2 = False
+-2 >= 3 = False
+
+-1 >= -3 = True
+-1 >= -2 = True
+-1 >= -1 = True
+-1 >= 0 = False
+-1 >= 1 = False
+-1 >= 2 = False
+-1 >= 3 = False
+
+0 >= -3 = True
+0 >= -2 = True
+0 >= -1 = True
+0 >= 0 = True
+0 >= 1 = False
+0 >= 2 = False
+0 >= 3 = False
+
+1 >= -3 = True
+1 >= -2 = True
+1 >= -1 = True
+1 >= 0 = True
+1 >= 1 = True
+1 >= 2 = False
+1 >= 3 = False
+
+2 >= -3 = True
+2 >= -2 = True
+2 >= -1 = True
+2 >= 0 = True
+2 >= 1 = True
+2 >= 2 = True
+2 >= 3 = False
+
+3 >= -3 = True
+3 >= -2 = True
+3 >= -1 = True
+3 >= 0 = True
+3 >= 1 = True
+3 >= 2 = True
+3 >= 3 = True
+
+#
+-3 `compare` -3 = EQ
+-3 `compare` -2 = LT
+-3 `compare` -1 = LT
+-3 `compare` 0 = LT
+-3 `compare` 1 = LT
+-3 `compare` 2 = LT
+-3 `compare` 3 = LT
+
+-2 `compare` -3 = GT
+-2 `compare` -2 = EQ
+-2 `compare` -1 = LT
+-2 `compare` 0 = LT
+-2 `compare` 1 = LT
+-2 `compare` 2 = LT
+-2 `compare` 3 = LT
+
+-1 `compare` -3 = GT
+-1 `compare` -2 = GT
+-1 `compare` -1 = EQ
+-1 `compare` 0 = LT
+-1 `compare` 1 = LT
+-1 `compare` 2 = LT
+-1 `compare` 3 = LT
+
+0 `compare` -3 = GT
+0 `compare` -2 = GT
+0 `compare` -1 = GT
+0 `compare` 0 = EQ
+0 `compare` 1 = LT
+0 `compare` 2 = LT
+0 `compare` 3 = LT
+
+1 `compare` -3 = GT
+1 `compare` -2 = GT
+1 `compare` -1 = GT
+1 `compare` 0 = GT
+1 `compare` 1 = EQ
+1 `compare` 2 = LT
+1 `compare` 3 = LT
+
+2 `compare` -3 = GT
+2 `compare` -2 = GT
+2 `compare` -1 = GT
+2 `compare` 0 = GT
+2 `compare` 1 = GT
+2 `compare` 2 = EQ
+2 `compare` 3 = LT
+
+3 `compare` -3 = GT
+3 `compare` -2 = GT
+3 `compare` -1 = GT
+3 `compare` 0 = GT
+3 `compare` 1 = GT
+3 `compare` 2 = GT
+3 `compare` 3 = EQ
+
+#
+testNum
+-3 + -3 = -6
+-3 + -2 = -5
+-3 + -1 = -4
+-3 + 0 = -3
+-3 + 1 = -2
+-3 + 2 = -1
+-3 + 3 = 0
+
+-2 + -3 = -5
+-2 + -2 = -4
+-2 + -1 = -3
+-2 + 0 = -2
+-2 + 1 = -1
+-2 + 2 = 0
+-2 + 3 = 1
+
+-1 + -3 = -4
+-1 + -2 = -3
+-1 + -1 = -2
+-1 + 0 = -1
+-1 + 1 = 0
+-1 + 2 = 1
+-1 + 3 = 2
+
+0 + -3 = -3
+0 + -2 = -2
+0 + -1 = -1
+0 + 0 = 0
+0 + 1 = 1
+0 + 2 = 2
+0 + 3 = 3
+
+1 + -3 = -2
+1 + -2 = -1
+1 + -1 = 0
+1 + 0 = 1
+1 + 1 = 2
+1 + 2 = 3
+1 + 3 = 4
+
+2 + -3 = -1
+2 + -2 = 0
+2 + -1 = 1
+2 + 0 = 2
+2 + 1 = 3
+2 + 2 = 4
+2 + 3 = 5
+
+3 + -3 = 0
+3 + -2 = 1
+3 + -1 = 2
+3 + 0 = 3
+3 + 1 = 4
+3 + 2 = 5
+3 + 3 = 6
+
+#
+-3 - -3 = 0
+-3 - -2 = -1
+-3 - -1 = -2
+-3 - 0 = -3
+-3 - 1 = -4
+-3 - 2 = -5
+-3 - 3 = -6
+
+-2 - -3 = 1
+-2 - -2 = 0
+-2 - -1 = -1
+-2 - 0 = -2
+-2 - 1 = -3
+-2 - 2 = -4
+-2 - 3 = -5
+
+-1 - -3 = 2
+-1 - -2 = 1
+-1 - -1 = 0
+-1 - 0 = -1
+-1 - 1 = -2
+-1 - 2 = -3
+-1 - 3 = -4
+
+0 - -3 = 3
+0 - -2 = 2
+0 - -1 = 1
+0 - 0 = 0
+0 - 1 = -1
+0 - 2 = -2
+0 - 3 = -3
+
+1 - -3 = 4
+1 - -2 = 3
+1 - -1 = 2
+1 - 0 = 1
+1 - 1 = 0
+1 - 2 = -1
+1 - 3 = -2
+
+2 - -3 = 5
+2 - -2 = 4
+2 - -1 = 3
+2 - 0 = 2
+2 - 1 = 1
+2 - 2 = 0
+2 - 3 = -1
+
+3 - -3 = 6
+3 - -2 = 5
+3 - -1 = 4
+3 - 0 = 3
+3 - 1 = 2
+3 - 2 = 1
+3 - 3 = 0
+
+#
+-3 * -3 = 9
+-3 * -2 = 6
+-3 * -1 = 3
+-3 * 0 = 0
+-3 * 1 = -3
+-3 * 2 = -6
+-3 * 3 = -9
+
+-2 * -3 = 6
+-2 * -2 = 4
+-2 * -1 = 2
+-2 * 0 = 0
+-2 * 1 = -2
+-2 * 2 = -4
+-2 * 3 = -6
+
+-1 * -3 = 3
+-1 * -2 = 2
+-1 * -1 = 1
+-1 * 0 = 0
+-1 * 1 = -1
+-1 * 2 = -2
+-1 * 3 = -3
+
+0 * -3 = 0
+0 * -2 = 0
+0 * -1 = 0
+0 * 0 = 0
+0 * 1 = 0
+0 * 2 = 0
+0 * 3 = 0
+
+1 * -3 = -3
+1 * -2 = -2
+1 * -1 = -1
+1 * 0 = 0
+1 * 1 = 1
+1 * 2 = 2
+1 * 3 = 3
+
+2 * -3 = -6
+2 * -2 = -4
+2 * -1 = -2
+2 * 0 = 0
+2 * 1 = 2
+2 * 2 = 4
+2 * 3 = 6
+
+3 * -3 = -9
+3 * -2 = -6
+3 * -1 = -3
+3 * 0 = 0
+3 * 1 = 3
+3 * 2 = 6
+3 * 3 = 9
+
+#
+negate -3 = 3
+negate -2 = 2
+negate -1 = 1
+negate 0 = 0
+negate 1 = -1
+negate 2 = -2
+negate 3 = -3
+#
+testReal
+toRational -3 = -3 % 1
+toRational -2 = -2 % 1
+toRational -1 = -1 % 1
+toRational 0 = 0 % 1
+toRational 1 = 1 % 1
+toRational 2 = 2 % 1
+toRational 3 = 3 % 1
+#
+testIntegral
+-3 `divMod` -3 = (1,0)
+-3 `divMod` -2 = (1,-1)
+-3 `divMod` -1 = (3,0)
+-3 `divMod` 1 = (-3,0)
+-3 `divMod` 2 = (-2,1)
+-3 `divMod` 3 = (-1,0)
+
+-2 `divMod` -3 = (0,-2)
+-2 `divMod` -2 = (1,0)
+-2 `divMod` -1 = (2,0)
+-2 `divMod` 1 = (-2,0)
+-2 `divMod` 2 = (-1,0)
+-2 `divMod` 3 = (-1,1)
+
+-1 `divMod` -3 = (0,-1)
+-1 `divMod` -2 = (0,-1)
+-1 `divMod` -1 = (1,0)
+-1 `divMod` 1 = (-1,0)
+-1 `divMod` 2 = (-1,1)
+-1 `divMod` 3 = (-1,2)
+
+0 `divMod` -3 = (0,0)
+0 `divMod` -2 = (0,0)
+0 `divMod` -1 = (0,0)
+0 `divMod` 1 = (0,0)
+0 `divMod` 2 = (0,0)
+0 `divMod` 3 = (0,0)
+
+1 `divMod` -3 = (-1,-2)
+1 `divMod` -2 = (-1,-1)
+1 `divMod` -1 = (-1,0)
+1 `divMod` 1 = (1,0)
+1 `divMod` 2 = (0,1)
+1 `divMod` 3 = (0,1)
+
+2 `divMod` -3 = (-1,-1)
+2 `divMod` -2 = (-1,0)
+2 `divMod` -1 = (-2,0)
+2 `divMod` 1 = (2,0)
+2 `divMod` 2 = (1,0)
+2 `divMod` 3 = (0,2)
+
+3 `divMod` -3 = (-1,0)
+3 `divMod` -2 = (-2,-1)
+3 `divMod` -1 = (-3,0)
+3 `divMod` 1 = (3,0)
+3 `divMod` 2 = (1,1)
+3 `divMod` 3 = (1,0)
+
+#
+-3 `div` -3 = 1
+-3 `div` -2 = 1
+-3 `div` -1 = 3
+-3 `div` 1 = -3
+-3 `div` 2 = -2
+-3 `div` 3 = -1
+
+-2 `div` -3 = 0
+-2 `div` -2 = 1
+-2 `div` -1 = 2
+-2 `div` 1 = -2
+-2 `div` 2 = -1
+-2 `div` 3 = -1
+
+-1 `div` -3 = 0
+-1 `div` -2 = 0
+-1 `div` -1 = 1
+-1 `div` 1 = -1
+-1 `div` 2 = -1
+-1 `div` 3 = -1
+
+0 `div` -3 = 0
+0 `div` -2 = 0
+0 `div` -1 = 0
+0 `div` 1 = 0
+0 `div` 2 = 0
+0 `div` 3 = 0
+
+1 `div` -3 = -1
+1 `div` -2 = -1
+1 `div` -1 = -1
+1 `div` 1 = 1
+1 `div` 2 = 0
+1 `div` 3 = 0
+
+2 `div` -3 = -1
+2 `div` -2 = -1
+2 `div` -1 = -2
+2 `div` 1 = 2
+2 `div` 2 = 1
+2 `div` 3 = 0
+
+3 `div` -3 = -1
+3 `div` -2 = -2
+3 `div` -1 = -3
+3 `div` 1 = 3
+3 `div` 2 = 1
+3 `div` 3 = 1
+
+#
+-3 `mod` -3 = 0
+-3 `mod` -2 = -1
+-3 `mod` -1 = 0
+-3 `mod` 1 = 0
+-3 `mod` 2 = 1
+-3 `mod` 3 = 0
+
+-2 `mod` -3 = -2
+-2 `mod` -2 = 0
+-2 `mod` -1 = 0
+-2 `mod` 1 = 0
+-2 `mod` 2 = 0
+-2 `mod` 3 = 1
+
+-1 `mod` -3 = -1
+-1 `mod` -2 = -1
+-1 `mod` -1 = 0
+-1 `mod` 1 = 0
+-1 `mod` 2 = 1
+-1 `mod` 3 = 2
+
+0 `mod` -3 = 0
+0 `mod` -2 = 0
+0 `mod` -1 = 0
+0 `mod` 1 = 0
+0 `mod` 2 = 0
+0 `mod` 3 = 0
+
+1 `mod` -3 = -2
+1 `mod` -2 = -1
+1 `mod` -1 = 0
+1 `mod` 1 = 0
+1 `mod` 2 = 1
+1 `mod` 3 = 1
+
+2 `mod` -3 = -1
+2 `mod` -2 = 0
+2 `mod` -1 = 0
+2 `mod` 1 = 0
+2 `mod` 2 = 0
+2 `mod` 3 = 2
+
+3 `mod` -3 = 0
+3 `mod` -2 = -1
+3 `mod` -1 = 0
+3 `mod` 1 = 0
+3 `mod` 2 = 1
+3 `mod` 3 = 0
+
+#
+-3 `quotRem` -3 = (1,0)
+-3 `quotRem` -2 = (1,-1)
+-3 `quotRem` -1 = (3,0)
+-3 `quotRem` 1 = (-3,0)
+-3 `quotRem` 2 = (-1,-1)
+-3 `quotRem` 3 = (-1,0)
+
+-2 `quotRem` -3 = (0,-2)
+-2 `quotRem` -2 = (1,0)
+-2 `quotRem` -1 = (2,0)
+-2 `quotRem` 1 = (-2,0)
+-2 `quotRem` 2 = (-1,0)
+-2 `quotRem` 3 = (0,-2)
+
+-1 `quotRem` -3 = (0,-1)
+-1 `quotRem` -2 = (0,-1)
+-1 `quotRem` -1 = (1,0)
+-1 `quotRem` 1 = (-1,0)
+-1 `quotRem` 2 = (0,-1)
+-1 `quotRem` 3 = (0,-1)
+
+0 `quotRem` -3 = (0,0)
+0 `quotRem` -2 = (0,0)
+0 `quotRem` -1 = (0,0)
+0 `quotRem` 1 = (0,0)
+0 `quotRem` 2 = (0,0)
+0 `quotRem` 3 = (0,0)
+
+1 `quotRem` -3 = (0,1)
+1 `quotRem` -2 = (0,1)
+1 `quotRem` -1 = (-1,0)
+1 `quotRem` 1 = (1,0)
+1 `quotRem` 2 = (0,1)
+1 `quotRem` 3 = (0,1)
+
+2 `quotRem` -3 = (0,2)
+2 `quotRem` -2 = (-1,0)
+2 `quotRem` -1 = (-2,0)
+2 `quotRem` 1 = (2,0)
+2 `quotRem` 2 = (1,0)
+2 `quotRem` 3 = (0,2)
+
+3 `quotRem` -3 = (-1,0)
+3 `quotRem` -2 = (-1,1)
+3 `quotRem` -1 = (-3,0)
+3 `quotRem` 1 = (3,0)
+3 `quotRem` 2 = (1,1)
+3 `quotRem` 3 = (1,0)
+
+#
+-3 `quot` -3 = 1
+-3 `quot` -2 = 1
+-3 `quot` -1 = 3
+-3 `quot` 1 = -3
+-3 `quot` 2 = -1
+-3 `quot` 3 = -1
+
+-2 `quot` -3 = 0
+-2 `quot` -2 = 1
+-2 `quot` -1 = 2
+-2 `quot` 1 = -2
+-2 `quot` 2 = -1
+-2 `quot` 3 = 0
+
+-1 `quot` -3 = 0
+-1 `quot` -2 = 0
+-1 `quot` -1 = 1
+-1 `quot` 1 = -1
+-1 `quot` 2 = 0
+-1 `quot` 3 = 0
+
+0 `quot` -3 = 0
+0 `quot` -2 = 0
+0 `quot` -1 = 0
+0 `quot` 1 = 0
+0 `quot` 2 = 0
+0 `quot` 3 = 0
+
+1 `quot` -3 = 0
+1 `quot` -2 = 0
+1 `quot` -1 = -1
+1 `quot` 1 = 1
+1 `quot` 2 = 0
+1 `quot` 3 = 0
+
+2 `quot` -3 = 0
+2 `quot` -2 = -1
+2 `quot` -1 = -2
+2 `quot` 1 = 2
+2 `quot` 2 = 1
+2 `quot` 3 = 0
+
+3 `quot` -3 = -1
+3 `quot` -2 = -1
+3 `quot` -1 = -3
+3 `quot` 1 = 3
+3 `quot` 2 = 1
+3 `quot` 3 = 1
+
+#
+-3 `rem` -3 = 0
+-3 `rem` -2 = -1
+-3 `rem` -1 = 0
+-3 `rem` 1 = 0
+-3 `rem` 2 = -1
+-3 `rem` 3 = 0
+
+-2 `rem` -3 = -2
+-2 `rem` -2 = 0
+-2 `rem` -1 = 0
+-2 `rem` 1 = 0
+-2 `rem` 2 = 0
+-2 `rem` 3 = -2
+
+-1 `rem` -3 = -1
+-1 `rem` -2 = -1
+-1 `rem` -1 = 0
+-1 `rem` 1 = 0
+-1 `rem` 2 = -1
+-1 `rem` 3 = -1
+
+0 `rem` -3 = 0
+0 `rem` -2 = 0
+0 `rem` -1 = 0
+0 `rem` 1 = 0
+0 `rem` 2 = 0
+0 `rem` 3 = 0
+
+1 `rem` -3 = 1
+1 `rem` -2 = 1
+1 `rem` -1 = 0
+1 `rem` 1 = 0
+1 `rem` 2 = 1
+1 `rem` 3 = 1
+
+2 `rem` -3 = 2
+2 `rem` -2 = 0
+2 `rem` -1 = 0
+2 `rem` 1 = 0
+2 `rem` 2 = 0
+2 `rem` 3 = 2
+
+3 `rem` -3 = 0
+3 `rem` -2 = 1
+3 `rem` -1 = 0
+3 `rem` 1 = 0
+3 `rem` 2 = 1
+3 `rem` 3 = 0
+
+#
+testBits
+-3 .&. -3 = -3
+-3 .&. -2 = -4
+-3 .&. -1 = -3
+-3 .&. 1 = 1
+-3 .&. 2 = 0
+-3 .&. 3 = 1
+
+-2 .&. -3 = -4
+-2 .&. -2 = -2
+-2 .&. -1 = -2
+-2 .&. 1 = 0
+-2 .&. 2 = 2
+-2 .&. 3 = 2
+
+-1 .&. -3 = -3
+-1 .&. -2 = -2
+-1 .&. -1 = -1
+-1 .&. 1 = 1
+-1 .&. 2 = 2
+-1 .&. 3 = 3
+
+0 .&. -3 = 0
+0 .&. -2 = 0
+0 .&. -1 = 0
+0 .&. 1 = 0
+0 .&. 2 = 0
+0 .&. 3 = 0
+
+1 .&. -3 = 1
+1 .&. -2 = 0
+1 .&. -1 = 1
+1 .&. 1 = 1
+1 .&. 2 = 0
+1 .&. 3 = 1
+
+2 .&. -3 = 0
+2 .&. -2 = 2
+2 .&. -1 = 2
+2 .&. 1 = 0
+2 .&. 2 = 2
+2 .&. 3 = 2
+
+3 .&. -3 = 1
+3 .&. -2 = 2
+3 .&. -1 = 3
+3 .&. 1 = 1
+3 .&. 2 = 2
+3 .&. 3 = 3
+
+#
+-3 .|. -3 = -3
+-3 .|. -2 = -1
+-3 .|. -1 = -1
+-3 .|. 1 = -3
+-3 .|. 2 = -1
+-3 .|. 3 = -1
+
+-2 .|. -3 = -1
+-2 .|. -2 = -2
+-2 .|. -1 = -1
+-2 .|. 1 = -1
+-2 .|. 2 = -2
+-2 .|. 3 = -1
+
+-1 .|. -3 = -1
+-1 .|. -2 = -1
+-1 .|. -1 = -1
+-1 .|. 1 = -1
+-1 .|. 2 = -1
+-1 .|. 3 = -1
+
+0 .|. -3 = -3
+0 .|. -2 = -2
+0 .|. -1 = -1
+0 .|. 1 = 1
+0 .|. 2 = 2
+0 .|. 3 = 3
+
+1 .|. -3 = -3
+1 .|. -2 = -1
+1 .|. -1 = -1
+1 .|. 1 = 1
+1 .|. 2 = 3
+1 .|. 3 = 3
+
+2 .|. -3 = -1
+2 .|. -2 = -2
+2 .|. -1 = -1
+2 .|. 1 = 3
+2 .|. 2 = 2
+2 .|. 3 = 3
+
+3 .|. -3 = -1
+3 .|. -2 = -1
+3 .|. -1 = -1
+3 .|. 1 = 3
+3 .|. 2 = 3
+3 .|. 3 = 3
+
+#
+-3 `xor` -3 = 0
+-3 `xor` -2 = 3
+-3 `xor` -1 = 2
+-3 `xor` 1 = -4
+-3 `xor` 2 = -1
+-3 `xor` 3 = -2
+
+-2 `xor` -3 = 3
+-2 `xor` -2 = 0
+-2 `xor` -1 = 1
+-2 `xor` 1 = -1
+-2 `xor` 2 = -4
+-2 `xor` 3 = -3
+
+-1 `xor` -3 = 2
+-1 `xor` -2 = 1
+-1 `xor` -1 = 0
+-1 `xor` 1 = -2
+-1 `xor` 2 = -3
+-1 `xor` 3 = -4
+
+0 `xor` -3 = -3
+0 `xor` -2 = -2
+0 `xor` -1 = -1
+0 `xor` 1 = 1
+0 `xor` 2 = 2
+0 `xor` 3 = 3
+
+1 `xor` -3 = -4
+1 `xor` -2 = -1
+1 `xor` -1 = -2
+1 `xor` 1 = 0
+1 `xor` 2 = 3
+1 `xor` 3 = 2
+
+2 `xor` -3 = -1
+2 `xor` -2 = -4
+2 `xor` -1 = -3
+2 `xor` 1 = 3
+2 `xor` 2 = 0
+2 `xor` 3 = 1
+
+3 `xor` -3 = -2
+3 `xor` -2 = -3
+3 `xor` -1 = -4
+3 `xor` 1 = 2
+3 `xor` 2 = 1
+3 `xor` 3 = 0
+
+#
+complement -3 = 2
+complement -2 = 1
+complement -1 = 0
+complement 0 = -1
+complement 1 = -2
+complement 2 = -3
+complement 3 = -4
+#
+-3 `shiftL` 0 = -3
+-3 `shiftL` 1 = -6
+-3 `shiftL` 2 = -12
+-3 `shiftL` 3 = -24
+-3 `shiftL` 32 = -12884901888
+
+-2 `shiftL` 0 = -2
+-2 `shiftL` 1 = -4
+-2 `shiftL` 2 = -8
+-2 `shiftL` 3 = -16
+-2 `shiftL` 32 = -8589934592
+
+-1 `shiftL` 0 = -1
+-1 `shiftL` 1 = -2
+-1 `shiftL` 2 = -4
+-1 `shiftL` 3 = -8
+-1 `shiftL` 32 = -4294967296
+
+0 `shiftL` 0 = 0
+0 `shiftL` 1 = 0
+0 `shiftL` 2 = 0
+0 `shiftL` 3 = 0
+0 `shiftL` 32 = 0
+
+1 `shiftL` 0 = 1
+1 `shiftL` 1 = 2
+1 `shiftL` 2 = 4
+1 `shiftL` 3 = 8
+1 `shiftL` 32 = 4294967296
+
+2 `shiftL` 0 = 2
+2 `shiftL` 1 = 4
+2 `shiftL` 2 = 8
+2 `shiftL` 3 = 16
+2 `shiftL` 32 = 8589934592
+
+3 `shiftL` 0 = 3
+3 `shiftL` 1 = 6
+3 `shiftL` 2 = 12
+3 `shiftL` 3 = 24
+3 `shiftL` 32 = 12884901888
+
+#
+-3 `shiftR` 0 = -3
+-3 `shiftR` 1 = -2
+-3 `shiftR` 2 = -1
+-3 `shiftR` 3 = -1
+-3 `shiftR` 32 = -1
+
+-2 `shiftR` 0 = -2
+-2 `shiftR` 1 = -1
+-2 `shiftR` 2 = -1
+-2 `shiftR` 3 = -1
+-2 `shiftR` 32 = -1
+
+-1 `shiftR` 0 = -1
+-1 `shiftR` 1 = -1
+-1 `shiftR` 2 = -1
+-1 `shiftR` 3 = -1
+-1 `shiftR` 32 = -1
+
+0 `shiftR` 0 = 0
+0 `shiftR` 1 = 0
+0 `shiftR` 2 = 0
+0 `shiftR` 3 = 0
+0 `shiftR` 32 = 0
+
+1 `shiftR` 0 = 1
+1 `shiftR` 1 = 0
+1 `shiftR` 2 = 0
+1 `shiftR` 3 = 0
+1 `shiftR` 32 = 0
+
+2 `shiftR` 0 = 2
+2 `shiftR` 1 = 1
+2 `shiftR` 2 = 0
+2 `shiftR` 3 = 0
+2 `shiftR` 32 = 0
+
+3 `shiftR` 0 = 3
+3 `shiftR` 1 = 1
+3 `shiftR` 2 = 0
+3 `shiftR` 3 = 0
+3 `shiftR` 32 = 0
+
+#
+-3 `rotate` -3 = -1
+-3 `rotate` -2 = -1
+-3 `rotate` -1 = -2
+-3 `rotate` 0 = -3
+-3 `rotate` 1 = -6
+-3 `rotate` 2 = -12
+-3 `rotate` 3 = -24
+
+-2 `rotate` -3 = -1
+-2 `rotate` -2 = -1
+-2 `rotate` -1 = -1
+-2 `rotate` 0 = -2
+-2 `rotate` 1 = -4
+-2 `rotate` 2 = -8
+-2 `rotate` 3 = -16
+
+-1 `rotate` -3 = -1
+-1 `rotate` -2 = -1
+-1 `rotate` -1 = -1
+-1 `rotate` 0 = -1
+-1 `rotate` 1 = -2
+-1 `rotate` 2 = -4
+-1 `rotate` 3 = -8
+
+0 `rotate` -3 = 0
+0 `rotate` -2 = 0
+0 `rotate` -1 = 0
+0 `rotate` 0 = 0
+0 `rotate` 1 = 0
+0 `rotate` 2 = 0
+0 `rotate` 3 = 0
+
+1 `rotate` -3 = 0
+1 `rotate` -2 = 0
+1 `rotate` -1 = 0
+1 `rotate` 0 = 1
+1 `rotate` 1 = 2
+1 `rotate` 2 = 4
+1 `rotate` 3 = 8
+
+2 `rotate` -3 = 0
+2 `rotate` -2 = 0
+2 `rotate` -1 = 1
+2 `rotate` 0 = 2
+2 `rotate` 1 = 4
+2 `rotate` 2 = 8
+2 `rotate` 3 = 16
+
+3 `rotate` -3 = 0
+3 `rotate` -2 = 0
+3 `rotate` -1 = 1
+3 `rotate` 0 = 3
+3 `rotate` 1 = 6
+3 `rotate` 2 = 12
+3 `rotate` 3 = 24
+
+#
+bit 0 = 1
+bit 1 = 2
+bit 2 = 4
+bit 3 = 8
+#
+-3 `setBit` 0 = -3
+-3 `setBit` 1 = -1
+-3 `setBit` 2 = -3
+-3 `setBit` 3 = -3
+-3 `setBit` 32 = -3
+
+-2 `setBit` 0 = -1
+-2 `setBit` 1 = -2
+-2 `setBit` 2 = -2
+-2 `setBit` 3 = -2
+-2 `setBit` 32 = -2
+
+-1 `setBit` 0 = -1
+-1 `setBit` 1 = -1
+-1 `setBit` 2 = -1
+-1 `setBit` 3 = -1
+-1 `setBit` 32 = -1
+
+0 `setBit` 0 = 1
+0 `setBit` 1 = 2
+0 `setBit` 2 = 4
+0 `setBit` 3 = 8
+0 `setBit` 32 = 4294967296
+
+1 `setBit` 0 = 1
+1 `setBit` 1 = 3
+1 `setBit` 2 = 5
+1 `setBit` 3 = 9
+1 `setBit` 32 = 4294967297
+
+2 `setBit` 0 = 3
+2 `setBit` 1 = 2
+2 `setBit` 2 = 6
+2 `setBit` 3 = 10
+2 `setBit` 32 = 4294967298
+
+3 `setBit` 0 = 3
+3 `setBit` 1 = 3
+3 `setBit` 2 = 7
+3 `setBit` 3 = 11
+3 `setBit` 32 = 4294967299
+
+#
+-3 `clearBit` 0 = -4
+-3 `clearBit` 1 = -3
+-3 `clearBit` 2 = -7
+-3 `clearBit` 3 = -11
+-3 `clearBit` 32 = -4294967299
+
+-2 `clearBit` 0 = -2
+-2 `clearBit` 1 = -4
+-2 `clearBit` 2 = -6
+-2 `clearBit` 3 = -10
+-2 `clearBit` 32 = -4294967298
+
+-1 `clearBit` 0 = -2
+-1 `clearBit` 1 = -3
+-1 `clearBit` 2 = -5
+-1 `clearBit` 3 = -9
+-1 `clearBit` 32 = -4294967297
+
+0 `clearBit` 0 = 0
+0 `clearBit` 1 = 0
+0 `clearBit` 2 = 0
+0 `clearBit` 3 = 0
+0 `clearBit` 32 = 0
+
+1 `clearBit` 0 = 0
+1 `clearBit` 1 = 1
+1 `clearBit` 2 = 1
+1 `clearBit` 3 = 1
+1 `clearBit` 32 = 1
+
+2 `clearBit` 0 = 2
+2 `clearBit` 1 = 0
+2 `clearBit` 2 = 2
+2 `clearBit` 3 = 2
+2 `clearBit` 32 = 2
+
+3 `clearBit` 0 = 2
+3 `clearBit` 1 = 1
+3 `clearBit` 2 = 3
+3 `clearBit` 3 = 3
+3 `clearBit` 32 = 3
+
+#
+-3 `complementBit` 0 = -4
+-3 `complementBit` 1 = -1
+-3 `complementBit` 2 = -7
+-3 `complementBit` 3 = -11
+-3 `complementBit` 32 = -4294967299
+
+-2 `complementBit` 0 = -1
+-2 `complementBit` 1 = -4
+-2 `complementBit` 2 = -6
+-2 `complementBit` 3 = -10
+-2 `complementBit` 32 = -4294967298
+
+-1 `complementBit` 0 = -2
+-1 `complementBit` 1 = -3
+-1 `complementBit` 2 = -5
+-1 `complementBit` 3 = -9
+-1 `complementBit` 32 = -4294967297
+
+0 `complementBit` 0 = 1
+0 `complementBit` 1 = 2
+0 `complementBit` 2 = 4
+0 `complementBit` 3 = 8
+0 `complementBit` 32 = 4294967296
+
+1 `complementBit` 0 = 0
+1 `complementBit` 1 = 3
+1 `complementBit` 2 = 5
+1 `complementBit` 3 = 9
+1 `complementBit` 32 = 4294967297
+
+2 `complementBit` 0 = 3
+2 `complementBit` 1 = 0
+2 `complementBit` 2 = 6
+2 `complementBit` 3 = 10
+2 `complementBit` 32 = 4294967298
+
+3 `complementBit` 0 = 2
+3 `complementBit` 1 = 1
+3 `complementBit` 2 = 7
+3 `complementBit` 3 = 11
+3 `complementBit` 32 = 4294967299
+
+#
+-3 `testBit` 0 = True
+-3 `testBit` 1 = False
+-3 `testBit` 2 = True
+-3 `testBit` 3 = True
+-3 `testBit` 32 = True
+
+-2 `testBit` 0 = False
+-2 `testBit` 1 = True
+-2 `testBit` 2 = True
+-2 `testBit` 3 = True
+-2 `testBit` 32 = True
+
+-1 `testBit` 0 = True
+-1 `testBit` 1 = True
+-1 `testBit` 2 = True
+-1 `testBit` 3 = True
+-1 `testBit` 32 = True
+
+0 `testBit` 0 = False
+0 `testBit` 1 = False
+0 `testBit` 2 = False
+0 `testBit` 3 = False
+0 `testBit` 32 = False
+
+1 `testBit` 0 = True
+1 `testBit` 1 = False
+1 `testBit` 2 = False
+1 `testBit` 3 = False
+1 `testBit` 32 = False
+
+2 `testBit` 0 = False
+2 `testBit` 1 = True
+2 `testBit` 2 = False
+2 `testBit` 3 = False
+2 `testBit` 32 = False
+
+3 `testBit` 0 = True
+3 `testBit` 1 = True
+3 `testBit` 2 = False
+3 `testBit` 3 = False
+3 `testBit` 32 = False
+
+#
+isSigned -3 = True
+isSigned -2 = True
+isSigned -1 = True
+isSigned 0 = True
+isSigned 1 = True
+isSigned 2 = True
+isSigned 3 = True
+#
--- /dev/null
+-- !!! Scopes in kind checking
+
+-- Exposes a bizarre bug in 4.08.1
+-- TestSh.hs:6:
+-- `Shape' is not in scope
+-- When checking kinds in `HasConfigValue Shape nodeTypeParms'
+-- In the class declaration for `HasShape'
+
+module ShouldCompile where
+
+data Shape value = Box | Circle
+
+class HasConfigValue Shape nodeTypeParms => HasShape nodeTypeParms where {}
+
+class HasConfigValue option configuration where
+ ($$$) :: option value -> configuration value -> configuration value
+
+
SUBDIRS = hp2ps stat2resid unlit
else
SUBDIRS = hp2ps \
+ hsc2hs \
parallel \
stat2resid \
prof \