Exemple #1
0
int
file_mmap(struct file *file)
{
#ifdef _WIN32
    file->begin = (char*)mmap_readonly_win32( file->name, &file->map_handle, &file->map_file );
#else
    file->begin=mmap(NULL, file->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
    g_assert(file->begin != NULL);
    if (file->begin == (void *)0xffffffff) {
        perror("mmap");
        return 0;
    }
#endif
    g_assert(file->begin != (void *)0xffffffff);
    file->end=file->begin+file->size;

    return 1;
}
Exemple #2
0
int
file_mmap(struct file *file)
{
#if 0
	int mmap_size=file->size+1024*1024;
#else
	int mmap_size=file->size;
#endif
#ifdef HAVE_API_WIN32_BASE
	file->begin = (char*)mmap_readonly_win32( file->name, &file->map_handle, &file->map_file );
#else
	file->begin=mmap(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
	dbg_assert(file->begin != NULL);
	if (file->begin == (void *)0xffffffff) {
		perror("mmap");
		return 0;
	}
#endif
	dbg_assert(file->begin != (void *)0xffffffff);
	file->mmap_end=file->begin+mmap_size;
	file->end=file->begin+file->size;

	return 1;
}