chromium/third_party/skia/include/private/base/SkThreadAnnotations.h

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

#ifndef SkThreadAnnotations_DEFINED
#define SkThreadAnnotations_DEFINED

#include "include/private/base/SkFeatures.h"  // IWYU pragma: keep

// The bulk of this code is cribbed from:
// http://clang.llvm.org/docs/ThreadSafetyAnalysis.html

#if defined(__clang__) && (!defined(SWIG))
#define SK_THREAD_ANNOTATION_ATTRIBUTE(x)
#else
#define SK_THREAD_ANNOTATION_ATTRIBUTE
#endif

#define SK_CAPABILITY(x)

#define SK_SCOPED_CAPABILITY

#define SK_GUARDED_BY(x)

#define SK_PT_GUARDED_BY(x)

#define SK_ACQUIRED_BEFORE(...)

#define SK_ACQUIRED_AFTER(...)

#define SK_REQUIRES(...)

#define SK_REQUIRES_SHARED(...)

#define SK_ACQUIRE(...)

#define SK_ACQUIRE_SHARED(...)

// Would be SK_RELEASE, but that is already in use as SK_DEBUG vs. SK_RELEASE.
#define SK_RELEASE_CAPABILITY(...)

// For symmetry with SK_RELEASE_CAPABILITY.
#define SK_RELEASE_SHARED_CAPABILITY(...)

#define SK_TRY_ACQUIRE(...)

#define SK_TRY_ACQUIRE_SHARED(...)

#define SK_EXCLUDES(...)

#define SK_ASSERT_CAPABILITY(x)

#define SK_ASSERT_SHARED_CAPABILITY(x)

#define SK_RETURN_CAPABILITY(x)

#define SK_NO_THREAD_SAFETY_ANALYSIS

#if defined(SK_BUILD_FOR_GOOGLE3) && !defined(SK_BUILD_FOR_WASM_IN_GOOGLE3) \
    && !defined(SK_BUILD_FOR_WIN)
    extern "C" {
        void __google_cxa_guard_acquire_begin(void) __attribute__((weak));
        void __google_cxa_guard_acquire_end  (void) __attribute__((weak));
    }
    static inline void sk_potentially_blocking_region_begin() {
        if (&__google_cxa_guard_acquire_begin) {
            __google_cxa_guard_acquire_begin();
        }
    }
    static inline void sk_potentially_blocking_region_end() {
        if (&__google_cxa_guard_acquire_end) {
            __google_cxa_guard_acquire_end();
        }
    }
    #define SK_POTENTIALLY_BLOCKING_REGION_BEGIN
    #define SK_POTENTIALLY_BLOCKING_REGION_END
#else
    #define SK_POTENTIALLY_BLOCKING_REGION_BEGIN
    #define SK_POTENTIALLY_BLOCKING_REGION_END
#endif

#endif  // SkThreadAnnotations_DEFINED