Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/datadog/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ enum Variable { DD_LIST_ENVIRONMENT_VARIABLES(WITH_COMMA) };
#define QUOTED_WITH_COMMA(ARG, TYPE, DEFAULT_VALUE) \
WITH_COMMA(QUOTED(ARG), TYPE, DEFAULT_VALUE)

inline const char *const variable_names[] = {
inline const char* const variable_names[] = {
DD_LIST_ENVIRONMENT_VARIABLES(QUOTED_WITH_COMMA)};

#undef QUOTED
Expand Down
4 changes: 2 additions & 2 deletions include/datadog/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace tracing {
// The release version at or before this code revision, e.g. "v0.1.12".
// That is, this code is at least as recent as `tracer_version`, but may be
// more recent.
extern const char *const tracer_version;
extern const char* const tracer_version;

// A string literal that contains `tracer_version` but also is easier to `grep`
// from the output of the `strings` command line utility, e.g. "[dd-trace-cpp
// version v0.1.12]".
extern const char *const tracer_version_string;
extern const char* const tracer_version_string;

} // namespace tracing
} // namespace datadog
58 changes: 29 additions & 29 deletions src/datadog/common/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ constexpr bool ALLOW_UNALIGNED_READS = true;
namespace datadog::common {
namespace details {

void SpookyHash::Short(const void *message, size_t length, uint64 *hash1,
uint64 *hash2) {
void SpookyHash::Short(const void* message, size_t length, uint64* hash1,
uint64* hash2) {
uint64 buf[2 * sc_numVars];
union {
const uint8 *p8;
uint32 *p32;
uint64 *p64;
const uint8* p8;
uint32* p32;
uint64* p64;
size_t i;
} u;

u.p8 = (const uint8 *)message;
u.p8 = (const uint8*)message;

if constexpr (!ALLOW_UNALIGNED_READS && (u.i & 0x7)) {
memcpy(buf, message, length);
Expand All @@ -36,7 +36,7 @@ void SpookyHash::Short(const void *message, size_t length, uint64 *hash1,
uint64 d = sc_const;

if (length > 15) {
const uint64 *end = u.p64 + (length / 32) * 4;
const uint64* end = u.p64 + (length / 32) * 4;

// handle all complete sets of 32 bytes
for (; u.p64 < end; u.p64 += 4) {
Expand Down Expand Up @@ -116,19 +116,19 @@ void SpookyHash::Short(const void *message, size_t length, uint64 *hash1,
}

// do the whole hash in one call
void SpookyHash::Hash128(const void *message, size_t length, uint64 *hash1,
uint64 *hash2) {
void SpookyHash::Hash128(const void* message, size_t length, uint64* hash1,
uint64* hash2) {
if (length < sc_bufSize) {
Short(message, length, hash1, hash2);
return;
}

uint64 h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
uint64 buf[sc_numVars];
uint64 *end;
uint64* end;
union {
const uint8 *p8;
uint64 *p64;
const uint8* p8;
uint64* p64;
size_t i;
} u;
size_t remainder;
Expand All @@ -137,7 +137,7 @@ void SpookyHash::Hash128(const void *message, size_t length, uint64 *hash1,
h1 = h4 = h7 = h10 = *hash2;
h2 = h5 = h8 = h11 = sc_const;

u.p8 = (const uint8 *)message;
u.p8 = (const uint8*)message;
end = u.p64 + (length / sc_blockSize) * sc_numVars;

// handle all whole sc_blockSize blocks of bytes
Expand All @@ -155,10 +155,10 @@ void SpookyHash::Hash128(const void *message, size_t length, uint64 *hash1,
}

// handle the last partial block of sc_blockSize bytes
remainder = (length - ((const uint8 *)end - (const uint8 *)message));
remainder = (length - ((const uint8*)end - (const uint8*)message));
memcpy(buf, end, remainder);
memset(((uint8 *)buf) + remainder, 0, sc_blockSize - remainder);
((uint8 *)buf)[sc_blockSize - 1] = remainder;
memset(((uint8*)buf) + remainder, 0, sc_blockSize - remainder);
((uint8*)buf)[sc_blockSize - 1] = remainder;

// do some final mixing
End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
Expand All @@ -175,20 +175,20 @@ void SpookyHash::Init(uint64 seed1, uint64 seed2) {
}

// add a message fragment to the state
void SpookyHash::Update(const void *message, size_t length) {
void SpookyHash::Update(const void* message, size_t length) {
uint64 h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
size_t newLength = length + m_remainder;
uint8 remainder;
union {
const uint8 *p8;
uint64 *p64;
const uint8* p8;
uint64* p64;
size_t i;
} u;
const uint64 *end;
const uint64* end;

// Is this message fragment too short? If it is, stuff it away.
if (newLength < sc_bufSize) {
memcpy(&((uint8 *)m_data)[m_remainder], message, length);
memcpy(&((uint8*)m_data)[m_remainder], message, length);
m_length = length + m_length;
m_remainder = (uint8)newLength;
return;
Expand Down Expand Up @@ -218,19 +218,19 @@ void SpookyHash::Update(const void *message, size_t length) {
// if we've got anything stuffed away, use it now
if (m_remainder) {
uint8 prefix = sc_bufSize - m_remainder;
memcpy(&(((uint8 *)m_data)[m_remainder]), message, prefix);
memcpy(&(((uint8*)m_data)[m_remainder]), message, prefix);
u.p64 = m_data;
Mix(u.p64, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
Mix(&u.p64[sc_numVars], h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
u.p8 = ((const uint8 *)message) + prefix;
u.p8 = ((const uint8*)message) + prefix;
length -= prefix;
} else {
u.p8 = (const uint8 *)message;
u.p8 = (const uint8*)message;
}

// handle all whole blocks of sc_blockSize bytes
end = u.p64 + (length / sc_blockSize) * sc_numVars;
remainder = (uint8)(length - ((const uint8 *)end - u.p8));
remainder = (uint8)(length - ((const uint8*)end - u.p8));
if constexpr (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0) {
while (u.p64 < end) {
Mix(u.p64, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
Expand Down Expand Up @@ -264,7 +264,7 @@ void SpookyHash::Update(const void *message, size_t length) {
}

// report the hash for the concatenation of all message fragments so far
void SpookyHash::Final(uint64 *hash1, uint64 *hash2) {
void SpookyHash::Final(uint64* hash1, uint64* hash2) {
// init the variables
if (m_length < sc_bufSize) {
*hash1 = m_state[0];
Expand All @@ -273,7 +273,7 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2) {
return;
}

const uint64 *data = (const uint64 *)m_data;
const uint64* data = (const uint64*)m_data;
uint8 remainder = m_remainder;

uint64 h0 = m_state[0];
Expand All @@ -297,9 +297,9 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2) {
}

// mix in the last partial block, and the length mod sc_blockSize
memset(&((uint8 *)data)[remainder], 0, (sc_blockSize - remainder));
memset(&((uint8*)data)[remainder], 0, (sc_blockSize - remainder));

((uint8 *)data)[sc_blockSize - 1] = remainder;
((uint8*)data)[sc_blockSize - 1] = remainder;

// do some final mixing
End(data, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
Expand Down
52 changes: 26 additions & 26 deletions src/datadog/common/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class SpookyHash {
//
// SpookyHash: hash a single message in one call, produce 128-bit output
//
static void Hash128(const void *message, // message to hash
static void Hash128(const void* message, // message to hash
size_t length, // length of message in bytes
uint64 *hash1, // in/out: in seed 1, out hash value 1
uint64 *hash2); // in/out: in seed 2, out hash value 2
uint64* hash1, // in/out: in seed 1, out hash value 1
uint64* hash2); // in/out: in seed 2, out hash value 2

//
// Hash64: hash a single message in one call, return 64-bit output
//
static uint64 Hash64(const void *message, // message to hash
static uint64 Hash64(const void* message, // message to hash
size_t length, // length of message in bytes
uint64 seed) // seed
{
Expand All @@ -74,7 +74,7 @@ class SpookyHash {
//
// Hash32: hash a single message in one call, produce 32-bit output
//
static uint32 Hash32(const void *message, // message to hash
static uint32 Hash32(const void* message, // message to hash
size_t length, // length of message in bytes
uint32 seed) // seed
{
Expand All @@ -92,7 +92,7 @@ class SpookyHash {
//
// Update: add a piece of a message to a SpookyHash state
//
void Update(const void *message, // message fragment
void Update(const void* message, // message fragment
size_t length); // length of message fragment in bytes

//
Expand All @@ -103,8 +103,8 @@ class SpookyHash {
// The result is the same as if SpookyHash() had been called with
// all the pieces concatenated into one message.
//
void Final(uint64 *hash1, // out only: first 64 bits of hash value.
uint64 *hash2); // out only: second 64 bits of hash value.
void Final(uint64* hash1, // out only: first 64 bits of hash value.
uint64* hash2); // out only: second 64 bits of hash value.

//
// left rotate a 64-bit value by k bytes
Expand All @@ -126,10 +126,10 @@ class SpookyHash {
// When run forward or backwards one Mix
// I tried 3 pairs of each; they all differed by at least 212 bits.
//
static INLINE void Mix(const uint64 *data, uint64 &s0, uint64 &s1, uint64 &s2,
uint64 &s3, uint64 &s4, uint64 &s5, uint64 &s6,
uint64 &s7, uint64 &s8, uint64 &s9, uint64 &s10,
uint64 &s11) {
static INLINE void Mix(const uint64* data, uint64& s0, uint64& s1, uint64& s2,
uint64& s3, uint64& s4, uint64& s5, uint64& s6,
uint64& s7, uint64& s8, uint64& s9, uint64& s10,
uint64& s11) {
s0 += data[0];
s2 ^= s10;
s11 ^= s0;
Expand Down Expand Up @@ -208,10 +208,10 @@ class SpookyHash {
// Two iterations was almost good enough for a 64-bit result, but a
// 128-bit result is reported, so End() does three iterations.
//
static INLINE void EndPartial(uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7,
uint64 &h8, uint64 &h9, uint64 &h10,
uint64 &h11) {
static INLINE void EndPartial(uint64& h0, uint64& h1, uint64& h2, uint64& h3,
uint64& h4, uint64& h5, uint64& h6, uint64& h7,
uint64& h8, uint64& h9, uint64& h10,
uint64& h11) {
h11 += h1;
h2 ^= h11;
h1 = Rot64(h1, 44);
Expand Down Expand Up @@ -250,10 +250,10 @@ class SpookyHash {
h0 = Rot64(h0, 54);
}

static INLINE void End(const uint64 *data, uint64 &h0, uint64 &h1, uint64 &h2,
uint64 &h3, uint64 &h4, uint64 &h5, uint64 &h6,
uint64 &h7, uint64 &h8, uint64 &h9, uint64 &h10,
uint64 &h11) {
static INLINE void End(const uint64* data, uint64& h0, uint64& h1, uint64& h2,
uint64& h3, uint64& h4, uint64& h5, uint64& h6,
uint64& h7, uint64& h8, uint64& h9, uint64& h10,
uint64& h11) {
h0 += data[0];
h1 += data[1];
h2 += data[2];
Expand Down Expand Up @@ -286,7 +286,7 @@ class SpookyHash {
// with diffs defined by either xor or subtraction
// with a base of all zeros plus a counter, or plus another bit, or random
//
static INLINE void ShortMix(uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3) {
static INLINE void ShortMix(uint64& h0, uint64& h1, uint64& h2, uint64& h3) {
h2 = Rot64(h2, 50);
h2 += h3;
h0 ^= h2;
Expand Down Expand Up @@ -337,7 +337,7 @@ class SpookyHash {
// For every pair of input bits,
// with probability 50 +- .75% (the worst case is approximately that)
//
static INLINE void ShortEnd(uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3) {
static INLINE void ShortEnd(uint64& h0, uint64& h1, uint64& h2, uint64& h3) {
h3 ^= h2;
h2 = Rot64(h2, 15);
h3 += h2;
Expand Down Expand Up @@ -381,10 +381,10 @@ class SpookyHash {
// held to the same quality bar.
//
static void Short(
const void *message, // message (array of bytes, not necessarily aligned)
const void* message, // message (array of bytes, not necessarily aligned)
size_t length, // length of message (in bytes)
uint64 *hash1, // in/out: in the seed, out the hash value
uint64 *hash2); // in/out: in the seed, out the hash value
uint64* hash1, // in/out: in the seed, out the hash value
uint64* hash2); // in/out: in the seed, out the hash value

// number of uint64's in internal state
static const size_t sc_numVars = 12;
Expand Down Expand Up @@ -430,7 +430,7 @@ class FastHash final {
///
/// @param data Pointer to the data to hash.
/// @param length Size of the data in bytes.
void append(const void *data, size_t length) { hasher_.Update(data, length); }
void append(const void* data, size_t length) { hasher_.Update(data, length); }

/// Finalizes the hash computation and returns a 64-bit hash value.
///
Expand Down
4 changes: 2 additions & 2 deletions src/datadog/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ class ConfigManager : public remote_config::Listener {

public:
ConfigManager(const FinalizedTracerConfig& config);
~ConfigManager() override{};
~ConfigManager() override {};

remote_config::Products get_products() override;
remote_config::Capabilities get_capabilities() override;

Optional<std::string> on_update(
const Listener::Configuration& config) override;
void on_revert(const Listener::Configuration& config) override;
void on_post_process() override{};
void on_post_process() override {};

// Return the `TraceSampler` consistent with the most recent configuration.
std::shared_ptr<TraceSampler> trace_sampler();
Expand Down
Loading
Loading