Ignore:
Timestamp:
2011-05-19T09:26:07+12:00 (13 years ago)
Author:
jmt12
Message:

Found mg indexing randomly broke on 64bit machines. Tracked it down to random.c and perf_hash.c. Replaced all occurances of 'long' (which is not well defined on 64 bit machines) with the more stable mg_s_long (mglong.h) to fix this issue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mg/lib/random.c

    r16583 r24031  
    3333 *  The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
    3434 */
    35 
    36 #define MASK ((long) 593970775)
     35#include "random.h"
     36
     37#define MASK ((mg_s_long) 593970775)
    3738/*  or in hex, 23674657 */
    3839
     
    4041/*  i.e. 2 to power -31 */
    4142
    42 static long mt [128] =   {
     43static mg_s_long mt [128] =   {
    4344      902906369,
    4445     2030498053,
     
    172173
    173174double
    174 random (long is [2])
     175random (mg_s_long is [2])
    175176{
    176     long it, leh, nit;
     177    mg_s_long it, leh, nit;
    177178
    178179    it = is [0];
     
    187188    is [0] = it;    is [1] = leh;
    188189    if (leh < 0) leh = ~leh;
    189     return (SCALE * ((long) (leh | 1)));
     190    return (SCALE * ((mg_s_long) (leh | 1)));
    190191}
    191192
    192193
    193194
    194 long
    195 irandm (long is [2])
     195mg_s_long
     196irandm (mg_s_long is [2])
    196197{
    197     long it, leh, nit;
     198    mg_s_long it, leh, nit;
    198199
    199200    it = is [0];
Note: See TracChangeset for help on using the changeset viewer.