CMS 3D CMS Logo

Macros | Functions | Variables
crc32c.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>

Go to the source code of this file.

Macros

#define POLY   0x82f63b78
 

Functions

uint32_t crc32c (uint32_t crc, const unsigned char *buf, size_t len)
 
bool crc32c_hw_test ()
 
static void crc32c_init_sw (void)
 
static uint32_t crc32c_sw (uint32_t crci, const unsigned char *buf, size_t len)
 

Variables

static pthread_once_t crc32c_once_sw = PTHREAD_ONCE_INIT
 
static uint32_t crc32c_table [8][256]
 

Macro Definition Documentation

#define POLY   0x82f63b78

Definition at line 49 of file crc32c.cc.

Referenced by crc32c_init_sw(), and crc32c_sw().

Function Documentation

uint32_t crc32c ( uint32_t  crc,
const unsigned char *  buf,
size_t  len 
)

Definition at line 340 of file crc32c.cc.

References crc32c_sw().

Referenced by FedRawDataInputSource::getNextEvent(), FRDStreamSource::setRunAndEventInfo(), and RawEventOutputModuleForBU< Consumer >::write().

341 {
342 #if defined(__x86_64__)
343  int sse42;
344 
345  SSE42(sse42);
346  return sse42 ? crc32c_hw(crc, buf, len) : crc32c_sw(crc, buf, len);
347 #else
348  return crc32c_sw(crc, buf, len);
349 #endif
350 }
static uint32_t crc32c_sw(uint32_t crci, const unsigned char *buf, size_t len)
Definition: crc32c.cc:84
bool crc32c_hw_test ( )

Definition at line 354 of file crc32c.cc.

Referenced by FedRawDataInputSource::FedRawDataInputSource().

355 {
356 
357 #if defined(__x86_64__)
358  int sse42;
359 
360  SSE42(sse42);
361  return sse42;
362 #else
363  return 0;
364 #endif
365 }
static void crc32c_init_sw ( void  )
static

Definition at line 56 of file crc32c.cc.

References crc32c_table, gen::k, gen::n, and POLY.

Referenced by crc32c_sw().

57 {
58  uint32_t n, crc, k;
59 
60  for (n = 0; n < 256; n++) {
61  crc = n;
62  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
63  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
64  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
65  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
66  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
67  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
68  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
69  crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1;
70  crc32c_table[0][n] = crc;
71  }
72  for (n = 0; n < 256; n++) {
73  crc = crc32c_table[0][n];
74  for (k = 1; k < 8; k++) {
75  crc = crc32c_table[0][crc & 0xff] ^ (crc >> 8);
76  crc32c_table[k][n] = crc;
77  }
78  }
79 }
static uint32_t crc32c_table[8][256]
Definition: crc32c.cc:53
int k[5][pyjets_maxn]
#define POLY
Definition: crc32c.cc:49
static uint32_t crc32c_sw ( uint32_t  crci,
const unsigned char *  buf,
size_t  len 
)
static

Definition at line 84 of file crc32c.cc.

References crc32c_init_sw(), crc32c_once_sw, crc32c_table, end, gen::n, GetRecoTauVFromDQM_MC_cff::next, POLY, and square().

Referenced by crc32c().

85 {
86  const unsigned char *next = buf;
87  uint64_t crc;
88 
89  pthread_once(&crc32c_once_sw, crc32c_init_sw);
90  crc = crci ^ 0xffffffff;
91  while (len && ((const uintptr_t)next & 7) != 0) {
92  crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
93  len--;
94  }
95  while (len >= 8) {
96  crc ^= *(uint64_t *)next;
97  crc = crc32c_table[7][crc & 0xff] ^
98  crc32c_table[6][(crc >> 8) & 0xff] ^
99  crc32c_table[5][(crc >> 16) & 0xff] ^
100  crc32c_table[4][(crc >> 24) & 0xff] ^
101  crc32c_table[3][(crc >> 32) & 0xff] ^
102  crc32c_table[2][(crc >> 40) & 0xff] ^
103  crc32c_table[1][(crc >> 48) & 0xff] ^
104  crc32c_table[0][crc >> 56];
105  next += 8;
106  len -= 8;
107  }
108  while (len) {
109  crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
110  len--;
111  }
112  return (uint32_t)crc ^ 0xffffffff;
113 }
static pthread_once_t crc32c_once_sw
Definition: crc32c.cc:52
static uint32_t crc32c_table[8][256]
Definition: crc32c.cc:53
unsigned long long uint64_t
Definition: Time.h:15
static void crc32c_init_sw(void)
Definition: crc32c.cc:56

Variable Documentation

pthread_once_t crc32c_once_sw = PTHREAD_ONCE_INIT
static

Definition at line 52 of file crc32c.cc.

Referenced by crc32c_sw().

uint32_t crc32c_table[8][256]
static

Definition at line 53 of file crc32c.cc.

Referenced by crc32c_init_sw(), and crc32c_sw().