xref: /optee_os/lib/libutils/isoc/newlib/_ansi.h (revision 1bb929836182ecb96d2d9d268daa807c67596396)
1*1bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-3-Clause */
2b0104773SPascal Brand /*
3b0104773SPascal Brand  * Copyright (c) 1994-2009  Red Hat, Inc.
4b0104773SPascal Brand  * All rights reserved.
5b0104773SPascal Brand  *
6b0104773SPascal Brand  * Redistribution and use in source and binary forms, with or without
7b0104773SPascal Brand  * modification, are permitted provided that the following conditions are met:
8b0104773SPascal Brand  *
9b0104773SPascal Brand  * 1. Redistributions of source code must retain the above copyright notice,
10b0104773SPascal Brand  * this list of conditions and the following disclaimer.
11b0104773SPascal Brand  *
12b0104773SPascal Brand  * 2. Redistributions in binary form must reproduce the above copyright notice,
13b0104773SPascal Brand  * this list of conditions and the following disclaimer in the documentation
14b0104773SPascal Brand  * and/or other materials provided with the distribution.
15b0104773SPascal Brand  *
16b0104773SPascal Brand  * 3. Neither the name of the copyright holder nor the names of its
17b0104773SPascal Brand  * contributors may be used to endorse or promote products derived from this
18b0104773SPascal Brand  * software without specific prior written permission.
19b0104773SPascal Brand  *
20b0104773SPascal Brand  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21b0104773SPascal Brand  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22b0104773SPascal Brand  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23b0104773SPascal Brand  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24b0104773SPascal Brand  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25b0104773SPascal Brand  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26b0104773SPascal Brand  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27b0104773SPascal Brand  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28b0104773SPascal Brand  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29b0104773SPascal Brand  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30b0104773SPascal Brand  * POSSIBILITY OF SUCH DAMAGE.
31b0104773SPascal Brand  */
32b0104773SPascal Brand 
33b0104773SPascal Brand /* Provide support for both ANSI and non-ANSI environments.  */
34b0104773SPascal Brand 
35b0104773SPascal Brand /* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
36b0104773SPascal Brand    relied upon to have it's intended meaning.  Therefore we must use our own
37b0104773SPascal Brand    concoction: _HAVE_STDC.  Always use _HAVE_STDC instead of __STDC__ in newlib
38b0104773SPascal Brand    sources!
39b0104773SPascal Brand 
40b0104773SPascal Brand    To get a strict ANSI C environment, define macro __STRICT_ANSI__.  This will
41b0104773SPascal Brand    "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
42b0104773SPascal Brand    files aren't affected).  */
43b0104773SPascal Brand 
44b0104773SPascal Brand #ifndef _ANSIDECL_H_
45b0104773SPascal Brand #define _ANSIDECL_H_
46b0104773SPascal Brand 
47b0104773SPascal Brand /*#include <newlib.h> */
48b0104773SPascal Brand /*#include <sys/config.h> */
49b0104773SPascal Brand 
50b0104773SPascal Brand /*
51b0104773SPascal Brand  * First try to figure out whether we really are in an ANSI C environment.
52b0104773SPascal Brand  * This probably needs some work.  Perhaps sys/config.h can be
53b0104773SPascal Brand  * prevailed upon to give us a clue.
54b0104773SPascal Brand  */
55b0104773SPascal Brand 
56b0104773SPascal Brand #ifdef __STDC__
57b0104773SPascal Brand #define _HAVE_STDC
58b0104773SPascal Brand #endif
59b0104773SPascal Brand 
60b0104773SPascal Brand #ifdef _HAVE_STDC
61b0104773SPascal Brand #define _PTR    void *
62b0104773SPascal Brand #define _AND    ,
63b0104773SPascal Brand #define _NOARGS   void
64b0104773SPascal Brand #define _CONST    const
65b0104773SPascal Brand #define _VOLATILE volatile
66b0104773SPascal Brand #define _SIGNED   signed
67b0104773SPascal Brand #define _DOTS   , ...
68b0104773SPascal Brand #define _VOID void
69b0104773SPascal Brand #ifdef __CYGWIN__
70b0104773SPascal Brand #define _EXFUN(name, proto)   __cdecl name proto
71b0104773SPascal Brand #define _EXPARM(name, proto)    (* __cdecl name) proto
72b0104773SPascal Brand #else
73b0104773SPascal Brand #define _EXFUN(name, proto)   name proto
74b0104773SPascal Brand #define _EXPARM(name, proto)    (* name) proto
75b0104773SPascal Brand #endif
76b0104773SPascal Brand #define _DEFUN(name, arglist, args) name(args)
77b0104773SPascal Brand #define _DEFUN_VOID(name)   name(_NOARGS)
78b0104773SPascal Brand #define _CAST_VOID (void)
79b0104773SPascal Brand #ifndef _LONG_DOUBLE
80b0104773SPascal Brand #define _LONG_DOUBLE long double
81b0104773SPascal Brand #endif
82b0104773SPascal Brand #ifndef _PARAMS
83b0104773SPascal Brand #define _PARAMS(paramlist)    paramlist
84b0104773SPascal Brand #endif
85b0104773SPascal Brand #else
86b0104773SPascal Brand #define _PTR    char *
87b0104773SPascal Brand #define _AND    ;
88b0104773SPascal Brand #define _NOARGS
89b0104773SPascal Brand #define _CONST
90b0104773SPascal Brand #define _VOLATILE
91b0104773SPascal Brand #define _SIGNED
92b0104773SPascal Brand #define _DOTS
93b0104773SPascal Brand #define _VOID void
94b0104773SPascal Brand #define _EXFUN(name, proto)   name()
95b0104773SPascal Brand #define _DEFUN(name, arglist, args) name arglist args;
96b0104773SPascal Brand #define _DEFUN_VOID(name)   name()
97b0104773SPascal Brand #define _CAST_VOID
98b0104773SPascal Brand #define _LONG_DOUBLE double
99b0104773SPascal Brand #ifndef _PARAMS
100b0104773SPascal Brand #define _PARAMS(paramlist)    ()
101b0104773SPascal Brand #endif
102b0104773SPascal Brand #endif
103b0104773SPascal Brand 
104b0104773SPascal Brand /* Support gcc's __attribute__ facility.  */
105b0104773SPascal Brand 
106b0104773SPascal Brand #ifdef __GNUC__
107b0104773SPascal Brand #define _ATTRIBUTE(attrs) __attribute__ (attrs)
108b0104773SPascal Brand #else
109b0104773SPascal Brand #define _ATTRIBUTE(attrs)
110b0104773SPascal Brand #endif
111b0104773SPascal Brand 
112b0104773SPascal Brand /*  ISO C++.  */
113b0104773SPascal Brand 
114b0104773SPascal Brand #ifdef __cplusplus
115b0104773SPascal Brand #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
116b0104773SPascal Brand #ifdef _HAVE_STD_CXX
117b0104773SPascal Brand #define _BEGIN_STD_C namespace std { extern "C" {
118b0104773SPascal Brand #define _END_STD_C  } }
119b0104773SPascal Brand #else
120b0104773SPascal Brand #define _BEGIN_STD_C extern "C" {
121b0104773SPascal Brand #define _END_STD_C  }
122b0104773SPascal Brand #endif
123b0104773SPascal Brand #endif
124b0104773SPascal Brand #else
125b0104773SPascal Brand #define _BEGIN_STD_C
126b0104773SPascal Brand #define _END_STD_C
127b0104773SPascal Brand #endif
128b0104773SPascal Brand 
129b0104773SPascal Brand #endif /* _ANSIDECL_H_ */
130