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_no_thread_safety_analysis \ 44 __attribute__((no_thread_safety_analysis)) 45 46 #else /* ! RTE_ANNOTATE_LOCKS */ 47 48 #define __rte_lockable 49 50 #define __rte_guarded_by(...) 51 #define __rte_guarded_var 52 53 #define __rte_exclusive_locks_required(...) 54 #define __rte_exclusive_lock_function(...) 55 #define __rte_exclusive_trylock_function(...) 56 #define __rte_assert_exclusive_lock(...) 57 58 #define __rte_shared_locks_required(...) 59 #define __rte_shared_lock_function(...) 60 #define __rte_shared_trylock_function(...) 61 #define __rte_assert_shared_lock(...) 62 63 #define __rte_unlock_function(...) 64 65 #define __rte_no_thread_safety_analysis 66 67 #endif /* RTE_ANNOTATE_LOCKS */ 68 69 #ifdef __cplusplus 70 } 71 #endif 72 73 #endif /* RTE_LOCK_ANNOTATIONS_H */ 74