~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libc/_ansi.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <newlib.h>
 
16
#include <sys/config.h>
 
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
 
37
#if defined(__GNUC__) && \
 
38
  ( (__GNUC__ >= 4) || \
 
39
    ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
 
40
#define _NOTHROW __attribute__ ((nothrow))
 
41
#else
 
42
#define _NOTHROW throw()
 
43
#endif
 
44
#endif
 
45
#else
 
46
#define _BEGIN_STD_C
 
47
#define _END_STD_C
 
48
#define _NOTHROW
 
49
#endif
 
50
 
 
51
#ifdef _HAVE_STDC
 
52
#define _PTR            void *
 
53
#define _AND            ,
 
54
#define _NOARGS         void
 
55
#define _CONST          const
 
56
#define _VOLATILE       volatile
 
57
#define _SIGNED         signed
 
58
#define _DOTS           , ...
 
59
#define _VOID void
 
60
#ifdef __CYGWIN__
 
61
#define _EXFUN_NOTHROW(name, proto)     __cdecl name proto _NOTHROW
 
62
#define _EXFUN(name, proto)             __cdecl name proto
 
63
#define _EXPARM(name, proto)            (* __cdecl name) proto
 
64
#define _EXFNPTR(name, proto)           (__cdecl * name) proto
 
65
#else
 
66
#define _EXFUN_NOTHROW(name, proto)     name proto _NOTHROW
 
67
#define _EXFUN(name, proto)             name proto
 
68
#define _EXPARM(name, proto)            (* name) proto
 
69
#define _EXFNPTR(name, proto)           (* name) proto
 
70
#endif
 
71
#define _DEFUN(name, arglist, args)     name(args)
 
72
#define _DEFUN_VOID(name)               name(_NOARGS)
 
73
#define _CAST_VOID (void)
 
74
#ifndef _LONG_DOUBLE
 
75
#define _LONG_DOUBLE long double
 
76
#endif
 
77
#ifndef _LONG_LONG_TYPE
 
78
#define _LONG_LONG_TYPE long long
 
79
#endif
 
80
#ifndef _PARAMS
 
81
#define _PARAMS(paramlist)              paramlist
 
82
#endif
 
83
#else   
 
84
#define _PTR            char *
 
85
#define _AND            ;
 
86
#define _NOARGS
 
87
#define _CONST
 
88
#define _VOLATILE
 
89
#define _SIGNED
 
90
#define _DOTS
 
91
#define _VOID void
 
92
#define _EXFUN(name, proto)             name()
 
93
#define _EXFUN_NOTHROW(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
#define _LONG_LONG_TYPE long
 
99
#ifndef _PARAMS
 
100
#define _PARAMS(paramlist)              ()
 
101
#endif
 
102
#endif
 
103
 
 
104
/* Support gcc's __attribute__ facility.  */
 
105
 
 
106
#ifndef _ATTRIBUTE /* XXX Emscripten */
 
107
#ifdef __GNUC__
 
108
#define _ATTRIBUTE(attr) __attribute__ ((attr))
 
109
#else
 
110
#define _ATTRIBUTE(attr)
 
111
#endif
 
112
#endif /* XXX Emscripten */
 
113
 
 
114
/*  The traditional meaning of 'extern inline' for GCC is not
 
115
  to emit the function body unless the address is explicitly
 
116
  taken.  However this behaviour is changing to match the C99
 
117
  standard, which uses 'extern inline' to indicate that the
 
118
  function body *must* be emitted.  If we are using GCC, but do
 
119
  not have the new behaviour, we need to use extern inline; if
 
120
  we are using a new GCC with the C99-compatible behaviour, or
 
121
  a non-GCC compiler (which we will have to hope is C99, since
 
122
  there is no other way to achieve the effect of omitting the
 
123
  function if it isn't referenced) we just use plain 'inline',
 
124
  which c99 defines to mean more-or-less the same as the Gnu C
 
125
  'extern inline'.  */
 
126
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
 
127
/* We're using GCC, but without the new C99-compatible behaviour.  */
 
128
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
 
129
#else
 
130
/* We're using GCC in C99 mode, or an unknown compiler which 
 
131
  we just have to hope obeys the C99 semantics of inline.  */
 
132
#define _ELIDABLE_INLINE __inline__
 
133
#endif
 
134
 
 
135
#endif /* _ANSIDECL_H_ */