mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-23 07:49:48 +00:00
Update
This commit is contained in:
parent
30be0296be
commit
17c4b822b3
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010-2017 The RetroArch team
|
||||
/* Copyright (C) 2010-2016 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (boolean.h).
|
||||
|
@ -41,7 +41,7 @@ RETRO_BEGIN_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRL
|
||||
/* Avoid possible naming collisions during link since
|
||||
/* Avoid possible naming collisions during link since
|
||||
* we prefer to use the actual name. */
|
||||
#define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size)
|
||||
|
||||
@ -52,8 +52,6 @@ size_t strlcat(char *dest, const char *source, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
char *strldup(const char *s, size_t n);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010-2017 The RetroArch team
|
||||
/* Copyright (C) 2010-2016 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (memmap.h).
|
||||
@ -23,7 +23,7 @@
|
||||
#ifndef _LIBRETRO_MEMMAP_H
|
||||
#define _LIBRETRO_MEMMAP_H
|
||||
|
||||
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU)
|
||||
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS)
|
||||
/* No mman available */
|
||||
#elif defined(_WIN32) && !defined(_XBOX)
|
||||
#include <windows.h>
|
||||
|
@ -25,14 +25,14 @@
|
||||
|
||||
/*
|
||||
This file is designed to normalize the libretro-common compiling environment
|
||||
for public API headers. This should be leaner than a normal compiling environment,
|
||||
for public API headers. This should be leaner than a normal compiling environment,
|
||||
since it gets #included into other project's sources.
|
||||
*/
|
||||
|
||||
/* ------------------------------------ */
|
||||
|
||||
/*
|
||||
Ordinarily we want to put #ifdef __cplusplus extern "C" in C library
|
||||
Ordinarily we want to put #ifdef __cplusplus extern "C" in C library
|
||||
headers to enable them to get used by c++ sources.
|
||||
However, we want to support building this library as C++ as well, so a
|
||||
special technique is called for.
|
||||
@ -75,19 +75,18 @@ typedef int ssize_t;
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define STRING_REP_INT64 "%I64u"
|
||||
#define STRING_REP_UINT64 "%I64u"
|
||||
#define STRING_REP_ULONG "%Iu"
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L && !defined(VITA)
|
||||
#define STRING_REP_INT64 "%llu"
|
||||
#define STRING_REP_UINT64 "%llu"
|
||||
#define STRING_REP_ULONG "%zu"
|
||||
#else
|
||||
#define STRING_REP_INT64 "%llu"
|
||||
#define STRING_REP_UINT64 "%llu"
|
||||
#define STRING_REP_ULONG "%lu"
|
||||
#ifdef _MSC_VER
|
||||
#ifndef PRId64
|
||||
#define PRId64 "I64d"
|
||||
#define PRIu64 "I64u"
|
||||
#define PRIuPTR "Iu"
|
||||
#endif
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#define STRING_REP_INT64 "%" PRId64
|
||||
#define STRING_REP_UINT64 "%" PRIu64
|
||||
#define STRING_REP_USIZE "%" PRIuPTR
|
||||
|
||||
/*
|
||||
I would like to see retro_inline.h moved in here; possibly boolean too.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010-2017 The RetroArch team
|
||||
/* Copyright (C) 2010-2016 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (retro_inline.h).
|
||||
|
@ -24,14 +24,16 @@
|
||||
#define __RARCH_MISCELLANEOUS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(_WIN32) && defined(_XBOX)
|
||||
#include <Xtl.h>
|
||||
#include <windows.h>
|
||||
#elif defined(_WIN32) && defined(_XBOX)
|
||||
#include <Xtl.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
@ -40,6 +42,24 @@
|
||||
#include <compat/msvc.h>
|
||||
#endif
|
||||
|
||||
static INLINE void bits_clear_bits(uint32_t *a, uint32_t *b, uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < count;i++)
|
||||
a[i] &= ~b[i];
|
||||
}
|
||||
|
||||
static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (ptr[i] != 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef PATH_MAX_LENGTH
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)|| defined(WIIU)
|
||||
#define PATH_MAX_LENGTH 512
|
||||
@ -56,35 +76,64 @@
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
#define BITS_GET_ELEM(a, i) ((a).data[i])
|
||||
#define BITS_GET_ELEM_PTR(a, i) ((a)->data[i])
|
||||
|
||||
#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
|
||||
#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
|
||||
#define BIT_GET(a, bit) ((a)[(bit) >> 3] & (1 << ((bit) & 7)))
|
||||
#define BIT_GET(a, bit) (((a)[(bit) >> 3] >> ((bit) & 7)) & 1)
|
||||
|
||||
#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
|
||||
#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
|
||||
#define BIT16_GET(a, bit) (!!((a) & (1 << ((bit) & 15))))
|
||||
#define BIT16_GET(a, bit) (((a) >> ((bit) & 15)) & 1)
|
||||
#define BIT16_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
|
||||
#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
|
||||
#define BIT32_GET(a, bit) (!!((a) & (1 << ((bit) & 31))))
|
||||
#define BIT32_GET(a, bit) (((a) >> ((bit) & 31)) & 1)
|
||||
#define BIT32_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
|
||||
#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
|
||||
#define BIT64_GET(a, bit) (!!((a) & (UINT64_C(1) << ((bit) & 63))))
|
||||
#define BIT64_GET(a, bit) (((a) >> ((bit) & 63)) & 1)
|
||||
#define BIT64_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31)))
|
||||
#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
|
||||
#define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31)))
|
||||
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a));
|
||||
#define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1)
|
||||
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a))
|
||||
|
||||
/* Helper macros and struct to keep track of many booleans.
|
||||
* To check for multiple bits, use &&, not &.
|
||||
* For OR, | can be used. */
|
||||
#define BIT128_SET_PTR(a, bit) BIT128_SET(*a, bit)
|
||||
#define BIT128_CLEAR_PTR(a, bit) BIT128_CLEAR(*a, bit)
|
||||
#define BIT128_GET_PTR(a, bit) BIT128_GET(*a, bit)
|
||||
#define BIT128_CLEAR_ALL_PTR(a) BIT128_CLEAR_ALL(*a)
|
||||
|
||||
#define BIT256_SET(a, bit) BIT128_SET(a, bit)
|
||||
#define BIT256_CLEAR(a, bit) BIT128_CLEAR(a, bit)
|
||||
#define BIT256_GET(a, bit) BIT128_GET(a, bit)
|
||||
#define BIT256_CLEAR_ALL(a) BIT128_CLEAR_ALL(a)
|
||||
|
||||
#define BIT256_SET_PTR(a, bit) BIT256_SET(*a, bit)
|
||||
#define BIT256_CLEAR_PTR(a, bit) BIT256_CLEAR(*a, bit)
|
||||
#define BIT256_GET_PTR(a, bit) BIT256_GET(*a, bit)
|
||||
#define BIT256_CLEAR_ALL_PTR(a) BIT256_CLEAR_ALL(*a)
|
||||
|
||||
#define BITS_COPY16_PTR(a,bits) \
|
||||
{ \
|
||||
BIT128_CLEAR_ALL_PTR(a); \
|
||||
BITS_GET_ELEM_PTR(a, 0) = (bits) & 0xffff; \
|
||||
}
|
||||
|
||||
#define BITS_COPY32_PTR(a,bits) \
|
||||
{ \
|
||||
BIT128_CLEAR_ALL_PTR(a); \
|
||||
BITS_GET_ELEM_PTR(a, 0) = (bits); \
|
||||
}
|
||||
|
||||
/* Helper macros and struct to keep track of many booleans. */
|
||||
/* This struct has 256 bits. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t data[8];
|
||||
|
@ -51,6 +51,7 @@ struct RFILE
|
||||
{
|
||||
struct retro_vfs_file_handle *hfile;
|
||||
bool error_flag;
|
||||
bool eof_flag;
|
||||
};
|
||||
|
||||
/* VFS Initialization */
|
||||
@ -150,6 +151,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints)
|
||||
|
||||
output = (RFILE*)malloc(sizeof(RFILE));
|
||||
output->error_flag = false;
|
||||
output->eof_flag = false;
|
||||
output->hfile = fp;
|
||||
return output;
|
||||
}
|
||||
@ -157,13 +159,13 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints)
|
||||
char *filestream_gets(RFILE *stream, char *s, size_t len)
|
||||
{
|
||||
int c = 0;
|
||||
char *p = NULL;
|
||||
char *p = s;
|
||||
if (!stream)
|
||||
return NULL;
|
||||
|
||||
/* get max bytes or up to a newline */
|
||||
|
||||
for (p = s, len--; len > 0; len--)
|
||||
for (len--; len > 0; len--)
|
||||
{
|
||||
if ((c = filestream_getc(stream)) == EOF)
|
||||
break;
|
||||
@ -173,9 +175,9 @@ char *filestream_gets(RFILE *stream, char *s, size_t len)
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
if (p == s || c == EOF)
|
||||
if (p == s && c == EOF)
|
||||
return NULL;
|
||||
return (p);
|
||||
return (s);
|
||||
}
|
||||
|
||||
int filestream_getc(RFILE *stream)
|
||||
@ -199,18 +201,14 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int seek_position)
|
||||
|
||||
if (output == vfs_error_return_value)
|
||||
stream->error_flag = true;
|
||||
stream->eof_flag = false;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
int filestream_eof(RFILE *stream)
|
||||
{
|
||||
int64_t current_position = filestream_tell(stream);
|
||||
int64_t end_position = filestream_get_size(stream);
|
||||
|
||||
if (current_position >= end_position)
|
||||
return 1;
|
||||
return 0;
|
||||
return stream->eof_flag;
|
||||
}
|
||||
|
||||
|
||||
@ -235,6 +233,7 @@ void filestream_rewind(RFILE *stream)
|
||||
return;
|
||||
filestream_seek(stream, 0L, RETRO_VFS_SEEK_POSITION_START);
|
||||
stream->error_flag = false;
|
||||
stream->eof_flag = false;
|
||||
}
|
||||
|
||||
ssize_t filestream_read(RFILE *stream, void *s, int64_t len)
|
||||
@ -249,6 +248,8 @@ ssize_t filestream_read(RFILE *stream, void *s, int64_t len)
|
||||
|
||||
if (output == vfs_error_return_value)
|
||||
stream->error_flag = true;
|
||||
if (output < len)
|
||||
stream->eof_flag = true;
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -312,7 +313,7 @@ int filestream_putc(RFILE *stream, int c)
|
||||
char c_char = (char)c;
|
||||
if (!stream)
|
||||
return EOF;
|
||||
return filestream_write(stream, &c_char, 1);
|
||||
return filestream_write(stream, &c_char, 1)==1 ? c : EOF;
|
||||
}
|
||||
|
||||
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
|
||||
|
@ -235,13 +235,18 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
/* TODO/FIXME - implement */
|
||||
case RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING:
|
||||
break;
|
||||
/* TODO/FIXME - implement */
|
||||
goto error;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str)
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
if (!mode_str)
|
||||
goto error;
|
||||
|
||||
stream->fp = fopen_utf8(path, mode_str);
|
||||
|
||||
if (!stream->fp)
|
||||
@ -448,7 +453,7 @@ int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
return fflush(stream->fp);
|
||||
return fflush(stream->fp)==0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int retro_vfs_file_remove_impl(const char *path)
|
||||
@ -457,7 +462,7 @@ int retro_vfs_file_remove_impl(const char *path)
|
||||
wchar_t *path_wide = NULL;
|
||||
|
||||
if (!path || !*path)
|
||||
return false;
|
||||
return -1;
|
||||
|
||||
(void)path_local;
|
||||
(void)path_wide;
|
||||
@ -472,7 +477,7 @@ int retro_vfs_file_remove_impl(const char *path)
|
||||
free(path_local);
|
||||
|
||||
if (ret == 0)
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
path_wide = utf8_to_utf16_string_alloc(path);
|
||||
@ -483,14 +488,14 @@ int retro_vfs_file_remove_impl(const char *path)
|
||||
free(path_wide);
|
||||
|
||||
if (ret == 0)
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if (remove(path) == 0)
|
||||
return true;
|
||||
return 0;
|
||||
#endif
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
@ -520,7 +525,7 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
int ret = rename(old_path_local, new_path_local);
|
||||
free(old_path_local);
|
||||
free(new_path_local);
|
||||
return ret;
|
||||
return ret==0 ? 0 : -1;
|
||||
}
|
||||
|
||||
free(old_path_local);
|
||||
@ -539,7 +544,7 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
int ret = _wrename(old_path_wide, new_path_wide);
|
||||
free(old_path_wide);
|
||||
free(new_path_wide);
|
||||
return ret;
|
||||
return ret==0 ? 0 : -1;
|
||||
}
|
||||
|
||||
free(old_path_wide);
|
||||
@ -550,7 +555,7 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
#endif
|
||||
return -1;
|
||||
#else
|
||||
return rename(old_path, new_path);
|
||||
return rename(old_path, new_path)==0 ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user