]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/mmap.cc
use forward declaration in headers if possible instead of includes
[apt.git] / apt-pkg / contrib / mmap.cc
index 19381ae4719ea7005ac338463bdbe7e4a5e3cd95..f76169a92dea39e5c341eb3583942b20bd5856fc 100644 (file)
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
 #define _BSD_SOURCE
+#include <config.h>
+
 #include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
-
-#include <apti18n.h>
+#include <apt-pkg/fileutl.h>
 
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <errno.h>
-
 #include <cstring>
-                                                                       /*}}}*/
+
+#include <apti18n.h>
+                                                                       /*}}}*/
 
 // MMap::MMap - Constructor                                            /*{{{*/
 // ---------------------------------------------------------------------
@@ -94,7 +96,7 @@ bool MMap::Map(FileFd &Fd)
            return false;
       }
       else
-        return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),
+        return _error->Errno("mmap",_("Couldn't make mmap of %llu bytes"),
                              iSize);
      }
 
@@ -165,7 +167,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
       return true;
    
 #ifdef _POSIX_SYNCHRONIZED_IO
-   unsigned long PSize = sysconf(_SC_PAGESIZE);
+   unsigned long long PSize = sysconf(_SC_PAGESIZE);
    if ((Flags & ReadOnly) != ReadOnly)
    {
       if (SyncToFd != 0)
@@ -176,7 +178,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
       }
       else
       {
-        if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
+        if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
            return _error->Errno("msync", _("Unable to synchronize mmap"));
       }
    }
@@ -196,7 +198,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work
    if (_error->PendingError() == true)
       return;
    
-   unsigned long EndOfFile = Fd->Size();
+   unsigned long long EndOfFile = Fd->Size();
    if (EndOfFile > WorkSpace)
       WorkSpace = EndOfFile;
    else if(WorkSpace > 0)
@@ -284,7 +286,7 @@ DynamicMMap::~DynamicMMap()
       return;
    }
    
-   unsigned long EndOfFile = iSize;
+   unsigned long long EndOfFile = iSize;
    iSize = WorkSpace;
    Close(false);
    if(ftruncate(Fd->Fd(),EndOfFile) < 0)
@@ -294,9 +296,9 @@ DynamicMMap::~DynamicMMap()
 // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space  /*{{{*/
 // ---------------------------------------------------------------------
 /* This allocates a block of memory aligned to the given size */
-unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
+unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln)
 {
-   unsigned long Result = iSize;
+   unsigned long long Result = iSize;
    if (Aln != 0)
       Result += Aln - (iSize%Aln);
 
@@ -411,7 +413,7 @@ bool DynamicMMap::Grow() {
        if (GrowFactor <= 0)
                return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
 
-       unsigned long const newSize = WorkSpace + GrowFactor;
+       unsigned long long const newSize = WorkSpace + GrowFactor;
 
        if(Fd != 0) {
                Fd->Seek(newSize - 1);