1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 1992-2009, Free Software Foundation, Inc. *
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/>. *
21 * GNAT was originally developed by the GNAT team at New York University. *
22 * Extensive contributions were provided by Ada Core Technologies Inc. *
24 ****************************************************************************/
26 /* This file contains some standard macros for performing Ada-like
27 operations. These are used to aid in the translation of other headers. */
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
38 #define INLINE static inline
44 /* Define a macro to concatenate two strings. Write it for ANSI C and
51 #define CAT(A,B) ECHO(A)B
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. */
60 #define SUBTYPE(SUBTYPE,TYPE,FIRST,LAST) \
61 typedef TYPE SUBTYPE; \
62 enum { CAT (SUBTYPE,__First) = FIRST, \
63 CAT (SUBTYPE,__Last) = LAST };
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. */
69 #define IN(VALUE,SUBTYPE) \
70 (((VALUE) >= (SUBTYPE) CAT (SUBTYPE,__First)) \
71 && ((VALUE) <= (SUBTYPE) CAT (SUBTYPE,__Last)))