// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: mmap.cc,v 1.1 1998/07/02 02:58:13 jgg Exp $
+// $Id: mmap.cc,v 1.4 1998/07/07 04:17:14 jgg Exp $
/* ######################################################################
MMap Class - Provides 'real' mmap or a faked mmap using read().
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#ifdef __GNUG__
+#pragma implementation "pkglib/mmap.h"
+#endif
+
#define _BSD_SOURCE
#include <pkglib/mmap.h>
#include <pkglib/error.h>
/*}}}*/
// MMap::Sync - Syncronize the map with the disk /*{{{*/
// ---------------------------------------------------------------------
-/* */
+/* This is done in syncronous mode - the docs indicate that this will
+ not return till all IO is complete */
bool MMap::Sync()
{
if ((Flags & ReadOnly) == ReadOnly)
/*}}}*/
// DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/
// ---------------------------------------------------------------------
-/* */
-unsigned long DynamicMMap::RawAllocate(unsigned long Size)
+/* This allocates a block of memory aligned to the given size */
+unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
{
unsigned long Result = iSize;
- iSize += Size;
+ if (Aln != 0)
+ Result += Aln - (iSize%Aln);
+
+ iSize = Result + Size;
// Just in case error check
if (Result > WorkSpace)
_error->Error("Dynamic MMap ran out of room");
return 0;
}
-
return Result;
}
/*}}}*/
if (I->Count == 0)
{
I->Count = 20*1024/ItemSize;
- I->Start = RawAllocate(I->Count*ItemSize);
+ I->Start = RawAllocate(I->Count*ItemSize,ItemSize);
}
-
+
I->Count--;
unsigned long Result = I->Start;
I->Start += ItemSize;