xref: /freebsd/sys/dev/sfxge/common/efx_annote.h (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2018 Solarflare Communications Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * The views and conclusions contained in the software and documentation are
29  * those of the authors and should not be interpreted as representing official
30  * policies, either expressed or implied, of the FreeBSD Project.
31  */
32 
33 #ifndef	_SYS_EFX_ANNOTE_H
34 #define	_SYS_EFX_ANNOTE_H
35 
36 #if defined(_WIN32) || defined(_WIN64)
37 #define	EFX_HAVE_WINDOWS_ANNOTATIONS 1
38 #else
39 #define	EFX_HAVE_WINDOWS_ANNOTATIONS 0
40 #endif	/* defined(_WIN32) || defined(_WIN64) */
41 
42 #if defined(__sun)
43 #define	EFX_HAVE_SOLARIS_ANNOTATIONS 1
44 #else
45 #define	EFX_HAVE_SOLARIS_ANNOTATIONS 0
46 #endif	/* defined(__sun) */
47 
48 #if !EFX_HAVE_WINDOWS_ANNOTATIONS
49 
50 /* Ignore Windows SAL annotations on other platforms */
51 #define	__in
52 #define	__in_opt
53 #define	__in_ecount(_n)
54 #define	__in_ecount_opt(_n)
55 #define	__in_bcount(_n)
56 #define	__in_bcount_opt(_n)
57 
58 #define	__out
59 #define	__out_opt
60 #define	__out_ecount(_n)
61 #define	__out_ecount_opt(_n)
62 #define	__out_ecount_part(_n, _l)
63 #define	__out_bcount(_n)
64 #define	__out_bcount_opt(_n)
65 #define	__out_bcount_part(_n, _l)
66 #define	__out_bcount_part_opt(_n, _l)
67 
68 #define	__deref_out
69 #define	__deref_inout
70 
71 #define	__inout
72 #define	__inout_opt
73 #define	__inout_ecount(_n)
74 #define	__inout_ecount_opt(_n)
75 #define	__inout_bcount(_n)
76 #define	__inout_bcount_opt(_n)
77 #define	__inout_bcount_full_opt(_n)
78 
79 #define	__deref_out_bcount_opt(n)
80 
81 #define	__checkReturn
82 #define	__success(_x)
83 
84 #define	__drv_when(_p, _c)
85 
86 #endif	/* !EFX_HAVE_WINDOWS_ANNOTATIONS */
87 
88 #if !EFX_HAVE_SOLARIS_ANNOTATIONS
89 
90 #if EFX_HAVE_WINDOWS_ANNOTATIONS
91 
92 /*
93  * Support some SunOS/Solaris style _NOTE() annotations
94  *
95  * At present with the facilities provided in the WDL and the SAL we can only
96  * easily act upon _NOTE(ARGUNUSED(arglist)) annotations.
97  *
98  * Intermediate macros to expand individual _NOTE annotation types into
99  * something the WDK or SAL can understand.  They shouldn't be used directly,
100  * for example EFX_NOTE_ARGUNUSED() is only used as an intermediate step on the
101  * transformation of _NOTE(ARGUNSED(arg1, arg2)) into
102  * UNREFERENCED_PARAMETER((arg1, arg2));
103  */
104 #define	EFX_NOTE_ALIGNMENT(_fname, _n)
105 #define	EFX_NOTE_ARGUNUSED(...)		UNREFERENCED_PARAMETER((__VA_ARGS__));
106 #define	EFX_NOTE_CONSTANTCONDITION
107 #define	EFX_NOTE_CONSTCOND
108 #define	EFX_NOTE_EMPTY
109 #define	EFX_NOTE_FALLTHROUGH
110 #define	EFX_NOTE_FALLTHRU
111 #define	EFX_NOTE_LINTED(_msg)
112 #define	EFX_NOTE_NOTREACHED
113 #define	EFX_NOTE_PRINTFLIKE(_n)
114 #define	EFX_NOTE_SCANFLIKE(_n)
115 #define	EFX_NOTE_VARARGS(_n)
116 
117 #define	_NOTE(_annotation)		EFX_NOTE_ ## _annotation
118 
119 #else
120 
121 /* Ignore Solaris annotations on other platforms */
122 
123 #define	_NOTE(_annotation)
124 
125 #endif	/* EFX_HAVE_WINDOWS_ANNOTATIONS */
126 
127 #endif	/* !EFX_HAVE_SOLARIS_ANNOTATIONS */
128 
129 #endif	/* _SYS_EFX_ANNOTE_H */
130