mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-28 04:01:48 +01:00
Merge pull request #81 from Aftnet/master
Using libretro_common's filestream for file access
This commit is contained in:
commit
61b6fb9169
@ -190,7 +190,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
#include "streams/file_stream.h"
|
||||||
|
|
||||||
#define u32 unsigned int
|
#define u32 unsigned int
|
||||||
|
|
||||||
@ -1016,13 +1016,13 @@ static void debug_dump_mem(void)
|
|||||||
|
|
||||||
static void debug_dump2file(const char *fname, void *mem, int len)
|
static void debug_dump2file(const char *fname, void *mem, int len)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(fname, "wb");
|
RFILE *f = filestream_open(fname, RFILE_MODE_WRITE, -1);
|
||||||
unsigned short *p = mem;
|
unsigned short *p = mem;
|
||||||
int i;
|
int i;
|
||||||
if (f) {
|
if (f) {
|
||||||
for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
|
for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
|
||||||
fwrite(mem, 1, len, f);
|
filestream_write(f, mem, len);
|
||||||
fclose(f);
|
filestream_close(f);
|
||||||
for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
|
for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
|
||||||
printf("dumped to %s\n", fname);
|
printf("dumped to %s\n", fname);
|
||||||
}
|
}
|
||||||
|
182
core/cd_hw/cdd.c
182
core/cd_hw/cdd.c
@ -36,6 +36,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
#include "streams/file_stream.h"
|
||||||
|
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#define SUPPORTED_EXT 20
|
#define SUPPORTED_EXT 20
|
||||||
@ -129,6 +130,31 @@ static const unsigned char waveHeader[28] =
|
|||||||
0x02,0x00,0x44,0xac,0x00,0x00,0x10,0xb1,0x02,0x00,0x04,0x00,0x10,0x00
|
0x02,0x00,0x44,0xac,0x00,0x00,0x10,0xb1,0x02,0x00,0x04,0x00,0x10,0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* vorbis file callbacks to use RFILEs*/
|
||||||
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
|
size_t fs_vorbis_read(void *ptr, size_t size, size_t nmemb, void *datasource)
|
||||||
|
{
|
||||||
|
return filestream_read(datasource, ptr, size*nmemb);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fs_vorbis_seek(void *datasource, ogg_int64_t offset, int whence)
|
||||||
|
{
|
||||||
|
return filestream_seek(datasource, offset, whence);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fs_vorbis_close (void *datasource)
|
||||||
|
{
|
||||||
|
return filestream_close(datasource);
|
||||||
|
}
|
||||||
|
|
||||||
|
long fs_vorbis_tell(void *datasource)
|
||||||
|
{
|
||||||
|
return filestream_tell(datasource);
|
||||||
|
}
|
||||||
|
|
||||||
|
ov_callbacks fs_ov_callbacks = { filestream_read, fs_vorbis_seek, fs_vorbis_close, fs_vorbis_tell };
|
||||||
|
#endif
|
||||||
|
|
||||||
/* supported WAVE file extensions */
|
/* supported WAVE file extensions */
|
||||||
static const char extensions[SUPPORTED_EXT][16] =
|
static const char extensions[SUPPORTED_EXT][16] =
|
||||||
{
|
{
|
||||||
@ -170,7 +196,7 @@ static void ogg_free(int i)
|
|||||||
cdd.toc.tracks[i].vf.seekable = 1;
|
cdd.toc.tracks[i].vf.seekable = 1;
|
||||||
|
|
||||||
/* reset file reading position */
|
/* reset file reading position */
|
||||||
fseek(cdd.toc.tracks[i].fd, 0, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[i].fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -255,21 +281,21 @@ int cdd_context_load(uint8 *state)
|
|||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
/* 96 bytes per sector */
|
/* 96 bytes per sector */
|
||||||
fseek(cdd.toc.sub, lba * 96, SEEK_SET);
|
filestream_seek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track position */
|
||||||
if (cdd.toc.tracks[cdd.index].type)
|
if (cdd.toc.tracks[cdd.index].type)
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.index].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* VORBIS file need to be opened first */
|
/* VORBIS file need to be opened first */
|
||||||
ov_open(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0);
|
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,fs_ov_callbacks);
|
||||||
#endif
|
#endif
|
||||||
/* VORBIS AUDIO track */
|
/* VORBIS AUDIO track */
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (lba * 588) - cdd.toc.tracks[cdd.index].offset);
|
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (lba * 588) - cdd.toc.tracks[cdd.index].offset);
|
||||||
@ -278,7 +304,7 @@ int cdd_context_load(uint8 *state)
|
|||||||
else if (cdd.toc.tracks[cdd.index].fd)
|
else if (cdd.toc.tracks[cdd.index].fd)
|
||||||
{
|
{
|
||||||
/* PCM AUDIO track */
|
/* PCM AUDIO track */
|
||||||
fseek(cdd.toc.tracks[cdd.index].fd, (lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.index].fd, (lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bufferptr;
|
return bufferptr;
|
||||||
@ -298,7 +324,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd_unload();
|
cdd_unload();
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
fd = fopen(filename, "rb");
|
fd = filestream_open(filename, RFILE_MODE_READ, -1);
|
||||||
if (!fd) return (-1);
|
if (!fd) return (-1);
|
||||||
|
|
||||||
/* save a copy of base filename */
|
/* save a copy of base filename */
|
||||||
@ -310,7 +336,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* read first 16 bytes */
|
/* read first 16 bytes */
|
||||||
fread(header, 0x10, 1, fd);
|
filestream_read(fd, header, 0x10);
|
||||||
|
|
||||||
/* look for valid CD image identifier */
|
/* look for valid CD image identifier */
|
||||||
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
||||||
@ -321,7 +347,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* read next 16 bytes */
|
/* read next 16 bytes */
|
||||||
fread(header, 0x10, 1, fd);
|
filestream_read(fd, header, 0x10);
|
||||||
|
|
||||||
/* look for valid CD image identifier */
|
/* look for valid CD image identifier */
|
||||||
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
if (!memcmp("SEGADISCSYSTEM", header, 14))
|
||||||
@ -335,7 +361,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
if (cdd.sectorSize)
|
if (cdd.sectorSize)
|
||||||
{
|
{
|
||||||
/* read CD image header + security code */
|
/* read CD image header + security code */
|
||||||
fread(header + 0x10, 0x200, 1, fd);
|
filestream_read(fd, header + 0x10, 0x200);
|
||||||
|
|
||||||
/* initialize first track file descriptor */
|
/* initialize first track file descriptor */
|
||||||
cdd.toc.tracks[0].fd = fd;
|
cdd.toc.tracks[0].fd = fd;
|
||||||
@ -344,8 +370,8 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.toc.tracks[0].type = TYPE_CDROM;
|
cdd.toc.tracks[0].type = TYPE_CDROM;
|
||||||
|
|
||||||
/* DATA track end LBA (based on DATA file length) */
|
/* DATA track end LBA (based on DATA file length) */
|
||||||
fseek(fd, 0, SEEK_END);
|
filestream_seek(fd, 0, SEEK_END);
|
||||||
cdd.toc.tracks[0].end = ftell(fd) / cdd.sectorSize;
|
cdd.toc.tracks[0].end = filestream_tell(fd) / cdd.sectorSize;
|
||||||
|
|
||||||
/* DATA track length should be at least 2s (BIOS requirement) */
|
/* DATA track length should be at least 2s (BIOS requirement) */
|
||||||
if (cdd.toc.tracks[0].end < 150)
|
if (cdd.toc.tracks[0].end < 150)
|
||||||
@ -354,7 +380,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* DATA track start LBA (logical block 0) */
|
/* DATA track start LBA (logical block 0) */
|
||||||
fseek(fd, 0, SEEK_SET);
|
filestream_seek(fd, 0, SEEK_SET);
|
||||||
cdd.toc.tracks[0].start = 0;
|
cdd.toc.tracks[0].start = 0;
|
||||||
|
|
||||||
/* initialize TOC */
|
/* initialize TOC */
|
||||||
@ -367,14 +393,14 @@ int cdd_load(char *filename, char *header)
|
|||||||
isCDfile = 0;
|
isCDfile = 0;
|
||||||
|
|
||||||
/* close file */
|
/* close file */
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* automatically try to mount CD associated CUE file */
|
/* automatically try to mount CD associated CUE file */
|
||||||
len = strlen(fname);
|
len = strlen(fname);
|
||||||
while ((len && (fname[len] != '.')) || (len > 251)) len--;
|
while ((len && (fname[len] != '.')) || (len > 251)) len--;
|
||||||
strcpy(&fname[len], ".cue");
|
strcpy(&fname[len], ".cue");
|
||||||
fd = fopen(fname, "rb");
|
fd = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse CUE file */
|
/* parse CUE file */
|
||||||
@ -386,7 +412,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
if (cdd.toc.last)
|
if (cdd.toc.last)
|
||||||
{
|
{
|
||||||
/* skip first track */
|
/* skip first track */
|
||||||
while (fgets(line, 128, fd))
|
while (filestream_gets(fd, line, 128))
|
||||||
{
|
{
|
||||||
if (strstr(line, "INDEX 01") && !strstr(line, "INDEX 1"))
|
if (strstr(line, "INDEX 01") && !strstr(line, "INDEX 1"))
|
||||||
break;
|
break;
|
||||||
@ -394,7 +420,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read lines until end of file */
|
/* read lines until end of file */
|
||||||
while (fgets(line, 128, fd))
|
while (filestream_gets(fd, line, 128))
|
||||||
{
|
{
|
||||||
/* skip any SPACE characters */
|
/* skip any SPACE characters */
|
||||||
lptr = line;
|
lptr = line;
|
||||||
@ -431,7 +457,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
/* open current track file descriptor */
|
/* open current track file descriptor */
|
||||||
cdd.toc.tracks[cdd.toc.last].fd = fopen(fname, "rb");
|
cdd.toc.tracks[cdd.toc.last].fd = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
if (!cdd.toc.tracks[cdd.toc.last].fd)
|
if (!cdd.toc.tracks[cdd.toc.last].fd)
|
||||||
{
|
{
|
||||||
/* error opening file */
|
/* error opening file */
|
||||||
@ -449,32 +475,32 @@ int cdd_load(char *filename, char *header)
|
|||||||
{
|
{
|
||||||
/* read file header */
|
/* read file header */
|
||||||
unsigned char head[28];
|
unsigned char head[28];
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 8, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 8, SEEK_SET);
|
||||||
fread(head, 28, 1, cdd.toc.tracks[cdd.toc.last].fd);
|
filestream_read(cdd.toc.tracks[cdd.toc.last].fd, head, 28);
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
||||||
|
|
||||||
/* autodetect WAVE file header (44.1KHz 16-bit stereo format only) */
|
/* autodetect WAVE file header (44.1KHz 16-bit stereo format only) */
|
||||||
if (!memcmp(head, waveHeader, 28))
|
if (!memcmp(head, waveHeader, 28))
|
||||||
{
|
{
|
||||||
/* look for 'data' chunk id */
|
/* look for 'data' chunk id */
|
||||||
int dataOffset = 0;
|
int dataOffset = 0;
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 36, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 36, SEEK_SET);
|
||||||
while (fread(head, 4, 1, cdd.toc.tracks[cdd.toc.last].fd))
|
while (filestream_read(cdd.toc.tracks[cdd.toc.last].fd, head, 4))
|
||||||
{
|
{
|
||||||
if (!memcmp(head, "data", 4))
|
if (!memcmp(head, "data", 4))
|
||||||
{
|
{
|
||||||
dataOffset = ftell(cdd.toc.tracks[cdd.toc.last].fd) + 4;
|
dataOffset = filestream_tell(cdd.toc.tracks[cdd.toc.last].fd) + 4;
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, -2, SEEK_CUR);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, -2, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if 'data' chunk has not been found */
|
/* check if 'data' chunk has not been found */
|
||||||
if (!dataOffset)
|
if (!dataOffset)
|
||||||
{
|
{
|
||||||
/* invalid WAVE file */
|
/* invalid WAVE file */
|
||||||
fclose(cdd.toc.tracks[cdd.toc.last].fd);
|
filestream_close(cdd.toc.tracks[cdd.toc.last].fd);
|
||||||
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -483,7 +509,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.toc.tracks[cdd.toc.last].offset -= dataOffset;
|
cdd.toc.tracks[cdd.toc.last].offset -= dataOffset;
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (!ov_open(cdd.toc.tracks[cdd.toc.last].fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
else if (!ov_open_callbacks(cdd.toc.tracks[cdd.toc.last].fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0,fs_ov_callbacks))
|
||||||
{
|
{
|
||||||
/* retrieve stream infos */
|
/* retrieve stream infos */
|
||||||
vorbis_info *info = ov_info(&cdd.toc.tracks[cdd.toc.last].vf,-1);
|
vorbis_info *info = ov_info(&cdd.toc.tracks[cdd.toc.last].vf,-1);
|
||||||
@ -499,7 +525,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* unsupported audio file */
|
/* unsupported audio file */
|
||||||
fclose(cdd.toc.tracks[cdd.toc.last].fd);
|
filestream_close(cdd.toc.tracks[cdd.toc.last].fd);
|
||||||
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -515,7 +541,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
/* close any opened file */
|
/* close any opened file */
|
||||||
if (cdd.toc.tracks[cdd.toc.last].fd)
|
if (cdd.toc.tracks[cdd.toc.last].fd)
|
||||||
{
|
{
|
||||||
fclose(cdd.toc.tracks[cdd.toc.last].fd);
|
filestream_close(cdd.toc.tracks[cdd.toc.last].fd);
|
||||||
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
cdd.toc.tracks[cdd.toc.last].fd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +564,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.sectorSize = 2352;
|
cdd.sectorSize = 2352;
|
||||||
|
|
||||||
/* skip 16-byte header */
|
/* skip 16-byte header */
|
||||||
fseek(cdd.toc.tracks[0].fd, 0x10, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, 0x10, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cdd.sectorSize)
|
if (cdd.sectorSize)
|
||||||
@ -547,8 +573,8 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.toc.tracks[0].type = TYPE_CDROM;
|
cdd.toc.tracks[0].type = TYPE_CDROM;
|
||||||
|
|
||||||
/* read CD image header + security code */
|
/* read CD image header + security code */
|
||||||
fread(header, 0x210, 1, cdd.toc.tracks[0].fd);
|
filestream_read(cdd.toc.tracks[0].fd, header, 0x210);
|
||||||
fseek(cdd.toc.tracks[0].fd, 0, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -638,18 +664,18 @@ int cdd_load(char *filename, char *header)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* current track end time */
|
/* current track end time */
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_END);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_END);
|
||||||
if (cdd.toc.tracks[cdd.toc.last].type)
|
if (cdd.toc.tracks[cdd.toc.last].type)
|
||||||
{
|
{
|
||||||
/* DATA track length */
|
/* DATA track length */
|
||||||
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((ftell(cdd.toc.tracks[cdd.toc.last].fd) + cdd.sectorSize - 1) / cdd.sectorSize);
|
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((filestream_tell(cdd.toc.tracks[cdd.toc.last].fd) + cdd.sectorSize - 1) / cdd.sectorSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* AUDIO track length */
|
/* AUDIO track length */
|
||||||
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((ftell(cdd.toc.tracks[cdd.toc.last].fd) + 2351) / 2352);
|
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((filestream_tell(cdd.toc.tracks[cdd.toc.last].fd) + 2351) / 2352);
|
||||||
}
|
}
|
||||||
fseek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.toc.last].fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust track start time (based on current file start time + index absolute time) */
|
/* adjust track start time (based on current file start time + index absolute time) */
|
||||||
@ -687,11 +713,11 @@ int cdd_load(char *filename, char *header)
|
|||||||
#endif
|
#endif
|
||||||
if (cdd.toc.tracks[cdd.toc.last].fd)
|
if (cdd.toc.tracks[cdd.toc.last].fd)
|
||||||
{
|
{
|
||||||
fclose(cdd.toc.tracks[cdd.toc.last].fd);
|
filestream_close(cdd.toc.tracks[cdd.toc.last].fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close CUE file */
|
/* close CUE file */
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -705,7 +731,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
{
|
{
|
||||||
/* auto-detect wrong initial track index */
|
/* auto-detect wrong initial track index */
|
||||||
sprintf(ptr, extensions[i], cdd.toc.last);
|
sprintf(ptr, extensions[i], cdd.toc.last);
|
||||||
fd = fopen(fname, "rb");
|
fd = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@ -713,7 +739,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprintf(ptr, extensions[i], cdd.toc.last + 1);
|
sprintf(ptr, extensions[i], cdd.toc.last + 1);
|
||||||
fd = fopen(fname, "rb");
|
fd = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
if (fd) break;
|
if (fd) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,31 +748,31 @@ int cdd_load(char *filename, char *header)
|
|||||||
{
|
{
|
||||||
/* read file HEADER */
|
/* read file HEADER */
|
||||||
unsigned char head[28];
|
unsigned char head[28];
|
||||||
fseek(fd, 8, SEEK_SET);
|
filestream_seek(fd, 8, SEEK_SET);
|
||||||
fread(head, 28, 1, fd);
|
filestream_read(fd, head, 28);
|
||||||
fseek(fd, 0, SEEK_SET);
|
filestream_seek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
/* check if this is a valid WAVE file (44.1KHz 16-bit stereo format only) */
|
/* check if this is a valid WAVE file (44.1KHz 16-bit stereo format only) */
|
||||||
if (!memcmp(head, waveHeader, 28))
|
if (!memcmp(head, waveHeader, 28))
|
||||||
{
|
{
|
||||||
/* look for 'data' chunk id */
|
/* look for 'data' chunk id */
|
||||||
int dataOffset = 0;
|
int dataOffset = 0;
|
||||||
fseek(fd, 36, SEEK_SET);
|
filestream_seek(fd, 36, SEEK_SET);
|
||||||
while (fread(head, 4, 1, fd))
|
while (filestream_read(fd, head, 4))
|
||||||
{
|
{
|
||||||
if (!memcmp(head, "data", 4))
|
if (!memcmp(head, "data", 4))
|
||||||
{
|
{
|
||||||
dataOffset = ftell(fd) + 4;
|
dataOffset = filestream_tell(fd) + 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fseek(fd, -2, SEEK_CUR);
|
filestream_seek(fd, -2, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if 'data' chunk has not been found */
|
/* check if 'data' chunk has not been found */
|
||||||
if (!dataOffset)
|
if (!dataOffset)
|
||||||
{
|
{
|
||||||
/* invalid WAVE file */
|
/* invalid WAVE file */
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,16 +786,16 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.toc.tracks[cdd.toc.last].start += 150;
|
cdd.toc.tracks[cdd.toc.last].start += 150;
|
||||||
|
|
||||||
/* current track end time */
|
/* current track end time */
|
||||||
fseek(fd, 0, SEEK_END);
|
filestream_seek(fd, 0, SEEK_END);
|
||||||
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((ftell(fd) - dataOffset + 2351) / 2352);
|
cdd.toc.tracks[cdd.toc.last].end = cdd.toc.tracks[cdd.toc.last].start + ((filestream_tell(fd) - dataOffset + 2351) / 2352);
|
||||||
|
|
||||||
/* initialize file read offset for current track */
|
/* initialize file read offset for current track */
|
||||||
cdd.toc.tracks[cdd.toc.last].offset = cdd.toc.tracks[cdd.toc.last].start * 2352;
|
cdd.toc.tracks[cdd.toc.last].offset = cdd.toc.tracks[cdd.toc.last].start * 2352;
|
||||||
|
|
||||||
/* auto-detect PAUSE within audio files */
|
/* auto-detect PAUSE within audio files */
|
||||||
fseek(fd, 100 * 2352, SEEK_SET);
|
filestream_seek(fd, 100 * 2352, SEEK_SET);
|
||||||
fread(head, 4, 1, fd);
|
filestream_read(fd, head, 4);
|
||||||
fseek(fd, 0, SEEK_SET);
|
filestream_seek(fd, 0, SEEK_SET);
|
||||||
if (*(int32 *)head == 0)
|
if (*(int32 *)head == 0)
|
||||||
{
|
{
|
||||||
/* assume 2s PAUSE is included at the beginning of the file */
|
/* assume 2s PAUSE is included at the beginning of the file */
|
||||||
@ -787,7 +813,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
cdd.toc.last++;
|
cdd.toc.last++;
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (!ov_open(fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
else if (!ov_open_callbacks(fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0,fs_ov_callbacks))
|
||||||
{
|
{
|
||||||
/* retrieve stream infos */
|
/* retrieve stream infos */
|
||||||
vorbis_info *info = ov_info(&cdd.toc.tracks[cdd.toc.last].vf,-1);
|
vorbis_info *info = ov_info(&cdd.toc.tracks[cdd.toc.last].vf,-1);
|
||||||
@ -852,7 +878,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* unsupported audio file format */
|
/* unsupported audio file format */
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,7 +887,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
|
|
||||||
/* try to open next audio track file */
|
/* try to open next audio track file */
|
||||||
sprintf(ptr, extensions[i], cdd.toc.last + offset);
|
sprintf(ptr, extensions[i], cdd.toc.last + offset);
|
||||||
fd = fopen(fname, "rb");
|
fd = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,7 +1002,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
|
|
||||||
/* Automatically try to open associated subcode data file */
|
/* Automatically try to open associated subcode data file */
|
||||||
strncpy(&fname[strlen(fname) - 4], ".sub", 4);
|
strncpy(&fname[strlen(fname) - 4], ".sub", 4);
|
||||||
cdd.toc.sub = fopen(fname, "rb");
|
cdd.toc.sub = filestream_open(fname, RFILE_MODE_READ, -1);
|
||||||
|
|
||||||
/* return 1 if loaded file is CD image file */
|
/* return 1 if loaded file is CD image file */
|
||||||
return (isCDfile);
|
return (isCDfile);
|
||||||
@ -1014,13 +1040,13 @@ void cdd_unload(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* close file */
|
/* close file */
|
||||||
fclose(cdd.toc.tracks[i].fd);
|
filestream_close(cdd.toc.tracks[i].fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close any opened subcode file */
|
/* close any opened subcode file */
|
||||||
if (cdd.toc.sub) fclose(cdd.toc.sub);
|
if (cdd.toc.sub) filestream_close(cdd.toc.sub);
|
||||||
|
|
||||||
/* CD unloaded */
|
/* CD unloaded */
|
||||||
cdd.loaded = 0;
|
cdd.loaded = 0;
|
||||||
@ -1042,16 +1068,16 @@ void cdd_read_data(uint8 *dst)
|
|||||||
if (cdd.sectorSize == 2048)
|
if (cdd.sectorSize == 2048)
|
||||||
{
|
{
|
||||||
/* Mode 1 COOKED data (ISO) */
|
/* Mode 1 COOKED data (ISO) */
|
||||||
fseek(cdd.toc.tracks[0].fd, cdd.lba * 2048, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, cdd.lba * 2048, SEEK_SET);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Mode 1 RAW data (skip 16-byte header) */
|
/* Mode 1 RAW data (skip 16-byte header) */
|
||||||
fseek(cdd.toc.tracks[0].fd, cdd.lba * 2352 + 16, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, cdd.lba * 2352 + 16, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read sector data (Mode 1 = 2048 bytes) */
|
/* read sector data (Mode 1 = 2048 bytes) */
|
||||||
fread(dst, 2048, 1, cdd.toc.tracks[0].fd);
|
filestream_read(cdd.toc.tracks[0].fd, dst, 2048);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1139,7 +1165,7 @@ void cdd_read_audio(unsigned int samples)
|
|||||||
#else
|
#else
|
||||||
uint8 *ptr = cdc.ram;
|
uint8 *ptr = cdc.ram;
|
||||||
#endif
|
#endif
|
||||||
fread(cdc.ram, 1, samples * 4, cdd.toc.tracks[cdd.index].fd);
|
filestream_read(cdd.toc.tracks[cdd.index].fd, cdc.ram, samples * 4);
|
||||||
|
|
||||||
/* process 16-bit (little-endian) stereo samples */
|
/* process 16-bit (little-endian) stereo samples */
|
||||||
for (i=0; i<samples; i++)
|
for (i=0; i<samples; i++)
|
||||||
@ -1217,7 +1243,7 @@ static void cdd_read_subcode(void)
|
|||||||
index = (scd.regs[0x68>>1].byte.l + 0x100) >> 1;
|
index = (scd.regs[0x68>>1].byte.l + 0x100) >> 1;
|
||||||
|
|
||||||
/* read interleaved subcode data from .sub file (12 x 8-bit of P subchannel first, then Q subchannel, etc) */
|
/* read interleaved subcode data from .sub file (12 x 8-bit of P subchannel first, then Q subchannel, etc) */
|
||||||
fread(subc, 1, 96, cdd.toc.sub);
|
filestream_read(cdd.toc.sub, subc, 96);
|
||||||
|
|
||||||
/* convert back to raw subcode format (96 bytes with 8 x P-W subchannel bits per byte) */
|
/* convert back to raw subcode format (96 bytes with 8 x P-W subchannel bits per byte) */
|
||||||
for (i=0; i<96; i+=2)
|
for (i=0; i<96; i+=2)
|
||||||
@ -1345,7 +1371,7 @@ void cdd_update(void)
|
|||||||
{
|
{
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* VORBIS file need to be opened first */
|
/* VORBIS file need to be opened first */
|
||||||
ov_open(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0);
|
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,fs_ov_callbacks);
|
||||||
#endif
|
#endif
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (cdd.toc.tracks[cdd.index].start * 588) - cdd.toc.tracks[cdd.index].offset);
|
ov_pcm_seek(&cdd.toc.tracks[cdd.index].vf, (cdd.toc.tracks[cdd.index].start * 588) - cdd.toc.tracks[cdd.index].offset);
|
||||||
}
|
}
|
||||||
@ -1353,7 +1379,7 @@ void cdd_update(void)
|
|||||||
#endif
|
#endif
|
||||||
if (cdd.toc.tracks[cdd.index].fd)
|
if (cdd.toc.tracks[cdd.index].fd)
|
||||||
{
|
{
|
||||||
fseek(cdd.toc.tracks[cdd.index].fd, (cdd.toc.tracks[cdd.index].start * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.index].fd, (cdd.toc.tracks[cdd.index].start * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1431,14 +1457,14 @@ void cdd_update(void)
|
|||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
fseek(cdd.toc.sub, cdd.lba * 96, SEEK_SET);
|
filestream_seek(cdd.toc.sub, cdd.lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track position */
|
||||||
if (cdd.toc.tracks[cdd.index].type)
|
if (cdd.toc.tracks[cdd.index].type)
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
@ -1448,7 +1474,7 @@ void cdd_update(void)
|
|||||||
if (!cdd.toc.tracks[cdd.index].vf.datasource)
|
if (!cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
{
|
{
|
||||||
/* VORBIS file need to be opened first */
|
/* VORBIS file need to be opened first */
|
||||||
ov_open(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0);
|
ov_open_callbacks(cdd.toc.tracks[cdd.index].fd,&cdd.toc.tracks[cdd.index].vf,0,0,fs_ov_callbacks);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* VORBIS AUDIO track */
|
/* VORBIS AUDIO track */
|
||||||
@ -1458,7 +1484,7 @@ void cdd_update(void)
|
|||||||
else if (cdd.toc.tracks[cdd.index].fd)
|
else if (cdd.toc.tracks[cdd.index].fd)
|
||||||
{
|
{
|
||||||
/* PCM AUDIO track */
|
/* PCM AUDIO track */
|
||||||
fseek(cdd.toc.tracks[cdd.index].fd, (cdd.lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[cdd.index].fd, (cdd.lba * 2352) - cdd.toc.tracks[cdd.index].offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1641,7 +1667,7 @@ void cdd_process(void)
|
|||||||
/* open current track VORBIS file */
|
/* open current track VORBIS file */
|
||||||
if (cdd.toc.tracks[index].vf.seekable)
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
{
|
{
|
||||||
ov_open(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0);
|
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,fs_ov_callbacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1659,14 +1685,14 @@ void cdd_process(void)
|
|||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
fseek(cdd.toc.sub, lba * 96, SEEK_SET);
|
filestream_seek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current track position */
|
/* seek to current track position */
|
||||||
if (cdd.toc.tracks[index].type)
|
if (cdd.toc.tracks[index].type)
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
@ -1678,7 +1704,7 @@ void cdd_process(void)
|
|||||||
else if (cdd.toc.tracks[index].fd)
|
else if (cdd.toc.tracks[index].fd)
|
||||||
{
|
{
|
||||||
/* PCM AUDIO track */
|
/* PCM AUDIO track */
|
||||||
fseek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no audio track playing (yet) */
|
/* no audio track playing (yet) */
|
||||||
@ -1739,7 +1765,7 @@ void cdd_process(void)
|
|||||||
/* open current track VORBIS file */
|
/* open current track VORBIS file */
|
||||||
if (cdd.toc.tracks[index].vf.seekable)
|
if (cdd.toc.tracks[index].vf.seekable)
|
||||||
{
|
{
|
||||||
ov_open(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0);
|
ov_open_callbacks(cdd.toc.tracks[index].fd,&cdd.toc.tracks[index].vf,0,0,fs_ov_callbacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1758,7 +1784,7 @@ void cdd_process(void)
|
|||||||
if (cdd.toc.tracks[index].type)
|
if (cdd.toc.tracks[index].type)
|
||||||
{
|
{
|
||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
@ -1770,13 +1796,13 @@ void cdd_process(void)
|
|||||||
else if (cdd.toc.tracks[index].fd)
|
else if (cdd.toc.tracks[index].fd)
|
||||||
{
|
{
|
||||||
/* PCM AUDIO track */
|
/* PCM AUDIO track */
|
||||||
fseek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
filestream_seek(cdd.toc.tracks[index].fd, (lba * 2352) - cdd.toc.tracks[index].offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek to current subcode position */
|
/* seek to current subcode position */
|
||||||
if (cdd.toc.sub)
|
if (cdd.toc.sub)
|
||||||
{
|
{
|
||||||
fseek(cdd.toc.sub, lba * 96, SEEK_SET);
|
filestream_seek(cdd.toc.sub, lba * 96, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no audio track playing */
|
/* no audio track playing */
|
||||||
|
@ -61,10 +61,12 @@
|
|||||||
|
|
||||||
#define CD_MAX_TRACKS 100
|
#define CD_MAX_TRACKS 100
|
||||||
|
|
||||||
|
typedef struct RFILE RFILE;
|
||||||
|
|
||||||
/* CD track */
|
/* CD track */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE *fd;
|
RFILE *fd;
|
||||||
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
#endif
|
#endif
|
||||||
@ -80,7 +82,7 @@ typedef struct
|
|||||||
int end;
|
int end;
|
||||||
int last;
|
int last;
|
||||||
track_t tracks[CD_MAX_TRACKS];
|
track_t tracks[CD_MAX_TRACKS];
|
||||||
FILE *sub;
|
RFILE *sub;
|
||||||
} toc_t;
|
} toc_t;
|
||||||
|
|
||||||
/* CDD hardware */
|
/* CDD hardware */
|
||||||
|
39
libretro-common/include/boolean.h
Normal file
39
libretro-common/include/boolean.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (boolean.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_BOOLEAN_H
|
||||||
|
#define __LIBRETRO_SDK_BOOLEAN_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
|
||||||
|
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
|
||||||
|
#define bool unsigned char
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
#else
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
84
libretro-common/include/compat/apple_compat.h
Normal file
84
libretro-common/include/compat/apple_compat.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (apple_compat.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __APPLE_COMPAT_H
|
||||||
|
#define __APPLE_COMPAT_H
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
|
||||||
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
|
||||||
|
typedef int NSInteger;
|
||||||
|
typedef unsigned NSUInteger;
|
||||||
|
typedef float CGFloat;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __has_feature
|
||||||
|
/* Compatibility with non-Clang compilers. */
|
||||||
|
#define __has_feature(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CF_RETURNS_RETAINED
|
||||||
|
#if __has_feature(attribute_cf_returns_retained)
|
||||||
|
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
|
||||||
|
#else
|
||||||
|
#define CF_RETURNS_RETAINED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NS_INLINE
|
||||||
|
#define NS_INLINE inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
|
||||||
|
{
|
||||||
|
#if __has_feature(objc_arc)
|
||||||
|
return (__bridge_retained CFTypeRef)X;
|
||||||
|
#else
|
||||||
|
return X;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IOS
|
||||||
|
#ifndef __IPHONE_5_0
|
||||||
|
#warning "This project uses features only available in iOS SDK 5.0 and later."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <GLKit/GLKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#include <objc/objc-runtime.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
30
libretro-common/include/compat/fnmatch.h
Normal file
30
libretro-common/include/compat/fnmatch.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (fnmatch.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
||||||
|
|
||||||
|
#define FNM_NOMATCH 1
|
||||||
|
|
||||||
|
int rl_fnmatch(const char *pattern, const char *string, int flags);
|
||||||
|
|
||||||
|
#endif
|
75
libretro-common/include/compat/getopt.h
Normal file
75
libretro-common/include/compat/getopt.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (getopt.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_GETOPT_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_GETOPT_H
|
||||||
|
|
||||||
|
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||||
|
#include "../../../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Custom implementation of the GNU getopt_long for portability.
|
||||||
|
* Not designed to be fully compatible, but compatible with
|
||||||
|
* the features RetroArch uses. */
|
||||||
|
|
||||||
|
#ifdef HAVE_GETOPT_LONG
|
||||||
|
#include <getopt.h>
|
||||||
|
#else
|
||||||
|
/* Avoid possible naming collisions during link since we
|
||||||
|
* prefer to use the actual name. */
|
||||||
|
#define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex)
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
struct option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* argv[] is declared with char * const argv[] in GNU,
|
||||||
|
* but this makes no sense, as non-POSIX getopt_long
|
||||||
|
* mutates argv (non-opts are moved to the end). */
|
||||||
|
int getopt_long(int argc, char *argv[],
|
||||||
|
const char *optstring, const struct option *longopts, int *longindex);
|
||||||
|
extern char *optarg;
|
||||||
|
extern int optind, opterr, optopt;
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
/* If these are variously #defined, then we have bigger problems */
|
||||||
|
#ifndef no_argument
|
||||||
|
#define no_argument 0
|
||||||
|
#define required_argument 1
|
||||||
|
#define optional_argument 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* HAVE_GETOPT_LONG */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* pragma once */
|
||||||
|
#endif
|
||||||
|
|
53
libretro-common/include/compat/ifaddrs.h
Normal file
53
libretro-common/include/compat/ifaddrs.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1995, 1999
|
||||||
|
* Berkeley Software Design, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _IFADDRS_H_
|
||||||
|
#define _IFADDRS_H_
|
||||||
|
|
||||||
|
struct ifaddrs
|
||||||
|
{
|
||||||
|
struct ifaddrs *ifa_next;
|
||||||
|
char *ifa_name;
|
||||||
|
unsigned int ifa_flags;
|
||||||
|
struct sockaddr *ifa_addr;
|
||||||
|
struct sockaddr *ifa_netmask;
|
||||||
|
struct sockaddr *ifa_dstaddr;
|
||||||
|
void *ifa_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
|
||||||
|
* to be included it must be included before this header file.
|
||||||
|
*/
|
||||||
|
#ifndef ifa_broadaddr
|
||||||
|
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
extern int getifaddrs(struct ifaddrs **ifap);
|
||||||
|
extern void freeifaddrs(struct ifaddrs *ifa);
|
||||||
|
|
||||||
|
#endif
|
85
libretro-common/include/compat/intrinsics.h
Normal file
85
libretro-common/include/compat/intrinsics.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (intrinsics.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_INTRINSICS_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_INTRINSICS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
#include <retro_inline.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined(_XBOX)
|
||||||
|
#if (_MSC_VER > 1310)
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Count Leading Zero, unsigned 16bit input value */
|
||||||
|
static INLINE unsigned compat_clz_u16(uint16_t val)
|
||||||
|
{
|
||||||
|
#ifdef __GNUC__
|
||||||
|
return __builtin_clz(val << 16 | 0x8000);
|
||||||
|
#else
|
||||||
|
unsigned ret = 0;
|
||||||
|
|
||||||
|
while(!(val & 0x8000) && ret < 16)
|
||||||
|
{
|
||||||
|
val <<= 1;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Count Trailing Zero */
|
||||||
|
static INLINE int compat_ctz(unsigned x)
|
||||||
|
{
|
||||||
|
#if defined(__GNUC__) && !defined(RARCH_CONSOLE)
|
||||||
|
return __builtin_ctz(x);
|
||||||
|
#elif _MSC_VER >= 1400
|
||||||
|
unsigned long r = 0;
|
||||||
|
_BitScanReverse((unsigned long*)&r, x);
|
||||||
|
return (int)r;
|
||||||
|
#else
|
||||||
|
/* Only checks at nibble granularity,
|
||||||
|
* because that's what we need. */
|
||||||
|
if (x & 0x000f)
|
||||||
|
return 0;
|
||||||
|
if (x & 0x00f0)
|
||||||
|
return 4;
|
||||||
|
if (x & 0x0f00)
|
||||||
|
return 8;
|
||||||
|
if (x & 0xf000)
|
||||||
|
return 12;
|
||||||
|
return 16;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
104
libretro-common/include/compat/msvc.h
Normal file
104
libretro-common/include/compat/msvc.h
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (msvc.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_MSVC_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_MSVC_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */
|
||||||
|
#if _MSC_VER < 1900
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifndef snprintf
|
||||||
|
#define snprintf c99_snprintf_retro__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */
|
||||||
|
#if _MSC_VER < 1600
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifndef vsnprintf
|
||||||
|
#define vsnprintf c99_vsnprintf_retro__
|
||||||
|
#endif
|
||||||
|
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef UNICODE /* Do not bother with UNICODE at this time. */
|
||||||
|
#include <direct.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
|
||||||
|
* Cannot duplicate these efforts.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_SSIZE_T
|
||||||
|
#if defined(_WIN64)
|
||||||
|
typedef __int64 ssize_t;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
typedef int ssize_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define mkdir(dirname, unused) _mkdir(dirname)
|
||||||
|
#define strtoull _strtoui64
|
||||||
|
#undef strcasecmp
|
||||||
|
#define strcasecmp _stricmp
|
||||||
|
#undef strncasecmp
|
||||||
|
#define strncasecmp _strnicmp
|
||||||
|
|
||||||
|
/* Disable some of the annoying warnings. */
|
||||||
|
#pragma warning(disable : 4800)
|
||||||
|
#pragma warning(disable : 4805)
|
||||||
|
#pragma warning(disable : 4244)
|
||||||
|
#pragma warning(disable : 4305)
|
||||||
|
#pragma warning(disable : 4146)
|
||||||
|
#pragma warning(disable : 4267)
|
||||||
|
#pragma warning(disable : 4723)
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
|
/* roundf is available since MSVC 2013 */
|
||||||
|
#if _MSC_VER < 1800
|
||||||
|
#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX _MAX_PATH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIZE_MAX
|
||||||
|
#define SIZE_MAX _UI32_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
254
libretro-common/include/compat/msvc/stdint.h
Normal file
254
libretro-common/include/compat/msvc/stdint.h
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/* ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||||
|
* Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006-2008 Alexander Chemeris
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. The name of the author may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __RARCH_STDINT_H
|
||||||
|
#define __RARCH_STDINT_H
|
||||||
|
|
||||||
|
#if _MSC_VER && (_MSC_VER < 1600)
|
||||||
|
/* Pre-MSVC 2010 needs an implementation of stdint.h. */
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
/* For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||||
|
* compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||||
|
* or compiler give many errors like this:
|
||||||
|
*
|
||||||
|
* error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
# include <wchar.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define _W64 macros to mark types changing their size, like intptr_t. */
|
||||||
|
#ifndef _W64
|
||||||
|
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||||
|
# define _W64 __w64
|
||||||
|
# else
|
||||||
|
# define _W64
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* 7.18.1 Integer types. */
|
||||||
|
|
||||||
|
/* 7.18.1.1 Exact-width integer types. */
|
||||||
|
|
||||||
|
/* Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||||
|
* realize that, e.g. char has the same size as __int8
|
||||||
|
* so we give up on __intX for them.
|
||||||
|
*/
|
||||||
|
#if (_MSC_VER < 1300)
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef signed int int32_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
#else
|
||||||
|
typedef signed __int8 int8_t;
|
||||||
|
typedef signed __int16 int16_t;
|
||||||
|
typedef signed __int32 int32_t;
|
||||||
|
typedef unsigned __int8 uint8_t;
|
||||||
|
typedef unsigned __int16 uint16_t;
|
||||||
|
typedef unsigned __int32 uint32_t;
|
||||||
|
#endif
|
||||||
|
typedef signed __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* 7.18.1.2 Minimum-width integer types. */
|
||||||
|
typedef int8_t int_least8_t;
|
||||||
|
typedef int16_t int_least16_t;
|
||||||
|
typedef int32_t int_least32_t;
|
||||||
|
typedef int64_t int_least64_t;
|
||||||
|
typedef uint8_t uint_least8_t;
|
||||||
|
typedef uint16_t uint_least16_t;
|
||||||
|
typedef uint32_t uint_least32_t;
|
||||||
|
typedef uint64_t uint_least64_t;
|
||||||
|
|
||||||
|
/* 7.18.1.3 Fastest minimum-width integer types. */
|
||||||
|
typedef int8_t int_fast8_t;
|
||||||
|
typedef int16_t int_fast16_t;
|
||||||
|
typedef int32_t int_fast32_t;
|
||||||
|
typedef int64_t int_fast64_t;
|
||||||
|
typedef uint8_t uint_fast8_t;
|
||||||
|
typedef uint16_t uint_fast16_t;
|
||||||
|
typedef uint32_t uint_fast32_t;
|
||||||
|
typedef uint64_t uint_fast64_t;
|
||||||
|
|
||||||
|
/* 7.18.1.4 Integer types capable of holding object pointers. */
|
||||||
|
#ifdef _WIN64 /* [ */
|
||||||
|
typedef signed __int64 intptr_t;
|
||||||
|
typedef unsigned __int64 uintptr_t;
|
||||||
|
#else /* _WIN64 ][ */
|
||||||
|
typedef _W64 signed int intptr_t;
|
||||||
|
typedef _W64 unsigned int uintptr_t;
|
||||||
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
|
/* 7.18.1.5 Greatest-width integer types. */
|
||||||
|
typedef int64_t intmax_t;
|
||||||
|
typedef uint64_t uintmax_t;
|
||||||
|
|
||||||
|
/* 7.18.2 Limits of specified-width integer types. */
|
||||||
|
|
||||||
|
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||||
|
/* [ See footnote 220 at page 257 and footnote 221 at page 259. */
|
||||||
|
|
||||||
|
/* 7.18.2.1 Limits of exact-width integer types. */
|
||||||
|
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||||
|
#define INT8_MAX _I8_MAX
|
||||||
|
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||||
|
#define INT16_MAX _I16_MAX
|
||||||
|
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||||
|
#define INT32_MAX _I32_MAX
|
||||||
|
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||||
|
#define INT64_MAX _I64_MAX
|
||||||
|
#define UINT8_MAX _UI8_MAX
|
||||||
|
#define UINT16_MAX _UI16_MAX
|
||||||
|
#define UINT32_MAX _UI32_MAX
|
||||||
|
#define UINT64_MAX _UI64_MAX
|
||||||
|
|
||||||
|
/* 7.18.2.2 Limits of minimum-width integer types. */
|
||||||
|
#define INT_LEAST8_MIN INT8_MIN
|
||||||
|
#define INT_LEAST8_MAX INT8_MAX
|
||||||
|
#define INT_LEAST16_MIN INT16_MIN
|
||||||
|
#define INT_LEAST16_MAX INT16_MAX
|
||||||
|
#define INT_LEAST32_MIN INT32_MIN
|
||||||
|
#define INT_LEAST32_MAX INT32_MAX
|
||||||
|
#define INT_LEAST64_MIN INT64_MIN
|
||||||
|
#define INT_LEAST64_MAX INT64_MAX
|
||||||
|
#define UINT_LEAST8_MAX UINT8_MAX
|
||||||
|
#define UINT_LEAST16_MAX UINT16_MAX
|
||||||
|
#define UINT_LEAST32_MAX UINT32_MAX
|
||||||
|
#define UINT_LEAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
|
/* 7.18.2.3 Limits of fastest minimum-width integer types. */
|
||||||
|
#define INT_FAST8_MIN INT8_MIN
|
||||||
|
#define INT_FAST8_MAX INT8_MAX
|
||||||
|
#define INT_FAST16_MIN INT16_MIN
|
||||||
|
#define INT_FAST16_MAX INT16_MAX
|
||||||
|
#define INT_FAST32_MIN INT32_MIN
|
||||||
|
#define INT_FAST32_MAX INT32_MAX
|
||||||
|
#define INT_FAST64_MIN INT64_MIN
|
||||||
|
#define INT_FAST64_MAX INT64_MAX
|
||||||
|
#define UINT_FAST8_MAX UINT8_MAX
|
||||||
|
#define UINT_FAST16_MAX UINT16_MAX
|
||||||
|
#define UINT_FAST32_MAX UINT32_MAX
|
||||||
|
#define UINT_FAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
|
/* 7.18.2.4 Limits of integer types capable of holding object pointers. */
|
||||||
|
#ifdef _WIN64 /* [ */
|
||||||
|
# define INTPTR_MIN INT64_MIN
|
||||||
|
# define INTPTR_MAX INT64_MAX
|
||||||
|
# define UINTPTR_MAX UINT64_MAX
|
||||||
|
#else /* _WIN64 ][ */
|
||||||
|
# define INTPTR_MIN INT32_MIN
|
||||||
|
# define INTPTR_MAX INT32_MAX
|
||||||
|
# define UINTPTR_MAX UINT32_MAX
|
||||||
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
|
/* 7.18.2.5 Limits of greatest-width integer types */
|
||||||
|
#define INTMAX_MIN INT64_MIN
|
||||||
|
#define INTMAX_MAX INT64_MAX
|
||||||
|
#define UINTMAX_MAX UINT64_MAX
|
||||||
|
|
||||||
|
/* 7.18.3 Limits of other integer types */
|
||||||
|
|
||||||
|
#ifdef _WIN64 /* [ */
|
||||||
|
# define PTRDIFF_MIN _I64_MIN
|
||||||
|
# define PTRDIFF_MAX _I64_MAX
|
||||||
|
#else /* _WIN64 ][ */
|
||||||
|
# define PTRDIFF_MIN _I32_MIN
|
||||||
|
# define PTRDIFF_MAX _I32_MAX
|
||||||
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
|
#define SIG_ATOMIC_MIN INT_MIN
|
||||||
|
#define SIG_ATOMIC_MAX INT_MAX
|
||||||
|
|
||||||
|
#ifndef SIZE_MAX /* [ */
|
||||||
|
# ifdef _WIN64 /* [ */
|
||||||
|
# define SIZE_MAX _UI64_MAX
|
||||||
|
# else /* _WIN64 ][ */
|
||||||
|
# define SIZE_MAX _UI32_MAX
|
||||||
|
# endif /* _WIN64 ] */
|
||||||
|
#endif /* SIZE_MAX ] */
|
||||||
|
|
||||||
|
/* WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> */
|
||||||
|
#ifndef WCHAR_MIN /* [ */
|
||||||
|
# define WCHAR_MIN 0
|
||||||
|
#endif /* WCHAR_MIN ] */
|
||||||
|
#ifndef WCHAR_MAX // [
|
||||||
|
# define WCHAR_MAX _UI16_MAX
|
||||||
|
#endif /* WCHAR_MAX ] */
|
||||||
|
|
||||||
|
#define WINT_MIN 0
|
||||||
|
#define WINT_MAX _UI16_MAX
|
||||||
|
|
||||||
|
#endif /* __STDC_LIMIT_MACROS ] */
|
||||||
|
|
||||||
|
/* 7.18.4 Limits of other integer types */
|
||||||
|
|
||||||
|
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||||
|
/* [ See footnote 224 at page 260 */
|
||||||
|
|
||||||
|
/* 7.18.4.1 Macros for minimum-width integer constants */
|
||||||
|
|
||||||
|
#define INT8_C(val) val##i8
|
||||||
|
#define INT16_C(val) val##i16
|
||||||
|
#define INT32_C(val) val##i32
|
||||||
|
#define INT64_C(val) val##i64
|
||||||
|
|
||||||
|
#define UINT8_C(val) val##ui8
|
||||||
|
#define UINT16_C(val) val##ui16
|
||||||
|
#define UINT32_C(val) val##ui32
|
||||||
|
#define UINT64_C(val) val##ui64
|
||||||
|
|
||||||
|
/* 7.18.4.2 Macros for greatest-width integer constants */
|
||||||
|
#define INTMAX_C INT64_C
|
||||||
|
#define UINTMAX_C UINT64_C
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* __STDC_CONSTANT_MACROS ] */
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Sanity for everything else. */
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
61
libretro-common/include/compat/posix_string.h
Normal file
61
libretro-common/include/compat/posix_string.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (posix_string.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <compat/msvc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#undef strtok_r
|
||||||
|
#define strtok_r(str, delim, saveptr) retro_strtok_r__(str, delim, saveptr)
|
||||||
|
|
||||||
|
char *strtok_r(char *str, const char *delim, char **saveptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#undef strcasecmp
|
||||||
|
#undef strdup
|
||||||
|
#define strcasecmp(a, b) retro_strcasecmp__(a, b)
|
||||||
|
#define strdup(orig) retro_strdup__(orig)
|
||||||
|
int strcasecmp(const char *a, const char *b);
|
||||||
|
char *strdup(const char *orig);
|
||||||
|
|
||||||
|
/* isblank is available since MSVC 2013 */
|
||||||
|
#if _MSC_VER < 1800
|
||||||
|
#undef isblank
|
||||||
|
#define isblank(c) retro_isblank__(c)
|
||||||
|
int isblank(int c);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
49
libretro-common/include/compat/strcasestr.h
Normal file
49
libretro-common/include/compat/strcasestr.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (strcasestr.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||||
|
#include "../../../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCASESTR
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Avoid possible naming collisions during link
|
||||||
|
* since we prefer to use the actual name. */
|
||||||
|
#define strcasestr(haystack, needle) strcasestr_retro__(haystack, needle)
|
||||||
|
|
||||||
|
char *strcasestr(const char *haystack, const char *needle);
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
58
libretro-common/include/compat/strl.h
Normal file
58
libretro-common/include/compat/strl.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (strl.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_COMPAT_STRL_H
|
||||||
|
#define __LIBRETRO_SDK_COMPAT_STRL_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "../../../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
#ifdef __MACH__
|
||||||
|
#ifndef HAVE_STRL
|
||||||
|
#define HAVE_STRL
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRL
|
||||||
|
/* Avoid possible naming collisions during link since
|
||||||
|
* we prefer to use the actual name. */
|
||||||
|
#define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size)
|
||||||
|
|
||||||
|
#define strlcat(dst, src, size) strlcat_retro__(dst, src, size)
|
||||||
|
|
||||||
|
size_t strlcpy(char *dest, const char *source, size_t size);
|
||||||
|
size_t strlcat(char *dest, const char *source, size_t size);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
483
libretro-common/include/compat/zconf.h
Normal file
483
libretro-common/include/compat/zconf.h
Normal file
@ -0,0 +1,483 @@
|
|||||||
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
|
#ifndef ZCONF_H
|
||||||
|
#define ZCONF_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||||
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
|
*/
|
||||||
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_PREFIX_SET
|
||||||
|
|
||||||
|
/* all linked symbols */
|
||||||
|
# define _dist_code z__dist_code
|
||||||
|
# define _length_code z__length_code
|
||||||
|
# define _tr_align z__tr_align
|
||||||
|
# define _tr_flush_bits z__tr_flush_bits
|
||||||
|
# define _tr_flush_block z__tr_flush_block
|
||||||
|
# define _tr_init z__tr_init
|
||||||
|
# define _tr_stored_block z__tr_stored_block
|
||||||
|
# define _tr_tally z__tr_tally
|
||||||
|
# define adler32 z_adler32
|
||||||
|
# define adler32_combine z_adler32_combine
|
||||||
|
# define adler32_combine64 z_adler32_combine64
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define compress z_compress
|
||||||
|
# define compress2 z_compress2
|
||||||
|
# define compressBound z_compressBound
|
||||||
|
# endif
|
||||||
|
# define crc32 z_crc32
|
||||||
|
# define crc32_combine z_crc32_combine
|
||||||
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define deflate z_deflate
|
||||||
|
# define deflateBound z_deflateBound
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePending z_deflatePending
|
||||||
|
# define deflatePrime z_deflatePrime
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateResetKeep z_deflateResetKeep
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflate_copyright z_deflate_copyright
|
||||||
|
# define get_crc_table z_get_crc_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gz_error z_gz_error
|
||||||
|
# define gz_intmax z_gz_intmax
|
||||||
|
# define gz_strwinerror z_gz_strwinerror
|
||||||
|
# define gzbuffer z_gzbuffer
|
||||||
|
# define gzclearerr z_gzclearerr
|
||||||
|
# define gzclose z_gzclose
|
||||||
|
# define gzclose_r z_gzclose_r
|
||||||
|
# define gzclose_w z_gzclose_w
|
||||||
|
# define gzdirect z_gzdirect
|
||||||
|
# define gzdopen z_gzdopen
|
||||||
|
# define gzeof z_gzeof
|
||||||
|
# define gzerror z_gzerror
|
||||||
|
# define gzflush z_gzflush
|
||||||
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgetc_ z_gzgetc_
|
||||||
|
# define gzgets z_gzgets
|
||||||
|
# define gzoffset z_gzoffset
|
||||||
|
# define gzoffset64 z_gzoffset64
|
||||||
|
# define gzopen z_gzopen
|
||||||
|
# define gzopen64 z_gzopen64
|
||||||
|
# ifdef _WIN32
|
||||||
|
# define gzopen_w z_gzopen_w
|
||||||
|
# endif
|
||||||
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzvprintf z_gzvprintf
|
||||||
|
# define gzputc z_gzputc
|
||||||
|
# define gzputs z_gzputs
|
||||||
|
# define gzread z_gzread
|
||||||
|
# define gzrewind z_gzrewind
|
||||||
|
# define gzseek z_gzseek
|
||||||
|
# define gzseek64 z_gzseek64
|
||||||
|
# define gzsetparams z_gzsetparams
|
||||||
|
# define gztell z_gztell
|
||||||
|
# define gztell64 z_gztell64
|
||||||
|
# define gzungetc z_gzungetc
|
||||||
|
# define gzwrite z_gzwrite
|
||||||
|
# endif
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateBack z_inflateBack
|
||||||
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
# define inflateBackInit_ z_inflateBackInit_
|
||||||
|
# define inflateCopy z_inflateCopy
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define inflateGetHeader z_inflateGetHeader
|
||||||
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflateMark z_inflateMark
|
||||||
|
# define inflatePrime z_inflatePrime
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define inflateReset2 z_inflateReset2
|
||||||
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateGetDictionary z_inflateGetDictionary
|
||||||
|
# define inflateSync z_inflateSync
|
||||||
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
|
# define inflateUndermine z_inflateUndermine
|
||||||
|
# define inflateResetKeep z_inflateResetKeep
|
||||||
|
# define inflate_copyright z_inflate_copyright
|
||||||
|
# define inflate_fast z_inflate_fast
|
||||||
|
# define inflate_table z_inflate_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define uncompress z_uncompress
|
||||||
|
# endif
|
||||||
|
# define zError z_zError
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define zcalloc z_zcalloc
|
||||||
|
# define zcfree z_zcfree
|
||||||
|
# endif
|
||||||
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
|
/* all zlib typedefs in zlib.h and zconf.h */
|
||||||
|
# define Byte z_Byte
|
||||||
|
# define Bytef z_Bytef
|
||||||
|
# define alloc_func z_alloc_func
|
||||||
|
# define charf z_charf
|
||||||
|
# define free_func z_free_func
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gzFile z_gzFile
|
||||||
|
# endif
|
||||||
|
# define gz_header z_gz_header
|
||||||
|
# define gz_headerp z_gz_headerp
|
||||||
|
# define in_func z_in_func
|
||||||
|
# define intf z_intf
|
||||||
|
# define out_func z_out_func
|
||||||
|
# define uInt z_uInt
|
||||||
|
# define uIntf z_uIntf
|
||||||
|
# define uLong z_uLong
|
||||||
|
# define uLongf z_uLongf
|
||||||
|
# define voidp z_voidp
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
|
||||||
|
/* all zlib structs in zlib.h and zconf.h */
|
||||||
|
# define gz_header_s z_gz_header_s
|
||||||
|
# define internal_state z_internal_state
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||||
|
# define OS2
|
||||||
|
#endif
|
||||||
|
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||||
|
# define WINDOWS
|
||||||
|
#endif
|
||||||
|
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||||
|
# ifndef WIN32
|
||||||
|
# define WIN32
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||||
|
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||||
|
# ifndef SYS16BIT
|
||||||
|
# define SYS16BIT
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||||
|
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||||
|
*/
|
||||||
|
#ifdef SYS16BIT
|
||||||
|
# define MAXSEG_64K
|
||||||
|
#endif
|
||||||
|
#ifdef MSDOS
|
||||||
|
# define UNALIGNED_OK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __STDC_VERSION__
|
||||||
|
# ifndef STDC
|
||||||
|
# define STDC
|
||||||
|
# endif
|
||||||
|
# if __STDC_VERSION__ >= 199901L
|
||||||
|
# ifndef STDC99
|
||||||
|
# define STDC99
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDC
|
||||||
|
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||||
|
# define const /* note: need a more gentle solution here */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||||
|
# define z_const const
|
||||||
|
#else
|
||||||
|
# define z_const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some Mac compilers merge all .h files incorrectly: */
|
||||||
|
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||||
|
# define NO_DUMMY_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum value for memLevel in deflateInit2 */
|
||||||
|
#ifndef MAX_MEM_LEVEL
|
||||||
|
# ifdef MAXSEG_64K
|
||||||
|
# define MAX_MEM_LEVEL 8
|
||||||
|
# else
|
||||||
|
# define MAX_MEM_LEVEL 9
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||||
|
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||||
|
* created by gzip. (Files created by minigzip can still be extracted by
|
||||||
|
* gzip.)
|
||||||
|
*/
|
||||||
|
#ifndef MAX_WBITS
|
||||||
|
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The memory requirements for deflate are (in bytes):
|
||||||
|
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||||
|
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||||
|
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||||
|
the default memory requirements from 256K to 128K, compile with
|
||||||
|
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||||
|
Of course this will generally degrade compression (there's no free lunch).
|
||||||
|
|
||||||
|
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||||
|
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||||
|
for small objects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Type declarations */
|
||||||
|
|
||||||
|
#ifndef OF /* function prototypes */
|
||||||
|
# ifdef STDC
|
||||||
|
# define OF(args) args
|
||||||
|
# else
|
||||||
|
# define OF(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||||
|
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# define Z_ARG(args) args
|
||||||
|
# else
|
||||||
|
# define Z_ARG(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||||
|
* model programming (small or medium model with some far allocations).
|
||||||
|
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||||
|
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||||
|
* just define FAR to be empty.
|
||||||
|
*/
|
||||||
|
#ifdef SYS16BIT
|
||||||
|
# if defined(M_I86SM) || defined(M_I86MM)
|
||||||
|
/* MSC small or medium model */
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define FAR _far
|
||||||
|
# else
|
||||||
|
# define FAR far
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||||
|
/* Turbo C small or medium model */
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# ifdef __BORLANDC__
|
||||||
|
# define FAR _far
|
||||||
|
# else
|
||||||
|
# define FAR far
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINDOWS) || defined(WIN32)
|
||||||
|
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||||
|
* This is not mandatory, but it offers a little performance increase.
|
||||||
|
*/
|
||||||
|
# ifdef ZLIB_DLL
|
||||||
|
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||||
|
# ifdef ZLIB_INTERNAL
|
||||||
|
# define ZEXTERN extern __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define ZEXTERN extern __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif /* ZLIB_DLL */
|
||||||
|
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||||
|
* define ZLIB_WINAPI.
|
||||||
|
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||||
|
*/
|
||||||
|
# ifdef ZLIB_WINAPI
|
||||||
|
# ifdef FAR
|
||||||
|
# undef FAR
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FAR
|
||||||
|
# define FAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__MACTYPES__)
|
||||||
|
typedef unsigned char Byte; /* 8 bits */
|
||||||
|
#endif
|
||||||
|
typedef unsigned int uInt; /* 16 bits or more */
|
||||||
|
typedef unsigned long uLong; /* 32 bits or more */
|
||||||
|
|
||||||
|
#ifdef SMALL_MEDIUM
|
||||||
|
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||||
|
# define Bytef Byte FAR
|
||||||
|
#else
|
||||||
|
typedef Byte FAR Bytef;
|
||||||
|
#endif
|
||||||
|
typedef char FAR charf;
|
||||||
|
typedef int FAR intf;
|
||||||
|
typedef uInt FAR uIntf;
|
||||||
|
typedef uLong FAR uLongf;
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
typedef void const *voidpc;
|
||||||
|
typedef void FAR *voidpf;
|
||||||
|
typedef void *voidp;
|
||||||
|
#else
|
||||||
|
typedef Byte const *voidpc;
|
||||||
|
typedef Byte FAR *voidpf;
|
||||||
|
typedef Byte *voidp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (UINT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned
|
||||||
|
# elif (ULONG_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned long
|
||||||
|
# elif (USHRT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned short
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_U4
|
||||||
|
typedef Z_U4 z_crc_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long z_crc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_HAVE_STDARG_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <sys/types.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stdarg.h> /* for va_list */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stddef.h> /* for wchar_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
|
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||||
|
* though the former does not conform to the LFS document), but considering
|
||||||
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
|
* equivalently requesting no 64-bit operations
|
||||||
|
*/
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
|
# undef _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||||
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
|
# ifdef VMS
|
||||||
|
# include <unixio.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
# ifndef z_off_t
|
||||||
|
# define z_off_t off_t
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||||
|
# define Z_LFS64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||||
|
# define Z_LARGE64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||||
|
# define Z_WANT64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||||
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef z_off_t
|
||||||
|
# define z_off_t long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
|
# define z_off64_t off64_t
|
||||||
|
#else
|
||||||
|
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||||
|
# define z_off64_t __int64
|
||||||
|
# else
|
||||||
|
# define z_off64_t z_off_t
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
|
#if defined(__MVS__)
|
||||||
|
#pragma map(deflateInit_,"DEIN")
|
||||||
|
#pragma map(deflateInit2_,"DEIN2")
|
||||||
|
#pragma map(deflateEnd,"DEEND")
|
||||||
|
#pragma map(deflateBound,"DEBND")
|
||||||
|
#pragma map(inflateInit_,"ININ")
|
||||||
|
#pragma map(inflateInit2_,"ININ2")
|
||||||
|
#pragma map(inflateEnd,"INEND")
|
||||||
|
#pragma map(inflateSync,"INSY")
|
||||||
|
#pragma map(inflateSetDictionary,"INSEDI")
|
||||||
|
#pragma map(compressBound,"CMBND")
|
||||||
|
#pragma map(inflate_table,"INTABL")
|
||||||
|
#pragma map(inflate_fast,"INFA")
|
||||||
|
#pragma map(inflate_copyright,"INCOPY")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZCONF_H */
|
483
libretro-common/include/compat/zconf.h.in
Normal file
483
libretro-common/include/compat/zconf.h.in
Normal file
@ -0,0 +1,483 @@
|
|||||||
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
|
#ifndef ZCONF_H
|
||||||
|
#define ZCONF_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||||
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
|
*/
|
||||||
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_PREFIX_SET
|
||||||
|
|
||||||
|
/* all linked symbols */
|
||||||
|
# define _dist_code z__dist_code
|
||||||
|
# define _length_code z__length_code
|
||||||
|
# define _tr_align z__tr_align
|
||||||
|
# define _tr_flush_bits z__tr_flush_bits
|
||||||
|
# define _tr_flush_block z__tr_flush_block
|
||||||
|
# define _tr_init z__tr_init
|
||||||
|
# define _tr_stored_block z__tr_stored_block
|
||||||
|
# define _tr_tally z__tr_tally
|
||||||
|
# define adler32 z_adler32
|
||||||
|
# define adler32_combine z_adler32_combine
|
||||||
|
# define adler32_combine64 z_adler32_combine64
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define compress z_compress
|
||||||
|
# define compress2 z_compress2
|
||||||
|
# define compressBound z_compressBound
|
||||||
|
# endif
|
||||||
|
# define crc32 z_crc32
|
||||||
|
# define crc32_combine z_crc32_combine
|
||||||
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define deflate z_deflate
|
||||||
|
# define deflateBound z_deflateBound
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePending z_deflatePending
|
||||||
|
# define deflatePrime z_deflatePrime
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateResetKeep z_deflateResetKeep
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflate_copyright z_deflate_copyright
|
||||||
|
# define get_crc_table z_get_crc_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gz_error z_gz_error
|
||||||
|
# define gz_intmax z_gz_intmax
|
||||||
|
# define gz_strwinerror z_gz_strwinerror
|
||||||
|
# define gzbuffer z_gzbuffer
|
||||||
|
# define gzclearerr z_gzclearerr
|
||||||
|
# define gzclose z_gzclose
|
||||||
|
# define gzclose_r z_gzclose_r
|
||||||
|
# define gzclose_w z_gzclose_w
|
||||||
|
# define gzdirect z_gzdirect
|
||||||
|
# define gzdopen z_gzdopen
|
||||||
|
# define gzeof z_gzeof
|
||||||
|
# define gzerror z_gzerror
|
||||||
|
# define gzflush z_gzflush
|
||||||
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgetc_ z_gzgetc_
|
||||||
|
# define gzgets z_gzgets
|
||||||
|
# define gzoffset z_gzoffset
|
||||||
|
# define gzoffset64 z_gzoffset64
|
||||||
|
# define gzopen z_gzopen
|
||||||
|
# define gzopen64 z_gzopen64
|
||||||
|
# ifdef _WIN32
|
||||||
|
# define gzopen_w z_gzopen_w
|
||||||
|
# endif
|
||||||
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzvprintf z_gzvprintf
|
||||||
|
# define gzputc z_gzputc
|
||||||
|
# define gzputs z_gzputs
|
||||||
|
# define gzread z_gzread
|
||||||
|
# define gzrewind z_gzrewind
|
||||||
|
# define gzseek z_gzseek
|
||||||
|
# define gzseek64 z_gzseek64
|
||||||
|
# define gzsetparams z_gzsetparams
|
||||||
|
# define gztell z_gztell
|
||||||
|
# define gztell64 z_gztell64
|
||||||
|
# define gzungetc z_gzungetc
|
||||||
|
# define gzwrite z_gzwrite
|
||||||
|
# endif
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateBack z_inflateBack
|
||||||
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
# define inflateBackInit_ z_inflateBackInit_
|
||||||
|
# define inflateCopy z_inflateCopy
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define inflateGetHeader z_inflateGetHeader
|
||||||
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflateMark z_inflateMark
|
||||||
|
# define inflatePrime z_inflatePrime
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define inflateReset2 z_inflateReset2
|
||||||
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateGetDictionary z_inflateGetDictionary
|
||||||
|
# define inflateSync z_inflateSync
|
||||||
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
|
# define inflateUndermine z_inflateUndermine
|
||||||
|
# define inflateResetKeep z_inflateResetKeep
|
||||||
|
# define inflate_copyright z_inflate_copyright
|
||||||
|
# define inflate_fast z_inflate_fast
|
||||||
|
# define inflate_table z_inflate_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define uncompress z_uncompress
|
||||||
|
# endif
|
||||||
|
# define zError z_zError
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define zcalloc z_zcalloc
|
||||||
|
# define zcfree z_zcfree
|
||||||
|
# endif
|
||||||
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
|
/* all zlib typedefs in zlib.h and zconf.h */
|
||||||
|
# define Byte z_Byte
|
||||||
|
# define Bytef z_Bytef
|
||||||
|
# define alloc_func z_alloc_func
|
||||||
|
# define charf z_charf
|
||||||
|
# define free_func z_free_func
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gzFile z_gzFile
|
||||||
|
# endif
|
||||||
|
# define gz_header z_gz_header
|
||||||
|
# define gz_headerp z_gz_headerp
|
||||||
|
# define in_func z_in_func
|
||||||
|
# define intf z_intf
|
||||||
|
# define out_func z_out_func
|
||||||
|
# define uInt z_uInt
|
||||||
|
# define uIntf z_uIntf
|
||||||
|
# define uLong z_uLong
|
||||||
|
# define uLongf z_uLongf
|
||||||
|
# define voidp z_voidp
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
|
||||||
|
/* all zlib structs in zlib.h and zconf.h */
|
||||||
|
# define gz_header_s z_gz_header_s
|
||||||
|
# define internal_state z_internal_state
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||||
|
# define OS2
|
||||||
|
#endif
|
||||||
|
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||||
|
# define WINDOWS
|
||||||
|
#endif
|
||||||
|
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||||
|
# ifndef WIN32
|
||||||
|
# define WIN32
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||||
|
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||||
|
# ifndef SYS16BIT
|
||||||
|
# define SYS16BIT
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||||
|
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||||
|
*/
|
||||||
|
#ifdef SYS16BIT
|
||||||
|
# define MAXSEG_64K
|
||||||
|
#endif
|
||||||
|
#ifdef MSDOS
|
||||||
|
# define UNALIGNED_OK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __STDC_VERSION__
|
||||||
|
# ifndef STDC
|
||||||
|
# define STDC
|
||||||
|
# endif
|
||||||
|
# if __STDC_VERSION__ >= 199901L
|
||||||
|
# ifndef STDC99
|
||||||
|
# define STDC99
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDC
|
||||||
|
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||||
|
# define const /* note: need a more gentle solution here */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||||
|
# define z_const const
|
||||||
|
#else
|
||||||
|
# define z_const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some Mac compilers merge all .h files incorrectly: */
|
||||||
|
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||||
|
# define NO_DUMMY_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum value for memLevel in deflateInit2 */
|
||||||
|
#ifndef MAX_MEM_LEVEL
|
||||||
|
# ifdef MAXSEG_64K
|
||||||
|
# define MAX_MEM_LEVEL 8
|
||||||
|
# else
|
||||||
|
# define MAX_MEM_LEVEL 9
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||||
|
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||||
|
* created by gzip. (Files created by minigzip can still be extracted by
|
||||||
|
* gzip.)
|
||||||
|
*/
|
||||||
|
#ifndef MAX_WBITS
|
||||||
|
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The memory requirements for deflate are (in bytes):
|
||||||
|
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||||
|
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||||
|
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||||
|
the default memory requirements from 256K to 128K, compile with
|
||||||
|
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||||
|
Of course this will generally degrade compression (there's no free lunch).
|
||||||
|
|
||||||
|
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||||
|
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||||
|
for small objects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Type declarations */
|
||||||
|
|
||||||
|
#ifndef OF /* function prototypes */
|
||||||
|
# ifdef STDC
|
||||||
|
# define OF(args) args
|
||||||
|
# else
|
||||||
|
# define OF(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||||
|
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# define Z_ARG(args) args
|
||||||
|
# else
|
||||||
|
# define Z_ARG(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||||
|
* model programming (small or medium model with some far allocations).
|
||||||
|
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||||
|
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||||
|
* just define FAR to be empty.
|
||||||
|
*/
|
||||||
|
#ifdef SYS16BIT
|
||||||
|
# if defined(M_I86SM) || defined(M_I86MM)
|
||||||
|
/* MSC small or medium model */
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define FAR _far
|
||||||
|
# else
|
||||||
|
# define FAR far
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||||
|
/* Turbo C small or medium model */
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# ifdef __BORLANDC__
|
||||||
|
# define FAR _far
|
||||||
|
# else
|
||||||
|
# define FAR far
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINDOWS) || defined(WIN32)
|
||||||
|
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||||
|
* This is not mandatory, but it offers a little performance increase.
|
||||||
|
*/
|
||||||
|
# ifdef ZLIB_DLL
|
||||||
|
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||||
|
# ifdef ZLIB_INTERNAL
|
||||||
|
# define ZEXTERN extern __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define ZEXTERN extern __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif /* ZLIB_DLL */
|
||||||
|
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||||
|
* define ZLIB_WINAPI.
|
||||||
|
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||||
|
*/
|
||||||
|
# ifdef ZLIB_WINAPI
|
||||||
|
# ifdef FAR
|
||||||
|
# undef FAR
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FAR
|
||||||
|
# define FAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__MACTYPES__)
|
||||||
|
typedef unsigned char Byte; /* 8 bits */
|
||||||
|
#endif
|
||||||
|
typedef unsigned int uInt; /* 16 bits or more */
|
||||||
|
typedef unsigned long uLong; /* 32 bits or more */
|
||||||
|
|
||||||
|
#ifdef SMALL_MEDIUM
|
||||||
|
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||||
|
# define Bytef Byte FAR
|
||||||
|
#else
|
||||||
|
typedef Byte FAR Bytef;
|
||||||
|
#endif
|
||||||
|
typedef char FAR charf;
|
||||||
|
typedef int FAR intf;
|
||||||
|
typedef uInt FAR uIntf;
|
||||||
|
typedef uLong FAR uLongf;
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
typedef void const *voidpc;
|
||||||
|
typedef void FAR *voidpf;
|
||||||
|
typedef void *voidp;
|
||||||
|
#else
|
||||||
|
typedef Byte const *voidpc;
|
||||||
|
typedef Byte FAR *voidpf;
|
||||||
|
typedef Byte *voidp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (UINT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned
|
||||||
|
# elif (ULONG_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned long
|
||||||
|
# elif (USHRT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned short
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_U4
|
||||||
|
typedef Z_U4 z_crc_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long z_crc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_HAVE_STDARG_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <sys/types.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stdarg.h> /* for va_list */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stddef.h> /* for wchar_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
|
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||||
|
* though the former does not conform to the LFS document), but considering
|
||||||
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
|
* equivalently requesting no 64-bit operations
|
||||||
|
*/
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
|
# undef _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||||
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
|
# ifdef VMS
|
||||||
|
# include <unixio.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
# ifndef z_off_t
|
||||||
|
# define z_off_t off_t
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||||
|
# define Z_LFS64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||||
|
# define Z_LARGE64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||||
|
# define Z_WANT64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||||
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef z_off_t
|
||||||
|
# define z_off_t long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
|
# define z_off64_t off64_t
|
||||||
|
#else
|
||||||
|
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||||
|
# define z_off64_t __int64
|
||||||
|
# else
|
||||||
|
# define z_off64_t z_off_t
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
|
#if defined(__MVS__)
|
||||||
|
#pragma map(deflateInit_,"DEIN")
|
||||||
|
#pragma map(deflateInit2_,"DEIN2")
|
||||||
|
#pragma map(deflateEnd,"DEEND")
|
||||||
|
#pragma map(deflateBound,"DEBND")
|
||||||
|
#pragma map(inflateInit_,"ININ")
|
||||||
|
#pragma map(inflateInit2_,"ININ2")
|
||||||
|
#pragma map(inflateEnd,"INEND")
|
||||||
|
#pragma map(inflateSync,"INSY")
|
||||||
|
#pragma map(inflateSetDictionary,"INSEDI")
|
||||||
|
#pragma map(compressBound,"CMBND")
|
||||||
|
#pragma map(inflate_table,"INTABL")
|
||||||
|
#pragma map(inflate_fast,"INFA")
|
||||||
|
#pragma map(inflate_copyright,"INCOPY")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZCONF_H */
|
1780
libretro-common/include/compat/zlib.h
Normal file
1780
libretro-common/include/compat/zlib.h
Normal file
File diff suppressed because it is too large
Load Diff
253
libretro-common/include/compat/zutil.h
Normal file
253
libretro-common/include/compat/zutil.h
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
#ifndef _COMPAT_ZUTIL_H
|
||||||
|
#define _COMPAT_ZUTIL_H
|
||||||
|
|
||||||
|
#ifdef WANT_ZLIB
|
||||||
|
|
||||||
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WARNING: this file should *not* be used by applications. It is
|
||||||
|
part of the implementation of the compression library and is
|
||||||
|
subject to change. Applications should only use zlib.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
|
#ifndef ZUTIL_H
|
||||||
|
#define ZUTIL_H
|
||||||
|
|
||||||
|
#ifdef HAVE_HIDDEN
|
||||||
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
|
#else
|
||||||
|
# define ZLIB_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <compat/zlib.h>
|
||||||
|
|
||||||
|
#if defined(STDC) && !defined(Z_SOLO)
|
||||||
|
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||||
|
# include <stddef.h>
|
||||||
|
# endif
|
||||||
|
# include <string.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef local
|
||||||
|
# define local static
|
||||||
|
#endif
|
||||||
|
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||||
|
|
||||||
|
typedef unsigned char uch;
|
||||||
|
typedef uch FAR uchf;
|
||||||
|
typedef unsigned short ush;
|
||||||
|
typedef ush FAR ushf;
|
||||||
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
|
extern char z_errmsg[10][21]; /* indexed by 2-zlib_error */
|
||||||
|
/* (array size given to avoid silly warnings with Visual C++) */
|
||||||
|
/* (array entry size given to avoid silly string cast warnings) */
|
||||||
|
|
||||||
|
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||||
|
|
||||||
|
#define ERR_RETURN(strm,err) \
|
||||||
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
|
/* To be used only when the state is known to be valid */
|
||||||
|
|
||||||
|
/* common constants */
|
||||||
|
|
||||||
|
#ifndef DEF_WBITS
|
||||||
|
# define DEF_WBITS MAX_WBITS
|
||||||
|
#endif
|
||||||
|
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||||
|
|
||||||
|
#if MAX_MEM_LEVEL >= 8
|
||||||
|
# define DEF_MEM_LEVEL 8
|
||||||
|
#else
|
||||||
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
|
#endif
|
||||||
|
/* default memLevel */
|
||||||
|
|
||||||
|
#define STORED_BLOCK 0
|
||||||
|
#define STATIC_TREES 1
|
||||||
|
#define DYN_TREES 2
|
||||||
|
/* The three kinds of block type */
|
||||||
|
|
||||||
|
#define MIN_MATCH 3
|
||||||
|
#define MAX_MATCH 258
|
||||||
|
/* The minimum and maximum match lengths */
|
||||||
|
|
||||||
|
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||||
|
|
||||||
|
/* target dependencies */
|
||||||
|
|
||||||
|
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||||
|
# define OS_CODE 0x00
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||||
|
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||||
|
/* Allow compilation with ANSI keywords only enabled */
|
||||||
|
void _Cdecl farfree( void *block );
|
||||||
|
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||||
|
# else
|
||||||
|
# include <alloc.h>
|
||||||
|
# endif
|
||||||
|
# else /* MSC or DJGPP */
|
||||||
|
# include <malloc.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef AMIGA
|
||||||
|
# define OS_CODE 0x01
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VAXC) || defined(VMS)
|
||||||
|
# define OS_CODE 0x02
|
||||||
|
# define F_OPEN(name, mode) \
|
||||||
|
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ATARI) || defined(atarist)
|
||||||
|
# define OS_CODE 0x05
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OS2
|
||||||
|
# define OS_CODE 0x06
|
||||||
|
# if defined(M_I86) && !defined(Z_SOLO)
|
||||||
|
# include <malloc.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||||
|
# define OS_CODE 0x07
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||||
|
# include <unix.h> /* for fdopen */
|
||||||
|
# else
|
||||||
|
# ifndef fdopen
|
||||||
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOPS20
|
||||||
|
# define OS_CODE 0x0a
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
||||||
|
# define OS_CODE 0x0b
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||||
|
# define OS_CODE 0x0f
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BEOS_) || defined(RISCOS)
|
||||||
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||||
|
# if defined(_WIN32_WCE)
|
||||||
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
|
# ifndef _PTRDIFF_T_DEFINED
|
||||||
|
typedef int ptrdiff_t;
|
||||||
|
# define _PTRDIFF_T_DEFINED
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define fdopen(fd,type) _fdopen(fd,type)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||||
|
#pragma warn -8004
|
||||||
|
#pragma warn -8008
|
||||||
|
#pragma warn -8066
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
|
#if !defined(_WIN32) && \
|
||||||
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
|
uLong adler32_combine64 (uLong, uLong, z_off_t);
|
||||||
|
uLong crc32_combine64 (uLong, uLong, z_off_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* common defaults */
|
||||||
|
|
||||||
|
#ifndef OS_CODE
|
||||||
|
# define OS_CODE 0x03 /* assume Unix */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef F_OPEN
|
||||||
|
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
|
||||||
|
#if defined(pyr) || defined(Z_SOLO)
|
||||||
|
# define NO_MEMCPY
|
||||||
|
#endif
|
||||||
|
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||||
|
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||||
|
* You may have to use the same strategy for Borland C (untested).
|
||||||
|
* The __SC__ check is for Symantec.
|
||||||
|
*/
|
||||||
|
# define NO_MEMCPY
|
||||||
|
#endif
|
||||||
|
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||||
|
# define HAVE_MEMCPY
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MEMCPY
|
||||||
|
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||||
|
# define zmemcpy _fmemcpy
|
||||||
|
# define zmemcmp _fmemcmp
|
||||||
|
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||||
|
# else
|
||||||
|
# define zmemcpy memcpy
|
||||||
|
# define zmemcmp memcmp
|
||||||
|
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
void ZLIB_INTERNAL zmemcpy (Bytef* dest, const Bytef* source, uInt len);
|
||||||
|
int ZLIB_INTERNAL zmemcmp (const Bytef* s1, const Bytef* s2, uInt len);
|
||||||
|
void ZLIB_INTERNAL zmemzero (Bytef* dest, uInt len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Diagnostic functions */
|
||||||
|
# define Assert(cond,msg)
|
||||||
|
# define Trace(x)
|
||||||
|
# define Tracev(x)
|
||||||
|
# define Tracevv(x)
|
||||||
|
# define Tracec(c,x)
|
||||||
|
# define Tracecv(c,x)
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items,
|
||||||
|
unsigned size);
|
||||||
|
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ZALLOC(strm, items, size) \
|
||||||
|
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||||
|
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||||
|
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||||
|
|
||||||
|
/* Reverse the bytes in a 32-bit value */
|
||||||
|
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||||
|
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||||
|
|
||||||
|
#endif /* ZUTIL_H */
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <zutil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
49
libretro-common/include/memmap.h
Normal file
49
libretro-common/include/memmap.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (memmap.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBRETRO_MEMMAP_H
|
||||||
|
#define _LIBRETRO_MEMMAP_H
|
||||||
|
|
||||||
|
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU)
|
||||||
|
/* No mman available */
|
||||||
|
#elif defined(_WIN32) && !defined(_XBOX)
|
||||||
|
#include <windows.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#define HAVE_MMAN
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_MMAN) || defined(_WIN32)
|
||||||
|
void* mmap(void *addr, size_t len, int mmap_prot, int mmap_flags, int fildes, size_t off);
|
||||||
|
|
||||||
|
int munmap(void *addr, size_t len);
|
||||||
|
|
||||||
|
int mprotect(void *addr, size_t len, int prot);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int memsync(void *start, void *end);
|
||||||
|
|
||||||
|
int memprotect(void *addr, size_t len);
|
||||||
|
|
||||||
|
#endif
|
37
libretro-common/include/retro_common.h
Normal file
37
libretro-common/include/retro_common.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (retro_common.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_H
|
||||||
|
#define _LIBRETRO_COMMON_RETRO_COMMON_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is designed to normalize the libretro-common compiling environment.
|
||||||
|
It is not to be used in public API headers, as they should be designed as leanly as possible.
|
||||||
|
Nonetheless.. in the meantime, if you do something like use ssize_t, which is not fully portable,
|
||||||
|
in a public API, you may need this.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* conditional compilation is handled inside here */
|
||||||
|
#include <compat/msvc.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
108
libretro-common/include/retro_common_api.h
Normal file
108
libretro-common/include/retro_common_api.h
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (retro_common_api.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_API_H
|
||||||
|
#define _LIBRETRO_COMMON_RETRO_COMMON_API_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is designed to normalize the libretro-common 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
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define RETRO_BEGIN_DECLS
|
||||||
|
#define RETRO_END_DECLS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#ifdef CXX_BUILD
|
||||||
|
/* build wants everything to be built as c++, so no extern "C" */
|
||||||
|
#else
|
||||||
|
#undef RETRO_BEGIN_DECLS
|
||||||
|
#undef RETRO_END_DECLS
|
||||||
|
#define RETRO_BEGIN_DECLS extern "C" {
|
||||||
|
#define RETRO_END_DECLS }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* header is included by a C source file, so no extern "C" */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
IMO, this non-standard ssize_t should not be used.
|
||||||
|
However, it's a good example of how to handle something like this.
|
||||||
|
*/
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifndef HAVE_SSIZE_T
|
||||||
|
#define HAVE_SSIZE_T
|
||||||
|
#if defined(_WIN64)
|
||||||
|
typedef __int64 ssize_t;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
typedef int ssize_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#elif defined(__MACH__)
|
||||||
|
#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) && !defined(WIIU)
|
||||||
|
#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"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
I would like to see retro_inline.h moved in here; possibly boolean too.
|
||||||
|
|
||||||
|
rationale: these are used in public APIs, and it is easier to find problems
|
||||||
|
and write code that works the first time portably when theyre included uniformly
|
||||||
|
than to do the analysis from scratch each time you think you need it, for each feature.
|
||||||
|
|
||||||
|
Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h,
|
||||||
|
then you should pay the price everywhere, so you can see how much grief it will cause.
|
||||||
|
|
||||||
|
Of course, another school of thought is that you should do as little damage as possible
|
||||||
|
in as few places as possible...
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* _LIBRETRO_COMMON_RETRO_COMMON_API_H */
|
||||||
|
#endif
|
39
libretro-common/include/retro_inline.h
Normal file
39
libretro-common/include/retro_inline.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (retro_inline.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_INLINE_H
|
||||||
|
#define __LIBRETRO_SDK_INLINE_H
|
||||||
|
|
||||||
|
#ifndef INLINE
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__INTEL_COMPILER)
|
||||||
|
#define INLINE __inline
|
||||||
|
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
||||||
|
#define INLINE inline
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define INLINE __inline__
|
||||||
|
#else
|
||||||
|
#define INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
216
libretro-common/include/retro_miscellaneous.h
Normal file
216
libretro-common/include/retro_miscellaneous.h
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (retro_miscellaneous.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __RARCH_MISCELLANEOUS_H
|
||||||
|
#define __RARCH_MISCELLANEOUS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||||
|
#include <sys/timer.h>
|
||||||
|
#elif defined(XENON)
|
||||||
|
#include <time/time.h>
|
||||||
|
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||||
|
#include <unistd.h>
|
||||||
|
#elif defined(WIIU)
|
||||||
|
#include <wiiu/os/thread.h>
|
||||||
|
#elif defined(PSP)
|
||||||
|
#include <pspthreadman.h>
|
||||||
|
#elif defined(VITA)
|
||||||
|
#include <psp2/kernel/threadmgr.h>
|
||||||
|
#elif defined(_3DS)
|
||||||
|
#include <3ds.h>
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#elif defined(_WIN32) && defined(_XBOX)
|
||||||
|
#include <Xtl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <compat/msvc.h>
|
||||||
|
#endif
|
||||||
|
#include <retro_inline.h>
|
||||||
|
|
||||||
|
#ifndef PATH_MAX_LENGTH
|
||||||
|
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)|| defined(WIIU)
|
||||||
|
#define PATH_MAX_LENGTH 512
|
||||||
|
#else
|
||||||
|
#define PATH_MAX_LENGTH 4096
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#if !defined(_MSC_VER) && !defined(USE_MATH_DEFINES)
|
||||||
|
#define M_PI 3.14159265358979323846264338327
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
|
#ifdef DJGPP
|
||||||
|
#define timespec timeval
|
||||||
|
#define tv_nsec tv_usec
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
||||||
|
|
||||||
|
static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp)
|
||||||
|
{
|
||||||
|
usleep(1000000 * rqtp->tv_sec + rqtp->tv_nsec / 1000);
|
||||||
|
|
||||||
|
if (rmtp)
|
||||||
|
rmtp->tv_sec = rmtp->tv_nsec=0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define nanosleep nanosleepDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retro_sleep:
|
||||||
|
* @msec : amount in milliseconds to sleep
|
||||||
|
*
|
||||||
|
* Sleeps for a specified amount of milliseconds (@msec).
|
||||||
|
**/
|
||||||
|
static INLINE void retro_sleep(unsigned msec)
|
||||||
|
{
|
||||||
|
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||||
|
sys_timer_usleep(1000 * msec);
|
||||||
|
#elif defined(PSP) || defined(VITA)
|
||||||
|
sceKernelDelayThread(1000 * msec);
|
||||||
|
#elif defined(_3DS)
|
||||||
|
svcSleepThread(1000000 * (s64)msec);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
Sleep(msec);
|
||||||
|
#elif defined(XENON)
|
||||||
|
udelay(1000 * msec);
|
||||||
|
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||||
|
usleep(1000 * msec);
|
||||||
|
#elif defined(WIIU)
|
||||||
|
OSSleepTicks(ms_to_ticks(msec));
|
||||||
|
#else
|
||||||
|
struct timespec tv = {0};
|
||||||
|
tv.tv_sec = msec / 1000;
|
||||||
|
tv.tv_nsec = (msec % 1000) * 1000000;
|
||||||
|
nanosleep(&tv, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* next_pow2:
|
||||||
|
* @v : initial value
|
||||||
|
*
|
||||||
|
* Get next power of 2 value based on initial value.
|
||||||
|
*
|
||||||
|
* Returns: next power of 2 value (derived from @v).
|
||||||
|
**/
|
||||||
|
static INLINE uint32_t next_pow2(uint32_t v)
|
||||||
|
{
|
||||||
|
v--;
|
||||||
|
v |= v >> 1;
|
||||||
|
v |= v >> 2;
|
||||||
|
v |= v >> 4;
|
||||||
|
v |= v >> 8;
|
||||||
|
v |= v >> 16;
|
||||||
|
v++;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prev_pow2:
|
||||||
|
* @v : initial value
|
||||||
|
*
|
||||||
|
* Get previous power of 2 value based on initial value.
|
||||||
|
*
|
||||||
|
* Returns: previous power of 2 value (derived from @v).
|
||||||
|
**/
|
||||||
|
static INLINE uint32_t prev_pow2(uint32_t v)
|
||||||
|
{
|
||||||
|
v |= v >> 1;
|
||||||
|
v |= v >> 2;
|
||||||
|
v |= v >> 4;
|
||||||
|
v |= v >> 8;
|
||||||
|
v |= v >> 16;
|
||||||
|
return v - (v >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE uint32_t read_le(const uint8_t *data, unsigned size)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
uint32_t val = 0;
|
||||||
|
|
||||||
|
size *= 8;
|
||||||
|
for (i = 0; i < size; i += 8)
|
||||||
|
val |= (uint32_t)*data++ << i;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Helper macros and struct to keep track of many booleans.
|
||||||
|
* To check for multiple bits, use &&, not &.
|
||||||
|
* For OR, | can be used. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t data[8];
|
||||||
|
} retro_bits_t;
|
||||||
|
|
||||||
|
#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 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_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_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_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));
|
||||||
|
|
||||||
|
#endif
|
90
libretro-common/include/streams/file_stream.h
Normal file
90
libretro-common/include/streams/file_stream.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (file_stream.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_FILE_STREAM_H
|
||||||
|
#define __LIBRETRO_SDK_FILE_STREAM_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <retro_common_api.h>
|
||||||
|
#include <boolean.h>
|
||||||
|
|
||||||
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct RFILE RFILE;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RFILE_MODE_READ = 0,
|
||||||
|
RFILE_MODE_READ_TEXT,
|
||||||
|
RFILE_MODE_WRITE,
|
||||||
|
RFILE_MODE_READ_WRITE,
|
||||||
|
|
||||||
|
/* There is no garantee these requests will be attended. */
|
||||||
|
RFILE_HINT_UNBUFFERED = 1<<8,
|
||||||
|
RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
|
||||||
|
};
|
||||||
|
|
||||||
|
long long int filestream_get_size(RFILE *stream);
|
||||||
|
|
||||||
|
void filestream_set_size(RFILE *stream);
|
||||||
|
|
||||||
|
const char *filestream_get_ext(RFILE *stream);
|
||||||
|
|
||||||
|
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len);
|
||||||
|
|
||||||
|
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence);
|
||||||
|
|
||||||
|
ssize_t filestream_read(RFILE *stream, void *data, size_t len);
|
||||||
|
|
||||||
|
ssize_t filestream_write(RFILE *stream, const void *data, size_t len);
|
||||||
|
|
||||||
|
ssize_t filestream_tell(RFILE *stream);
|
||||||
|
|
||||||
|
void filestream_rewind(RFILE *stream);
|
||||||
|
|
||||||
|
int filestream_close(RFILE *stream);
|
||||||
|
|
||||||
|
int filestream_read_file(const char *path, void **buf, ssize_t *len);
|
||||||
|
|
||||||
|
char *filestream_gets(RFILE *stream, char *s, size_t len);
|
||||||
|
|
||||||
|
char *filestream_getline(RFILE *stream);
|
||||||
|
|
||||||
|
int filestream_getc(RFILE *stream);
|
||||||
|
|
||||||
|
int filestream_eof(RFILE *stream);
|
||||||
|
|
||||||
|
bool filestream_write_file(const char *path, const void *data, ssize_t size);
|
||||||
|
|
||||||
|
int filestream_putc(RFILE *stream, int c);
|
||||||
|
|
||||||
|
int filestream_get_fd(RFILE *stream);
|
||||||
|
|
||||||
|
int filestream_flush(RFILE *stream);
|
||||||
|
|
||||||
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
162
libretro-common/memmap/memmap.c
Normal file
162
libretro-common/memmap/memmap.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (memmap.c).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <memmap.h>
|
||||||
|
|
||||||
|
#ifndef PROT_READ
|
||||||
|
#define PROT_READ 0x1 /* Page can be read */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROT_WRITE
|
||||||
|
#define PROT_WRITE 0x2 /* Page can be written. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROT_READWRITE
|
||||||
|
#define PROT_READWRITE 0x3 /* Page can be written to and read from. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROT_EXEC
|
||||||
|
#define PROT_EXEC 0x4 /* Page can be executed. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROT_NONE
|
||||||
|
#define PROT_NONE 0x0 /* Page can not be accessed. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_FAILED
|
||||||
|
#define MAP_FAILED ((void *) -1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, size_t offset)
|
||||||
|
{
|
||||||
|
void *map = (void*)NULL;
|
||||||
|
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
|
switch (prot)
|
||||||
|
{
|
||||||
|
case PROT_READ:
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
handle = CreateFileMapping((HANDLE) _get_osfhandle(fildes), 0, PAGE_READONLY, 0,
|
||||||
|
len, 0);
|
||||||
|
if (!handle)
|
||||||
|
break;
|
||||||
|
map = (void*)MapViewOfFile(handle, FILE_MAP_READ, 0, 0, len);
|
||||||
|
CloseHandle(handle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PROT_WRITE:
|
||||||
|
{
|
||||||
|
handle = CreateFileMapping((HANDLE) _get_osfhandle(fildes),0,PAGE_READWRITE,0,
|
||||||
|
len, 0);
|
||||||
|
if (!handle)
|
||||||
|
break;
|
||||||
|
map = (void*)MapViewOfFile(handle, FILE_MAP_WRITE, 0, 0, len);
|
||||||
|
CloseHandle(handle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PROT_READWRITE:
|
||||||
|
{
|
||||||
|
handle = CreateFileMapping((HANDLE) _get_osfhandle(fildes),0,PAGE_READWRITE,0,
|
||||||
|
len, 0);
|
||||||
|
if (!handle)
|
||||||
|
break;
|
||||||
|
map = (void*)MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, len);
|
||||||
|
CloseHandle(handle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map == (void*)NULL)
|
||||||
|
return((void*)MAP_FAILED);
|
||||||
|
return((void*) ((int8_t*)map + offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
int munmap(void *addr, size_t length)
|
||||||
|
{
|
||||||
|
if (!UnmapViewOfFile(addr))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mprotect(void *addr, size_t len, int prot)
|
||||||
|
{
|
||||||
|
/* Incomplete, just assumes PAGE_EXECUTE_READWRITE right now
|
||||||
|
* instead of correctly handling prot */
|
||||||
|
prot = 0;
|
||||||
|
if (prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
|
||||||
|
prot = PAGE_EXECUTE_READWRITE;
|
||||||
|
return VirtualProtect(addr, len, prot, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif !defined(HAVE_MMAN)
|
||||||
|
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, size_t offset)
|
||||||
|
{
|
||||||
|
return malloc(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int munmap(void *addr, size_t len)
|
||||||
|
{
|
||||||
|
free(addr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mprotect(void *addr, size_t len, int prot)
|
||||||
|
{
|
||||||
|
/* stub - not really needed at this point since this codepath has no dynarecs */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MACH__) && defined(__arm__)
|
||||||
|
#include <libkern/OSCacheControl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int memsync(void *start, void *end)
|
||||||
|
{
|
||||||
|
size_t len = (char*)end - (char*)start;
|
||||||
|
#if defined(__MACH__) && defined(__arm__)
|
||||||
|
sys_dcache_flush(start ,len);
|
||||||
|
sys_icache_invalidate(start, len);
|
||||||
|
return 0;
|
||||||
|
#elif defined(__arm__) && !defined(__QNX__)
|
||||||
|
(void)len;
|
||||||
|
__clear_cache(start, end);
|
||||||
|
return 0;
|
||||||
|
#elif defined(HAVE_MMAN)
|
||||||
|
return msync(start, len, MS_SYNC | MS_INVALIDATE
|
||||||
|
#ifdef __QNX__
|
||||||
|
MS_CACHE_ONLY
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
(void)len;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int memprotect(void *addr, size_t len)
|
||||||
|
{
|
||||||
|
return mprotect(addr, len, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||||
|
}
|
660
libretro-common/streams/file_stream.c
Normal file
660
libretro-common/streams/file_stream.c
Normal file
@ -0,0 +1,660 @@
|
|||||||
|
/* Copyright (C) 2010-2017 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (file_stream.c).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define setmode _setmode
|
||||||
|
# endif
|
||||||
|
# ifdef _XBOX
|
||||||
|
# include <xtl.h>
|
||||||
|
# define INVALID_FILE_ATTRIBUTES -1
|
||||||
|
# else
|
||||||
|
# include <io.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <direct.h>
|
||||||
|
# include <windows.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined(PSP)
|
||||||
|
# include <pspiofilemgr.h>
|
||||||
|
# endif
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# if !defined(VITA)
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __CELLOS_LV2__
|
||||||
|
#include <cell/cell_fs.h>
|
||||||
|
#define O_RDONLY CELL_FS_O_RDONLY
|
||||||
|
#define O_WRONLY CELL_FS_O_WRONLY
|
||||||
|
#define O_CREAT CELL_FS_O_CREAT
|
||||||
|
#define O_TRUNC CELL_FS_O_TRUNC
|
||||||
|
#define O_RDWR CELL_FS_O_RDWR
|
||||||
|
#else
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <streams/file_stream.h>
|
||||||
|
#include <memmap.h>
|
||||||
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
|
struct RFILE
|
||||||
|
{
|
||||||
|
unsigned hints;
|
||||||
|
char *ext;
|
||||||
|
long long int size;
|
||||||
|
#if defined(PSP)
|
||||||
|
SceUID fd;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define HAVE_BUFFERED_IO 1
|
||||||
|
|
||||||
|
#define MODE_STR_READ "r"
|
||||||
|
#define MODE_STR_READ_UNBUF "rb"
|
||||||
|
#define MODE_STR_WRITE_UNBUF "wb"
|
||||||
|
#define MODE_STR_WRITE_PLUS "w+"
|
||||||
|
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
FILE *fp;
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_MMAP)
|
||||||
|
uint8_t *mapped;
|
||||||
|
uint64_t mappos;
|
||||||
|
uint64_t mapsize;
|
||||||
|
#endif
|
||||||
|
int fd;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
int filestream_get_fd(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return -1;
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
return fileno(stream->fp);
|
||||||
|
#endif
|
||||||
|
return stream->fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *filestream_get_ext(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return NULL;
|
||||||
|
return stream->ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long int filestream_get_size(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return 0;
|
||||||
|
return stream->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void filestream_set_size(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return;
|
||||||
|
|
||||||
|
filestream_seek(stream, 0, SEEK_SET);
|
||||||
|
filestream_seek(stream, 0, SEEK_END);
|
||||||
|
|
||||||
|
stream->size = filestream_tell(stream);
|
||||||
|
|
||||||
|
filestream_seek(stream, 0, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||||
|
{
|
||||||
|
int flags = 0;
|
||||||
|
int mode_int = 0;
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
const char *mode_str = NULL;
|
||||||
|
#endif
|
||||||
|
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));
|
||||||
|
|
||||||
|
if (!stream)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
(void)mode_int;
|
||||||
|
(void)flags;
|
||||||
|
|
||||||
|
stream->hints = mode;
|
||||||
|
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (stream->hints & RFILE_HINT_MMAP && (stream->hints & 0xff) == RFILE_MODE_READ)
|
||||||
|
stream->hints |= RFILE_HINT_UNBUFFERED;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
stream->hints &= ~RFILE_HINT_MMAP;
|
||||||
|
|
||||||
|
switch (mode & 0xff)
|
||||||
|
{
|
||||||
|
case RFILE_MODE_READ_TEXT:
|
||||||
|
#if defined(PSP)
|
||||||
|
mode_int = 0666;
|
||||||
|
flags = PSP_O_RDONLY;
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
mode_str = MODE_STR_READ;
|
||||||
|
#endif
|
||||||
|
/* No "else" here */
|
||||||
|
flags = O_RDONLY;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case RFILE_MODE_READ:
|
||||||
|
#if defined(PSP)
|
||||||
|
mode_int = 0666;
|
||||||
|
flags = PSP_O_RDONLY;
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
mode_str = MODE_STR_READ_UNBUF;
|
||||||
|
#endif
|
||||||
|
/* No "else" here */
|
||||||
|
flags = O_RDONLY;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case RFILE_MODE_WRITE:
|
||||||
|
#if defined(PSP)
|
||||||
|
mode_int = 0666;
|
||||||
|
flags = PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC;
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
mode_str = MODE_STR_WRITE_UNBUF;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
|
#ifndef _WIN32
|
||||||
|
flags |= S_IRUSR | S_IWUSR;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case RFILE_MODE_READ_WRITE:
|
||||||
|
#if defined(PSP)
|
||||||
|
mode_int = 0666;
|
||||||
|
flags = PSP_O_RDWR;
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
mode_str = MODE_STR_WRITE_PLUS;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flags = O_RDWR;
|
||||||
|
#ifdef _WIN32
|
||||||
|
flags |= O_BINARY;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PSP)
|
||||||
|
stream->fd = sceIoOpen(path, flags, mode_int);
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str)
|
||||||
|
{
|
||||||
|
stream->fp = fopen(path, mode_str);
|
||||||
|
if (!stream->fp)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* FIXME: HAVE_BUFFERED_IO is always 1, but if it is ever changed, open() needs to be changed to _wopen() for WIndows. */
|
||||||
|
stream->fd = open(path, flags, mode_int);
|
||||||
|
if (stream->fd == -1)
|
||||||
|
goto error;
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (stream->hints & RFILE_HINT_MMAP)
|
||||||
|
{
|
||||||
|
stream->mappos = 0;
|
||||||
|
stream->mapped = NULL;
|
||||||
|
stream->mapsize = filestream_seek(stream, 0, SEEK_END);
|
||||||
|
|
||||||
|
if (stream->mapsize == (uint64_t)-1)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
filestream_rewind(stream);
|
||||||
|
|
||||||
|
stream->mapped = (uint8_t*)mmap((void*)0,
|
||||||
|
stream->mapsize, PROT_READ, MAP_SHARED, stream->fd, 0);
|
||||||
|
|
||||||
|
if (stream->mapped == MAP_FAILED)
|
||||||
|
stream->hints &= ~RFILE_HINT_MMAP;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PSP)
|
||||||
|
if (stream->fd == -1)
|
||||||
|
goto error;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *ld = (const char*)strrchr(path, '.');
|
||||||
|
stream->ext = strdup(ld ? ld + 1 : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
filestream_set_size(stream);
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
error:
|
||||||
|
filestream_close(stream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *filestream_getline(RFILE *stream)
|
||||||
|
{
|
||||||
|
char* newline = (char*)malloc(9);
|
||||||
|
char* newline_tmp = NULL;
|
||||||
|
size_t cur_size = 8;
|
||||||
|
size_t idx = 0;
|
||||||
|
int in = filestream_getc(stream);
|
||||||
|
|
||||||
|
if (!newline)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
while (in != EOF && in != '\n')
|
||||||
|
{
|
||||||
|
if (idx == cur_size)
|
||||||
|
{
|
||||||
|
cur_size *= 2;
|
||||||
|
newline_tmp = (char*)realloc(newline, cur_size + 1);
|
||||||
|
|
||||||
|
if (!newline_tmp)
|
||||||
|
{
|
||||||
|
free(newline);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
newline = newline_tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
newline[idx++] = in;
|
||||||
|
in = filestream_getc(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
newline[idx] = '\0';
|
||||||
|
return newline;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *filestream_gets(RFILE *stream, char *s, size_t len)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return NULL;
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
return fgets(s, (int)len, stream->fp);
|
||||||
|
#elif defined(PSP)
|
||||||
|
if(filestream_read(stream,s,len)==len)
|
||||||
|
return s;
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
return gets(s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_getc(RFILE *stream)
|
||||||
|
{
|
||||||
|
char c = 0;
|
||||||
|
(void)c;
|
||||||
|
if (!stream)
|
||||||
|
return 0;
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
return fgetc(stream->fp);
|
||||||
|
#elif defined(PSP)
|
||||||
|
if(filestream_read(stream, &c, 1) == 1)
|
||||||
|
return (int)c;
|
||||||
|
return EOF;
|
||||||
|
#else
|
||||||
|
return getc(stream->fd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
#if defined(PSP)
|
||||||
|
if (sceIoLseek(stream->fd, (SceOff)offset, whence) == -1)
|
||||||
|
goto error;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
return fseek(stream->fp, (long)offset, whence);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
/* Need to check stream->mapped because this function is
|
||||||
|
* called in filestream_open() */
|
||||||
|
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||||
|
{
|
||||||
|
/* fseek() returns error on under/overflow but allows cursor > EOF for
|
||||||
|
read-only file descriptors. */
|
||||||
|
switch (whence)
|
||||||
|
{
|
||||||
|
case SEEK_SET:
|
||||||
|
if (offset < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
stream->mappos = offset;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_CUR:
|
||||||
|
if ((offset < 0 && stream->mappos + offset > stream->mappos) ||
|
||||||
|
(offset > 0 && stream->mappos + offset < stream->mappos))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
stream->mappos += offset;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_END:
|
||||||
|
if (stream->mapsize + offset < stream->mapsize)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
stream->mappos = stream->mapsize + offset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return stream->mappos;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (lseek(stream->fd, offset, whence) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_eof(RFILE *stream)
|
||||||
|
{
|
||||||
|
size_t current_position = filestream_tell(stream);
|
||||||
|
size_t end_position = filestream_seek(stream, 0, SEEK_END);
|
||||||
|
|
||||||
|
filestream_seek(stream, current_position, SEEK_SET);
|
||||||
|
|
||||||
|
if (current_position >= end_position)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t filestream_tell(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
goto error;
|
||||||
|
#if defined(PSP)
|
||||||
|
if (sceIoLseek(stream->fd, 0, SEEK_CUR) < 0)
|
||||||
|
goto error;
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
return ftell(stream->fp);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
/* Need to check stream->mapped because this function
|
||||||
|
* is called in filestream_open() */
|
||||||
|
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||||
|
return stream->mappos;
|
||||||
|
#endif
|
||||||
|
if (lseek(stream->fd, 0, SEEK_CUR) < 0)
|
||||||
|
goto error;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void filestream_rewind(RFILE *stream)
|
||||||
|
{
|
||||||
|
filestream_seek(stream, 0L, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t filestream_read(RFILE *stream, void *s, size_t len)
|
||||||
|
{
|
||||||
|
if (!stream || !s)
|
||||||
|
goto error;
|
||||||
|
#if defined(PSP)
|
||||||
|
return sceIoRead(stream->fd, s, len);
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
return fread(s, 1, len, stream->fp);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (stream->hints & RFILE_HINT_MMAP)
|
||||||
|
{
|
||||||
|
if (stream->mappos > stream->mapsize)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (stream->mappos + len > stream->mapsize)
|
||||||
|
len = stream->mapsize - stream->mappos;
|
||||||
|
|
||||||
|
memcpy(s, &stream->mapped[stream->mappos], len);
|
||||||
|
stream->mappos += len;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return read(stream->fd, s, len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
error:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_flush(RFILE *stream)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
return fflush(stream->fp);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t filestream_write(RFILE *stream, const void *s, size_t len)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
goto error;
|
||||||
|
#if defined(PSP)
|
||||||
|
return sceIoWrite(stream->fd, s, len);
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
return fwrite(s, 1, len, stream->fp);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (stream->hints & RFILE_HINT_MMAP)
|
||||||
|
goto error;
|
||||||
|
#endif
|
||||||
|
return write(stream->fd, s, len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
error:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_putc(RFILE *stream, int c)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
return EOF;
|
||||||
|
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
return fputc(c, stream->fp);
|
||||||
|
#else
|
||||||
|
/* unimplemented */
|
||||||
|
return EOF;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_close(RFILE *stream)
|
||||||
|
{
|
||||||
|
if (!stream)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (stream->ext)
|
||||||
|
free(stream->ext);
|
||||||
|
|
||||||
|
#if defined(PSP)
|
||||||
|
if (stream->fd > 0)
|
||||||
|
sceIoClose(stream->fd);
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
|
{
|
||||||
|
if (stream->fp)
|
||||||
|
fclose(stream->fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (stream->hints & RFILE_HINT_MMAP)
|
||||||
|
munmap(stream->mapped, stream->mapsize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (stream->fd > 0)
|
||||||
|
close(stream->fd);
|
||||||
|
#endif
|
||||||
|
free(stream);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* filestream_read_file:
|
||||||
|
* @path : path to file.
|
||||||
|
* @buf : buffer to allocate and read the contents of the
|
||||||
|
* file into. Needs to be freed manually.
|
||||||
|
*
|
||||||
|
* Read the contents of a file into @buf.
|
||||||
|
*
|
||||||
|
* Returns: number of items read, -1 on error.
|
||||||
|
*/
|
||||||
|
int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
||||||
|
{
|
||||||
|
ssize_t ret = 0;
|
||||||
|
ssize_t content_buf_size = 0;
|
||||||
|
void *content_buf = NULL;
|
||||||
|
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filestream_seek(file, 0, SEEK_END) != 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
content_buf_size = filestream_tell(file);
|
||||||
|
if (content_buf_size < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
filestream_rewind(file);
|
||||||
|
|
||||||
|
content_buf = malloc(content_buf_size + 1);
|
||||||
|
|
||||||
|
if (!content_buf)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ret = filestream_read(file, content_buf, content_buf_size);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to read %s: %s\n", path, strerror(errno));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
filestream_close(file);
|
||||||
|
|
||||||
|
*buf = content_buf;
|
||||||
|
|
||||||
|
/* Allow for easy reading of strings to be safe.
|
||||||
|
* Will only work with sane character formatting (Unix). */
|
||||||
|
((char*)content_buf)[ret] = '\0';
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
*len = ret;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (file)
|
||||||
|
filestream_close(file);
|
||||||
|
if (content_buf)
|
||||||
|
free(content_buf);
|
||||||
|
if (len)
|
||||||
|
*len = -1;
|
||||||
|
*buf = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* filestream_write_file:
|
||||||
|
* @path : path to file.
|
||||||
|
* @data : contents to write to the file.
|
||||||
|
* @size : size of the contents.
|
||||||
|
*
|
||||||
|
* Writes data to a file.
|
||||||
|
*
|
||||||
|
* Returns: true (1) on success, false (0) otherwise.
|
||||||
|
*/
|
||||||
|
bool filestream_write_file(const char *path, const void *data, ssize_t size)
|
||||||
|
{
|
||||||
|
ssize_t ret = 0;
|
||||||
|
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||||
|
if (!file)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ret = filestream_write(file, data, size);
|
||||||
|
filestream_close(file);
|
||||||
|
|
||||||
|
if (ret != size)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
@ -74,6 +74,7 @@
|
|||||||
#include "libretro.h"
|
#include "libretro.h"
|
||||||
#include "md_ntsc.h"
|
#include "md_ntsc.h"
|
||||||
#include "sms_ntsc.h"
|
#include "sms_ntsc.h"
|
||||||
|
#include "streams/file_stream.h"
|
||||||
|
|
||||||
sms_ntsc_t *sms_ntsc;
|
sms_ntsc_t *sms_ntsc;
|
||||||
md_ntsc_t *md_ntsc;
|
md_ntsc_t *md_ntsc;
|
||||||
@ -169,7 +170,7 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
|
|||||||
int size, left;
|
int size, left;
|
||||||
|
|
||||||
/* Open file */
|
/* Open file */
|
||||||
FILE *fd = fopen(filename, "rb");
|
RFILE *fd = filestream_open(filename, RFILE_MODE_READ, -1);
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
@ -193,13 +194,13 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get file size */
|
/* Get file size */
|
||||||
fseek(fd, 0, SEEK_END);
|
filestream_seek(fd, 0, SEEK_END);
|
||||||
size = ftell(fd);
|
size = filestream_tell(fd);
|
||||||
|
|
||||||
/* size limit */
|
/* size limit */
|
||||||
if (size > MAXROMSIZE)
|
if (size > MAXROMSIZE)
|
||||||
{
|
{
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_ERROR, "File is too large.\n");
|
log_cb(RETRO_LOG_ERROR, "File is too large.\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -221,19 +222,19 @@ int load_archive(char *filename, unsigned char *buffer, int maxsize, char *exten
|
|||||||
|
|
||||||
/* Read into buffer */
|
/* Read into buffer */
|
||||||
left = size;
|
left = size;
|
||||||
fseek(fd, 0, SEEK_SET);
|
filestream_seek(fd, 0, SEEK_SET);
|
||||||
while (left > CHUNKSIZE)
|
while (left > CHUNKSIZE)
|
||||||
{
|
{
|
||||||
fread(buffer, CHUNKSIZE, 1, fd);
|
filestream_read(fd, buffer, CHUNKSIZE);
|
||||||
buffer += CHUNKSIZE;
|
buffer += CHUNKSIZE;
|
||||||
left -= CHUNKSIZE;
|
left -= CHUNKSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read remaining bytes */
|
/* Read remaining bytes */
|
||||||
fread(buffer, left, 1, fd);
|
filestream_read(fd, buffer, left);
|
||||||
|
|
||||||
/* Close file */
|
/* Close file */
|
||||||
fclose(fd);
|
filestream_close(fd);
|
||||||
|
|
||||||
/* Return loaded ROM size */
|
/* Return loaded ROM size */
|
||||||
return size;
|
return size;
|
||||||
@ -538,19 +539,19 @@ static void config_default(void)
|
|||||||
|
|
||||||
static void bram_load(void)
|
static void bram_load(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
RFILE *fp;
|
||||||
|
|
||||||
/* automatically load internal backup RAM */
|
/* automatically load internal backup RAM */
|
||||||
switch (region_code)
|
switch (region_code)
|
||||||
{
|
{
|
||||||
case REGION_JAPAN_NTSC:
|
case REGION_JAPAN_NTSC:
|
||||||
fp = fopen(CD_BRAM_JP, "rb");
|
fp = filestream_open(CD_BRAM_JP, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_EUROPE:
|
case REGION_EUROPE:
|
||||||
fp = fopen(CD_BRAM_EU, "rb");
|
fp = filestream_open(CD_BRAM_EU, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_USA:
|
case REGION_USA:
|
||||||
fp = fopen(CD_BRAM_US, "rb");
|
fp = filestream_open(CD_BRAM_US, RFILE_MODE_READ, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -558,8 +559,8 @@ static void bram_load(void)
|
|||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fread(scd.bram, 0x2000, 1, fp);
|
filestream_read(fp, scd.bram, 0x2000);
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
||||||
@ -590,7 +591,7 @@ static void bram_load(void)
|
|||||||
/* automatically load cartridge backup RAM (if enabled) */
|
/* automatically load cartridge backup RAM (if enabled) */
|
||||||
if (scd.cartridge.id)
|
if (scd.cartridge.id)
|
||||||
{
|
{
|
||||||
fp = fopen(CART_BRAM, "rb");
|
fp = filestream_open(CART_BRAM, RFILE_MODE_READ, -1);
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
int filesize = scd.cartridge.mask + 1;
|
int filesize = scd.cartridge.mask + 1;
|
||||||
@ -599,7 +600,7 @@ static void bram_load(void)
|
|||||||
/* Read into buffer (2k blocks) */
|
/* Read into buffer (2k blocks) */
|
||||||
while (filesize > CHUNKSIZE)
|
while (filesize > CHUNKSIZE)
|
||||||
{
|
{
|
||||||
fread(scd.cartridge.area + done, CHUNKSIZE, 1, fp);
|
filestream_read(fp, scd.cartridge.area + done, CHUNKSIZE);
|
||||||
done += CHUNKSIZE;
|
done += CHUNKSIZE;
|
||||||
filesize -= CHUNKSIZE;
|
filesize -= CHUNKSIZE;
|
||||||
}
|
}
|
||||||
@ -607,11 +608,11 @@ static void bram_load(void)
|
|||||||
/* Read remaining bytes */
|
/* Read remaining bytes */
|
||||||
if (filesize)
|
if (filesize)
|
||||||
{
|
{
|
||||||
fread(scd.cartridge.area + done, filesize, 1, fp);
|
filestream_read(fp, scd.cartridge.area + done, filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close file */
|
/* close file */
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
||||||
@ -635,7 +636,7 @@ static void bram_load(void)
|
|||||||
|
|
||||||
static void bram_save(void)
|
static void bram_save(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
RFILE *fp;
|
||||||
|
|
||||||
/* verify that internal backup RAM has been modified */
|
/* verify that internal backup RAM has been modified */
|
||||||
if (crc32(0, scd.bram, 0x2000) != brm_crc[0])
|
if (crc32(0, scd.bram, 0x2000) != brm_crc[0])
|
||||||
@ -646,13 +647,13 @@ static void bram_save(void)
|
|||||||
switch (region_code)
|
switch (region_code)
|
||||||
{
|
{
|
||||||
case REGION_JAPAN_NTSC:
|
case REGION_JAPAN_NTSC:
|
||||||
fp = fopen(CD_BRAM_JP, "wb");
|
fp = filestream_open(CD_BRAM_JP, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_EUROPE:
|
case REGION_EUROPE:
|
||||||
fp = fopen(CD_BRAM_EU, "wb");
|
fp = filestream_open(CD_BRAM_EU, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
case REGION_USA:
|
case REGION_USA:
|
||||||
fp = fopen(CD_BRAM_US, "wb");
|
fp = filestream_open(CD_BRAM_US, RFILE_MODE_WRITE, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -660,8 +661,8 @@ static void bram_save(void)
|
|||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fwrite(scd.bram, 0x2000, 1, fp);
|
filestream_write(fp, scd.bram, 0x2000);
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
brm_crc[0] = crc32(0, scd.bram, 0x2000);
|
||||||
@ -675,7 +676,7 @@ static void bram_save(void)
|
|||||||
/* check if it is correctly formatted before saving */
|
/* check if it is correctly formatted before saving */
|
||||||
if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20))
|
if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20))
|
||||||
{
|
{
|
||||||
fp = fopen(CART_BRAM, "wb");
|
fp = filestream_open(CART_BRAM, RFILE_MODE_WRITE, -1);
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
int filesize = scd.cartridge.mask + 1;
|
int filesize = scd.cartridge.mask + 1;
|
||||||
@ -684,7 +685,7 @@ static void bram_save(void)
|
|||||||
/* Write to file (2k blocks) */
|
/* Write to file (2k blocks) */
|
||||||
while (filesize > CHUNKSIZE)
|
while (filesize > CHUNKSIZE)
|
||||||
{
|
{
|
||||||
fwrite(scd.cartridge.area + done, CHUNKSIZE, 1, fp);
|
filestream_write(fp, scd.cartridge.area + done, CHUNKSIZE);
|
||||||
done += CHUNKSIZE;
|
done += CHUNKSIZE;
|
||||||
filesize -= CHUNKSIZE;
|
filesize -= CHUNKSIZE;
|
||||||
}
|
}
|
||||||
@ -692,11 +693,11 @@ static void bram_save(void)
|
|||||||
/* Write remaining bytes */
|
/* Write remaining bytes */
|
||||||
if (filesize)
|
if (filesize)
|
||||||
{
|
{
|
||||||
fwrite(scd.cartridge.area + done, filesize, 1, fp);
|
filestream_write(fp, scd.cartridge.area + done, filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close file */
|
/* Close file */
|
||||||
fclose(fp);
|
filestream_close(fp);
|
||||||
|
|
||||||
/* update CRC */
|
/* update CRC */
|
||||||
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1);
|
||||||
|
0
libretro/libretro.h
Executable file → Normal file
0
libretro/libretro.h
Executable file → Normal file
Loading…
Reference in New Issue
Block a user