mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-25 20:25:42 +00:00
Can't have redefinitions of nbio_t in Griffin
This commit is contained in:
parent
fe12e079bb
commit
e78ec12973
@ -44,42 +44,42 @@ static nbio_intf_t *internal_nbio = &nbio_mmap_win32;
|
||||
static nbio_intf_t *internal_nbio = &nbio_stdio;
|
||||
#endif
|
||||
|
||||
struct nbio_t* nbio_open(const char * filename, unsigned mode)
|
||||
void *nbio_open(const char * filename, unsigned mode)
|
||||
{
|
||||
return internal_nbio->open(filename, mode);
|
||||
}
|
||||
|
||||
void nbio_begin_read(struct nbio_t* handle)
|
||||
void nbio_begin_read(void *data)
|
||||
{
|
||||
internal_nbio->begin_read(handle);
|
||||
internal_nbio->begin_read(data);
|
||||
}
|
||||
|
||||
void nbio_begin_write(struct nbio_t* handle)
|
||||
void nbio_begin_write(void *data)
|
||||
{
|
||||
internal_nbio->begin_write(handle);
|
||||
internal_nbio->begin_write(data);
|
||||
}
|
||||
|
||||
bool nbio_iterate(struct nbio_t* handle)
|
||||
bool nbio_iterate(void *data)
|
||||
{
|
||||
return internal_nbio->iterate(handle);
|
||||
return internal_nbio->iterate(data);
|
||||
}
|
||||
|
||||
void nbio_resize(struct nbio_t* handle, size_t len)
|
||||
void nbio_resize(void *data, size_t len)
|
||||
{
|
||||
internal_nbio->resize(handle, len);
|
||||
internal_nbio->resize(data, len);
|
||||
}
|
||||
|
||||
void *nbio_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
void *nbio_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
return internal_nbio->get_ptr(handle, len);
|
||||
return internal_nbio->get_ptr(data, len);
|
||||
}
|
||||
|
||||
void nbio_cancel(struct nbio_t* handle)
|
||||
void nbio_cancel(void *data)
|
||||
{
|
||||
internal_nbio->cancel(handle);
|
||||
internal_nbio->cancel(data);
|
||||
}
|
||||
|
||||
void nbio_free(struct nbio_t* handle)
|
||||
void nbio_free(void *data)
|
||||
{
|
||||
internal_nbio->free(handle);
|
||||
internal_nbio->free(data);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/aio_abi.h>
|
||||
|
||||
struct nbio_t
|
||||
struct nbio_linux_t
|
||||
{
|
||||
int fd;
|
||||
bool busy;
|
||||
@ -76,33 +76,7 @@ static int io_getevents(aio_context_t ctx, long min_nr, long nr,
|
||||
return syscall(__NR_io_getevents, ctx, min_nr, nr, events, timeout);
|
||||
}
|
||||
|
||||
static struct nbio_t* nbio_linux_open(const char * filename, unsigned mode)
|
||||
{
|
||||
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
|
||||
|
||||
aio_context_t ctx = 0;
|
||||
struct nbio_t* handle = NULL;
|
||||
int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
if (io_setup(128, &ctx) < 0)
|
||||
{
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = malloc(sizeof(struct nbio_t));
|
||||
handle->fd = fd;
|
||||
handle->ctx = ctx;
|
||||
handle->len = lseek(fd, 0, SEEK_END);
|
||||
handle->ptr = malloc(handle->len);
|
||||
handle->busy = false;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void nbio_begin_op(struct nbio_t* handle, uint16_t op)
|
||||
static void nbio_begin_op(struct nbio_linux_t* handle, uint16_t op)
|
||||
{
|
||||
struct iocb * cbp = &handle->cb;
|
||||
|
||||
@ -124,18 +98,51 @@ static void nbio_begin_op(struct nbio_t* handle, uint16_t op)
|
||||
handle->busy = true;
|
||||
}
|
||||
|
||||
static void nbio_linux_begin_read(struct nbio_t* handle)
|
||||
static void *nbio_linux_open(const char * filename, unsigned mode)
|
||||
{
|
||||
nbio_begin_op(handle, IOCB_CMD_PREAD);
|
||||
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
|
||||
|
||||
aio_context_t ctx = 0;
|
||||
struct nbio_linux_t* handle = NULL;
|
||||
int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
if (io_setup(128, &ctx) < 0)
|
||||
{
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = malloc(sizeof(struct nbio_linux_t));
|
||||
handle->fd = fd;
|
||||
handle->ctx = ctx;
|
||||
handle->len = lseek(fd, 0, SEEK_END);
|
||||
handle->ptr = malloc(handle->len);
|
||||
handle->busy = false;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void nbio_linux_begin_write(struct nbio_t* handle)
|
||||
static void nbio_linux_begin_read(void *data)
|
||||
{
|
||||
nbio_begin_op(handle, IOCB_CMD_PWRITE);
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (handle)
|
||||
nbio_begin_op(handle, IOCB_CMD_PREAD);
|
||||
}
|
||||
|
||||
static bool nbio_linux_iterate(struct nbio_t* handle)
|
||||
static void nbio_linux_begin_write(void *data)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (handle)
|
||||
nbio_begin_op(handle, IOCB_CMD_PWRITE);
|
||||
}
|
||||
|
||||
static bool nbio_linux_iterate(void *data)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (!handle)
|
||||
return false;
|
||||
if (handle->busy)
|
||||
{
|
||||
struct io_event ev;
|
||||
@ -145,8 +152,9 @@ static bool nbio_linux_iterate(struct nbio_t* handle)
|
||||
return !handle->busy;
|
||||
}
|
||||
|
||||
static void nbio_linux_resize(struct nbio_t* handle, size_t len)
|
||||
static void nbio_linux_resize(void *data, size_t len)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -169,8 +177,9 @@ static void nbio_linux_resize(struct nbio_t* handle, size_t len)
|
||||
handle->len = len;
|
||||
}
|
||||
|
||||
static void *nbio_linux_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
static void *nbio_linux_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (!handle)
|
||||
return NULL;
|
||||
if (len)
|
||||
@ -180,8 +189,9 @@ static void *nbio_linux_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nbio_linux_cancel(struct nbio_t* handle)
|
||||
static void nbio_linux_cancel(void *data)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -193,8 +203,9 @@ static void nbio_linux_cancel(struct nbio_t* handle)
|
||||
}
|
||||
}
|
||||
|
||||
static void nbio_linux_free(struct nbio_t* handle)
|
||||
static void nbio_linux_free(void *data)
|
||||
{
|
||||
struct nbio_linux_t* handle = (struct nbio_linux_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
struct nbio_t
|
||||
struct nbio_stdio_t
|
||||
{
|
||||
FILE* f;
|
||||
void* data;
|
||||
@ -52,21 +52,21 @@ struct nbio_t
|
||||
};
|
||||
|
||||
#if !defined(_WIN32) || defined(LEGACY_WIN32)
|
||||
static const char *stdio_modes[]={ "rb", "wb", "r+b", "rb", "wb", "r+b" };
|
||||
static const char *stdio_modes[] = { "rb", "wb", "r+b", "rb", "wb", "r+b" };
|
||||
#else
|
||||
static const wchar_t *stdio_modes[]={ L"rb", L"wb", L"r+b", L"rb", L"wb", L"r+b" };
|
||||
static const wchar_t *stdio_modes[] = { L"rb", L"wb", L"r+b", L"rb", L"wb", L"r+b" };
|
||||
#endif
|
||||
|
||||
static struct nbio_t* nbio_stdio_open(const char * filename, unsigned mode)
|
||||
static void *nbio_stdio_open(const char * filename, unsigned mode)
|
||||
{
|
||||
void *buf = NULL;
|
||||
struct nbio_t* handle = NULL;
|
||||
size_t len = 0;
|
||||
void *buf = NULL;
|
||||
struct nbio_stdio_t* handle = NULL;
|
||||
size_t len = 0;
|
||||
#if !defined(_WIN32) || defined(LEGACY_WIN32)
|
||||
FILE* f = fopen(filename, stdio_modes[mode]);
|
||||
FILE* f = fopen(filename, stdio_modes[mode]);
|
||||
#else
|
||||
wchar_t *filename_wide = utf8_to_utf16_string_alloc(filename);
|
||||
FILE* f = _wfopen(filename_wide, stdio_modes[mode]);
|
||||
wchar_t *filename_wide = utf8_to_utf16_string_alloc(filename);
|
||||
FILE* f = _wfopen(filename_wide, stdio_modes[mode]);
|
||||
|
||||
if (filename_wide)
|
||||
free(filename_wide);
|
||||
@ -74,7 +74,7 @@ static struct nbio_t* nbio_stdio_open(const char * filename, unsigned mode)
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
handle = (struct nbio_t*)malloc(sizeof(struct nbio_t));
|
||||
handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t));
|
||||
|
||||
if (!handle)
|
||||
goto error;
|
||||
@ -114,8 +114,9 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nbio_stdio_begin_read(struct nbio_t* handle)
|
||||
static void nbio_stdio_begin_read(void *data)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -131,8 +132,9 @@ static void nbio_stdio_begin_read(struct nbio_t* handle)
|
||||
handle->progress = 0;
|
||||
}
|
||||
|
||||
static void nbio_stdio_begin_write(struct nbio_t* handle)
|
||||
static void nbio_stdio_begin_write(void *data)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -147,9 +149,10 @@ static void nbio_stdio_begin_write(struct nbio_t* handle)
|
||||
handle->progress = 0;
|
||||
}
|
||||
|
||||
static bool nbio_stdio_iterate(struct nbio_t* handle)
|
||||
static bool nbio_stdio_iterate(void *data)
|
||||
{
|
||||
size_t amount = 65536;
|
||||
size_t amount = 65536;
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
|
||||
if (!handle)
|
||||
return false;
|
||||
@ -189,8 +192,9 @@ static bool nbio_stdio_iterate(struct nbio_t* handle)
|
||||
return (handle->op < 0);
|
||||
}
|
||||
|
||||
static void nbio_stdio_resize(struct nbio_t* handle, size_t len)
|
||||
static void nbio_stdio_resize(void *data, size_t len)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -211,8 +215,9 @@ static void nbio_stdio_resize(struct nbio_t* handle, size_t len)
|
||||
handle->progress = handle->len;
|
||||
}
|
||||
|
||||
static void *nbio_stdio_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
static void *nbio_stdio_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return NULL;
|
||||
if (len)
|
||||
@ -222,8 +227,9 @@ static void *nbio_stdio_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nbio_stdio_cancel(struct nbio_t* handle)
|
||||
static void nbio_stdio_cancel(void *data)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
@ -231,8 +237,9 @@ static void nbio_stdio_cancel(struct nbio_t* handle)
|
||||
handle->progress = handle->len;
|
||||
}
|
||||
|
||||
static void nbio_stdio_free(struct nbio_t* handle)
|
||||
static void nbio_stdio_free(void *data)
|
||||
{
|
||||
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
if (handle->op >= 0)
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
struct nbio_t
|
||||
struct nbio_mmap_unix_t
|
||||
{
|
||||
int fd;
|
||||
int map_flags;
|
||||
@ -43,15 +43,15 @@ struct nbio_t
|
||||
void* ptr;
|
||||
};
|
||||
|
||||
static struct nbio_t* nbio_mmap_unix_open(const char * filename, unsigned mode)
|
||||
static void *nbio_mmap_unix_open(const char * filename, unsigned mode)
|
||||
{
|
||||
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
|
||||
static const int map_flags[] = { PROT_READ, PROT_WRITE|PROT_READ, PROT_WRITE|PROT_READ, PROT_READ, PROT_WRITE|PROT_READ };
|
||||
|
||||
size_t len;
|
||||
void* ptr = NULL;
|
||||
struct nbio_t* handle = NULL;
|
||||
int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644);
|
||||
void* ptr = NULL;
|
||||
struct nbio_mmap_unix_t* handle = NULL;
|
||||
int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
@ -65,7 +65,7 @@ static struct nbio_t* nbio_mmap_unix_open(const char * filename, unsigned mode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = malloc(sizeof(struct nbio_t));
|
||||
handle = malloc(sizeof(struct nbio_mmap_unix_t));
|
||||
handle->fd = fd;
|
||||
handle->map_flags = map_flags[mode];
|
||||
handle->len = len;
|
||||
@ -73,23 +73,26 @@ static struct nbio_t* nbio_mmap_unix_open(const char * filename, unsigned mode)
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void nbio_mmap_unix_begin_read(struct nbio_t* handle)
|
||||
static void nbio_mmap_unix_begin_read(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void nbio_mmap_unix_begin_write(struct nbio_t* handle)
|
||||
static void nbio_mmap_unix_begin_write(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static bool nbio_mmap_unix_iterate(struct nbio_t* handle)
|
||||
static bool nbio_mmap_unix_iterate(void *data)
|
||||
{
|
||||
return true; /* not needed */
|
||||
}
|
||||
|
||||
static void nbio_mmap_unix_resize(struct nbio_t* handle, size_t len)
|
||||
static void nbio_mmap_unix_resize(void *data, size_t len)
|
||||
{
|
||||
struct nbio_mmap_unix_t* handle = (struct nbio_mmap_unix_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
if (len < handle->len)
|
||||
{
|
||||
/* this works perfectly fine if this check is removed, but it
|
||||
@ -118,8 +121,9 @@ static void nbio_mmap_unix_resize(struct nbio_t* handle, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
static void *nbio_mmap_unix_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
static void *nbio_mmap_unix_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
struct nbio_mmap_unix_t* handle = (struct nbio_mmap_unix_t*)data;
|
||||
if (!handle)
|
||||
return NULL;
|
||||
if (len)
|
||||
@ -127,13 +131,14 @@ static void *nbio_mmap_unix_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
return handle->ptr;
|
||||
}
|
||||
|
||||
static void nbio_mmap_unix_cancel(struct nbio_t* handle)
|
||||
static void nbio_mmap_unix_cancel(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void nbio_mmap_unix_free(struct nbio_t* handle)
|
||||
static void nbio_mmap_unix_free(void *data)
|
||||
{
|
||||
struct nbio_mmap_unix_t* handle = (struct nbio_mmap_unix_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
close(handle->fd);
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define FILE_SHARE_ALL (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE)
|
||||
#endif
|
||||
|
||||
struct nbio_t
|
||||
struct nbio_mmap_win32_t
|
||||
{
|
||||
HANDLE file;
|
||||
bool is_write;
|
||||
@ -51,20 +51,20 @@ struct nbio_t
|
||||
void* ptr;
|
||||
};
|
||||
|
||||
static struct nbio_t* nbio_mmap_win32_open(const char * filename, unsigned mode)
|
||||
static void *nbio_mmap_win32_open(const char * filename, unsigned mode)
|
||||
{
|
||||
static const DWORD dispositions[] = { OPEN_EXISTING, CREATE_ALWAYS, OPEN_ALWAYS, OPEN_EXISTING, CREATE_ALWAYS };
|
||||
HANDLE mem;
|
||||
LARGE_INTEGER len;
|
||||
struct nbio_t* handle = NULL;
|
||||
void* ptr = NULL;
|
||||
bool is_write = (mode == NBIO_WRITE || mode == NBIO_UPDATE || mode == BIO_WRITE);
|
||||
DWORD access = (is_write ? GENERIC_READ|GENERIC_WRITE : GENERIC_READ);
|
||||
struct nbio_mmap_win32_t* handle = NULL;
|
||||
void* ptr = NULL;
|
||||
bool is_write = (mode == NBIO_WRITE || mode == NBIO_UPDATE || mode == BIO_WRITE);
|
||||
DWORD access = (is_write ? GENERIC_READ|GENERIC_WRITE : GENERIC_READ);
|
||||
#if !defined(_WIN32) || defined(LEGACY_WIN32)
|
||||
HANDLE file = CreateFile(filename, access, FILE_SHARE_ALL, NULL, dispositions[mode], FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE file = CreateFile(filename, access, FILE_SHARE_ALL, NULL, dispositions[mode], FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#else
|
||||
wchar_t *filename_wide = utf8_to_utf16_string_alloc(filename);
|
||||
HANDLE file = CreateFileW(filename_wide, access, FILE_SHARE_ALL, NULL, dispositions[mode], FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
wchar_t *filename_wide = utf8_to_utf16_string_alloc(filename);
|
||||
HANDLE file = CreateFileW(filename_wide, access, FILE_SHARE_ALL, NULL, dispositions[mode], FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (filename_wide)
|
||||
free(filename_wide);
|
||||
@ -79,7 +79,7 @@ static struct nbio_t* nbio_mmap_win32_open(const char * filename, unsigned mode)
|
||||
ptr = MapViewOfFile(mem, is_write ? (FILE_MAP_READ|FILE_MAP_WRITE) : FILE_MAP_READ, 0, 0, len.QuadPart);
|
||||
CloseHandle(mem);
|
||||
|
||||
handle = malloc(sizeof(struct nbio_t));
|
||||
handle = malloc(sizeof(struct nbio_mmap_win32_t));
|
||||
|
||||
handle->file = file;
|
||||
handle->is_write = is_write;
|
||||
@ -89,26 +89,27 @@ static struct nbio_t* nbio_mmap_win32_open(const char * filename, unsigned mode)
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void nbio_mmap_win32_begin_read(struct nbio_t* handle)
|
||||
static void nbio_mmap_win32_begin_read(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void nbio_mmap_win32_begin_write(struct nbio_t* handle)
|
||||
static void nbio_mmap_win32_begin_write(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static bool nbio_mmap_win32_iterate(struct nbio_t* handle)
|
||||
static bool nbio_mmap_win32_iterate(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
return true;
|
||||
}
|
||||
|
||||
static void nbio_mmap_win32_resize(struct nbio_t* handle, size_t len)
|
||||
static void nbio_mmap_win32_resize(void *data, size_t len)
|
||||
{
|
||||
LARGE_INTEGER len_li;
|
||||
HANDLE mem;
|
||||
struct nbio_mmap_win32_t* handle = (struct nbio_mmap_win32_t*)data;
|
||||
|
||||
if (!handle)
|
||||
return;
|
||||
@ -145,8 +146,9 @@ static void nbio_mmap_win32_resize(struct nbio_t* handle, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
static void *nbio_mmap_win32_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
static void *nbio_mmap_win32_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
struct nbio_mmap_win32_t* handle = (struct nbio_mmap_win32_t*)data;
|
||||
if (!handle)
|
||||
return NULL;
|
||||
if (len)
|
||||
@ -154,13 +156,14 @@ static void *nbio_mmap_win32_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
return handle->ptr;
|
||||
}
|
||||
|
||||
static void nbio_mmap_win32_cancel(struct nbio_t* handle)
|
||||
static void nbio_mmap_win32_cancel(void *data)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
static void nbio_mmap_win32_free(struct nbio_t* handle)
|
||||
static void nbio_mmap_win32_free(void *data)
|
||||
{
|
||||
struct nbio_mmap_win32_t* handle = (struct nbio_mmap_win32_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
CloseHandle(handle->file);
|
||||
|
@ -51,74 +51,73 @@ RETRO_BEGIN_DECLS
|
||||
#define BIO_WRITE 4
|
||||
#endif
|
||||
|
||||
struct nbio_t;
|
||||
|
||||
typedef struct nbio_intf
|
||||
{
|
||||
struct nbio_t* (*open)(const char * filename, unsigned mode);
|
||||
void *(*open)(const char * filename, unsigned mode);
|
||||
|
||||
void (*begin_read)(struct nbio_t* handle);
|
||||
void (*begin_read)(void *data);
|
||||
|
||||
void (*begin_write)(struct nbio_t* handle);
|
||||
void (*begin_write)(void *data);
|
||||
|
||||
bool (*iterate)(struct nbio_t* handle);
|
||||
bool (*iterate)(void *data);
|
||||
|
||||
void (*resize)(struct nbio_t* handle, size_t len);
|
||||
void (*resize)(void *data, size_t len);
|
||||
|
||||
void *(*get_ptr)(struct nbio_t* handle, size_t* len);
|
||||
void *(*get_ptr)(void *data, size_t* len);
|
||||
|
||||
void (*cancel)(struct nbio_t* handle);
|
||||
void (*cancel)(void *data);
|
||||
|
||||
void (*free)(struct nbio_t* handle);
|
||||
void (*free)(void *data);
|
||||
|
||||
/* Human readable string. */
|
||||
const char *ident;
|
||||
} nbio_intf_t;
|
||||
|
||||
/*
|
||||
* Creates an nbio structure for performing the given operation on the given file.
|
||||
* Creates an nbio structure for performing the
|
||||
* given operation on the given file.
|
||||
*/
|
||||
struct nbio_t* nbio_open(const char * filename, unsigned mode);
|
||||
void *nbio_open(const char * filename, unsigned mode);
|
||||
|
||||
/*
|
||||
* Starts reading the given file. When done, it will be available in nbio_get_ptr.
|
||||
* Can not be done if the structure was created with {N,}BIO_WRITE.
|
||||
*/
|
||||
void nbio_begin_read(struct nbio_t* handle);
|
||||
void nbio_begin_read(void *data);
|
||||
|
||||
/*
|
||||
* Starts writing to the given file. Before this, you should've copied the data to nbio_get_ptr.
|
||||
* Can not be done if the structure was created with {N,}BIO_READ.
|
||||
*/
|
||||
void nbio_begin_write(struct nbio_t* handle);
|
||||
void nbio_begin_write(void *data);
|
||||
|
||||
/*
|
||||
* Performs part of the requested operation, or checks how it's going.
|
||||
* When it returns true, it's done.
|
||||
*/
|
||||
bool nbio_iterate(struct nbio_t* handle);
|
||||
bool nbio_iterate(void *data);
|
||||
|
||||
/*
|
||||
* Resizes the file up to the given size; cannot shrink.
|
||||
* Can not be done if the structure was created with {N,}BIO_READ.
|
||||
*/
|
||||
void nbio_resize(struct nbio_t* handle, size_t len);
|
||||
void nbio_resize(void *data, size_t len);
|
||||
|
||||
/*
|
||||
* Returns a pointer to the file data. Writable only if structure was not created with {N,}BIO_READ.
|
||||
* If any operation is in progress, the pointer will be NULL, but len will still be correct.
|
||||
*/
|
||||
void* nbio_get_ptr(struct nbio_t* handle, size_t* len);
|
||||
void* nbio_get_ptr(void *data, size_t* len);
|
||||
|
||||
/*
|
||||
* Stops any pending operation, allowing the object to be freed.
|
||||
*/
|
||||
void nbio_cancel(struct nbio_t* handle);
|
||||
void nbio_cancel(void *data);
|
||||
|
||||
/*
|
||||
* Deletes the nbio structure and its associated pointer.
|
||||
*/
|
||||
void nbio_free(struct nbio_t* handle);
|
||||
void nbio_free(void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user