Debian Codegraph @

nbcompat/cdefs.h

raw
1 /* $NetBSD: cdefs.h,v 1.4 2024/03/19 00:59:01 nia Exp $ */
2
3 /*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Johnny C. Lam.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _NBCOMPAT_SYS_CDEFS_H_
33 #define _NBCOMPAT_SYS_CDEFS_H_
34
35 #if HAVE_SYS_CDEFS_H
36 # include <sys/cdefs.h>
37 #endif
38
39 /*
40 * Declare macros and functions that may be missing in <sys/cdefs.h>.
41 */
42
43 #ifndef __IDSTRING
44 # define __IDSTRING(name,string) \
45 static const char name[] __attribute__((__unused__)) = string
46 #endif
47
48 #ifndef __COPYRIGHT
49 # define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
50 #endif
51
52 #ifndef __RCSID
53 # define __RCSID(_s) __IDSTRING(rcsid,_s)
54 #endif
55
56 #ifndef __P
57 # if defined(__STDC__) || defined(__cplusplus)
58 # define __P(protos) protos /* full-blown ANSI C */
59 # else
60 # define __P(protos) () /* traditional C preprocessor */
61 # endif
62 #endif
63
64 #ifndef __CONCAT
65 # if defined(__STDC__) || defined(__cplusplus)
66 # define __CONCAT(x,y) x ## y
67 # else
68 # define __CONCAT(x,y) x/**/y
69 # endif
70 #endif
71
72 #ifndef __BEGIN_DECLS
73 # if defined(__cplusplus)
74 # define __BEGIN_DECLS extern "C" {
75 # else
76 # define __BEGIN_DECLS
77 # endif
78 #endif
79
80 #ifndef __END_DECLS
81 # if defined(__cplusplus)
82 # define __END_DECLS };
83 # else
84 # define __END_DECLS
85 # endif
86 #endif
87
88 #ifndef __restrict
89 /*
90 * C99 defines the restrict type qualifier keyword, which was made available
91 * in GCC 2.92.
92 */
93 # if __STDC_VERSION__ >= 199901L
94 # define __restrict restrict
95 # else
96 # define __restrict /* delete __restrict when not supported */
97 # endif
98 #endif
99
100 /*
101 * The following macro is used to remove const cast-away warnings
102 * from gcc -Wcast-qual; it should be used with caution because it
103 * can hide valid errors; in particular most valid uses are in
104 * situations where the API requires it, not to cast away string
105 * constants. We don't use *intptr_t on purpose here and we are
106 * explicit about unsigned long so that we don't have additional
107 * dependencies.
108 */
109 #ifndef __UNCONST
110 # define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
111 #endif
112
113 #endif /* !_NBCOMPAT_SYS_CDEFS_H_ */