loader_xsb.h

00001 /* File:      loader_xsb.h
00002 ** Author(s): David S. Warren, Jiyang Xu
00003 ** Contact:   xsb-contact@cs.sunysb.edu
00004 ** 
00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998
00006 ** Copyright (C) ECRC, Germany, 1990
00007 ** 
00008 ** XSB is free software; you can redistribute it and/or modify it under the
00009 ** terms of the GNU Library General Public License as published by the Free
00010 ** Software Foundation; either version 2 of the License, or (at your option)
00011 ** any later version.
00012 ** 
00013 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00014 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00015 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00016 ** more details.
00017 ** 
00018 ** You should have received a copy of the GNU Library General Public License
00019 ** along with XSB; if not, write to the Free Software Foundation,
00020 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021 **
00022 ** $Id: loader_xsb.h,v 1.7 2005/11/12 15:48:50 dwarren Exp $
00023 ** 
00024 */
00025 
00026 #include "context.h"
00027 
00028 #define FOREIGN_NAMELEN   128
00029 #define SHORT_LDOPTIONLEN 254
00030 
00031 /* Data structures holding the compiled code */
00032 
00033 struct index_block {
00034   struct index_block *next ;
00035   unsigned long size ;
00036 } ;
00037  
00038 typedef struct index_block index_hdr, * pindex ;
00039  
00040 #define SIZE_IDX_HDR (sizeof(index_hdr))
00041  
00042 #define i_next(i)       ((i)->next)
00043 #define i_size(i)       ((i)->size)
00044 #define i_block(i)      ((CPtr)((i)+1))
00045  
00046 struct text_segment {
00047   struct text_segment * next ;
00048   struct text_segment * prev ;
00049   pindex index ;
00050   unsigned long size ;
00051 } ;
00052  
00053 typedef struct text_segment text_seg, seg_hdr, *pseg ;
00054  
00055 #define SIZE_SEG_HDR    (sizeof(seg_hdr))
00056  
00057 #define seg_hdr(s)      ((s)-1)
00058 #define seg_next(s)     (((s)-1)->next)
00059 #define seg_prev(s)     (((s)-1)->prev)
00060 #define seg_index(s)    (((s)-1)->index)
00061 #define seg_size(s)     (((s)-1)->size)
00062 #define seg_text(s)     ((CPtr)(s))
00063  
00064 #define OBJ_WORD_SIZE           4
00065 #define WORD_SIZE               ( sizeof(Cell) )
00066 /* Zoom the object file to fit actual word size */
00067 #define ZOOM_FACTOR             (WORD_SIZE / OBJ_WORD_SIZE)
00068 
00069 /************************************************************************/
00070 /*                                                                      */
00071 /* fix_bb: fixes the byte-backwards problem.  It is passed a pointer to */
00072 /* a sequence of 4 bytes read in from a file as bytes. It then converts */
00073 /* those bytes to represent a number.  This code works for any machine, */
00074 /* and makes the byte-code machine independent.                         */
00075 /*                                                                      */
00076 /************************************************************************/
00077 
00078 #define fix_bb(lptr) (cell((CPtr)(lptr)) = \
00079                     (((((Cell)(*(pb)(lptr)) << 8  | (Cell)(*((pb)(lptr)+1)))\
00080            << 8) | (Cell)(*((pb)(lptr)+2))) << 8) | (Cell)(*((pb)(lptr)+3)) \
00081                      )
00082 
00083 /* experimental */
00084 #define fix_bb4(lptr) (*(unsigned int *)(lptr) = \
00085                        (((((unsigned int)(*(pb)(lptr)) \
00086                         << 8  | (unsigned int)(*((pb)(lptr)+1)))\
00087                         << 8) | (unsigned int)(*((pb)(lptr)+2)))\
00088                         << 8) | (unsigned int)(*((pb)(lptr)+3)) \
00089                        )
00090 
00091 /* === functions used in other parts of the system ====================== */
00092 
00093 extern byte *loader(CTXTdeclc char *, int);
00094 extern void env_type_set(Psc, byte, byte, xsbBool);
00095 extern void unload_seg(pseg);
00096 extern unsigned int read_magic(FILE *);

Generated on Wed Jul 26 13:30:41 2006 for XSB by  doxygen 1.4.5