[gambit-list] Gambit-C 4.0 beta 18

Marc Feeley feeley at iro.umontreal.ca
Fri Sep 22 23:20:25 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 19-Sep-06, at 10:34 PM, Bradley Lucier wrote:

> One of the lower-lights of the release is that in gambit.h we find
>
>> #define ___FIXBITCOUNT(x)___FIX(1111)/****brad will fix this****/
>> #define ___FIXLENGTH(x)___FIX(2222)/****brad will fix this****/
>> #define ___FIXFIRSTBITSET(x)___FIX(3333)/****brad will fix this****/
>
> so
>
>> procedure: fxbit-count n
>>
>> procedure: fxfirst-bit-set n
>>
>> procedure: fxlength n
>
> don't work as advertised yet.
>
> Brad (unfortunately, yes, *that* brad)

Here is the fix needed to get these operations working properly.  I  
have not tested fully on 64 bit processors.  In the file include/ 
gambit.h replace the lines

#define ___FIXBITCOUNT(x)___FIX(1111)/****brad will fix this****/
#define ___FIXLENGTH(x)___FIX(2222)/****brad will fix this****/
#define ___FIXFIRSTBITSET(x)___FIX(3333)/****brad will fix this****/
#define ___FIXBITSETP(x,y)((x)&(1<<(___INT(y)+___TB)))

by

#if ___SCMOBJ_WIDTH == 32
#define ___SCMOBJ_MASK(x,y)y
#define ___BITCOUNT_TEMP() \
(___temp=(___temp&___SCMOBJ_MASK(0x55555555,0x55555555))+ \
          ((___temp>>1)&___SCMOBJ_MASK(0x55555555,0x55555555)), \
___temp=(___temp&___SCMOBJ_MASK(0x33333333,0x33333333))+ \
          ((___temp>>2)&___SCMOBJ_MASK(0x33333333,0x33333333)), \
___temp=(___temp&___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f))+ \
          ((___temp>>4)&___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f)), \
___temp=___temp+(___temp>>8), \
___temp=___temp+(___temp>>16), \
___FIX(___temp&0xff))
#define ___FIXLENGTH(x) \
(((___temp=___INT(x))<0)&&(___temp=~___temp), \
___temp|=(___temp>>1), \
___temp|=(___temp>>2), \
___temp|=(___temp>>4), \
___temp|=(___temp>>8), \
___temp|=(___temp>>16), \
___BITCOUNT_TEMP())
#define ___FIXFIRSTBITSET(x) \
(((___temp=(x))==0) \
?___FAL \
:(___temp=(___temp&-___temp), \
    ___FIX((((___temp&~___SCMOBJ_MASK(0x55555555,0x55555555))!=0)| \
            (((___temp&~___SCMOBJ_MASK(0x33333333,0x33333333))!=0) 
<<1)| \
            (((___temp&~___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f))!=0) 
<<2)| \
            (((___temp&~___SCMOBJ_MASK(0x00ff00ff,0x00ff00ff))!=0) 
<<3)| \
            (((___temp&~___SCMOBJ_MASK(0x0000ffff,0x0000ffff))!=0) 
<<4))-___TB)))
#else
#define ___SCMOBJ_MASK(x,y)((___CAST(___SCMOBJ,x)<<32)|y)
#define ___BITCOUNT_TEMP() \
(___temp=((___temp)&___SCMOBJ_MASK(0x55555555,0x55555555))+ \
          (((___temp)>>1)&___SCMOBJ_MASK(0x55555555,0x55555555)), \
___temp=(___temp&___SCMOBJ_MASK(0x33333333,0x33333333))+ \
          ((___temp>>2)&___SCMOBJ_MASK(0x33333333,0x33333333)), \
___temp=(___temp&___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f))+ \
          ((___temp>>4)&___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f)), \
___temp=___temp+(___temp>>8), \
___temp=___temp+(___temp>>16), \
___temp=___temp+(___temp>>32), \
___temp&0xff)
#define ___FIXLENGTH(x) \
(((___temp=___INT(x))<0)&&(___temp=~___temp), \
___temp|=(___temp>>1), \
___temp|=(___temp>>2), \
___temp|=(___temp>>4), \
___temp|=(___temp>>8), \
___temp|=(___temp>>16), \
___temp|=(___temp>>32), \
___BITCOUNT_TEMP())
#define ___FIXFIRSTBITSET(x) \
(((___temp=(x))==0) \
?___FAL \
:(___temp=(___temp&-___temp), \
    ___FIX((((___temp&~___SCMOBJ_MASK(0x55555555,0x55555555))!=0)| \
            (((___temp&~___SCMOBJ_MASK(0x33333333,0x33333333))!=0) 
<<1)| \
            (((___temp&~___SCMOBJ_MASK(0x0f0f0f0f,0x0f0f0f0f))!=0) 
<<2)| \
            (((___temp&~___SCMOBJ_MASK(0x00ff00ff,0x00ff00ff))!=0) 
<<3)| \
            (((___temp&~___SCMOBJ_MASK(0x0000ffff,0x0000ffff))!=0) 
<<4)| \
            (((___temp&~___SCMOBJ_MASK(0x00000000,0xffffffff))!=0) 
<<5))-___TB)))
#endif
#define ___FIXBITCOUNT(x) \
((((___temp=___INT(x))<0)&&(___temp=~___temp)),___BITCOUNT_TEMP())
#define ___FIXBITSETP(x,y)((x)&(___CAST(___SCMOBJ,1)<<(___INT(y) 
+___TB)))


Marc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFFKf5//V9Zc2T/v4RApWrAJ40UzkX+6/20vby6N15iGxq6LHoqACfed4v
E4adjLQJKRwIJ/Jp2KHXCwU=
=fmYz
-----END PGP SIGNATURE-----



More information about the Gambit-list mailing list