xref: /dpdk/drivers/common/sfc_efx/base/efx_annote.h (revision 672386c1e9e1f64f7aa3b1360ad22dc737ea8d72)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 2018-2019 Solarflare Communications Inc.
5  */
6 
7 #ifndef	_SYS_EFX_ANNOTE_H
8 #define	_SYS_EFX_ANNOTE_H
9 
10 #if defined(_WIN32) || defined(_WIN64)
11 #define	EFX_HAVE_WINDOWS_ANNOTATIONS 1
12 #else
13 #define	EFX_HAVE_WINDOWS_ANNOTATIONS 0
14 #endif	/* defined(_WIN32) || defined(_WIN64) */
15 
16 #if defined(__sun)
17 #define	EFX_HAVE_SOLARIS_ANNOTATIONS 1
18 #else
19 #define	EFX_HAVE_SOLARIS_ANNOTATIONS 0
20 #endif	/* defined(__sun) */
21 
22 #if !EFX_HAVE_WINDOWS_ANNOTATIONS
23 
24 /* Ignore Windows SAL annotations on other platforms */
25 #define	__in
26 #define	__in_opt
27 #define	__in_ecount(_n)
28 #define	__in_ecount_opt(_n)
29 #define	__in_bcount(_n)
30 #define	__in_bcount_opt(_n)
31 
32 #define	__out
33 #define	__out_opt
34 #define	__out_ecount(_n)
35 #define	__out_ecount_opt(_n)
36 #define	__out_ecount_part(_n, _l)
37 #define	__out_bcount(_n)
38 #define	__out_bcount_opt(_n)
39 #define	__out_bcount_part(_n, _l)
40 #define	__out_bcount_part_opt(_n, _l)
41 
42 #define	__deref_out
43 #define	__deref_inout
44 
45 #define	__inout
46 #define	__inout_opt
47 #define	__inout_ecount(_n)
48 #define	__inout_ecount_opt(_n)
49 #define	__inout_bcount(_n)
50 #define	__inout_bcount_opt(_n)
51 #define	__inout_bcount_full_opt(_n)
52 
53 #define	__deref_out_bcount_opt(n)
54 
55 #define	__checkReturn
56 #define	__success(_x)
57 
58 #define	__drv_when(_p, _c)
59 
60 #endif	/* !EFX_HAVE_WINDOWS_ANNOTATIONS */
61 
62 #if !EFX_HAVE_SOLARIS_ANNOTATIONS
63 
64 #if EFX_HAVE_WINDOWS_ANNOTATIONS
65 
66 /*
67  * Support some SunOS/Solaris style _NOTE() annotations
68  *
69  * At present with the facilities provided in the WDL and the SAL we can only
70  * easily act upon _NOTE(ARGUNUSED(arglist)) annotations.
71  *
72  * Intermediate macros to expand individual _NOTE annotation types into
73  * something the WDK or SAL can understand.  They shouldn't be used directly,
74  * for example EFX_NOTE_ARGUNUSED() is only used as an intermediate step on the
75  * transformation of _NOTE(ARGUNSED(arg1, arg2)) into
76  * UNREFERENCED_PARAMETER((arg1, arg2));
77  */
78 #define	EFX_NOTE_ALIGNMENT(_fname, _n)
79 #define	EFX_NOTE_ARGUNUSED(...)		UNREFERENCED_PARAMETER((__VA_ARGS__));
80 #define	EFX_NOTE_CONSTANTCONDITION
81 #define	EFX_NOTE_CONSTCOND
82 #define	EFX_NOTE_EMPTY
83 #define	EFX_NOTE_FALLTHROUGH
84 #define	EFX_NOTE_FALLTHRU
85 #define	EFX_NOTE_LINTED(_msg)
86 #define	EFX_NOTE_NOTREACHED
87 #define	EFX_NOTE_PRINTFLIKE(_n)
88 #define	EFX_NOTE_SCANFLIKE(_n)
89 #define	EFX_NOTE_VARARGS(_n)
90 
91 #define	_NOTE(_annotation)		EFX_NOTE_ ## _annotation
92 
93 #else
94 
95 /* Ignore Solaris annotations on other platforms */
96 
97 #define	_NOTE(_annotation)
98 
99 #endif	/* EFX_HAVE_WINDOWS_ANNOTATIONS */
100 
101 #endif	/* !EFX_HAVE_SOLARIS_ANNOTATIONS */
102 
103 #endif	/* _SYS_EFX_ANNOTE_H */
104