realloc.h

00001 /************************************************************************/
00002 /*                                                                      */
00003 /* XSB System                                                           */
00004 /* Copyright (C) SUNY at Stony Brook, 1995                              */
00005 /*                                                                      */
00006 /* Everyone is granted permission to copy, modify and redistribute XSB, */
00007 /* but only under the conditions described in the XSB Licence Agreement.*/
00008 /* A copy of this licence is supposed to have been given to you along   */
00009 /* with XSB so you can know your rights and responsibilities.           */
00010 /* It should be in a file named LICENCE.                                */
00011 /* Among other things, this notice must be preserved on all copies.     */
00012 /*                                                                      */
00013 /************************************************************************/
00014 
00015 /*======================================================================
00016   File                  :  realloc.h
00017   Author(s)             :  Bart Demoen
00018   Last modification     :  13 October, 1998
00019 
00020   For changes look at   :  13-10-1998
00021 ========================================================================*/
00022 
00023 /*----------------------------------------------------------------------*/
00024 /*                                                                      */
00025 /* certain macros that once appeared in heap.c are moved to this file   */
00026 /* since reallocation is no longer centralised                          */
00027 /* reallocation is done in heap.c and cat.c concerning heap and ls      */
00028 /* similar for printing stuff                                           */
00029 /*----------------------------------------------------------------------*/
00030 
00031 #define realloc_ref(cell_ptr, cell_val)                         \
00032 {       if (heap_bot <= cell_val)                               \
00033   {   if (cell_val <= heap_top)  /* <= because of heaptop in CP 13-10-1998 */     \
00034                 *cell_ptr = cell_val + heap_offset ;            \
00035             else if (cell_val <= ls_bot)                        \
00036                  *cell_ptr = cell_val + local_offset ;          \
00037 }       }
00038 
00039 #define realloc_ref_pre_image(cell_ptr, cell_val)                     \
00040 {       if (heap_bot <= cell_val)                                     \
00041       /* <= because of heaptop in CP 13-10-1998 */                    \
00042   {   if (cell_val <= heap_top)                                       \
00043                 *cell_ptr = (CPtr) ((Cell)(cell_val + heap_offset)   \
00044                             | PRE_IMAGE_MARK) ;                       \
00045             else if (cell_val <= ls_bot)                              \
00046                  *cell_ptr = (CPtr) ((Cell) (cell_val + local_offset) \
00047                             | PRE_IMAGE_MARK) ;                       \
00048 } }
00049 
00050 #define reallocate_heap_or_ls_pointer(cell_ptr)                 \
00051     cell_val = (Cell)*cell_ptr ;                                \
00052     switch (cell_tag(cell_val)) {                               \
00053     case XSB_REF:                                       \
00054     case XSB_REF1 :                                     \
00055       realloc_ref(cell_ptr,(CPtr)cell_val);             \
00056       break ; /* end case XSB_FREE or XSB_REF */                        \
00057     case XSB_STRUCT :                                           \
00058       if (heap_bot<=(clref_val(cell_val)) && (clref_val(cell_val))<heap_top)\
00059           *cell_ptr = (CPtr)makecs((Cell)(clref_val(cell_val)+heap_offset)) ; \
00060       break ;                                           \
00061     case XSB_LIST :                                             \
00062       if (heap_bot<=(clref_val(cell_val)) && (clref_val(cell_val))<heap_top)\
00063           *cell_ptr = (CPtr)makelist((Cell)(clref_val(cell_val)+heap_offset));\
00064       break ;                                           \
00065     case XSB_ATTV:                                                      \
00066       if (heap_bot<=(clref_val(cell_val)) && (clref_val(cell_val))<heap_top)\
00067           *cell_ptr = (CPtr)makeattv((Cell)(clref_val(cell_val)+heap_offset));\
00068       break ;                                           \
00069     default : /* no need to reallocate */                       \
00070       break ;                                           \
00071     }
00072 
00073 
00074 #define FROM_NOWHERE 0
00075 #define FROM_LS 1
00076 #define FROM_CP 2
00077 #define FROM_TR 3
00078 #define FROM_AREG 4
00079 #define FROM_HEAP 5
00080 #define FROM_COMPL 6
00081 
00082 #define TO_NOWHERE 0
00083 #define TO_LS 1
00084 #define TO_CP 2
00085 #define TO_TR 3
00086 #define TO_AREG 4
00087 #define TO_HEAP 5
00088 #define TO_COMPL 6
00089 
00090 
00091 /*------------------------- end of file realloc.h --------------------------*/

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