Skip to content

Commit

Permalink
tracing: use ‘real’ atomics
Browse files Browse the repository at this point in the history
Use actual atomic operations instead of things that are
named as if they were atomics, but aren’t.

Refs: #26100

PR-URL: #26156
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
  • Loading branch information
addaleax authored and rvagg committed Feb 28, 2019
1 parent 54896a6 commit 34c685b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tracing/trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "node_platform.h"
#include "v8-platform.h"
#include "trace_event_common.h"
#include <atomic>

// This header file defines implementation details of how the trace macros in
// trace_event_common.h collect and store trace events. Anything not
Expand Down Expand Up @@ -128,9 +129,10 @@ enum CategoryGroupEnabledFlags {
#define TRACE_EVENT_API_ADD_METADATA_EVENT node::tracing::AddMetadataEvent

// Defines atomic operations used internally by the tracing system.
#define TRACE_EVENT_API_ATOMIC_WORD intptr_t
#define TRACE_EVENT_API_ATOMIC_LOAD(var) (var)
#define TRACE_EVENT_API_ATOMIC_STORE(var, value) (var) = (value)
#define TRACE_EVENT_API_ATOMIC_WORD std::atomic<intptr_t>
#define TRACE_EVENT_API_ATOMIC_WORD_VALUE intptr_t
#define TRACE_EVENT_API_ATOMIC_LOAD(var) (var).load()
#define TRACE_EVENT_API_ATOMIC_STORE(var, value) (var).store(value)

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -157,12 +159,12 @@ enum CategoryGroupEnabledFlags {
category_group_enabled = \
TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); \
TRACE_EVENT_API_ATOMIC_STORE( \
atomic, reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \
atomic, reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD_VALUE>( \
category_group_enabled)); \
}

#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group) \
static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \
static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) {0}; \
const uint8_t* INTERNAL_TRACE_EVENT_UID(category_group_enabled); \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( \
category_group, INTERNAL_TRACE_EVENT_UID(atomic), \
Expand Down

0 comments on commit 34c685b

Please sign in to comment.