1 |
281 |
jeremybenn |
/****************************************************************************
|
2 |
|
|
* *
|
3 |
|
|
* GNAT COMPILER COMPONENTS *
|
4 |
|
|
* *
|
5 |
|
|
* A D A *
|
6 |
|
|
* *
|
7 |
|
|
* C Header File *
|
8 |
|
|
* *
|
9 |
|
|
* Copyright (C) 1992-2009, Free Software Foundation, Inc. *
|
10 |
|
|
* *
|
11 |
|
|
* GNAT is free software; you can redistribute it and/or modify it under *
|
12 |
|
|
* terms of the GNU General Public License as published by the Free Soft- *
|
13 |
|
|
* ware Foundation; either version 3, or (at your option) any later ver- *
|
14 |
|
|
* sion. GNAT is distributed in the hope that it will be useful, but WITH- *
|
15 |
|
|
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
|
16 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
|
17 |
|
|
* for more details. You should have received a copy of the GNU General *
|
18 |
|
|
* Public License distributed with GNAT; see file COPYING3. If not see *
|
19 |
|
|
* <http://www.gnu.org/licenses/>. *
|
20 |
|
|
* *
|
21 |
|
|
* GNAT was originally developed by the GNAT team at New York University. *
|
22 |
|
|
* Extensive contributions were provided by Ada Core Technologies Inc. *
|
23 |
|
|
* *
|
24 |
|
|
****************************************************************************/
|
25 |
|
|
|
26 |
|
|
/* This file contains some standard macros for performing Ada-like
|
27 |
|
|
operations. These are used to aid in the translation of other headers. */
|
28 |
|
|
|
29 |
|
|
#ifndef GCC_ADA_H
|
30 |
|
|
#define GCC_ADA_H
|
31 |
|
|
|
32 |
|
|
/* Inlined functions in header are preceded by INLINE, which is normally set
|
33 |
|
|
to extern inline for GCC, but may be set to static for use in standard
|
34 |
|
|
ANSI-C. */
|
35 |
|
|
|
36 |
|
|
#ifndef INLINE
|
37 |
|
|
#ifdef __GNUC__
|
38 |
|
|
#define INLINE static inline
|
39 |
|
|
#else
|
40 |
|
|
#define INLINE static
|
41 |
|
|
#endif
|
42 |
|
|
#endif
|
43 |
|
|
|
44 |
|
|
/* Define a macro to concatenate two strings. Write it for ANSI C and
|
45 |
|
|
for traditional C. */
|
46 |
|
|
|
47 |
|
|
#ifdef __STDC__
|
48 |
|
|
#define CAT(A,B) A##B
|
49 |
|
|
#else
|
50 |
|
|
#define _ECHO(A) A
|
51 |
|
|
#define CAT(A,B) ECHO(A)B
|
52 |
|
|
#endif
|
53 |
|
|
|
54 |
|
|
/* The following macro definition simulates the effect of a declaration of
|
55 |
|
|
a subtype, where the first two parameters give the name of the type and
|
56 |
|
|
subtype, and the third and fourth parameters give the subtype range. The
|
57 |
|
|
effect is to compile a typedef defining the subtype as a synonym for the
|
58 |
|
|
type, together with two constants defining the end points. */
|
59 |
|
|
|
60 |
|
|
#define SUBTYPE(SUBTYPE,TYPE,FIRST,LAST) \
|
61 |
|
|
typedef TYPE SUBTYPE; \
|
62 |
|
|
enum { CAT (SUBTYPE,__First) = FIRST, \
|
63 |
|
|
CAT (SUBTYPE,__Last) = LAST };
|
64 |
|
|
|
65 |
|
|
/* The following definition provides the equivalent of the Ada IN operator,
|
66 |
|
|
assuming that the subtype involved has been defined using the SUBTYPE
|
67 |
|
|
macro defined above. */
|
68 |
|
|
|
69 |
|
|
#define IN(VALUE,SUBTYPE) \
|
70 |
|
|
(((VALUE) >= (SUBTYPE) CAT (SUBTYPE,__First)) \
|
71 |
|
|
&& ((VALUE) <= (SUBTYPE) CAT (SUBTYPE,__Last)))
|
72 |
|
|
|
73 |
|
|
#endif
|