Home | History | Annotate | Line # | Download | only in common
      1       1.1  christos /* The common simulator framework for GDB, the GNU Debugger.
      2       1.1  christos 
      3  1.1.1.11  christos    Copyright 2002-2024 Free Software Foundation, Inc.
      4       1.1  christos 
      5       1.1  christos    Contributed by Andrew Cagney and Red Hat.
      6       1.1  christos 
      7       1.1  christos    This file is part of GDB.
      8       1.1  christos 
      9       1.1  christos    This program is free software; you can redistribute it and/or modify
     10       1.1  christos    it under the terms of the GNU General Public License as published by
     11       1.1  christos    the Free Software Foundation; either version 3 of the License, or
     12       1.1  christos    (at your option) any later version.
     13       1.1  christos 
     14       1.1  christos    This program is distributed in the hope that it will be useful,
     15       1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16       1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17       1.1  christos    GNU General Public License for more details.
     18       1.1  christos 
     19       1.1  christos    You should have received a copy of the GNU General Public License
     20       1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     21       1.1  christos 
     22       1.1  christos 
     23       1.1  christos #ifndef SIM_INLINE_H
     24       1.1  christos #define SIM_INLINE_H
     25       1.1  christos 
     26  1.1.1.10  christos #include "ansidecl.h"
     27       1.1  christos 
     28       1.1  christos /* INLINE CODE SELECTION:
     29       1.1  christos 
     30       1.1  christos    GCC -O3 attempts to inline any function or procedure in scope.  The
     31       1.1  christos    options below facilitate finer grained control over what is and
     32       1.1  christos    what is not inlined.  In particular, it allows the selection of
     33       1.1  christos    modules for inlining.  Doing this allows the compiler to both
     34       1.1  christos    eliminate the overhead of function calls and (as a consequence)
     35       1.1  christos    also eliminate further dead code.
     36       1.1  christos 
     37       1.1  christos    On a CISC (x86) I've found that I can achieve an order of magnitude
     38       1.1  christos    speed improvement (x3-x5).  In the case of RISC (sparc) while the
     39       1.1  christos    performance gain isn't as great it is still significant.
     40       1.1  christos 
     41  1.1.1.12  christos    Each module is controlled by the macro <module>_INLINE which can
     42       1.1  christos    have the values described below
     43       1.1  christos 
     44       1.1  christos        0 (ZERO)
     45       1.1  christos 
     46       1.1  christos          Do not inline any thing for the given module
     47       1.1  christos 
     48       1.1  christos    The following bit fields values can be combined:
     49       1.1  christos 
     50       1.1  christos       H_REVEALS_MODULE:
     51       1.1  christos       C_REVEALS_MODULE:
     52       1.1  christos 
     53       1.1  christos          Include the C file for the module into the file being
     54       1.1  christos          compiled.  The actual inlining is controlled separatly.
     55       1.1  christos 
     56       1.1  christos 	 While of no apparent benefit, this makes it possible for the
     57       1.1  christos 	 included module, when compiled, to inline its calls to what
     58       1.1  christos 	 would otherwize be external functions.
     59       1.1  christos 
     60       1.1  christos 	 {C_,H_} Determines where the module is inlined.  A
     61       1.1  christos 	 H_REVEALS_MODULE will be included everywhere.
     62       1.1  christos 
     63       1.1  christos       INLINE_GLOBALS:
     64       1.1  christos 
     65       1.1  christos          Make external functions within the module `inline'.  Thus if
     66       1.1  christos          the module is included into a file being compiled, calls to
     67       1.1  christos 	 the included modules funtions can be eliminated.  INLINE_MODULE
     68       1.1  christos 	 implies REVEAL_MODULE.
     69       1.1  christos 
     70       1.1  christos       INLINE_LOCALS:
     71       1.1  christos 
     72       1.1  christos          Make internal (static) functions within the module `inline'.
     73       1.1  christos 
     74       1.1  christos 
     75       1.1  christos    CODING STYLE:
     76       1.1  christos 
     77       1.1  christos    The inline ability is enabled by specifying every data and function
     78       1.1  christos    declaration and definition using one of the following methods:
     79       1.1  christos 
     80       1.1  christos 
     81       1.1  christos        GLOBAL INLINE FUNCTIONS:
     82       1.1  christos 
     83       1.1  christos           Such functions are small and used heavily.  Inlining them
     84       1.1  christos           will eliminate an unnecessary function call overhead.
     85       1.1  christos 
     86       1.1  christos 	  .h: INLINE_OURPKG (void) ourpkg_func
     87       1.1  christos 	      (int x,
     88       1.1  christos 	       int y);
     89       1.1  christos 
     90       1.1  christos 	  .c: INLINE_OURPKG (void)
     91       1.1  christos 	      ourpkg_func (int x,
     92       1.1  christos 	                   int y)
     93       1.1  christos 	      {
     94       1.1  christos 	        ...
     95       1.1  christos 	      }
     96       1.1  christos 
     97       1.1  christos 
     98       1.1  christos        GLOBAL INLINE VARIABLES:
     99       1.1  christos 
    100       1.1  christos           This doesn't make much sense.
    101       1.1  christos 
    102       1.1  christos 
    103       1.1  christos        GLOBAL NON-INLINE (EXTERN) FUNCTIONS AND VARIABLES:
    104       1.1  christos 
    105       1.1  christos           These include functions with varargs parameters.  It can
    106       1.1  christos           also include large rarely used functions that contribute
    107       1.1  christos           little when inlined.
    108       1.1  christos 
    109       1.1  christos 	  .h: extern int ourpkg_print
    110       1.1  christos 	      (char *fmt, ...);
    111       1.1  christos 	      extern int a_global_variable;
    112       1.1  christos 
    113       1.1  christos 	  .c: #if EXTERN_OURPKG_P
    114       1.1  christos 	      int
    115       1.1  christos 	      ourpkg_print (char *fmt,
    116       1.1  christos 	                    ...)
    117       1.1  christos               {
    118       1.1  christos 	         ...
    119       1.1  christos 	      }
    120       1.1  christos 	      #endif
    121       1.1  christos 	      #if EXTERN_OURPKG_P
    122       1.1  christos 	      int a_global_variable = 1;
    123       1.1  christos 	      #endif
    124       1.1  christos 
    125       1.1  christos 
    126       1.1  christos        LOCAL (STATIC) FUNCTIONS:
    127       1.1  christos 
    128       1.1  christos           These can either be marked inline or just static static vis:
    129       1.1  christos 
    130       1.1  christos 	  .h: STATIC_INLINE_OURPKG (int) ourpkg_staticf (void);
    131       1.1  christos 	  .c: STATIC_INLINE_OURPKG (int)
    132       1.1  christos 	      ourpkg_staticf (void)
    133       1.1  christos 	      {
    134       1.1  christos 	        ..
    135       1.1  christos 	      }
    136       1.1  christos 
    137       1.1  christos 	  .h: STATIC_OURPKG (int) ourpkg_staticf (void);
    138       1.1  christos 	  .c: STATIC_OURPKG (int)
    139       1.1  christos 	      ourpkg_staticf (void)
    140       1.1  christos 	      {
    141       1.1  christos 	        ..
    142       1.1  christos 	      }
    143       1.1  christos 
    144       1.1  christos 
    145       1.1  christos        All .h files:
    146       1.1  christos 
    147       1.1  christos 
    148       1.1  christos           All modules must wrap their .h code in the following:
    149       1.1  christos 
    150       1.1  christos 	  #ifndef OURPKG_H
    151       1.1  christos 	  #define OURPKG_H
    152       1.1  christos 	  ... code proper ...
    153       1.1  christos 	  #endif
    154       1.1  christos 
    155       1.1  christos           In addition, modules that want to allow global inlining must
    156       1.1  christos           include the lines (below) at the end of the .h file. (FIXME:
    157       1.1  christos           Shouldn't be needed).
    158       1.1  christos 
    159       1.1  christos           #if H_REVEALS_MODULE_P (OURPKG_INLINE)
    160       1.1  christos           #include "ourpkg.c"
    161       1.1  christos           #endif
    162       1.1  christos 
    163       1.1  christos 
    164       1.1  christos        All .c files:
    165       1.1  christos 
    166       1.1  christos           All modules must wrap their .c code in the following
    167       1.1  christos 
    168       1.1  christos 	  #ifndef OURPKG_C
    169       1.1  christos 	  #define OURPKG_C
    170       1.1  christos 	  ... code proper ...
    171       1.1  christos 	  #endif
    172       1.1  christos 
    173       1.1  christos 
    174       1.1  christos    NOW IT WORKS:
    175       1.1  christos 
    176       1.1  christos       0:
    177       1.1  christos 
    178       1.1  christos       Since no inlining is defined. All macro's get standard defaults
    179       1.1  christos       (extern, static, ...).
    180       1.1  christos 
    181       1.1  christos 
    182       1.1  christos 
    183       1.1  christos       H_REVEALS_MODULE (alt includes our):
    184       1.1  christos 
    185       1.1  christos 
    186       1.1  christos       altprog.c defines ALTPROG_C and then includes sim-inline.h.
    187       1.1  christos 
    188       1.1  christos       In sim-inline.h the expression `` H_REVEALS_MODULE_P
    189       1.1  christos       (OURPROG_INLINE) && !  defined (OURPROG_C) && REVEAL_MODULE_P
    190       1.1  christos       (OURPROG_INLINE) '' is TRUE so it defines *_OURPROG as static
    191       1.1  christos       and EXTERN_OURPROG_P as FALSE.
    192       1.1  christos 
    193       1.1  christos       altprog.c includes ourprog.h.
    194       1.1  christos 
    195       1.1  christos       In ourprog.h the expression ``H_REVEALS_MODULE_P
    196       1.1  christos       (OURPROG_INLINE)'' is TRUE so it includes ourprog.c.
    197       1.1  christos 
    198       1.1  christos       Consequently, all the code in ourprog.c is visible and static in
    199       1.1  christos       the file altprog.c
    200       1.1  christos 
    201       1.1  christos 
    202       1.1  christos 
    203       1.1  christos       H_REVEALS_MODULE (our includes our):
    204       1.1  christos 
    205       1.1  christos 
    206       1.1  christos       ourprog.c defines OURPROG_C and then includes sim-inline.h.
    207       1.1  christos 
    208       1.1  christos       In sim-inline.h the term `` ! defined (OURPROG_C) '' is FALSE so
    209       1.1  christos       it defines *_OURPROG as non-static and EXTERN_OURPROG_P as TRUE.
    210       1.1  christos 
    211       1.1  christos       ourprog.c includes ourprog.h.
    212       1.1  christos 
    213       1.1  christos       In ourprog.h the expression ``H_REVEALS_MODULE_P
    214       1.1  christos       (OURPROG_INLINE)'' is true so it includes ourprog.c.
    215       1.1  christos 
    216       1.1  christos       In ourprog.c (second include) the expression defined (OURPROG_C)
    217       1.1  christos       and so the body is not re-included.
    218       1.1  christos 
    219       1.1  christos       Consequently, ourprog.o will contain a non-static copy of all
    220       1.1  christos       the exported symbols.
    221       1.1  christos 
    222       1.1  christos 
    223       1.1  christos 
    224       1.1  christos       C_REVEALS_MODULE (alt includes our):
    225       1.1  christos 
    226       1.1  christos 
    227       1.1  christos       altprog.c defines ALTPROG_C and then includes sim-inline.c
    228       1.1  christos 
    229       1.1  christos       sim-inline.c defines C_INLINE_C and then includes sim-inline.h
    230       1.1  christos 
    231       1.1  christos       In sim-inline.h the expression `` defined (SIM_INLINE) && !
    232       1.1  christos       defined (OURPROG_C) && REVEAL_MODULE_P (OURPROG_INLINE) '' is
    233       1.1  christos       true so it defines *_OURPROG as static and EXTERN_OURPROG_P as
    234       1.1  christos       FALSE.
    235       1.1  christos 
    236       1.1  christos       In sim-inline.c the expression ``C_REVEALS_MODULE_P
    237       1.1  christos       (OURPROG_INLINE)'' is true so it includes ourprog.c.
    238       1.1  christos 
    239       1.1  christos       Consequently, all the code in ourprog.c is visible and static in
    240       1.1  christos       the file altprog.c.
    241       1.1  christos 
    242       1.1  christos 
    243       1.1  christos 
    244       1.1  christos       C_REVEALS_MODULE (our includes our):
    245       1.1  christos 
    246       1.1  christos 
    247       1.1  christos       ourprog.c defines OURPROG_C and then includes sim-inline.c
    248       1.1  christos 
    249       1.1  christos       sim-inline.c defines C_INLINE_C and then includes sim-inline.h
    250       1.1  christos 
    251       1.1  christos       In sim-inline.h the term `` !  defined (OURPROG_C) '' is FALSE
    252       1.1  christos       so it defines *_OURPROG as non-static and EXTERN_OURPROG_P as
    253       1.1  christos       TRUE.
    254       1.1  christos 
    255       1.1  christos       Consequently, ourprog.o will contain a non-static copy of all
    256       1.1  christos       the exported symbols.
    257       1.1  christos 
    258       1.1  christos 
    259       1.1  christos 
    260       1.1  christos    REALITY CHECK:
    261       1.1  christos 
    262       1.1  christos    This is not for the faint hearted.  I've seen GCC get up to 500mb
    263       1.1  christos    trying to compile what this can create. */
    264       1.1  christos 
    265       1.1  christos #define H_REVEALS_MODULE		1
    267       1.1  christos #define C_REVEALS_MODULE		2
    268       1.1  christos #define INLINE_GLOBALS			4
    269       1.1  christos #define INLINE_LOCALS			8
    270       1.1  christos 
    271       1.1  christos #define ALL_H_INLINE (H_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
    272       1.1  christos #define ALL_C_INLINE (C_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
    273       1.1  christos 
    274       1.1  christos 
    275       1.1  christos /* Default macro to simplify control several of key the inlines */
    276       1.1  christos 
    277       1.1  christos #ifndef DEFAULT_INLINE
    278       1.1  christos #define	DEFAULT_INLINE			INLINE_LOCALS
    279       1.1  christos #endif
    280       1.1  christos 
    281       1.1  christos #define REVEAL_MODULE_P(X) (X & (H_REVEALS_MODULE | C_REVEALS_MODULE))
    282       1.1  christos #define H_REVEALS_MODULE_P(X) ((X & H_REVEALS_MODULE))
    283       1.1  christos #define C_REVEALS_MODULE_P(X) ((X & C_REVEALS_MODULE))
    284       1.1  christos 
    285       1.1  christos 
    286       1.1  christos #ifndef HAVE_INLINE
    287       1.1  christos #ifdef __GNUC__
    288       1.1  christos #define HAVE_INLINE
    289       1.1  christos #endif
    290       1.1  christos #endif
    291       1.1  christos 
    292       1.1  christos 
    293       1.1  christos /* Your compilers inline prefix */
    294       1.1  christos 
    295       1.1  christos #ifndef INLINE
    296       1.1  christos #if defined (__GNUC__) && defined (__OPTIMIZE__)
    297       1.1  christos #define INLINE __inline__
    298       1.1  christos #else
    299       1.1  christos #define INLINE /*inline*/
    300       1.1  christos #endif
    301       1.1  christos #endif
    302       1.1  christos 
    303       1.1  christos /* ??? Temporary, pending decision to always use extern inline and do a vast
    304       1.1  christos    cleanup of inline support.  */
    305   1.1.1.5  christos #ifndef INLINE2
    306   1.1.1.5  christos #if defined (__GNUC_GNU_INLINE__) || defined (__GNUC_STDC_INLINE__)
    307   1.1.1.5  christos #define INLINE2 __inline__ __attribute__ ((__gnu_inline__))
    308       1.1  christos #elif defined (__GNUC__)
    309       1.1  christos #define INLINE2 __inline__
    310       1.1  christos #else
    311       1.1  christos #define INLINE2 /*inline*/
    312       1.1  christos #endif
    313       1.1  christos #endif
    314       1.1  christos 
    315       1.1  christos 
    316       1.1  christos /* Your compiler's static inline prefix */
    317       1.1  christos 
    318       1.1  christos #ifndef STATIC_INLINE
    319       1.1  christos #define STATIC_INLINE static INLINE
    320       1.1  christos #endif
    321       1.1  christos 
    322       1.1  christos 
    323       1.1  christos /* Your compiler's extern inline prefix */
    324       1.1  christos 
    325       1.1  christos #ifndef EXTERN_INLINE
    326       1.1  christos #define EXTERN_INLINE extern INLINE2
    327       1.1  christos #endif
    328       1.1  christos 
    329       1.1  christos 
    330       1.1  christos /* Your compilers's unused reserved word */
    331       1.1  christos 
    332  1.1.1.10  christos #if !defined (UNUSED)
    333       1.1  christos #define UNUSED ATTRIBUTE_UNUSED
    334       1.1  christos #endif
    335       1.1  christos 
    336       1.1  christos 
    337       1.1  christos 
    338   1.1.1.9  christos 
    339   1.1.1.9  christos 
    341   1.1.1.9  christos /* sim_arange */
    342   1.1.1.9  christos 
    343   1.1.1.9  christos #if !defined (SIM_ARANGE_INLINE) && (DEFAULT_INLINE)
    344   1.1.1.9  christos # define SIM_ARANGE_INLINE (ALL_H_INLINE)
    345   1.1.1.9  christos #endif
    346   1.1.1.9  christos 
    347   1.1.1.9  christos #if ((H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) || defined (SIM_INLINE_C)) \
    348   1.1.1.9  christos      && !defined (SIM_ARANGE_C) \
    349  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_ARANGE_INLINE)))
    350   1.1.1.9  christos # if (SIM_ARANGE_INLINE & INLINE_GLOBALS)
    351   1.1.1.9  christos #  define INLINE_SIM_ARANGE(TYPE) static INLINE UNUSED TYPE
    352  1.1.1.10  christos #  define EXTERN_SIM_ARANGE_P 0
    353   1.1.1.9  christos # else
    354   1.1.1.9  christos #  define INLINE_SIM_ARANGE(TYPE) static UNUSED TYPE
    355   1.1.1.9  christos #  define EXTERN_SIM_ARANGE_P 0
    356   1.1.1.9  christos # endif
    357   1.1.1.9  christos #else
    358   1.1.1.9  christos # define INLINE_SIM_ARANGE(TYPE) TYPE
    359   1.1.1.9  christos # define EXTERN_SIM_ARANGE_P 1
    360   1.1.1.9  christos #endif
    361   1.1.1.9  christos 
    362   1.1.1.9  christos #if (SIM_ARANGE_INLINE & INLINE_LOCALS)
    363   1.1.1.9  christos # define STATIC_INLINE_SIM_ARANGE(TYPE) static INLINE TYPE
    364   1.1.1.9  christos #else
    365   1.1.1.9  christos # define STATIC_INLINE_SIM_ARANGE(TYPE) static TYPE
    366   1.1.1.9  christos #endif
    367   1.1.1.9  christos 
    368   1.1.1.9  christos #define STATIC_SIM_ARANGE(TYPE) static TYPE
    369   1.1.1.9  christos 
    370       1.1  christos 
    371       1.1  christos 
    372       1.1  christos /* *****
    373       1.1  christos    sim-bits and sim-endian are treated differently from the rest
    374       1.1  christos    of the modules below.  Their default value is ALL_H_INLINE.
    375       1.1  christos    The rest are ALL_C_INLINE.  Don't blink, you'll miss it!
    376       1.1  christos    *****
    377       1.1  christos    */
    378       1.1  christos 
    379       1.1  christos /* sim-bits */
    380       1.1  christos 
    381       1.1  christos #if !defined (SIM_BITS_INLINE) && (DEFAULT_INLINE)
    382       1.1  christos # define SIM_BITS_INLINE (ALL_H_INLINE)
    383       1.1  christos #endif
    384       1.1  christos 
    385       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_BITS_INLINE) || defined (SIM_INLINE_C)) \
    386       1.1  christos      && !defined (SIM_BITS_C) \
    387  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_BITS_INLINE)))
    388       1.1  christos # if (SIM_BITS_INLINE & INLINE_GLOBALS)
    389       1.1  christos #  define INLINE_SIM_BITS(TYPE) static INLINE UNUSED TYPE
    390  1.1.1.10  christos #  define EXTERN_SIM_BITS_P 0
    391       1.1  christos # else
    392       1.1  christos #  define INLINE_SIM_BITS(TYPE) static UNUSED TYPE
    393       1.1  christos #  define EXTERN_SIM_BITS_P 0
    394   1.1.1.6  christos # endif
    395       1.1  christos #else
    396       1.1  christos # define INLINE_SIM_BITS(TYPE) TYPE
    397       1.1  christos # define EXTERN_SIM_BITS_P 1
    398       1.1  christos #endif
    399       1.1  christos 
    400       1.1  christos #if (SIM_BITS_INLINE & INLINE_LOCALS)
    401   1.1.1.6  christos # define STATIC_INLINE_SIM_BITS(TYPE) static INLINE TYPE
    402       1.1  christos #else
    403       1.1  christos # define STATIC_INLINE_SIM_BITS(TYPE) static TYPE
    404       1.1  christos #endif
    405       1.1  christos 
    406       1.1  christos #define STATIC_SIM_BITS(TYPE) static TYPE
    407       1.1  christos 
    408       1.1  christos 
    409       1.1  christos 
    410       1.1  christos /* sim-core */
    411       1.1  christos 
    412       1.1  christos #if !defined (SIM_CORE_INLINE) && (DEFAULT_INLINE)
    413       1.1  christos # define SIM_CORE_INLINE ALL_C_INLINE
    414       1.1  christos #endif
    415       1.1  christos 
    416       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_CORE_INLINE) || defined (SIM_INLINE_C)) \
    417       1.1  christos      && !defined (SIM_CORE_C) \
    418  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_CORE_INLINE)))
    419       1.1  christos # if (SIM_CORE_INLINE & INLINE_GLOBALS)
    420       1.1  christos #  define INLINE_SIM_CORE(TYPE) static INLINE UNUSED TYPE
    421  1.1.1.10  christos #  define EXTERN_SIM_CORE_P 0
    422       1.1  christos #else
    423       1.1  christos #  define INLINE_SIM_CORE(TYPE) static UNUSED TYPE
    424       1.1  christos #  define EXTERN_SIM_CORE_P 0
    425   1.1.1.6  christos #endif
    426       1.1  christos #else
    427       1.1  christos # define INLINE_SIM_CORE(TYPE) TYPE
    428       1.1  christos # define EXTERN_SIM_CORE_P 1
    429       1.1  christos #endif
    430       1.1  christos 
    431       1.1  christos #if (SIM_CORE_INLINE & INLINE_LOCALS)
    432   1.1.1.6  christos # define STATIC_INLINE_SIM_CORE(TYPE) static INLINE TYPE
    433       1.1  christos #else
    434       1.1  christos # define STATIC_INLINE_SIM_CORE(TYPE) static TYPE
    435       1.1  christos #endif
    436       1.1  christos 
    437       1.1  christos #define STATIC_SIM_CORE(TYPE) static TYPE
    438       1.1  christos 
    439       1.1  christos 
    440       1.1  christos 
    441       1.1  christos /* sim-endian */
    442       1.1  christos 
    443       1.1  christos #if !defined (SIM_ENDIAN_INLINE) && (DEFAULT_INLINE)
    444       1.1  christos # define SIM_ENDIAN_INLINE ALL_H_INLINE
    445       1.1  christos #endif
    446       1.1  christos 
    447       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_ENDIAN_INLINE) || defined (SIM_INLINE_C)) \
    448       1.1  christos      && !defined (SIM_ENDIAN_C) \
    449  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
    450       1.1  christos # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
    451       1.1  christos #  define INLINE_SIM_ENDIAN(TYPE) static INLINE UNUSED TYPE
    452  1.1.1.10  christos #  define EXTERN_SIM_ENDIAN_P 0
    453       1.1  christos # else
    454       1.1  christos #  define INLINE_SIM_ENDIAN(TYPE) static UNUSED TYPE
    455       1.1  christos #  define EXTERN_SIM_ENDIAN_P 0
    456   1.1.1.6  christos # endif
    457       1.1  christos #else
    458       1.1  christos # define INLINE_SIM_ENDIAN(TYPE) TYPE
    459       1.1  christos # define EXTERN_SIM_ENDIAN_P 1
    460       1.1  christos #endif
    461       1.1  christos 
    462       1.1  christos #if (SIM_ENDIAN_INLINE & INLINE_LOCALS)
    463   1.1.1.6  christos # define STATIC_INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE
    464       1.1  christos #else
    465       1.1  christos # define STATIC_INLINE_SIM_ENDIAN(TYPE) static TYPE
    466       1.1  christos #endif
    467       1.1  christos 
    468       1.1  christos #define STATIC_SIM_ENDIAN(TYPE) static TYPE
    469       1.1  christos 
    470       1.1  christos 
    471       1.1  christos 
    472       1.1  christos /* sim-events */
    473       1.1  christos 
    474       1.1  christos #if !defined (SIM_EVENTS_INLINE) && (DEFAULT_INLINE)
    475       1.1  christos # define SIM_EVENTS_INLINE ALL_C_INLINE
    476       1.1  christos #endif
    477       1.1  christos 
    478       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_EVENTS_INLINE) || defined (SIM_INLINE_C)) \
    479       1.1  christos      && !defined (SIM_EVENTS_C) \
    480  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_EVENTS_INLINE)))
    481       1.1  christos # if (SIM_EVENTS_INLINE & INLINE_GLOBALS)
    482       1.1  christos #  define INLINE_SIM_EVENTS(TYPE) static INLINE UNUSED TYPE
    483  1.1.1.10  christos #  define EXTERN_SIM_EVENTS_P 0
    484       1.1  christos # else
    485       1.1  christos #  define INLINE_SIM_EVENTS(TYPE) static UNUSED TYPE
    486       1.1  christos #  define EXTERN_SIM_EVENTS_P 0
    487   1.1.1.6  christos # endif
    488       1.1  christos #else
    489       1.1  christos # define INLINE_SIM_EVENTS(TYPE) TYPE
    490       1.1  christos # define EXTERN_SIM_EVENTS_P 1
    491       1.1  christos #endif
    492       1.1  christos 
    493       1.1  christos #if (SIM_EVENTS_INLINE & INLINE_LOCALS)
    494   1.1.1.6  christos # define STATIC_INLINE_SIM_EVENTS(TYPE) static INLINE TYPE
    495       1.1  christos #else
    496       1.1  christos # define STATIC_INLINE_SIM_EVENTS(TYPE) static TYPE
    497       1.1  christos #endif
    498       1.1  christos 
    499       1.1  christos #define STATIC_SIM_EVENTS(TYPE) static TYPE
    500       1.1  christos 
    501       1.1  christos 
    502       1.1  christos 
    503       1.1  christos /* sim-fpu */
    504       1.1  christos 
    505       1.1  christos #if !defined (SIM_FPU_INLINE) && (DEFAULT_INLINE)
    506       1.1  christos # define SIM_FPU_INLINE ALL_C_INLINE
    507       1.1  christos #endif
    508       1.1  christos 
    509       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_FPU_INLINE) || defined (SIM_INLINE_C)) \
    510       1.1  christos      && !defined (SIM_FPU_C) \
    511  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_FPU_INLINE)))
    512       1.1  christos # if (SIM_FPU_INLINE & INLINE_GLOBALS)
    513       1.1  christos #  define INLINE_SIM_FPU(TYPE) static INLINE UNUSED TYPE
    514  1.1.1.10  christos #  define EXTERN_SIM_FPU_P 0
    515       1.1  christos # else
    516       1.1  christos #  define INLINE_SIM_FPU(TYPE) static UNUSED TYPE
    517       1.1  christos #  define EXTERN_SIM_FPU_P 0
    518   1.1.1.6  christos # endif
    519       1.1  christos #else
    520       1.1  christos # define INLINE_SIM_FPU(TYPE) TYPE
    521       1.1  christos # define EXTERN_SIM_FPU_P 1
    522       1.1  christos #endif
    523       1.1  christos 
    524       1.1  christos #if (SIM_FPU_INLINE & INLINE_LOCALS)
    525   1.1.1.6  christos # define STATIC_INLINE_SIM_FPU(TYPE) static INLINE TYPE
    526       1.1  christos #else
    527       1.1  christos # define STATIC_INLINE_SIM_FPU(TYPE) static TYPE
    528       1.1  christos #endif
    529       1.1  christos 
    530       1.1  christos #define STATIC_SIM_FPU(TYPE) static TYPE
    531       1.1  christos 
    532       1.1  christos 
    533       1.1  christos 
    534       1.1  christos /* sim-types */
    535       1.1  christos 
    536       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_TYPES_INLINE) || defined (SIM_INLINE_C)) \
    537       1.1  christos      && !defined (SIM_TYPES_C) \
    538  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_TYPES_INLINE)))
    539       1.1  christos # if (SIM_TYPES_INLINE & INLINE_GLOBALS)
    540       1.1  christos #  define INLINE_SIM_TYPES(TYPE) static INLINE UNUSED TYPE
    541  1.1.1.10  christos #  define EXTERN_SIM_TYPES_P 0
    542       1.1  christos # else
    543       1.1  christos #  define INLINE_SIM_TYPES(TYPE) static UNUSED TYPE
    544       1.1  christos #  define EXTERN_SIM_TYPES_P 0
    545   1.1.1.6  christos # endif
    546       1.1  christos #else
    547       1.1  christos # define INLINE_SIM_TYPES(TYPE) TYPE
    548       1.1  christos # define EXTERN_SIM_TYPES_P 1
    549       1.1  christos #endif
    550       1.1  christos 
    551       1.1  christos #if (SIM_TYPES_INLINE & INLINE_LOCALS)
    552   1.1.1.6  christos # define STATIC_INLINE_SIM_TYPES(TYPE) static INLINE TYPE
    553       1.1  christos #else
    554       1.1  christos # define STATIC_INLINE_SIM_TYPES(TYPE) static TYPE
    555       1.1  christos #endif
    556       1.1  christos 
    557       1.1  christos #define STATIC_SIM_TYPES(TYPE) static TYPE
    558       1.1  christos 
    559       1.1  christos 
    560       1.1  christos 
    561       1.1  christos /* sim_main */
    562       1.1  christos 
    563       1.1  christos #if !defined (SIM_MAIN_INLINE) && (DEFAULT_INLINE)
    564       1.1  christos # define SIM_MAIN_INLINE (ALL_C_INLINE)
    565       1.1  christos #endif
    566       1.1  christos 
    567       1.1  christos #if ((H_REVEALS_MODULE_P (SIM_MAIN_INLINE) || defined (SIM_INLINE_C)) \
    568       1.1  christos      && !defined (SIM_MAIN_C) \
    569  1.1.1.10  christos      && (REVEAL_MODULE_P (SIM_MAIN_INLINE)))
    570       1.1  christos # if (SIM_MAIN_INLINE & INLINE_GLOBALS)
    571       1.1  christos #  define INLINE_SIM_MAIN(TYPE) static INLINE UNUSED TYPE
    572  1.1.1.10  christos #  define EXTERN_SIM_MAIN_P 0
    573       1.1  christos # else
    574       1.1  christos #  define INLINE_SIM_MAIN(TYPE) static UNUSED TYPE
    575       1.1  christos #  define EXTERN_SIM_MAIN_P 0
    576   1.1.1.6  christos # endif
    577       1.1  christos #else
    578       1.1  christos # define INLINE_SIM_MAIN(TYPE) TYPE
    579       1.1  christos # define EXTERN_SIM_MAIN_P 1
    580       1.1  christos #endif
    581       1.1  christos 
    582       1.1  christos #if (SIM_MAIN_INLINE & INLINE_LOCALS)
    583   1.1.1.6  christos # define STATIC_INLINE_SIM_MAIN(TYPE) static INLINE TYPE
    584       1.1  christos #else
    585       1.1  christos # define STATIC_INLINE_SIM_MAIN(TYPE) static TYPE
    586       1.1  christos #endif
    587       1.1  christos 
    588       1.1  christos #define STATIC_SIM_MAIN(TYPE) static TYPE
    589       1.1  christos 
    590       1.1  christos /* engine */
    592       1.1  christos 
    593       1.1  christos #if ((H_REVEALS_MODULE_P (ENGINE_INLINE) || defined (SIM_INLINE_C)) \
    594  1.1.1.10  christos      && !defined (ENGINE_C) \
    595       1.1  christos      && (REVEAL_MODULE_P (ENGINE_INLINE)))
    596       1.1  christos # if (ENGINE_INLINE & INLINE_GLOBALS)
    597  1.1.1.10  christos #  define INLINE_ENGINE(TYPE) static INLINE UNUSED TYPE
    598       1.1  christos #  define EXTERN_ENGINE_P 0
    599       1.1  christos # else
    600       1.1  christos #  define INLINE_ENGINE(TYPE) static UNUSED TYPE
    601   1.1.1.6  christos #  define EXTERN_ENGINE_P 0
    602       1.1  christos # endif
    603       1.1  christos #else
    604       1.1  christos # define INLINE_ENGINE(TYPE) TYPE
    605       1.1  christos # define EXTERN_ENGINE_P 1
    606       1.1  christos #endif
    607       1.1  christos 
    608   1.1.1.6  christos #if (ENGINE_INLINE & INLINE_LOCALS)
    609       1.1  christos # define STATIC_INLINE_ENGINE(TYPE) static INLINE TYPE
    610       1.1  christos #else
    611       1.1  christos # define STATIC_INLINE_ENGINE(TYPE) static TYPE
    612       1.1  christos #endif
    613       1.1  christos 
    614       1.1  christos #define STATIC_ENGINE(TYPE) static TYPE
    615       1.1  christos 
    616       1.1  christos 
    617       1.1  christos 
    618       1.1  christos /* icache */
    619       1.1  christos 
    620       1.1  christos #if ((H_REVEALS_MODULE_P (ICACHE_INLINE) || defined (SIM_INLINE_C)) \
    621  1.1.1.10  christos      && !defined (ICACHE_C) \
    622       1.1  christos      && (REVEAL_MODULE_P (ICACHE_INLINE)))
    623       1.1  christos # if (ICACHE_INLINE & INLINE_GLOBALS)
    624  1.1.1.10  christos #  define INLINE_ICACHE(TYPE) static INLINE UNUSED TYPE
    625       1.1  christos #  define EXTERN_ICACHE_P 0
    626       1.1  christos #else
    627       1.1  christos #  define INLINE_ICACHE(TYPE) static UNUSED TYPE
    628   1.1.1.6  christos #  define EXTERN_ICACHE_P 0
    629       1.1  christos #endif
    630       1.1  christos #else
    631       1.1  christos # define INLINE_ICACHE(TYPE) TYPE
    632       1.1  christos # define EXTERN_ICACHE_P 1
    633       1.1  christos #endif
    634       1.1  christos 
    635   1.1.1.6  christos #if (ICACHE_INLINE & INLINE_LOCALS)
    636       1.1  christos # define STATIC_INLINE_ICACHE(TYPE) static INLINE TYPE
    637       1.1  christos #else
    638       1.1  christos # define STATIC_INLINE_ICACHE(TYPE) static TYPE
    639       1.1  christos #endif
    640       1.1  christos 
    641       1.1  christos #define STATIC_ICACHE(TYPE) static TYPE
    642       1.1  christos 
    643       1.1  christos 
    644       1.1  christos 
    645       1.1  christos /* idecode */
    646       1.1  christos 
    647       1.1  christos #if ((H_REVEALS_MODULE_P (IDECODE_INLINE) || defined (SIM_INLINE_C)) \
    648  1.1.1.10  christos      && !defined (IDECODE_C) \
    649       1.1  christos      && (REVEAL_MODULE_P (IDECODE_INLINE)))
    650       1.1  christos # if (IDECODE_INLINE & INLINE_GLOBALS)
    651  1.1.1.10  christos #  define INLINE_IDECODE(TYPE) static INLINE UNUSED TYPE
    652       1.1  christos #  define EXTERN_IDECODE_P 0
    653       1.1  christos #else
    654       1.1  christos #  define INLINE_IDECODE(TYPE) static UNUSED TYPE
    655   1.1.1.6  christos #  define EXTERN_IDECODE_P 0
    656       1.1  christos #endif
    657       1.1  christos #else
    658       1.1  christos # define INLINE_IDECODE(TYPE) TYPE
    659       1.1  christos # define EXTERN_IDECODE_P 1
    660       1.1  christos #endif
    661       1.1  christos 
    662   1.1.1.6  christos #if (IDECODE_INLINE & INLINE_LOCALS)
    663       1.1  christos # define STATIC_INLINE_IDECODE(TYPE) static INLINE TYPE
    664       1.1  christos #else
    665       1.1  christos # define STATIC_INLINE_IDECODE(TYPE) static TYPE
    666       1.1  christos #endif
    667       1.1  christos 
    668       1.1  christos #define STATIC_IDECODE(TYPE) static TYPE
    669       1.1  christos 
    670       1.1  christos 
    671       1.1  christos 
    672       1.1  christos /* semantics */
    673       1.1  christos 
    674       1.1  christos #if ((H_REVEALS_MODULE_P (SEMANTICS_INLINE) || defined (SIM_INLINE_C)) \
    675  1.1.1.10  christos      && !defined (SEMANTICS_C) \
    676       1.1  christos      && (REVEAL_MODULE_P (SEMANTICS_INLINE)))
    677       1.1  christos # if (SEMANTICS_INLINE & INLINE_GLOBALS)
    678  1.1.1.10  christos #  define INLINE_SEMANTICS(TYPE) static INLINE UNUSED TYPE
    679       1.1  christos #  define EXTERN_SEMANTICS_P 0
    680       1.1  christos #else
    681       1.1  christos #  define INLINE_SEMANTICS(TYPE) static UNUSED TYPE
    682   1.1.1.6  christos #  define EXTERN_SEMANTICS_P 0
    683       1.1  christos #endif
    684       1.1  christos #else
    685       1.1  christos # define INLINE_SEMANTICS(TYPE) TYPE
    686       1.1  christos # define EXTERN_SEMANTICS_P 1
    687   1.1.1.6  christos #endif
    688       1.1  christos 
    689  1.1.1.10  christos #if EXTERN_SEMANTICS_P
    690       1.1  christos # define EXTERN_SEMANTICS(TYPE) TYPE
    691       1.1  christos #else
    692       1.1  christos # define EXTERN_SEMANTICS(TYPE) static UNUSED TYPE
    693       1.1  christos #endif
    694       1.1  christos 
    695   1.1.1.6  christos #if (SEMANTICS_INLINE & INLINE_LOCALS)
    696       1.1  christos # define STATIC_INLINE_SEMANTICS(TYPE) static INLINE TYPE
    697       1.1  christos #else
    698       1.1  christos # define STATIC_INLINE_SEMANTICS(TYPE) static TYPE
    699       1.1  christos #endif
    700       1.1  christos 
    701       1.1  christos #define STATIC_SEMANTICS(TYPE) static TYPE
    702       1.1  christos 
    703       1.1  christos 
    704       1.1  christos 
    705       1.1  christos /* support */
    706       1.1  christos 
    707       1.1  christos #if !defined (SUPPORT_INLINE) && (DEFAULT_INLINE)
    708       1.1  christos # define SUPPORT_INLINE ALL_C_INLINE
    709       1.1  christos #endif
    710       1.1  christos 
    711       1.1  christos #if ((H_REVEALS_MODULE_P (SUPPORT_INLINE) || defined (SIM_INLINE_C)) \
    712  1.1.1.10  christos      && !defined (SUPPORT_C) \
    713       1.1  christos      && (REVEAL_MODULE_P (SUPPORT_INLINE)))
    714       1.1  christos # if (SUPPORT_INLINE & INLINE_GLOBALS)
    715  1.1.1.10  christos #  define INLINE_SUPPORT(TYPE) static INLINE UNUSED TYPE
    716       1.1  christos #  define EXTERN_SUPPORT_P 0
    717       1.1  christos #else
    718       1.1  christos #  define INLINE_SUPPORT(TYPE) static UNUSED TYPE
    719   1.1.1.6  christos #  define EXTERN_SUPPORT_P 0
    720       1.1  christos #endif
    721       1.1  christos #else
    722       1.1  christos # define INLINE_SUPPORT(TYPE) TYPE
    723       1.1  christos # define EXTERN_SUPPORT_P 1
    724       1.1  christos #endif
    725       1.1  christos 
    726   1.1.1.6  christos #if (SUPPORT_INLINE & INLINE_LOCALS)
    727       1.1  christos # define STATIC_INLINE_SUPPORT(TYPE) static INLINE TYPE
    728       1.1  christos #else
    729       1.1  christos # define STATIC_INLINE_SUPPORT(TYPE) static TYPE
    730       1.1  christos #endif
    731       1.1  christos 
    732       1.1  christos #define STATIC_SUPPORT(TYPE) static TYPE
    733       1.1  christos 
    734                     
    735                     
    736                     #endif
    737