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