Files
veejay/veejay-ng/libel/vj-mmap.h
Niels Elburg 96342dd9f4 Added veejay next generation branch
git-svn-id: svn://code.dyne.org/veejay/trunk@571 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
2006-07-08 16:25:31 +00:00

54 lines
1.6 KiB
C

/*
* Linux VeeJay
*
* Copyright(C)2002-2004 Niels Elburg <nelburg@looze.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License , or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*/
#ifndef VJ_MMAP_H
#define VJ_MMAP_H
#include <sys/types.h>
#include <sys/mman.h>
#include <stdint.h>
typedef struct
{
void *map_start; /* result of mmap() */
void *data_start; /* start of data */
uint64_t start_region;
uint64_t end_region;
off_t mem_offset; /* start of image */
int fd; /* file descriptor */
size_t page_size; /* page size */
size_t map_length; /* requested map size */
long eof; /* file size */
} mmap_region_t;
// map file portion to memory, return mapped region
mmap_region_t * mmap_file(int fd, int offset, int length, int fs);
// see if requested boundaries is mapped in memory
int is_mapped( mmap_region_t *map, int offset, int size );
// remap a portion of a file in memory
int remap_file( mmap_region_t *map, int offset );
// unmap memory
int munmap_file( mmap_region_t *map );
void mmap_free(mmap_region_t *map );
int mmap_read( mmap_region_t *map, int offset, int bytes, uint8_t *buf);
#endif