Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

VForward.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 //
00020 // VForward.C
00021 // Last modified on Thu Jul 29 14:19:14 EDT 2004 by ken@xorian.net
00022 //      modified on Tue Sep 12 13:41:05 PDT 2000 by mann
00023 //
00024 
00025 #include "VestaSource.H"
00026 #include "VMemPool.H"
00027 #include "VForward.H"
00028 #include <assert.h>
00029 #include "logging.H"
00030 
00031 Bit32
00032 VForward::create(const LongId& longid) throw ()
00033 {
00034     VForward* vf;
00035     vf = (VForward*) VMemPool::allocate(VMemPool::vForward, sizeof(VForward));
00036     *(vf->longid()) = longid;
00037     return VMemPool::shortenPointer(vf);
00038 }
00039 
00040 void
00041 VForward::markCallback(void* closure, VMemPool::typeCode type) throw ()
00042 {
00043     // Nothing to do!
00044 }
00045 
00046 bool
00047 VForward::sweepCallback(void* closure, VMemPool::typeCode type,
00048                         void* addr, Bit32& size) throw ()
00049 {
00050     VForward* vf = (VForward*) addr;
00051     bool ret = vf->visited();
00052     vf->setVisited(false);
00053     size = sizeof(VForward);
00054     return ret;
00055 }
00056 
00057 void
00058 VForward::rebuildCallback(void* closure, VMemPool::typeCode type,
00059                           void* addr, Bit32& size) throw ()
00060 {
00061     // Just compute size
00062     VForward* vf = (VForward*) addr;
00063     size = sizeof(VForward);
00064 }
00065 
00066 Bit32
00067 VForward::checkpoint(Bit32& nextSP, std::fstream& ckpt) throw ()
00068 {
00069     if (visited()) return redirection();
00070     Bit32 newSP = nextSP;
00071     int pad = (-sizeof(VForward)) & VMemPool::alignmentMask;
00072     nextSP += sizeof(VForward) + pad;
00073     ckpt.write((char *) rep, sizeof(VForward));
00074     while (pad--) {
00075         ckpt.put(VMemPool::freeByte);
00076     }
00077     // Crash if writing to the checkpoint file is failing
00078     if (!ckpt.good()) {
00079         Repos::dprintf(DBG_ALWAYS,
00080                        "write to checkpoint file failed: errno %d\n", errno);
00081         assert(ckpt.good());  // crash
00082     }
00083     setVisited(true);
00084     setRedirection(newSP);  // reuse (smash) longid field
00085     return newSP;
00086 }

Generated on Mon May 8 00:48:53 2006 for Vesta by  doxygen 1.4.2