Repository : ssh://darcs.haskell.org//srv/darcs/packages/ghc-prim On branch : master
http://hackage.haskell.org/trac/ghc/changeset/9cd14ba0f2b05a71b3682b2966949e8ba00ed910 >--------------------------------------------------------------- commit 9cd14ba0f2b05a71b3682b2966949e8ba00ed910 Author: Daniel Fischer <[email protected]> Date: Sat Aug 27 17:41:07 2011 +0200 Fix return type of hs_popcntX All the hs_popcntX functions should return an StgWord in accordance with the primop types. I'm not sure whether the argument should also become an StgWord (except for the 64-bit versions), the primops have type Word# -> Word#, but we have e.g. StgWord hs_popcnt8(StgWord8 x). StgWord8 is an unsigned char (usually, at least), but I think arguments are passed at least word-sized to C-functions, so it probably works. For the moment it works and passes tests, I'll ask tibbe to be sure. >--------------------------------------------------------------- cbits/popcnt.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cbits/popcnt.c b/cbits/popcnt.c index 10d6fa4..b17b624 100644 --- a/cbits/popcnt.c +++ b/cbits/popcnt.c @@ -12,23 +12,23 @@ static const unsigned char popcount_tab[] = 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, }; -extern StgWord8 hs_popcnt8(StgWord8 x); -StgWord8 +extern StgWord hs_popcnt8(StgWord8 x); +StgWord hs_popcnt8(StgWord8 x) { return popcount_tab[(unsigned char)x]; } -extern StgWord16 hs_popcnt16(StgWord16 x); -StgWord16 +extern StgWord hs_popcnt16(StgWord16 x); +StgWord hs_popcnt16(StgWord16 x) { return popcount_tab[(unsigned char)x] + popcount_tab[(unsigned char)(x >> 8)]; } -extern StgWord32 hs_popcnt32(StgWord32 x); -StgWord32 +extern StgWord hs_popcnt32(StgWord32 x); +StgWord hs_popcnt32(StgWord32 x) { return popcount_tab[(unsigned char)x] + @@ -37,8 +37,8 @@ hs_popcnt32(StgWord32 x) popcount_tab[(unsigned char)(x >> 24)]; } -extern StgWord64 hs_popcnt64(StgWord64 x); -StgWord64 +extern StgWord hs_popcnt64(StgWord64 x); +StgWord hs_popcnt64(StgWord64 x) { return popcount_tab[(unsigned char)x] + @@ -53,8 +53,8 @@ hs_popcnt64(StgWord64 x) #ifdef i386_HOST_ARCH -extern StgWord32 hs_popcnt(StgWord32 x); -StgWord32 +extern StgWord hs_popcnt(StgWord32 x); +StgWord hs_popcnt(StgWord32 x) { return popcount_tab[(unsigned char)x] + @@ -65,8 +65,8 @@ hs_popcnt(StgWord32 x) #else -extern StgWord64 hs_popcnt(StgWord64 x); -StgWord64 +extern StgWord hs_popcnt(StgWord64 x); +StgWord hs_popcnt(StgWord64 x) { return popcount_tab[(unsigned char)x] + _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
