1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 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 * $FreeBSD$ 33 */ 34 35 #ifndef _SYS_EFX_ANNOTE_H 36 #define _SYS_EFX_ANNOTE_H 37 38 #if defined(_WIN32) || defined(_WIN64) 39 #define EFX_HAVE_WINDOWS_ANNOTATIONS 1 40 #else 41 #define EFX_HAVE_WINDOWS_ANNOTATIONS 0 42 #endif /* defined(_WIN32) || defined(_WIN64) */ 43 44 #if defined(__sun) 45 #define EFX_HAVE_SOLARIS_ANNOTATIONS 1 46 #else 47 #define EFX_HAVE_SOLARIS_ANNOTATIONS 0 48 #endif /* defined(__sun) */ 49 50 #if !EFX_HAVE_WINDOWS_ANNOTATIONS 51 52 /* Ignore Windows SAL annotations on other platforms */ 53 #define __in 54 #define __in_opt 55 #define __in_ecount(_n) 56 #define __in_ecount_opt(_n) 57 #define __in_bcount(_n) 58 #define __in_bcount_opt(_n) 59 60 #define __out 61 #define __out_opt 62 #define __out_ecount(_n) 63 #define __out_ecount_opt(_n) 64 #define __out_ecount_part(_n, _l) 65 #define __out_bcount(_n) 66 #define __out_bcount_opt(_n) 67 #define __out_bcount_part(_n, _l) 68 #define __out_bcount_part_opt(_n, _l) 69 70 #define __deref_out 71 #define __deref_inout 72 73 #define __inout 74 #define __inout_opt 75 #define __inout_ecount(_n) 76 #define __inout_ecount_opt(_n) 77 #define __inout_bcount(_n) 78 #define __inout_bcount_opt(_n) 79 #define __inout_bcount_full_opt(_n) 80 81 #define __deref_out_bcount_opt(n) 82 83 #define __checkReturn 84 #define __success(_x) 85 86 #define __drv_when(_p, _c) 87 88 #endif /* !EFX_HAVE_WINDOWS_ANNOTATIONS */ 89 90 #if !EFX_HAVE_SOLARIS_ANNOTATIONS 91 92 #if EFX_HAVE_WINDOWS_ANNOTATIONS 93 94 /* 95 * Support some SunOS/Solaris style _NOTE() annotations 96 * 97 * At present with the facilities provided in the WDL and the SAL we can only 98 * easily act upon _NOTE(ARGUNUSED(arglist)) annotations. 99 * 100 * Intermediate macros to expand individual _NOTE annotation types into 101 * something the WDK or SAL can understand. They shouldn't be used directly, 102 * for example EFX_NOTE_ARGUNUSED() is only used as an intermediate step on the 103 * transformation of _NOTE(ARGUNSED(arg1, arg2)) into 104 * UNREFERENCED_PARAMETER((arg1, arg2)); 105 */ 106 #define EFX_NOTE_ALIGNMENT(_fname, _n) 107 #define EFX_NOTE_ARGUNUSED(...) UNREFERENCED_PARAMETER((__VA_ARGS__)); 108 #define EFX_NOTE_CONSTANTCONDITION 109 #define EFX_NOTE_CONSTCOND 110 #define EFX_NOTE_EMPTY 111 #define EFX_NOTE_FALLTHROUGH 112 #define EFX_NOTE_FALLTHRU 113 #define EFX_NOTE_LINTED(_msg) 114 #define EFX_NOTE_NOTREACHED 115 #define EFX_NOTE_PRINTFLIKE(_n) 116 #define EFX_NOTE_SCANFLIKE(_n) 117 #define EFX_NOTE_VARARGS(_n) 118 119 #define _NOTE(_annotation) EFX_NOTE_ ## _annotation 120 121 #else 122 123 /* Ignore Solaris annotations on other platforms */ 124 125 #define _NOTE(_annotation) 126 127 #endif /* EFX_HAVE_WINDOWS_ANNOTATIONS */ 128 129 #endif /* !EFX_HAVE_SOLARIS_ANNOTATIONS */ 130 131 #endif /* _SYS_EFX_ANNOTE_H */ 132