Changeset 10596:54f9c123f145 in orange


Ignore:
Timestamp:
03/21/12 14:25:16 (2 years ago)
Author:
Matija Polajnar <matija.polajnar@…>
Branch:
default
Message:

Urgent bugfix: Refactor CRC variables from unsigned long to unsigned int to make it work properly on 64-bit machines (with 64-bit Python and libraries). Fixes #1146.

Location:
source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • source/include/crc.h

    r10591 r10596  
    2222#define __CRC_H 
    2323 
    24 extern unsigned long crc_table[256]; 
     24extern unsigned int crc_table[256]; 
    2525 
    2626#define INIT_CRC(x) (x) = 0xffffffff 
     
    3232      crc = (crc >> 8) ^ crc_table[(crc & 0xFF) ^ *(b++)]); \ 
    3333 
    34 inline void add_CRC(const int data, unsigned long &crc) 
     34inline void add_CRC(const int data, unsigned int &crc) 
    3535{ ADD_CRC } 
    3636 
    37 inline void add_CRC(const unsigned long data, unsigned long &crc) 
     37inline void add_CRC(const unsigned long data, unsigned int &crc) 
    3838{ ADD_CRC } 
    3939 
    40 inline void add_CRC(const float data, unsigned long &crc) 
     40inline void add_CRC(const float data, unsigned int &crc) 
    4141{ ADD_CRC } 
    4242 
    43 inline void add_CRC(const unsigned char c, unsigned long &crc) 
     43inline void add_CRC(const unsigned char c, unsigned int &crc) 
    4444{ crc = (crc >> 8) ^ crc_table[(crc & 0xFF) ^ c]; } 
    4545 
    46 inline void add_CRC(const char *c, unsigned long &crc) 
     46inline void add_CRC(const char *c, unsigned int &crc) 
    4747{ 
    4848  for(; *c; add_CRC((unsigned char)*c++, crc)); 
  • source/include/crc32.cpp

    r3289 r10596  
    1 unsigned long crc_table[256]; 
     1unsigned int crc_table[256]; 
    22 
    3 long reflect(unsigned long ref, char ch)  
    4 { unsigned long value(0);  
     3int reflect(unsigned int ref, char ch) 
     4{ unsigned int value(0); 
    55 
    66  for(int i = 1; i < (ch + 1); i++) { 
  • source/orange/distvars.cpp

    r8103 r10596  
    753753  int i, e; 
    754754 
    755   unsigned long crc; 
     755  unsigned int crc; 
    756756  INIT_CRC(crc); 
    757757 
     
    909909 
    910910int TDiscDistribution::sumValues() const 
    911 { unsigned long crc; 
     911{ unsigned int crc; 
    912912  INIT_CRC(crc); 
    913913 
     
    12941294 
    12951295int TContDistribution::sumValues() const 
    1296 { unsigned long crc; 
     1296{ unsigned int crc; 
    12971297  INIT_CRC(crc); 
    12981298 
     
    13831383 
    13841384int TGaussianDistribution::sumValues() const 
    1385 { unsigned long crc; 
     1385{ unsigned int crc; 
    13861386  INIT_CRC(crc); 
    13871387  add_CRC(mean, crc); 
  • source/orange/domain.cpp

    r9415 r10596  
    618618#include "crc.h" 
    619619 
    620 void TDomain::addToCRC(unsigned long &crc) const 
     620void TDomain::addToCRC(unsigned int &crc) const 
    621621{ 
    622622  const_PITERATE(TVarList, vi, variables) { 
     
    631631 
    632632int TDomain::sumValues() const 
    633 { unsigned long crc; 
     633{ unsigned int crc; 
    634634  INIT_CRC(crc); 
    635635  addToCRC(crc); 
  • source/orange/domain.hpp

    r9417 r10596  
    150150  PVariable hasOtherAttributes(bool checkClass = true) const; 
    151151   
    152   void addToCRC(unsigned long &crc) const; 
     152  void addToCRC(unsigned int &crc) const; 
    153153  int sumValues() const; 
    154154}; 
  • source/orange/examplegen.cpp

    r6531 r10596  
    9696 
    9797int TExampleGenerator::checkSum(const bool includeMetas) 
    98 { unsigned long crc; 
     98{ unsigned int crc; 
    9999  INIT_CRC(crc); 
    100100  for(TExampleIterator ei(begin()); ei; ++ei) 
  • source/orange/examples.cpp

    r10591 r10596  
    383383#include "stringvars.hpp" 
    384384 
    385 inline void addToCRC(unsigned long &crc, const PVarList &vars, TValue *&vli) 
     385inline void addToCRC(unsigned int &crc, const PVarList &vars, TValue *&vli) 
    386386{ 
    387387  const_PITERATE(TVarList, vi, vars) { 
     
    400400} 
    401401 
    402 void TExample::addToCRC(unsigned long &crc, const bool includeMetas) const 
     402void TExample::addToCRC(unsigned int &crc, const bool includeMetas) const 
    403403{ 
    404404  TValue *vli = values; 
     
    426426 
    427427int TExample::sumValues(const bool includeMetas) const 
    428 { unsigned long crc; 
     428{ unsigned int crc; 
    429429  INIT_CRC(crc); 
    430430  addToCRC(crc, includeMetas); 
  • source/orange/examples.hpp

    r9401 r10596  
    156156  bool compatible(const TExample &other, const bool ignoreClass = false) const; 
    157157 
    158   void addToCRC(unsigned long &crc, const bool includeMetas = false) const; 
     158  void addToCRC(unsigned int &crc, const bool includeMetas = false) const; 
    159159  int sumValues(const bool includeMetas = false) const; 
    160160   
  • source/orange/table.cpp

    r9411 r10596  
    875875 
    876876int TExampleTable::checkSum(const bool includeMetas) 
    877 { unsigned long crc; 
     877{ unsigned int crc; 
    878878  INIT_CRC(crc); 
    879879 
     
    885885 
    886886int TExampleTable::checkSum(const bool includeMetas) const 
    887 { unsigned long crc; 
     887{ unsigned int crc; 
    888888  INIT_CRC(crc); 
    889889 
Note: See TracChangeset for help on using the changeset viewer.