mirror of
https://github.com/morgan9e/VolumeControl
synced 2026-04-13 15:55:02 +09:00
105 lines
3.3 KiB
C
105 lines
3.3 KiB
C
// This file is part of Background Music.
|
|
//
|
|
// Background Music is free software: you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License as
|
|
// published by the Free Software Foundation, either version 2 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// Background Music is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// Original licence at the end of this file.
|
|
|
|
//
|
|
// VCThreadSafetyAnalysis.h
|
|
// PublicUtility
|
|
//
|
|
// © Copyright 2007-2020, The Clang Team
|
|
// Copyright © 2020 Kyle Neideck
|
|
//
|
|
// Macros that wrap Clang's attributes for statically checking concurrency properties. From
|
|
// <https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutexheader>.
|
|
//
|
|
|
|
|
|
#ifndef PublicUtility__VCThreadSafetyAnalysis
|
|
#define PublicUtility__VCThreadSafetyAnalysis
|
|
|
|
// Enable thread safety attributes only with clang.
|
|
// The attributes can be safely erased when compiling with other compilers.
|
|
#if defined(__clang__) && (!defined(SWIG))
|
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
|
#else
|
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
|
#endif
|
|
|
|
#define CAPABILITY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
|
|
|
#define SCOPED_CAPABILITY \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
|
|
|
|
#define GUARDED_BY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
|
|
|
#define PT_GUARDED_BY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
|
|
|
#define ACQUIRED_BEFORE(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
|
|
|
#define ACQUIRED_AFTER(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
|
|
|
#define REQUIRES(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
|
|
|
#define REQUIRES_SHARED(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
|
|
|
#define ACQUIRE(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
|
|
|
#define ACQUIRE_SHARED(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
|
|
|
#define RELEASE(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
|
|
|
#define RELEASE_SHARED(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
|
|
|
#define TRY_ACQUIRE(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
|
|
|
#define TRY_ACQUIRE_SHARED(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
|
|
|
#define EXCLUDES(...) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
|
|
|
|
#define ASSERT_CAPABILITY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
|
|
|
#define ASSERT_SHARED_CAPABILITY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
|
|
|
#define RETURN_CAPABILITY(x) \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
|
|
|
#define NO_THREAD_SAFETY_ANALYSIS \
|
|
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
|
|
|
#endif /* PublicUtility__VCThreadSafetyAnalysis */
|
|
|
|
/*
|
|
This file is derived from "mutex.h" from the Clang documentation at
|
|
<https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>. See the LLVM license at
|
|
<https://llvm.org/docs/DeveloperPolicy.html#legacy>.
|
|
*/
|