chromium/third_party/openscreen/src/util/trace_logging/macro_support.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UTIL_TRACE_LOGGING_MACRO_SUPPORT_H_
#define UTIL_TRACE_LOGGING_MACRO_SUPPORT_H_

#ifndef INCLUDING_FROM_UTIL_TRACE_LOGGING_H_
#error "Do not include this header directly. Use util/trace_logging.h."
#endif

#ifndef ENABLE_TRACE_LOGGING
#error "BUG: This file should not have been reached."
#endif

#include "platform/api/trace_logging_platform.h"
#include "platform/base/trace_logging_activation.h"
#include "platform/base/trace_logging_types.h"
#include "util/trace_logging/scoped_trace_operations.h"

// Helper macros. These are used to simplify the macros below.
// NOTE: These cannot be #undef'd or they will stop working outside this file.
// NOTE: Two of these below macros are intentionally the same. This is to work
// around optimizations in the C++ Precompiler.
#define TRACE_INTERNAL_CONCAT(a, b)
#define TRACE_INTERNAL_CONCAT_CONST(a, b)
#define TRACE_INTERNAL_UNIQUE_VAR_NAME(a)

// Because we need to suppress unused variables, and this code is used
// repeatedly in below macros, define helper macros to do this on a per-compiler
// basis until we begin using C++ 17 which supports [[maybe_unused]] officially.
#if defined(__clang__)
#define TRACE_INTERNAL_IGNORE_UNUSED_VAR
#elif defined(__GNUC__)
#define TRACE_INTERNAL_IGNORE_UNUSED_VAR
#else
#define TRACE_INTERNAL_IGNORE_UNUSED_VAR
#endif  // defined(__clang__)

namespace openscreen::internal {

inline bool IsTraceLoggingEnabled(TraceCategory category) {}

}  // namespace openscreen::internal

#define TRACE_IS_ENABLED(category)

// Internal logging macros.
#define TRACE_SET_HIERARCHY_INTERNAL(line, ids)

#define TRACE_SCOPED_INTERNAL(line, category, name, ...)

#define TRACE_ASYNC_START_INTERNAL(line, category, name, ...)

#endif  // UTIL_TRACE_LOGGING_MACRO_SUPPORT_H_