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