Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/* Provide support for both ANSI and non-ANSI environments.  */
2
 
3
/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
4
   relied upon to have it's intended meaning.  Therefore we must use our own
5
   concoction: _HAVE_STDC.  Always use _HAVE_STDC instead of __STDC__ in newlib
6
   sources!
7
 
8
   To get a strict ANSI C environment, define macro __STRICT_ANSI__.  This will
9
   "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
10
   files aren't affected).  */
11
 
12
#ifndef	_ANSIDECL_H_
13
#define	_ANSIDECL_H_
14
 
15
#include 
16
#include 
17
 
18
/* First try to figure out whether we really are in an ANSI C environment.  */
19
/* FIXME: This probably needs some work.  Perhaps sys/config.h can be
20
   prevailed upon to give us a clue.  */
21
 
22
#ifdef __STDC__
23
#define _HAVE_STDC
24
#endif
25
 
26
/*  ISO C++.  */
27
 
28
#ifdef __cplusplus
29
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
30
#ifdef _HAVE_STD_CXX
31
#define _BEGIN_STD_C namespace std { extern "C" {
32
#define _END_STD_C  } }
33
#else
34
#define _BEGIN_STD_C extern "C" {
35
#define _END_STD_C  }
36
#endif
4921 Serge 37
#if __GNUC_PREREQ (3, 3)
4349 Serge 38
#define _NOTHROW __attribute__ ((nothrow))
39
#else
40
#define _NOTHROW throw()
41
#endif
42
#endif
43
#else
44
#define _BEGIN_STD_C
45
#define _END_STD_C
46
#define _NOTHROW
47
#endif
48
 
49
#ifdef _HAVE_STDC
50
#define	_PTR		void *
51
#define	_AND		,
52
#define	_NOARGS		void
53
#define	_CONST		const
54
#define	_VOLATILE	volatile
55
#define	_SIGNED		signed
56
#define	_DOTS		, ...
57
#define _VOID void
58
#ifdef __CYGWIN__
59
#define	_EXFUN_NOTHROW(name, proto)	__cdecl name proto _NOTHROW
60
#define	_EXFUN(name, proto)		__cdecl name proto
61
#define	_EXPARM(name, proto)		(* __cdecl name) proto
62
#define	_EXFNPTR(name, proto)		(__cdecl * name) proto
63
#else
64
#define	_EXFUN_NOTHROW(name, proto)	name proto _NOTHROW
65
#define	_EXFUN(name, proto)		name proto
66
#define _EXPARM(name, proto)		(* name) proto
67
#define _EXFNPTR(name, proto)		(* name) proto
68
#endif
69
#define	_DEFUN(name, arglist, args)	name(args)
70
#define	_DEFUN_VOID(name)		name(_NOARGS)
71
#define _CAST_VOID (void)
72
#ifndef _LONG_DOUBLE
73
#define _LONG_DOUBLE long double
74
#endif
75
#ifndef _LONG_LONG_TYPE
76
#define _LONG_LONG_TYPE long long
77
#endif
78
#ifndef _PARAMS
79
#define _PARAMS(paramlist)		paramlist
80
#endif
81
#else
82
#define	_PTR		char *
83
#define	_AND		;
84
#define	_NOARGS
85
#define	_CONST
86
#define	_VOLATILE
87
#define	_SIGNED
88
#define	_DOTS
89
#define _VOID void
90
#define	_EXFUN(name, proto)		name()
91
#define	_EXFUN_NOTHROW(name, proto)	name()
92
#define	_DEFUN(name, arglist, args)	name arglist args;
93
#define	_DEFUN_VOID(name)		name()
94
#define _CAST_VOID
95
#define _LONG_DOUBLE double
96
#define _LONG_LONG_TYPE long
97
#ifndef _PARAMS
98
#define _PARAMS(paramlist)		()
99
#endif
100
#endif
101
 
102
/* Support gcc's __attribute__ facility.  */
103
 
104
#ifdef __GNUC__
105
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
106
#else
107
#define _ATTRIBUTE(attrs)
108
#endif
109
 
110
/*  The traditional meaning of 'extern inline' for GCC is not
111
  to emit the function body unless the address is explicitly
112
  taken.  However this behaviour is changing to match the C99
113
  standard, which uses 'extern inline' to indicate that the
4921 Serge 114
  function body *must* be emitted.  Likewise, a function declared
115
  without either 'extern' or 'static' defaults to extern linkage
116
  (C99 6.2.2p5), and the compiler may choose whether to use the
117
  inline version or call the extern linkage version (6.7.4p6).
118
  If we are using GCC, but do not have the new behaviour, we need
119
  to use extern inline; if we are using a new GCC with the
120
  C99-compatible behaviour, or a non-GCC compiler (which we will
121
  have to hope is C99, since there is no other way to achieve the
122
  effect of omitting the function if it isn't referenced) we use
123
  'static inline', which c99 defines to mean more-or-less the same
124
  as the Gnu C 'extern inline'.  */
4349 Serge 125
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
126
/* We're using GCC, but without the new C99-compatible behaviour.  */
127
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
128
#else
129
/* We're using GCC in C99 mode, or an unknown compiler which
130
  we just have to hope obeys the C99 semantics of inline.  */
4921 Serge 131
#define _ELIDABLE_INLINE static __inline__
4349 Serge 132
#endif
133
 
4921 Serge 134
#if __GNUC_PREREQ (3, 1)
135
#define _NOINLINE		__attribute__ ((__noinline__))
136
#define _NOINLINE_STATIC	_NOINLINE static
137
#else
138
/* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be
139
   trusted not to inline if it is static. */
140
#define _NOINLINE
141
#define _NOINLINE_STATIC
142
#endif
143
 
4349 Serge 144
#endif /* _ANSIDECL_H_ */