ATLAS Offline Software
Loading...
Searching...
No Matches
crc64.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4*/
5/*
6 */
7// $Id$
13
14
15#ifndef CXXUTILS_CRC64_H
16#define CXXUTILS_CRC64_H
17
18
19#include "CxxUtils/features.h"
20#include <memory>
21#include <cstdint>
22#include <string>
23
24
25// Use the vectorized version if we're compiling with gcc on x86_64.
26// clang > 7 allows function multiversioning but some of the intrinsics we
27// use exist only for gcc
28#if defined(__x86_64__) && HAVE_GCC_INTRINSICS
29# define ATH_CRC64_VEC 1
30#else
31# define ATH_CRC64_VEC 0
32#endif
33
34
35// Forward declarations.
36namespace CxxUtils {
38class CRCTable;
41}
42
43
47namespace std {
48template<>
49struct default_delete<CxxUtils::CRCTable>
50{
51 void operator() (CxxUtils::CRCTable* table) const
52 { deleteCRCTable (table); }
53};
54}
55
56
57namespace CxxUtils {
58
59
60class CRCTable;
61
62
69std::unique_ptr<CRCTable> makeCRCTable (uint64_t p,
70 uint64_t initial = 0xffffffffffffffff);
71
72
79uint64_t crc64_bytewise (const CRCTable& table,
80 const char* data,
81 size_t data_len);
82
83
91uint64_t crc64_bytewise (const char* data,
92 size_t data_len);
93
94
101uint64_t crc64_bytewise (const std::string& s);
102
103
104#if ATH_CRC64_VEC
113__attribute__ ((target ("pclmul")))
114uint64_t crc64 (const CRCTable& table,
115 const char* data,
116 size_t data_len);
117#endif // ATH_CRC64_VEC
118
119
128#if ATH_CRC64_VEC
129__attribute__ ((target ("default")))
130#endif
131uint64_t crc64 (const CRCTable& table,
132 const char* data,
133 size_t data_len);
134
135
141uint64_t crc64 (const char* data,
142 size_t data_len);
143
144
149uint64_t crc64 (const std::string& s);
150
151
158uint64_t crc64addint (uint64_t crc, uint64_t x);
159
160
165std::string crc64format (uint64_t crc);
166
167
168
169
176std::string crc64digest (const std::string& str);
177
178
179} // namespace CxxUtils
180
181
182#endif // not CXXUTILS_CRC64_H
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
#define x
Precomputed tables and constants for the CRC calculation.
Definition crc64.cxx:465
Some additional feature test macros.
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
Definition crc64.cxx:696
uint64_t crc64_bytewise(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string, using a byte-by-byte algorithm.
Definition crc64.cxx:560
std::unique_ptr< CRCTable > makeCRCTable(uint64_t p, uint64_t initial=0xffffffffffffffff)
Initialize CRC tables and constants.
Definition crc64.cxx:547
std::string crc64digest(const std::string &str)
Return a CRC-64 digest of a string.
Definition crc64.cxx:761
std::string crc64format(uint64_t crc)
Format a CRC-64 as a string.
Definition crc64.cxx:746
void deleteCRCTable(CxxUtils::CRCTable *table)
Delete a CRCTable object.
Definition crc64.cxx:535
uint64_t crc64addint(uint64_t crc, uint64_t x)
Extend a previously-calculated CRC to include an int.
Definition crc64.cxx:732
STL namespace.