Changeset View
Changeset View
Standalone View
Standalone View
src/threadsafety.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2014 The Bitcoin Core developers | // Copyright (c) 2009-2014 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_THREADSAFETY_H | #ifndef BITCOIN_THREADSAFETY_H | ||||
#define BITCOIN_THREADSAFETY_H | #define BITCOIN_THREADSAFETY_H | ||||
#ifdef __clang__ | #ifdef __clang__ | ||||
// TL;DR Add GUARDED_BY(mutex) to member variables. The others are rarely | // TL;DR Add GUARDED_BY(mutex) to member variables. The others are rarely | ||||
// necessary. Ex: int nFoo GUARDED_BY(cs_foo); | // necessary. Ex: int nFoo GUARDED_BY(cs_foo); | ||||
// | // | ||||
// See http://clang.llvm.org/docs/LanguageExtensions.html#threadsafety for | // See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html for documentation. | ||||
// documentation. The clang compiler can do advanced static analysis of locking | // The clang compiler can do advanced static analysis of locking when given the | ||||
// when given the -Wthread-safety option. | // -Wthread-safety option. | ||||
#define LOCKABLE __attribute__((lockable)) | #define LOCKABLE __attribute__((lockable)) | ||||
#define SCOPED_LOCKABLE __attribute__((scoped_lockable)) | #define SCOPED_LOCKABLE __attribute__((scoped_lockable)) | ||||
#define GUARDED_BY(x) __attribute__((guarded_by(x))) | #define GUARDED_BY(x) __attribute__((guarded_by(x))) | ||||
#define GUARDED_VAR __attribute__((guarded_var)) | #define GUARDED_VAR __attribute__((guarded_var)) | ||||
#define PT_GUARDED_BY(x) __attribute__((pt_guarded_by(x))) | #define PT_GUARDED_BY(x) __attribute__((pt_guarded_by(x))) | ||||
#define PT_GUARDED_VAR __attribute__((pt_guarded_var)) | #define PT_GUARDED_VAR __attribute__((pt_guarded_var)) | ||||
#define ACQUIRED_AFTER(...) __attribute__((acquired_after(__VA_ARGS__))) | #define ACQUIRED_AFTER(...) __attribute__((acquired_after(__VA_ARGS__))) | ||||
#define ACQUIRED_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__))) | #define ACQUIRED_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__))) | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |