xref: /freebsd/sys/dev/sfxge/common/efx_annote.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1383a1cceSAndrew Rybchenko /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3383a1cceSAndrew Rybchenko  *
4383a1cceSAndrew Rybchenko  * Copyright (c) 2018 Solarflare Communications Inc.
5383a1cceSAndrew Rybchenko  * All rights reserved.
6383a1cceSAndrew Rybchenko  *
7383a1cceSAndrew Rybchenko  * Redistribution and use in source and binary forms, with or without
8383a1cceSAndrew Rybchenko  * modification, are permitted provided that the following conditions are met:
9383a1cceSAndrew Rybchenko  *
10383a1cceSAndrew Rybchenko  * 1. Redistributions of source code must retain the above copyright notice,
11383a1cceSAndrew Rybchenko  *    this list of conditions and the following disclaimer.
12383a1cceSAndrew Rybchenko  * 2. Redistributions in binary form must reproduce the above copyright notice,
13383a1cceSAndrew Rybchenko  *    this list of conditions and the following disclaimer in the documentation
14383a1cceSAndrew Rybchenko  *    and/or other materials provided with the distribution.
15383a1cceSAndrew Rybchenko  *
16383a1cceSAndrew Rybchenko  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17383a1cceSAndrew Rybchenko  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18383a1cceSAndrew Rybchenko  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19383a1cceSAndrew Rybchenko  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20383a1cceSAndrew Rybchenko  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21383a1cceSAndrew Rybchenko  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22383a1cceSAndrew Rybchenko  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23383a1cceSAndrew Rybchenko  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24383a1cceSAndrew Rybchenko  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25383a1cceSAndrew Rybchenko  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26383a1cceSAndrew Rybchenko  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27383a1cceSAndrew Rybchenko  *
28383a1cceSAndrew Rybchenko  * The views and conclusions contained in the software and documentation are
29383a1cceSAndrew Rybchenko  * those of the authors and should not be interpreted as representing official
30383a1cceSAndrew Rybchenko  * policies, either expressed or implied, of the FreeBSD Project.
31383a1cceSAndrew Rybchenko  */
32383a1cceSAndrew Rybchenko 
33383a1cceSAndrew Rybchenko #ifndef	_SYS_EFX_ANNOTE_H
34383a1cceSAndrew Rybchenko #define	_SYS_EFX_ANNOTE_H
35383a1cceSAndrew Rybchenko 
36383a1cceSAndrew Rybchenko #if defined(_WIN32) || defined(_WIN64)
37383a1cceSAndrew Rybchenko #define	EFX_HAVE_WINDOWS_ANNOTATIONS 1
38383a1cceSAndrew Rybchenko #else
39383a1cceSAndrew Rybchenko #define	EFX_HAVE_WINDOWS_ANNOTATIONS 0
40383a1cceSAndrew Rybchenko #endif	/* defined(_WIN32) || defined(_WIN64) */
41383a1cceSAndrew Rybchenko 
42383a1cceSAndrew Rybchenko #if defined(__sun)
43383a1cceSAndrew Rybchenko #define	EFX_HAVE_SOLARIS_ANNOTATIONS 1
44383a1cceSAndrew Rybchenko #else
45383a1cceSAndrew Rybchenko #define	EFX_HAVE_SOLARIS_ANNOTATIONS 0
46383a1cceSAndrew Rybchenko #endif	/* defined(__sun) */
47383a1cceSAndrew Rybchenko 
48383a1cceSAndrew Rybchenko #if !EFX_HAVE_WINDOWS_ANNOTATIONS
49383a1cceSAndrew Rybchenko 
50383a1cceSAndrew Rybchenko /* Ignore Windows SAL annotations on other platforms */
51383a1cceSAndrew Rybchenko #define	__in
52383a1cceSAndrew Rybchenko #define	__in_opt
53383a1cceSAndrew Rybchenko #define	__in_ecount(_n)
54383a1cceSAndrew Rybchenko #define	__in_ecount_opt(_n)
55383a1cceSAndrew Rybchenko #define	__in_bcount(_n)
56383a1cceSAndrew Rybchenko #define	__in_bcount_opt(_n)
57383a1cceSAndrew Rybchenko 
58383a1cceSAndrew Rybchenko #define	__out
59383a1cceSAndrew Rybchenko #define	__out_opt
60383a1cceSAndrew Rybchenko #define	__out_ecount(_n)
61383a1cceSAndrew Rybchenko #define	__out_ecount_opt(_n)
6294a7dab5SAndrew Rybchenko #define	__out_ecount_part(_n, _l)
63383a1cceSAndrew Rybchenko #define	__out_bcount(_n)
64383a1cceSAndrew Rybchenko #define	__out_bcount_opt(_n)
65383a1cceSAndrew Rybchenko #define	__out_bcount_part(_n, _l)
66383a1cceSAndrew Rybchenko #define	__out_bcount_part_opt(_n, _l)
67383a1cceSAndrew Rybchenko 
68383a1cceSAndrew Rybchenko #define	__deref_out
69d86bef48SAndrew Rybchenko #define	__deref_inout
70383a1cceSAndrew Rybchenko 
71383a1cceSAndrew Rybchenko #define	__inout
72383a1cceSAndrew Rybchenko #define	__inout_opt
73383a1cceSAndrew Rybchenko #define	__inout_ecount(_n)
74383a1cceSAndrew Rybchenko #define	__inout_ecount_opt(_n)
75383a1cceSAndrew Rybchenko #define	__inout_bcount(_n)
76383a1cceSAndrew Rybchenko #define	__inout_bcount_opt(_n)
77383a1cceSAndrew Rybchenko #define	__inout_bcount_full_opt(_n)
78383a1cceSAndrew Rybchenko 
79383a1cceSAndrew Rybchenko #define	__deref_out_bcount_opt(n)
80383a1cceSAndrew Rybchenko 
81383a1cceSAndrew Rybchenko #define	__checkReturn
82383a1cceSAndrew Rybchenko #define	__success(_x)
83383a1cceSAndrew Rybchenko 
84383a1cceSAndrew Rybchenko #define	__drv_when(_p, _c)
85383a1cceSAndrew Rybchenko 
86383a1cceSAndrew Rybchenko #endif	/* !EFX_HAVE_WINDOWS_ANNOTATIONS */
87383a1cceSAndrew Rybchenko 
88383a1cceSAndrew Rybchenko #if !EFX_HAVE_SOLARIS_ANNOTATIONS
89383a1cceSAndrew Rybchenko 
90383a1cceSAndrew Rybchenko #if EFX_HAVE_WINDOWS_ANNOTATIONS
91383a1cceSAndrew Rybchenko 
92383a1cceSAndrew Rybchenko /*
93383a1cceSAndrew Rybchenko  * Support some SunOS/Solaris style _NOTE() annotations
94383a1cceSAndrew Rybchenko  *
95383a1cceSAndrew Rybchenko  * At present with the facilities provided in the WDL and the SAL we can only
96383a1cceSAndrew Rybchenko  * easily act upon _NOTE(ARGUNUSED(arglist)) annotations.
97383a1cceSAndrew Rybchenko  *
98383a1cceSAndrew Rybchenko  * Intermediate macros to expand individual _NOTE annotation types into
99383a1cceSAndrew Rybchenko  * something the WDK or SAL can understand.  They shouldn't be used directly,
100383a1cceSAndrew Rybchenko  * for example EFX_NOTE_ARGUNUSED() is only used as an intermediate step on the
101383a1cceSAndrew Rybchenko  * transformation of _NOTE(ARGUNSED(arg1, arg2)) into
102383a1cceSAndrew Rybchenko  * UNREFERENCED_PARAMETER((arg1, arg2));
103383a1cceSAndrew Rybchenko  */
104383a1cceSAndrew Rybchenko #define	EFX_NOTE_ALIGNMENT(_fname, _n)
105383a1cceSAndrew Rybchenko #define	EFX_NOTE_ARGUNUSED(...)		UNREFERENCED_PARAMETER((__VA_ARGS__));
106383a1cceSAndrew Rybchenko #define	EFX_NOTE_CONSTANTCONDITION
107383a1cceSAndrew Rybchenko #define	EFX_NOTE_CONSTCOND
108383a1cceSAndrew Rybchenko #define	EFX_NOTE_EMPTY
109383a1cceSAndrew Rybchenko #define	EFX_NOTE_FALLTHROUGH
110383a1cceSAndrew Rybchenko #define	EFX_NOTE_FALLTHRU
111383a1cceSAndrew Rybchenko #define	EFX_NOTE_LINTED(_msg)
112383a1cceSAndrew Rybchenko #define	EFX_NOTE_NOTREACHED
113383a1cceSAndrew Rybchenko #define	EFX_NOTE_PRINTFLIKE(_n)
114383a1cceSAndrew Rybchenko #define	EFX_NOTE_SCANFLIKE(_n)
115383a1cceSAndrew Rybchenko #define	EFX_NOTE_VARARGS(_n)
116383a1cceSAndrew Rybchenko 
117383a1cceSAndrew Rybchenko #define	_NOTE(_annotation)		EFX_NOTE_ ## _annotation
118383a1cceSAndrew Rybchenko 
119383a1cceSAndrew Rybchenko #else
120383a1cceSAndrew Rybchenko 
121383a1cceSAndrew Rybchenko /* Ignore Solaris annotations on other platforms */
122383a1cceSAndrew Rybchenko 
123383a1cceSAndrew Rybchenko #define	_NOTE(_annotation)
124383a1cceSAndrew Rybchenko 
125383a1cceSAndrew Rybchenko #endif	/* EFX_HAVE_WINDOWS_ANNOTATIONS */
126383a1cceSAndrew Rybchenko 
127383a1cceSAndrew Rybchenko #endif	/* !EFX_HAVE_SOLARIS_ANNOTATIONS */
128383a1cceSAndrew Rybchenko 
129383a1cceSAndrew Rybchenko #endif	/* _SYS_EFX_ANNOTE_H */
130