Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
engineIDulong.cc
이 파일의 문서화 페이지로 가기
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- engineIDulong ---
7 // function implementation file
8 // -----------------------------------------------------------------------
9 //
10 // =======================================================================
11 // Mark Fischler - Created: Mar. 8, 2005
12 // =======================================================================
13 
14 #include <string>
15 #include <vector>
16 
17 namespace CLHEP {
18 
19 static std::vector<unsigned long> gen_crc_table() {
20  /* generate the table of CRC remainders for all possible bytes */
21  static const unsigned long POLYNOMIAL = 0x04c11db7UL;
22  std::vector<unsigned long> crc_table;
23  for ( unsigned long i = 0; i < 256; ++i ) {
24  unsigned long crc = i << 24;
25  for ( int j = 0; j < 8; j++ ) {
26  if ( crc & 0x80000000UL ) {
27  crc = ( ( crc << 1 ) ^ POLYNOMIAL ) & 0xffffffffUL;
28  } else {
29  crc = ( crc << 1 ) & 0xffffffffUL;
30  }
31  }
32  crc_table.push_back(crc);
33  }
34  return crc_table;
35 }
36 
37 unsigned long crc32ul(const std::string & s) {
38  static const std::vector<unsigned long> crc_table = gen_crc_table();
39  unsigned long crc = 0;
40  int end = s.length();
41  for (int j = 0; j != end; ++j) {
42  int i = ( (int) ( crc >> 24) ^ s[j] ) & 0xff;
43  crc = ( ( crc << 8 ) ^ crc_table[i] ) & 0xffffffffUL;
44  }
45  return crc;
46 }
47 
48 } // namespace CLHEP
49 
local const z_crc_t FAR crc_table[TBLS][256]
Definition: crc32.h:5
const XML_Char * s
Definition: expat.h:262
unsigned long crc32ul(const std::string &s)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static std::vector< unsigned long > gen_crc_table()