1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2022 Red Hat, Inc. 3 */ 4 5 #ifndef RTE_LOCK_ANNOTATIONS_H 6 #define RTE_LOCK_ANNOTATIONS_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #ifdef RTE_ANNOTATE_LOCKS 13 14 #define __rte_lockable \ 15 __attribute__((lockable)) 16 17 #define __rte_guarded_by(...) \ 18 __attribute__((guarded_by(__VA_ARGS__))) 19 #define __rte_guarded_var \ 20 __attribute__((guarded_var)) 21 22 #define __rte_exclusive_locks_required(...) \ 23 __attribute__((exclusive_locks_required(__VA_ARGS__))) 24 #define __rte_exclusive_lock_function(...) \ 25 __attribute__((exclusive_lock_function(__VA_ARGS__))) 26 #define __rte_exclusive_trylock_function(ret, ...) \ 27 __attribute__((exclusive_trylock_function(ret, __VA_ARGS__))) 28 #define __rte_assert_exclusive_lock(...) \ 29 __attribute__((assert_exclusive_lock(__VA_ARGS__))) 30 31 #define __rte_shared_locks_required(...) \ 32 __attribute__((shared_locks_required(__VA_ARGS__))) 33 #define __rte_shared_lock_function(...) \ 34 __attribute__((shared_lock_function(__VA_ARGS__))) 35 #define __rte_shared_trylock_function(ret, ...) \ 36 __attribute__((shared_trylock_function(ret, __VA_ARGS__))) 37 #define __rte_assert_shared_lock(...) \ 38 __attribute__((assert_shared_lock(__VA_ARGS__))) 39 40 #define __rte_unlock_function(...) \ 41 __attribute__((unlock_function(__VA_ARGS__))) 42 43 #define __rte_locks_excluded(...) \ 44 __attribute__((locks_excluded(__VA_ARGS__))) 45 46 #define __rte_no_thread_safety_analysis \ 47 __attribute__((no_thread_safety_analysis)) 48 49 #else /* ! RTE_ANNOTATE_LOCKS */ 50 51 #define __rte_lockable 52 53 #define __rte_guarded_by(...) 54 #define __rte_guarded_var 55 56 #define __rte_exclusive_locks_required(...) 57 #define __rte_exclusive_lock_function(...) 58 #define __rte_exclusive_trylock_function(...) 59 #define __rte_assert_exclusive_lock(...) 60 61 #define __rte_shared_locks_required(...) 62 #define __rte_shared_lock_function(...) 63 #define __rte_shared_trylock_function(...) 64 #define __rte_assert_shared_lock(...) 65 66 #define __rte_unlock_function(...) 67 68 #define __rte_locks_excluded(...) 69 70 #define __rte_no_thread_safety_analysis 71 72 #endif /* RTE_ANNOTATE_LOCKS */ 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* RTE_LOCK_ANNOTATIONS_H */ 79