Annotation of gforth/threading.h, revision 1.2

1.1       pazsan      1: /* This file defines a number of threading schemes.
1.2     ! anton       2: 
        !             3:   Copyright (C) 1995 Free Software Foundation, Inc.
        !             4: 
        !             5:   This file is part of Gforth.
        !             6: 
        !             7:   Gforth is free software; you can redistribute it and/or
        !             8:   modify it under the terms of the GNU General Public License
        !             9:   as published by the Free Software Foundation; either version 2
        !            10:   of the License, or (at your option) any later version.
        !            11: 
        !            12:   This program is distributed in the hope that it will be useful,
        !            13:   but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            14:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            15:   GNU General Public License for more details.
        !            16: 
        !            17:   You should have received a copy of the GNU General Public License
        !            18:   along with this program; if not, write to the Free Software
        !            19:   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            20: 
        !            21: 
        !            22:   To organize the former ifdef chaos, each path is separated
        !            23:   This gives a quite impressive number of paths, but you clearly
        !            24:   find things that go together.
        !            25: */
1.1       pazsan     26: 
                     27: #ifndef GETCFA
                     28: #  define CFA_NEXT
                     29: #endif
                     30: 
                     31: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                     32:     && defined(LONG_LATENCY) && defined(CFA_NEXT)
                     33: #warning scheme 1
                     34: #  define NEXT_P0      ({cfa=*ip++;})
                     35: #  define IP           (ip-1)
                     36: #  define NEXT_INST    (cfa)
                     37: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                     38: #  define DEF_CA
                     39: #  define NEXT_P1
                     40: #  define NEXT_P2      ({goto *cfa;})
                     41: #  define EXEC(XT)     ({cfa=(XT); goto *cfa;})
                     42: #endif
                     43: 
                     44: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                     45:     && defined(LONG_LATENCY) && !defined(CFA_NEXT)
                     46: #warning scheme 2
                     47: #  define NEXT_P0      (ip++)
                     48: #  define IP           (ip-1)
                     49: #  define NEXT_INST    (*(ip-1))
                     50: #  define INC_IP(const_inc)    ({ ip+=(const_inc);})
                     51: #  define DEF_CA
                     52: #  define NEXT_P1
                     53: #  define NEXT_P2      ({goto **(ip-1);})
                     54: #  define EXEC(XT)     ({goto *(XT);})
                     55: #endif
                     56: 
                     57: 
                     58: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                     59:     && !defined(LONG_LATENCY) && defined(CFA_NEXT)
                     60: #warning scheme 3
                     61: #  define NEXT_P0
                     62: #  define IP           (ip)
                     63: #  define NEXT_INST    (*ip)
                     64: #  define INC_IP(const_inc)    ({ip+=(const_inc);})
                     65: #  define DEF_CA
                     66: #  define NEXT_P1      ({cfa=*ip++;})
                     67: #  define NEXT_P2      ({goto *cfa;})
                     68: #  define EXEC(XT)     ({cfa=(XT); goto *cfa;})
                     69: #endif
                     70: 
                     71: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                     72:     && !defined(LONG_LATENCY) && !defined(CFA_NEXT)
                     73: #warning scheme 4
                     74: #  define NEXT_P0
                     75: #  define IP           (ip)
                     76: #  define NEXT_INST    (*ip)
                     77: #  define INC_IP(const_inc)    ({ ip+=(const_inc);})
                     78: #  define DEF_CA
                     79: #  define NEXT_P1
                     80: #  define NEXT_P2      ({goto **(ip++);})
                     81: #  define EXEC(XT)     ({goto *(XT);})
                     82: #endif
                     83: 
                     84: /* without autoincrement */
                     85: 
                     86: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                     87:     && defined(LONG_LATENCY) && defined(CFA_NEXT)
                     88: #warning scheme 5
                     89: #  define NEXT_P0      ({cfa=*ip;})
                     90: #  define IP           (ip)
                     91: #  define NEXT_INST    (cfa)
                     92: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                     93: #  define DEF_CA
                     94: #  define NEXT_P1      (ip++)
                     95: #  define NEXT_P2      ({goto *cfa;})
                     96: #  define EXEC(XT)     ({cfa=(XT); goto *cfa;})
                     97: #endif
                     98: 
                     99: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    100:     && defined(LONG_LATENCY) && !defined(CFA_NEXT)
                    101: #warning scheme 6
                    102: #  define NEXT_P0
                    103: #  define IP           (ip)
                    104: #  define NEXT_INST    (*ip)
1.2     ! anton     105: #  define INC_IP(const_inc)    ({ip+=(const_inc);})
1.1       pazsan    106: #  define DEF_CA
                    107: #  define NEXT_P1      (ip++)
                    108: #  define NEXT_P2      ({goto **(ip-1);})
                    109: #  define EXEC(XT)     ({goto *(XT);})
                    110: #endif
                    111: 
                    112: 
                    113: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    114:     && !defined(LONG_LATENCY) && defined(CFA_NEXT)
                    115: #warning scheme 7
                    116: #  define NEXT_P0
                    117: #  define IP           (ip)
                    118: #  define NEXT_INST    (*ip)
                    119: #  define INC_IP(const_inc)    ({ip+=(const_inc);})
                    120: #  define DEF_CA
                    121: #  define NEXT_P1      ({cfa=*ip++;})
                    122: #  define NEXT_P2      ({goto *cfa;})
                    123: #  define EXEC(XT)     ({cfa=(XT); goto *cfa;})
                    124: #endif
                    125: 
                    126: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    127:     && !defined(LONG_LATENCY) && !defined(CFA_NEXT)
                    128: #warning scheme 8
                    129: #  define NEXT_P0
                    130: #  define IP           (ip)
                    131: #  define NEXT_INST    (*IP)
                    132: #  define INC_IP(const_inc)    ({ ip+=(const_inc);})
                    133: #  define DEF_CA
                    134: #  define NEXT_P1      (ip++)
                    135: #  define NEXT_P2      ({goto **(ip-1);})
                    136: #  define EXEC(XT)     ({goto *(XT);})
                    137: #endif
                    138: 
                    139: /* common settings for direct THREADED */
                    140: 
                    141: 
                    142: /* indirect THREADED  */
                    143: 
                    144: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                    145:     && defined(LONG_LATENCY) && defined(CISC_NEXT)
                    146: #  define NEXT_P0      ({cfa=*ip++;})
                    147: #  define IP           (ip-1)
                    148: #  define NEXT_INST    (cfa)
                    149: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    150: #  define DEF_CA
                    151: #  define NEXT_P1
                    152: #  define NEXT_P2      ({goto **cfa;})
                    153: #  define EXEC(XT)     ({cfa=(XT); goto **cfa;})
                    154: #endif
                    155: 
                    156: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                    157:     && defined(LONG_LATENCY) && !defined(CISC_NEXT)
                    158: #  define NEXT_P0      ({cfa=*ip++;})
                    159: #  define IP           (ip-1)
                    160: #  define NEXT_INST    (cfa)
                    161: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    162: #  define DEF_CA       Label ca;
                    163: #  define NEXT_P1      ({ca=*cfa;})
                    164: #  define NEXT_P2      ({goto *ca;})
                    165: #  define EXEC(XT)     ({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
                    166: #endif
                    167: 
                    168: 
                    169: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                    170:     && !defined(LONG_LATENCY) && defined(CISC_NEXT)
                    171: #  define NEXT_P0
                    172: #  define IP           (ip)
                    173: #  define NEXT_INST    (*ip)
                    174: #  define INC_IP(const_inc)    ({ip+=(const_inc);})
                    175: #  define DEF_CA
                    176: #  define NEXT_P1      ({cfa=*ip++;})
                    177: #  define NEXT_P2      ({goto **cfa;})
                    178: #  define EXEC(XT)     ({cfa=(XT); goto **cfa;})
                    179: #endif
                    180: 
                    181: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
                    182:     && !defined(LONG_LATENCY) && !defined(CISC_NEXT)
                    183: #  define NEXT_P0      ({cfa=*ip++;})
                    184: #  define IP           (ip-1)
                    185: #  define NEXT_INST    (cfa)
                    186: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    187: #  define DEF_CA       Label ca;
                    188: #  define NEXT_P1      ({ca=*cfa;})
                    189: #  define NEXT_P2      ({goto *ca;})
                    190: #  define EXEC(XT)     ({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
                    191: #endif
                    192: 
                    193: 
                    194: /* without autoincrement */
                    195: 
                    196: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    197:     && defined(LONG_LATENCY) && defined(CISC_NEXT)
                    198: #  define NEXT_P0      ({cfa=*ip;})
                    199: #  define IP           (ip)
                    200: #  define NEXT_INST    (cfa)
                    201: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    202: #  define DEF_CA
                    203: #  define NEXT_P1      (ip++)
                    204: #  define NEXT_P2      ({goto **cfa;})
                    205: #  define EXEC(XT)     ({cfa=(XT); goto **cfa;})
                    206: #endif
                    207: 
                    208: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    209:     && defined(LONG_LATENCY) && !defined(CISC_NEXT)
                    210: #  define NEXT_P0      ({cfa=*ip;})
                    211: #  define IP           (ip)
                    212: #  define NEXT_INST    (cfa)
                    213: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    214: #  define DEF_CA       Label ca;
                    215: #  define NEXT_P1      ({ip++; ca=*cfa;})
                    216: #  define NEXT_P2      ({goto *ca;})
                    217: #  define EXEC(XT)     ({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
                    218: #endif
                    219: 
                    220: 
                    221: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    222:     && !defined(LONG_LATENCY) && defined(CISC_NEXT)
                    223: #  define NEXT_P0
                    224: #  define IP           (ip)
                    225: #  define NEXT_INST    (*ip)
                    226: #  define INC_IP(const_inc)    ({ip+=(const_inc);})
                    227: #  define DEF_CA
                    228: #  define NEXT_P1      ({cfa=*ip;})
                    229: #  define NEXT_P2      ({ip++; goto **cfa;})
                    230: #  define EXEC(XT)     ({cfa=(XT); goto **cfa;})
                    231: #endif
                    232: 
                    233: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
                    234:     && !defined(LONG_LATENCY) && !defined(CISC_NEXT)
                    235: #  define NEXT_P0      ({cfa=*ip;})
                    236: #  define IP           (ip)
                    237: #  define NEXT_INST    (cfa)
                    238: #  define INC_IP(const_inc)    ({cfa=IP[const_inc]; ip+=(const_inc);})
                    239: #  define DEF_CA       Label ca;
                    240: #  define NEXT_P1      ({ip++; ca=*cfa;})
                    241: #  define NEXT_P2      ({goto *ca;})
                    242: #  define EXEC(XT)     ({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
                    243: #endif
                    244: 
                    245: #define NEXT ({DEF_CA NEXT_P1; NEXT_P2;})
                    246: 
                    247: #if defined(CISC_NEXT) && !defined(LONG_LATENCY)
                    248: # define NEXT1_P1
                    249: # ifdef DIRECT_THREADED
                    250: #  define NEXT1_P2 ({goto *cfa;})
                    251: # else
                    252: #  define NEXT1_P2 ({goto **cfa;})
                    253: # endif /* DIRECT_THREADED */
                    254: #else /* defined(CISC_NEXT) && !defined(LONG_LATENCY) */
                    255: # ifdef DIRECT_THREADED
                    256: #  define NEXT1_P1
                    257: #  define NEXT1_P2 ({goto *cfa;})
                    258: # else /* DIRECT_THREADED */
                    259: #  define NEXT1_P1 ({ca = *cfa;})
                    260: #  define NEXT1_P2 ({goto *ca;})
                    261: # endif /* DIRECT_THREADED */
                    262: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>