Hello again almut. I would rather not just compile in the & MASK32 if it is not needed. It is easy enough to set a define in the Makefile.PL if use64bitint is set:
DEFINE => ($Config{use64bitint} ? '-DUSING_64_BIT_INT' : ''),
Then in the C you can use this to provide 2 versions of the MIX macro. I may well be wrong (can't test) but it seems to me that none of the & MASK32 are required in the main jhash code, provided you use a macro setup as shown below. The a b c ints will probably overflow into the low bits of the 64 bit space but because all the operations are addition the low order bits will be the valid representation in 32 bit space. Could you give this a try:
/* Need to constrain U32 to only 32 bits on 64 bit systems
* For efficiency we only use the & 0xffffffff if required
*/
#define USING_64_BIT_INT /* save messing with Makefile.PL define */
#if defined(USING_64_BIT_INT)
#define MIX(a,b,c) \
{ \
a &= 0xffffffff; b &= 0xffffffff; c &= 0xffffffff; \
a -= b; a -= c; a ^= (c>>13); a &= 0xffffffff; \
b -= c; b -= a; b ^= (a<<8); b &= 0xffffffff; \
c -= a; c -= b; c ^= (b>>13); c &= 0xffffffff; \
a -= b; a -= c; a ^= (c>>12); a &= 0xffffffff; \
b -= c; b -= a; b ^= (a<<16); b &= 0xffffffff; \
c -= a; c -= b; c ^= (b>>5); c &= 0xffffffff; \
a -= b; a -= c; a ^= (c>>3); a &= 0xffffffff; \
b -= c; b -= a; b ^= (a<<10); b &= 0xffffffff; \
c -= a; c -= b; c ^= (b>>15); c &= 0xffffffff; \
}
#else
#define MIX(a,b,c) \
{ \
a -= b; a -= c; a ^= (c>>13); \
b -= c; b -= a; b ^= (a<<8); \
c -= a; c -= b; c ^= (b>>13); \
a -= b; a -= c; a ^= (c>>12); \
b -= c; b -= a; b ^= (a<<16); \
c -= a; c -= b; c ^= (b>>5); \
a -= b; a -= c; a ^= (c>>3); \
b -= c; b -= a; b ^= (a<<10); \
c -= a; c -= b; c ^= (b>>15); \
}
#endif
/* rest of code unchanged with no masking */
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|