File:  [gforth] / gforth / engine / libcc.h.in
Revision 1.19: download - view: text, annotated - select for diffs
Mon Dec 31 15:25:19 2012 UTC (8 years, 6 months ago) by anton
Branches: MAIN
CVS tags: HEAD
updated copyright year

    1: /* header file for libcc-generated C code
    2: 
    3:   Copyright (C) 2006,2007,2008,2012 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 3
   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, see http://www.gnu.org/licenses/.
   19: */
   20: 
   21: #include <gforth/@PACKAGE_VERSION@/config.h>
   22: 
   23: #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__ANDROID__)
   24: #undef HAS_BACKLINK
   25: #else
   26: #define HAS_BACKLINK 1
   27: #endif
   28: 
   29: typedef CELL_TYPE Cell;
   30: typedef unsigned char Char;
   31: typedef double Float;
   32: typedef Char *Address;
   33: typedef void **Xt;
   34: 
   35: #define Clongest long long
   36: typedef unsigned Clongest UClongest;
   37: 
   38: typedef struct {
   39:   Cell next_task;
   40:   Cell prev_task;
   41:   Cell save_task;
   42:   Cell* sp0;
   43:   Cell* rp0;
   44:   Float* fp0;
   45:   Address lp0;
   46:   Xt *throw_entry;
   47: } user_area;
   48: 
   49: #ifdef HAS_BACKLINK
   50: extern __thread Cell *gforth_SP;
   51: extern __thread Float *gforth_FP;
   52: extern __thread Cell *gforth_RP;
   53: extern __thread char *gforth_LP;
   54: extern __thread char *gforth_UP;
   55: extern void *gforth_engine(void *);
   56: extern char *cstr(char *from, Cell size);
   57: extern char *tilde_cstr(char *from, Cell size);
   58: extern __thread void *throw_jmp_handler;
   59: extern user_area* gforth_stacks(Cell dsize, Cell rsize, Cell fsize, Cell lsize);
   60: extern void gforth_free_stacks(user_area* t);
   61: #define GFORTH_ARGS void
   62: #else
   63: #define gforth_SP *((Cell **)(gforth_pointers(0)))
   64: #define gforth_FP *((Float **)(gforth_pointers(1)))
   65: #define gforth_LP *((char **)(gforth_pointers(2)))
   66: #define gforth_RP *((Cell **)(gforth_pointers(3)))
   67: #define gforth_UP *((char **)(gforth_pointers(4)))
   68: #define gforth_engine ((char *(*)(void *))gforth_pointers(5))
   69: #define cstr ((char *(*)(char *, Cell))gforth_pointers(6))
   70: #define tilde_cstr ((char *(*)(char *, Cell))gforth_pointers(7))
   71: #define throw_jmp_handler *((void**)(gforth_pointers(8)))
   72: #define gforth_stacks ((user_area *(*)(Cell, Cell, Cell, Cell))gforth_pointers(9))
   73: #define gforth_free_stacks ((void(*)(user_area* t))gforth_pointers(10))
   74: #define GFORTH_ARGS void *(*gforth_pointers)(Cell)
   75: #endif
   76: 
   77: #define CELL_BITS	(sizeof(Cell) * 8)
   78: 
   79: #define gforth_d2ll(lo,hi) \
   80:   ((sizeof(Cell) < sizeof(Clongest)) \
   81:    ? (((UClongest)(lo))|(((UClongest)(hi))<<CELL_BITS)) \
   82:    : (lo))
   83: 
   84: #define gforth_ll2d(ll,lo,hi) \
   85:   do { \
   86:     UClongest _ll = (ll); \
   87:     (lo) = (Cell)_ll; \
   88:     (hi) = ((sizeof(Cell) < sizeof(Clongest)) \
   89:             ? (_ll >> CELL_BITS) \
   90:             : 0); \
   91:   } while (0);

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