blob: 4681e7c695a82a60343f4b9778395d7a067b1065 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* $NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $ */
2
3/*
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Berkeley Software Design, Inc.
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 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
35 */
36
37/*
38 * This is a minimum version of cdefs.h for LK, this might be
39 * modified if necessary
40 */
41#ifndef _SYS_CDEFS_H_
42#define _SYS_CDEFS_H_
43
44/*-
45 * Deal with _ANSI_SOURCE:
46 * If it is defined, and no other compilation environment is explicitly
47 * requested, then define our internal feature-test macros to zero. This
48 * makes no difference to the preprocessor (undefined symbols in preprocessing
49 * expressions are defined to have value zero), but makes it more convenient for
50 * a test program to print out the values.
51 *
52 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
53 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
54 * environment (and in fact we will never get here).
55 */
56#if defined(_ANSI_SOURCE) /* Hide almost everything. */
57#define __POSIX_VISIBLE 0
58#define __XSI_VISIBLE 0
59#define __BSD_VISIBLE 0
60#define __ISO_C_VISIBLE 1990
61#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
62#define __POSIX_VISIBLE 0
63#define __XSI_VISIBLE 0
64#define __BSD_VISIBLE 0
65#define __ISO_C_VISIBLE 1999
66#else /* Default environment: show everything. */
67#define __POSIX_VISIBLE 200809
68#define __XSI_VISIBLE 700
69#define __BSD_VISIBLE 1
70#define __ISO_C_VISIBLE 1999
71#endif
72
73/*
74 * Default values.
75 */
76#ifndef __XPG_VISIBLE
77# define __XPG_VISIBLE 700
78#endif
79#ifndef __POSIX_VISIBLE
80# define __POSIX_VISIBLE 200809
81#endif
82#ifndef __ISO_C_VISIBLE
83# define __ISO_C_VISIBLE 1999
84#endif
85#ifndef __BSD_VISIBLE
86# define __BSD_VISIBLE 1
87#endif
88
89
90/*
91 * Some of the FreeBSD sources used in Bionic need this.
92 * Originally, this is used to embed the rcs versions of each source file
93 * in the generated binary. We certainly don't want this in Bionic.
94 */
95#define __FBSDID(s) /* nothing */
96
97#define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */
98
99/*
100 * Macro to test if we're using a GNU C compiler of a specific vintage
101 * or later, for e.g. features that appeared in a particular version
102 * of GNU C. Usage:
103 *
104 * #if __GNUC_PREREQ__(major, minor)
105 * ...cool feature...
106 * #else
107 * ...delete feature...
108 * #endif
109 */
110#ifdef __GNUC__
111#define __GNUC_PREREQ__(x, y) \
112 ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
113 (__GNUC__ > (x)))
114#else
115#define __GNUC_PREREQ__(x, y) 0
116#endif
117
118#if defined(__cplusplus)
119#define __BEGIN_DECLS extern "C" {
120#define __END_DECLS }
121#define __static_cast(x,y) static_cast<x>(y)
122#else
123#define __BEGIN_DECLS
124#define __END_DECLS
125#define __static_cast(x,y) (x)y
126#endif
127
128#if defined(__cplusplus)
129#define __inline inline /* convert to C++ keyword */
130#else
131#if !defined(__GNUC__) && !defined(__lint__)
132#define __inline /* delete GCC keyword */
133#endif /* !__GNUC__ && !__lint__ */
134#endif /* !__cplusplus */
135
136#if __GNUC_PREREQ__(3, 1)
137#define __always_inline __attribute__((__always_inline__))
138#else
139#define __always_inline
140#endif
141
142
143
144#endif /* !_SYS_CDEFS_H_ */