File:  [gforth] / gforth / engine / libcc.h.in
Revision 1.15: download - view: text, annotated - select for diffs
Fri Jul 20 23:52:37 2012 UTC (10 years, 4 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Fixed libcc.h.in

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

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