rlib
Convenience library for useful things
Loading...
Searching...
No Matches
rmemfile.h
Go to the documentation of this file.
1/* RLIB - Convenience library for useful things
2 * Copyright (C) 2015 Haakon Sporsheim <haakon.sporsheim@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3.0 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library.
16 * See the COPYING file at the root of the source repository.
17 */
39#ifndef __R_MEM_FILE_H__
40#define __R_MEM_FILE_H__
41
42#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
43#error "#include <rlib.h> only please."
44#endif
45
46#include <rlib/rtypes.h>
47#include <rlib/rref.h>
48
50
58typedef struct RMemFile RMemFile;
59
73
90R_API RMemFile * r_mem_file_new (const rchar * file, RMemProt prot, rboolean writeback) R_ATTR_MALLOC;
91
106R_API RMemFile * r_mem_file_new_from_handle (RIOHandle handle, RMemProt prot, rboolean writeback) R_ATTR_MALLOC;
107
109#define r_mem_file_ref r_ref_ref
110
112#define r_mem_file_unref r_ref_unref
113
121
133
134R_END_DECLS
135
138#endif /* __R_MEM_FILE_H__ */
139
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
RMemFile * r_mem_file_new(const rchar *file, RMemProt prot, rboolean writeback)
Map file into memory by pathname.
struct RMemFile RMemFile
Opaque handle to a memory-mapped file region.
Definition rmemfile.h:58
rsize r_mem_file_get_size(RMemFile *file)
Size of the mapped region in bytes.
rpointer r_mem_file_get_mem(RMemFile *file)
Pointer to the first byte of the mapped region.
RMemFile * r_mem_file_new_from_handle(RIOHandle handle, RMemProt prot, rboolean writeback)
Map an already-opened file handle into memory.
RMemProt
Page-level protection flags for the mapping.
Definition rmemfile.h:67
@ R_MEM_PROT_READ
Definition rmemfile.h:69
@ R_MEM_PROT_NONE
Definition rmemfile.h:68
@ R_MEM_PROT_EXEC
Definition rmemfile.h:71
@ R_MEM_PROT_WRITE
Definition rmemfile.h:70
char rchar
Default character type (char).
Definition rtypes.h:137
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
Refcount base struct shared by every refcounted type in rlib.
Foundational type aliases used by every rlib header.