/ Check-in [431aecc8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use mremap() on Linux.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental-mmap
Files: files | file ages | folders
SHA1:431aecc8600c29c203546e48d256510510238887
User & Date: dan 2013-03-25 20:30:13
Context
2013-03-25
20:50
Add munmap and mremap to the set of os interfaces that can be overloaded in os_unix.c. check-in: 8776047b user: drh tags: experimental-mmap
20:30
Use mremap() on Linux. check-in: 431aecc8 user: dan tags: experimental-mmap
19:57
Merge all recent trunk changes into the experimental-mmap branch. check-in: a607d63f user: drh tags: experimental-mmap
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

4540
4541
4542
4543
4544
4545
4546
4547
4548







4549
4550
4551
4552
4553



4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
    nMap = statbuf.st_size;
  }
  if( nMap>pFd->mmapLimit ){
    nMap = pFd->mmapLimit;
  }

  if( nMap!=pFd->mmapSize ){
    unixUnmapfile(pFd);








    if( nMap>0 ){
      void *pNew;
      int flags = PROT_READ;
      if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;
      pNew = osMmap(0, nMap, flags, MAP_SHARED, pFd->h, 0);



      if( pNew==MAP_FAILED ){
        return SQLITE_IOERR_MMAP;
      }

      pFd->pMapRegion = pNew;
      pFd->mmapSize = nMap;
      pFd->mmapOrigsize = nMap;
    }
  }

  return SQLITE_OK;
}

/*
** If possible, return a pointer to a mapping of file fd starting at offset







|

>
>
>
>
>
>
>
|
<
|
|
|
>
>
>
|
|
|
<
|
|
|
<







4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556

4557
4558
4559
4560
4561
4562
4563
4564
4565

4566
4567
4568

4569
4570
4571
4572
4573
4574
4575
    nMap = statbuf.st_size;
  }
  if( nMap>pFd->mmapLimit ){
    nMap = pFd->mmapLimit;
  }

  if( nMap!=pFd->mmapSize ){
    void *pNew = 0;

#if defined(__linux__) && defined(_GNU_SOURCE)
    if( pFd->pMapRegion && nMap>0 ){
      pNew = mremap(pFd->pMapRegion, pFd->mmapOrigsize, nMap, MREMAP_MAYMOVE);
    }else
#endif
    {
      unixUnmapfile(pFd);
      if( nMap>0 ){

        int flags = PROT_READ;
        if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;
        pNew = osMmap(0, nMap, flags, MAP_SHARED, pFd->h, 0);
      }
    }

    if( pNew==MAP_FAILED ){
      return SQLITE_IOERR_MMAP;
    }

    pFd->pMapRegion = pNew;
    pFd->mmapSize = nMap;
    pFd->mmapOrigsize = nMap;

  }

  return SQLITE_OK;
}

/*
** If possible, return a pointer to a mapping of file fd starting at offset