#include "lib/lib.h"
#include "lib/fastbuf.h"
#include "lib/lfs.h"
-#include "lib/conf2.h"
+#include "lib/conf.h"
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
-#include <sys/user.h>
-static uns mmap_window_size = 16*PAGE_SIZE;
-static uns mmap_extend_size = 4*PAGE_SIZE;
+static uns mmap_window_size = 16*CPU_PAGE_SIZE;
+static uns mmap_extend_size = 4*CPU_PAGE_SIZE;
static struct cf_section fbmm_config = {
CF_ITEMS {
bfmm_map_window(struct fastbuf *f)
{
struct fb_mmap *F = FB_MMAP(f);
- sh_off_t pos0 = f->pos & ~(sh_off_t)(PAGE_SIZE-1);
+ sh_off_t pos0 = f->pos & ~(sh_off_t)(CPU_PAGE_SIZE-1);
int l = MIN((sh_off_t)mmap_window_size, F->file_extend - pos0);
- uns ll = ALIGN(l, PAGE_SIZE);
- uns oll = ALIGN(f->bufend - f->buffer, PAGE_SIZE);
+ uns ll = ALIGN_TO(l, CPU_PAGE_SIZE);
+ uns oll = ALIGN_TO(f->bufend - f->buffer, CPU_PAGE_SIZE);
int prot = ((F->mode & O_ACCMODE) == O_RDONLY) ? PROT_READ : (PROT_READ | PROT_WRITE);
DBG(" ... Mapping %x(%x)+%x(%x) len=%x extend=%x", (int)pos0, (int)f->pos, ll, l, (int)F->file_size, (int)F->file_extend);
if (f->buffer == (byte *) MAP_FAILED)
die("mmap(%s): %m", f->name);
#ifdef MADV_SEQUENTIAL
- if (ll > PAGE_SIZE)
+ if (ll > CPU_PAGE_SIZE)
madvise(f->buffer, ll, MADV_SEQUENTIAL);
#endif
f->bufend = f->buffer + l;
f->pos = end;
if (f->pos >= F->file_extend)
{
- F->file_extend = ALIGN(F->file_extend + mmap_extend_size, (sh_off_t)PAGE_SIZE);
+ F->file_extend = ALIGN_TO(F->file_extend + mmap_extend_size, (sh_off_t)CPU_PAGE_SIZE);
if (sh_ftruncate(F->fd, F->file_extend))
die("ftruncate(%s): %m", f->name);
}
DBG(" -> %p %p %p(%x) %p", f->buffer, f->bptr, f->bstop, (int)f->pos, f->bufend);
}
-static void
+static int
bfmm_seek(struct fastbuf *f, sh_off_t pos, int whence)
{
if (whence == SEEK_END)
f->pos = pos;
f->bptr = f->bstop = f->bufend; /* force refill/spout call */
DBG("Seek -> %p %p %p(%x) %p", f->buffer, f->bptr, f->bstop, (int)f->pos, f->bufend);
+ return 1;
}
static void
struct fb_mmap *F = FB_MMAP(f);
if (f->buffer)
- munmap(f->buffer, ALIGN(f->bufend-f->buffer, PAGE_SIZE));
+ munmap(f->buffer, ALIGN_TO(f->bufend-f->buffer, CPU_PAGE_SIZE));
if (F->file_extend > F->file_size &&
sh_ftruncate(F->fd, F->file_size))
die("ftruncate(%s): %m", f->name);