On Tue, May 15, 2012 at 6:23 AM, Paolo Capriotti <[email protected]> wrote: > Repository : ssh://darcs.haskell.org//srv/darcs/hsc2hs > > On branch : master > > http://hackage.haskell.org/trac/ghc/changeset/fc8a91274534f8f94ec5480ad7504b9fb94b6b6d > >>--------------------------------------------------------------- > > commit fc8a91274534f8f94ec5480ad7504b9fb94b6b6d > Author: Michał Masłowski <[email protected]> > Date: Fri May 11 15:18:06 2012 +0200 > > Recognize huge unsigned long long values as integers when cross compiling. > > MIPS N32 has RLIM_INFINITY in resource.h defined as > 0x7fffffffffffffffULL which doesn't fit in a 32 bit unsigned long to > which it was casted before applying this patch, so a cross build of > libraries/unix for mips64el failed. > >>--------------------------------------------------------------- > > CrossCodegen.hs | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/CrossCodegen.hs b/CrossCodegen.hs > index b4f648f..7fbd20a 100644 > --- a/CrossCodegen.hs > +++ b/CrossCodegen.hs > @@ -499,7 +499,7 @@ checkConditional _ = error "checkConditional argument > isn't a Special" > -- Make sure the value we're trying to binary search isn't floating point. > checkValueIsIntegral :: ZCursor Token -> Bool -> TestMonad Bool > checkValueIsIntegral z@(ZCursor (Special _ _ value) _ _) nonNegative = do > - let intType = if nonNegative then "unsigned long" else "long" > + let intType = if nonNegative then "unsigned long long" else "long long" > testLog ("checking if " ++ value ++ " is an integer") $ do > success <- runCompileBooleanTest z $ "(" ++ intType ++ ")(" ++ value > ++ ") == (" ++ value ++ ")" > testLog' $ "result: " ++ (if success then "integer" else "floating")
I would have used rlim_t defined in <sys/resource.h> as integral types used for limit values (which, from my understanding is not required to be any of the standard named integer types) instead of having to worry whether it is unsigned long, or unsigned long long, or unsigned __int128. The change is still fragile -- MIPS n32 is just one example of ABIs that try to "maximize" basic type uses in environments where the natural machine register width is greater than the width of int or long, and there is evidence that this practice is to be continued as new ABIs are surfacing. intmax_t (and its unsigned counter part) is guranteed to be the largest integer type, even if the underlying type isn't a standard-named integer type (e.g. __int128.) -- Gaby _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
