This commit is contained in:
twinaphex 2021-05-19 16:45:56 +02:00
parent f9fb573c35
commit 80fcb83503
19 changed files with 2202 additions and 85 deletions

58
Makefile.test Normal file
View file

@ -0,0 +1,58 @@
OBJDIR = ../obj-unix
TEST_UNIT_CFLAGS = $(CFLAGS) -Iinclude $(LDFLAGS) -lcheck $(LIBCHECK_CFLAGS) -Werror -Wdeclaration-after-statement -fsanitize=address -fsanitize=undefined -ftest-coverage -fprofile-arcs -ggdb
TEST_GENERIC_QUEUE = test/queues/test_generic_queue
TEST_GENERIC_QUEUE_SRC = test/queues/test_generic_queue.c queues/generic_queue.c
TEST_LINKED_LIST = test/lists/test_linked_list
TEST_LINKED_LIST_SRC = test/lists/test_linked_list.c lists/linked_list.c
TEST_STDSTRING = test/string/test_stdstring
TEST_STDSTRING_SRC = test/string/test_stdstring.c string/stdstring.c encodings/encoding_utf.c \
compat/compat_strl.c
TEST_UTILS = test/utils/test_utils
TEST_UTILS_SRC = test/utils/test_utils.c utils/md5.c encodings/encoding_crc32.c \
streams/file_stream.c vfs/vfs_implementation.c file/file_path.c \
compat/compat_strl.c time/rtime.c string/stdstring.c encodings/encoding_utf.c
TEST_HASH = test/hash/test_hash
TEST_HASH_SRC = test/hash/test_hash.c hash/lrc_hash.c \
streams/file_stream.c vfs/vfs_implementation.c file/file_path.c \
compat/compat_strl.c time/rtime.c string/stdstring.c encodings/encoding_utf.c
all:
# Build and execute tests in order, to avoid coverage file collision
# string
$(CC) $(TEST_UNIT_CFLAGS) $(TEST_STDSTRING_SRC) -o $(TEST_STDSTRING)
$(TEST_STDSTRING)
lcov -c -d . -o `dirname $(TEST_STDSTRING)`/coverage.info
# utils
$(CC) $(TEST_UNIT_CFLAGS) $(TEST_UTILS_SRC) -o $(TEST_UTILS)
$(TEST_UTILS)
lcov -c -d . -o `dirname $(TEST_UTILS)`/coverage.info
# utils
$(CC) $(TEST_UNIT_CFLAGS) $(TEST_HASH_SRC) -o $(TEST_HASH)
$(TEST_HASH)
lcov -c -d . -o `dirname $(TEST_HASH)`/coverage.info
# list
$(CC) $(TEST_UNIT_CFLAGS) $(TEST_LINKED_LIST_SRC) -o $(TEST_LINKED_LIST)
$(TEST_LINKED_LIST)
lcov -c -d . -o `dirname $(TEST_LINKED_LIST)`/coverage.info
# queue
$(CC) $(TEST_UNIT_CFLAGS) $(TEST_GENERIC_QUEUE_SRC) -o $(TEST_GENERIC_QUEUE)
$(TEST_GENERIC_QUEUE)
lcov -c -d . -o `dirname $(TEST_GENERIC_QUEUE)`/coverage.info
lcov -o test/coverage.info \
-a test/utils/coverage.info \
-a test/string/coverage.info \
-a test/lists/coverage.info \
-a test/queues/coverage.info
genhtml -o test/coverage/ test/coverage.info
clean:
rm -f *.gcda *.gcno

View file

@ -177,7 +177,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
time_ticks = gettime();
#elif !defined(__MACH__) && (defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__) || defined(__PSL1GHT__) || defined(__PPC64__) || defined(__powerpc64__))
time_ticks = __mftb();
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__)
#elif (defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0) || defined(__QNX__) || defined(ANDROID)
struct timespec tv = {0};
if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
@ -191,6 +191,8 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
time_ticks = (retro_perf_tick_t)a | ((retro_perf_tick_t)d << 32);
#elif defined(__ARM_ARCH_6__)
__asm__ volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time_ticks) );
#elif defined(__aarch64__)
__asm__ volatile( "mrs %0, cntvct_el0" : "=r"(time_ticks) );
#elif defined(PSP) || defined(VITA)
time_ticks = sceKernelGetSystemTimeWide();
#elif defined(PS2)
@ -600,18 +602,20 @@ uint64_t cpu_features_get(void)
#endif
#if defined(__MACH__)
size_t len = sizeof(size_t);
if (sysctlbyname("hw.optional.floatingpoint", NULL, &len, NULL, 0) == 0)
{
cpu |= RETRO_SIMD_CMOV;
}
#if defined(CPU_X86)
len = sizeof(size_t);
if (sysctlbyname("hw.optional.mmx", NULL, &len, NULL, 0) == 0)
{
cpu |= RETRO_SIMD_MMX;
cpu |= RETRO_SIMD_MMXEXT;
}
len = sizeof(size_t);
if (sysctlbyname("hw.optional.floatingpoint", NULL, &len, NULL, 0) == 0)
{
cpu |= RETRO_SIMD_CMOV;
}
len = sizeof(size_t);
if (sysctlbyname("hw.optional.sse", NULL, &len, NULL, 0) == 0)
cpu |= RETRO_SIMD_SSE;
@ -652,10 +656,19 @@ uint64_t cpu_features_get(void)
if (sysctlbyname("hw.optional.altivec", NULL, &len, NULL, 0) == 0)
cpu |= RETRO_SIMD_VMX;
#else
len = sizeof(size_t);
if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0)
cpu |= RETRO_SIMD_NEON;
len = sizeof(size_t);
if (sysctlbyname("hw.optional.neon_fp16", NULL, &len, NULL, 0) == 0)
cpu |= RETRO_SIMD_VFPV3;
len = sizeof(size_t);
if (sysctlbyname("hw.optional.neon_hpfp", NULL, &len, NULL, 0) == 0)
cpu |= RETRO_SIMD_VFPV4;
#endif
#elif defined(_XBOX1)
cpu |= RETRO_SIMD_MMX;
cpu |= RETRO_SIMD_SSE;

View file

@ -38,6 +38,7 @@
#define SEVENZIP_MAGIC "7z\xBC\xAF\x27\x1C"
#define SEVENZIP_MAGIC_LEN 6
#define SEVENZIP_LOOKTOREAD_BUF_SIZE (1 << 14)
/* Assume W-functions do not work below Win2K and Xbox platforms */
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX)
@ -50,25 +51,25 @@ struct sevenzip_context_t
{
uint8_t *output;
CFileInStream archiveStream;
CLookToRead lookStream;
CLookToRead2 lookStream;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
CSzArEx db;
size_t temp_size;
uint32_t block_index;
uint32_t parse_index;
uint32_t decompress_index;
uint32_t packIndex;
UInt32 block_index;
};
static void *sevenzip_stream_alloc_impl(void *p, size_t size)
static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t size)
{
if (size == 0)
return 0;
return malloc(size);
}
static void sevenzip_stream_free_impl(void *p, void *address)
static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address)
{
(void)p;
@ -76,7 +77,7 @@ static void sevenzip_stream_free_impl(void *p, void *address)
free(address);
}
static void *sevenzip_stream_alloc_tmp_impl(void *p, size_t size)
static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t size)
{
(void)p;
if (size == 0)
@ -98,6 +99,12 @@ static void* sevenzip_stream_new(void)
sevenzip_context->block_index = 0xFFFFFFFF;
sevenzip_context->output = NULL;
sevenzip_context->lookStream.bufSize = SEVENZIP_LOOKTOREAD_BUF_SIZE * sizeof(Byte);
sevenzip_context->lookStream.buf = (Byte*)malloc(sevenzip_context->lookStream.bufSize);
if (!sevenzip_context->lookStream.buf)
sevenzip_context->lookStream.bufSize = 0;
return sevenzip_context;
}
@ -117,6 +124,9 @@ static void sevenzip_parse_file_free(void *context)
SzArEx_Free(&sevenzip_context->db, &sevenzip_context->allocImp);
File_Close(&sevenzip_context->archiveStream.file);
if (sevenzip_context->lookStream.buf)
free(sevenzip_context->lookStream.buf);
free(sevenzip_context);
}
@ -131,7 +141,7 @@ static int64_t sevenzip_file_read(
const char *optional_outfile)
{
CFileInStream archiveStream;
CLookToRead lookStream;
CLookToRead2 lookStream;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
CSzArEx db;
@ -145,6 +155,12 @@ static int64_t sevenzip_file_read(
allocTempImp.Alloc = sevenzip_stream_alloc_tmp_impl;
allocTempImp.Free = sevenzip_stream_free_impl;
lookStream.bufSize = SEVENZIP_LOOKTOREAD_BUF_SIZE * sizeof(Byte);
lookStream.buf = (Byte*)malloc(lookStream.bufSize);
if (!lookStream.buf)
lookStream.bufSize = 0;
#if defined(_WIN32) && defined(USE_WINDOWS_FILE) && !defined(LEGACY_WIN32)
if (!string_is_empty(path))
{
@ -169,51 +185,34 @@ static int64_t sevenzip_file_read(
#endif
FileInStream_CreateVTable(&archiveStream);
LookToRead_CreateVTable(&lookStream, false);
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);
LookToRead2_CreateVTable(&lookStream, false);
lookStream.realStream = &archiveStream.vt;
LookToRead2_Init(&lookStream);
CrcGenerateTable();
db.db.PackSizes = NULL;
db.db.PackCRCsDefined = NULL;
db.db.PackCRCs = NULL;
db.db.Folders = NULL;
db.db.Files = NULL;
db.db.NumPackStreams = 0;
db.db.NumFolders = 0;
db.db.NumFiles = 0;
db.startPosAfterHeader = 0;
db.dataPos = 0;
db.FolderStartPackStreamIndex = NULL;
db.PackStreamStartPositions = NULL;
db.FolderStartFileIndex = NULL;
db.FileIndexToFolderIndexMap = NULL;
db.FileNameOffsets = NULL;
db.FileNames.data = NULL;
db.FileNames.size = 0;
memset(&db, 0, sizeof(db));
SzArEx_Init(&db);
if (SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp) == SZ_OK)
if (SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp) == SZ_OK)
{
uint32_t i;
bool file_found = false;
uint16_t *temp = NULL;
size_t temp_size = 0;
uint32_t block_index = 0xFFFFFFFF;
UInt32 block_index = 0xFFFFFFFF;
SRes res = SZ_OK;
for (i = 0; i < db.db.NumFiles; i++)
for (i = 0; i < db.NumFiles; i++)
{
size_t len;
char infile[PATH_MAX_LENGTH];
size_t offset = 0;
size_t outSizeProcessed = 0;
const CSzFileItem *f = db.db.Files + i;
/* We skip over everything which is not a directory.
* FIXME: Why continue then if f->IsDir is true?*/
if (f->IsDir)
* FIXME: Why continue then if IsDir is true?*/
if (SzArEx_IsDir(&db, i))
continue;
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
@ -248,7 +247,7 @@ static int64_t sevenzip_file_read(
* sourceforge.net/p/sevenzip/discussion/45798/thread/6fb59aaf/
* */
file_found = true;
res = SzArEx_Extract(&db, &lookStream.s, i, &block_index,
res = SzArEx_Extract(&db, &lookStream.vt, i, &block_index,
&output, &output_size, &offset, &outSizeProcessed,
&allocImp, &allocTempImp);
@ -301,6 +300,9 @@ static int64_t sevenzip_file_read(
SzArEx_Free(&db, &allocImp);
File_Close(&archiveStream.file);
if (lookStream.buf)
free(lookStream.buf);
return outsize;
}
@ -331,7 +333,7 @@ static int sevenzip_stream_decompress_data_to_file_iterate(
size_t outSizeProcessed = 0;
res = SzArEx_Extract(&sevenzip_context->db,
&sevenzip_context->lookStream.s, sevenzip_context->decompress_index,
&sevenzip_context->lookStream.vt, sevenzip_context->decompress_index,
&sevenzip_context->block_index, &sevenzip_context->output,
&output_size, &offset, &outSizeProcessed,
&sevenzip_context->allocImp, &sevenzip_context->allocTempImp);
@ -388,17 +390,17 @@ static int sevenzip_parse_file_init(file_archive_transfer_t *state,
#endif
FileInStream_CreateVTable(&sevenzip_context->archiveStream);
LookToRead_CreateVTable(&sevenzip_context->lookStream, false);
sevenzip_context->lookStream.realStream = &sevenzip_context->archiveStream.s;
LookToRead_Init(&sevenzip_context->lookStream);
LookToRead2_CreateVTable(&sevenzip_context->lookStream, false);
sevenzip_context->lookStream.realStream = &sevenzip_context->archiveStream.vt;
LookToRead2_Init(&sevenzip_context->lookStream);
CrcGenerateTable();
SzArEx_Init(&sevenzip_context->db);
if (SzArEx_Open(&sevenzip_context->db, &sevenzip_context->lookStream.s,
if (SzArEx_Open(&sevenzip_context->db, &sevenzip_context->lookStream.vt,
&sevenzip_context->allocImp, &sevenzip_context->allocTempImp) != SZ_OK)
goto error;
state->step_total = sevenzip_context->db.db.NumFiles;
state->step_total = sevenzip_context->db.NumFiles;
return 0;
@ -414,9 +416,7 @@ static int sevenzip_parse_file_iterate_step_internal(
uint32_t *size, uint32_t *csize, uint32_t *checksum,
unsigned *payback, struct archive_extract_userdata *userdata)
{
const CSzFileItem *file = sevenzip_context->db.db.Files + sevenzip_context->parse_index;
if (sevenzip_context->parse_index < sevenzip_context->db.db.NumFiles)
if (sevenzip_context->parse_index < sevenzip_context->db.NumFiles)
{
size_t len = SzArEx_GetFileNameUtf16(&sevenzip_context->db,
sevenzip_context->parse_index, NULL);
@ -424,11 +424,14 @@ static int sevenzip_parse_file_iterate_step_internal(
if (sevenzip_context->packIndex < sevenzip_context->db.db.NumPackStreams)
{
compressed_size = sevenzip_context->db.db.PackSizes[sevenzip_context->packIndex];
compressed_size = sevenzip_context->db.db.PackPositions[sevenzip_context->packIndex + 1] -
sevenzip_context->db.db.PackPositions[sevenzip_context->packIndex];
sevenzip_context->packIndex++;
}
if (len < PATH_MAX_LENGTH && !file->IsDir)
if (len < PATH_MAX_LENGTH &&
!SzArEx_IsDir(&sevenzip_context->db, sevenzip_context->parse_index))
{
char infile[PATH_MAX_LENGTH];
SRes res = SZ_ERROR_FAIL;
@ -455,8 +458,8 @@ static int sevenzip_parse_file_iterate_step_internal(
strlcpy(filename, infile, PATH_MAX_LENGTH);
*cmode = 0; /* unused for 7zip */
*checksum = file->Crc;
*size = (uint32_t)file->Size;
*checksum = sevenzip_context->db.CRCs.Vals[sevenzip_context->parse_index];
*size = (uint32_t)SzArEx_GetFileSize(&sevenzip_context->db, sevenzip_context->parse_index);
*csize = (uint32_t)compressed_size;
*cdata = (uint8_t *)(size_t)sevenzip_context->parse_index;

View file

@ -39,6 +39,7 @@
#include <file/file_path.h>
#include <string/stdstring.h>
#include <streams/file_stream.h>
#include <array/rhmap.h>
#define MAX_INCLUDE_DEPTH 16
@ -273,6 +274,8 @@ static char *config_file_extract_value(char *line, bool is_value)
static void config_file_add_child_list(config_file_t *parent, config_file_t *child)
{
struct config_entry_list *list = child->entries;
bool merge_hash_map = false;
if (parent->entries)
{
struct config_entry_list *head = parent->entries;
@ -286,6 +289,8 @@ static void config_file_add_child_list(config_file_t *parent, config_file_t *chi
list = list->next;
}
head->next = child->entries;
merge_hash_map = true;
}
else
{
@ -298,8 +303,6 @@ static void config_file_add_child_list(config_file_t *parent, config_file_t *chi
parent->entries = child->entries;
}
child->entries = NULL;
/* Rebase tail. */
if (parent->entries)
{
@ -312,6 +315,46 @@ static void config_file_add_child_list(config_file_t *parent, config_file_t *chi
}
else
parent->tail = NULL;
/* Update hash map */
if (merge_hash_map)
{
size_t i;
size_t cap;
/* We are merging two lists - if any child entry
* (key) is not present in the parent list, add it
* to the parent hash map */
for (i = 0, cap = RHMAP_CAP(child->entries_map); i != cap; i++)
{
uint32_t child_hash = RHMAP_KEY(child->entries_map, i);
const char *child_key = RHMAP_KEY_STR(child->entries_map, i);
if (child_hash &&
child_key &&
!RHMAP_HAS_FULL(parent->entries_map, child_hash, child_key))
{
struct config_entry_list *entry = child->entries_map[i];
if (entry)
RHMAP_SET_FULL(parent->entries_map, child_hash, child_key, entry);
}
}
/* Child entries map is no longer required,
* so free it now */
RHMAP_FREE(child->entries_map);
}
else
{
/* If parent list was originally empty,
* take map from child list */
RHMAP_FREE(parent->entries_map);
parent->entries_map = child->entries_map;
child->entries_map = NULL;
}
child->entries = NULL;
}
static void config_file_get_realpath(char *s, size_t len,
@ -426,8 +469,21 @@ static int config_file_load_internal(
conf->tail = list;
if (cb && list->key && list->value)
cb->config_file_new_entry_cb(list->key, list->value) ;
if (list->key)
{
/* Only add entry to the map if an entry
* with the specified value does not
* already exist */
uint32_t hash = rhmap_hash_string(list->key);
if (!RHMAP_HAS_FULL(conf->entries_map, hash, list->key))
{
RHMAP_SET_FULL(conf->entries_map, hash, list->key, list);
if (cb && list->value)
cb->config_file_new_entry_cb(list->key, list->value);
}
}
}
free(line);
@ -628,6 +684,16 @@ static int config_file_from_string_internal(
conf->entries = list;
conf->tail = list;
if (list->key)
{
/* Only add entry to the map if an entry
* with the specified value does not
* already exist */
uint32_t hash = rhmap_hash_string(list->key);
if (!RHMAP_HAS_FULL(conf->entries_map, hash, list->key))
RHMAP_SET_FULL(conf->entries_map, hash, list->key, list);
}
}
if (list != conf->tail)
@ -705,6 +771,9 @@ bool config_file_deinitialize(config_file_t *conf)
if (conf->path)
free(conf->path);
RHMAP_FREE(conf->entries_map);
return true;
}
@ -718,9 +787,27 @@ void config_file_free(config_file_t *conf)
bool config_append_file(config_file_t *conf, const char *path)
{
config_file_t *new_conf = config_file_new_from_path_to_string(path);
size_t i;
size_t cap;
if (!new_conf)
return false;
/* Update hash map */
for (i = 0, cap = RHMAP_CAP(new_conf->entries_map); i != cap; i++)
{
uint32_t new_hash = RHMAP_KEY(new_conf->entries_map, i);
const char *new_key = RHMAP_KEY_STR(new_conf->entries_map, i);
if (new_hash && new_key)
{
struct config_entry_list *entry = new_conf->entries_map[i];
if (entry)
RHMAP_SET_FULL(conf->entries_map, new_hash, new_key, entry);
}
}
if (new_conf->tail)
{
new_conf->tail->next = conf->entries;
@ -818,6 +905,7 @@ void config_file_initialize(struct config_file *conf)
return;
conf->path = NULL;
conf->entries_map = NULL;
conf->entries = NULL;
conf->tail = NULL;
conf->last = NULL;
@ -844,16 +932,18 @@ static struct config_entry_list *config_get_entry_internal(
struct config_entry_list *entry = NULL;
struct config_entry_list *previous = prev ? *prev : NULL;
for (entry = conf->entries; entry; entry = entry->next)
{
if (string_is_equal(key, entry->key))
return entry;
entry = RHMAP_GET_STR(conf->entries_map, key);
previous = entry;
}
if (entry)
return entry;
if (prev)
{
for (entry = conf->entries; entry; entry = entry->next)
previous = entry;
*prev = previous;
}
return NULL;
}
@ -861,16 +951,9 @@ static struct config_entry_list *config_get_entry_internal(
struct config_entry_list *config_get_entry(
const config_file_t *conf, const char *key)
{
struct config_entry_list *entry = NULL;
for (entry = conf->entries; entry; entry = entry->next)
{
if (string_is_equal(key, entry->key))
return entry;
}
return NULL;
return RHMAP_GET_STR(conf->entries_map, key);
}
bool config_get_double(config_file_t *conf, const char *key, double *in)
{
const struct config_entry_list *entry = config_get_entry(conf, key);
@ -1141,6 +1224,8 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
conf->entries = entry;
conf->last = entry;
RHMAP_SET_STR(conf->entries_map, entry->key, entry);
}
void config_unset(config_file_t *conf, const char *key)
@ -1157,6 +1242,8 @@ void config_unset(config_file_t *conf, const char *key)
if (!entry)
return;
(void)RHMAP_DEL_STR(conf->entries_map, entry->key);
if (entry->key)
free(entry->key);
@ -1376,16 +1463,7 @@ void config_file_dump(config_file_t *conf, FILE *file, bool sort)
bool config_entry_exists(config_file_t *conf, const char *entry)
{
struct config_entry_list *list = conf->entries;
while (list)
{
if (string_is_equal(entry, list->key))
return true;
list = list->next;
}
return false;
return (bool)RHMAP_HAS_STR(conf->entries_map, entry);
}
bool config_get_entry_list_head(config_file_t *conf,

View file

@ -1235,7 +1235,13 @@ chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex,
UINT32 faux_length;
/* fill in the faux metadata */
sprintf(faux_metadata, HARD_DISK_METADATA_FORMAT, chd->header.obsolete_cylinders, chd->header.obsolete_heads, chd->header.obsolete_sectors, chd->header.hunkbytes / chd->header.obsolete_hunksize);
snprintf(faux_metadata,
sizeof(faux_metadata),
HARD_DISK_METADATA_FORMAT,
chd->header.obsolete_cylinders,
chd->header.obsolete_heads,
chd->header.obsolete_sectors,
chd->header.hunkbytes / chd->header.obsolete_hunksize);
faux_length = (UINT32)strlen(faux_metadata) + 1;
/* copy the metadata itself */

View file

@ -42,12 +42,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <libchdr/chd.h>
#include <libchdr/minmax.h>
#include <libchdr/cdrom.h>
#include <libchdr/lzma.h>
#include <libchdr/huffman.h>
#include <zlib.h>
#include <retro_inline.h>
#include <streams/file_stream.h>

View file

@ -1035,7 +1035,9 @@ bool rpng_iterate_image(rpng_t *rpng)
rpng->ihdr.interlace = buf[12];
if ( rpng->ihdr.width == 0
|| rpng->ihdr.height == 0)
|| rpng->ihdr.height == 0
/* ensure multiplications don't overflow and wrap around, that'd give buffer overflow crashes */
|| (uint64_t)rpng->ihdr.width*rpng->ihdr.height*sizeof(uint32_t) >= 0x80000000)
return false;
if (!png_process_ihdr(&rpng->ihdr))
@ -1169,6 +1171,7 @@ error:
if (rpng->process->stream)
rpng->process->stream_backend->stream_free(rpng->process->stream);
free(rpng->process);
rpng->process = NULL;
}
return IMAGE_PROCESS_ERROR;
}

284
include/array/rhmap.h Normal file
View file

@ -0,0 +1,284 @@
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (rhmap.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_ARRAY_RHMAP_H__
#define __LIBRETRO_SDK_ARRAY_RHMAP_H__
/*
* This file implements a hash map with 32-bit keys.
* Based on the implementation from the public domain Bitwise project
* by Per Vognsen - https://github.com/pervognsen/bitwise
*
* It's a super simple type safe hash map for C with no need
* to predeclare any type or anything.
* Will always allocate memory for twice the amount of max elements
* so larger structs should be stored as pointers or indices to an array.
* Can be used in C++ with POD types (without any constructor/destructor).
*
* Be careful not to supply modifying statements to the macro arguments.
* Something like RHMAP_FIT(map, i++); would have unintended results.
*
* Sample usage:
*
* -- Set 2 elements with string keys and mytype_t values:
* mytype_t* map = NULL;
* RHMAP_SET_STR(map, "foo", foo_element);
* RHMAP_SET_STR(map, "bar", bar_element);
* -- now RHMAP_LEN(map) == 2, RHMAP_GET_STR(map, "foo") == foo_element
*
* -- Check if keys exist:
* bool has_foo = RHMAP_HAS_STR(map, "foo");
* bool has_baz = RHMAP_HAS_STR(map, "baz");
* -- now has_foo == true, has_baz == false
*
* -- Removing a key:
* bool removed = RHMAP_DEL_STR(map, "bar");
* bool removed_again = RHMAP_DEL_STR(map, "bar");
* -- now RHMAP_LEN(map) == 1, removed == true, removed_again == false
*
* -- Add/modify via pointer:
* mytype_t* p_elem = RHMAP_PTR_STR(map, "qux");
* p_elem->a = 123;
* -- New keys initially have memory uninitialized
* -- Pointers can get invalidated when a key is added/removed
*
* -- Looking up the index for a given key:
* ptrdiff_t idx_foo = RHMAP_IDX_STR(map, "foo");
* ptrdiff_t idx_invalid = RHMAP_IDX_STR(map, "invalid");
* -- now idx_foo >= 0, idx_invalid == -1, map[idx_foo] == foo_element
* -- Indices can change when a key is added/removed
*
* -- Clear all elements (keep memory allocated):
* RHMAP_CLEAR(map);
* -- now RHMAP_LEN(map) == 0, RHMAP_CAP(map) == 16
*
* -- Reserve memory for at least N elements:
* RHMAP_FIT(map, 30);
* -- now RHMAP_LEN(map) == 0, RHMAP_CAP(map) == 64
*
* -- Add elements with custom hash keys:
* RHMAP_SET(map, my_uint32_hash(key1), some_element);
* RHMAP_SET(map, my_uint32_hash(key2), other_element);
* -- now RHMAP_LEN(map) == 2, _GET/_HAS/_DEL/_PTR/_IDX also exist
*
* -- Iterate elements (random order, order can change on insert):
* for (size_t i = 0, cap = RHMAP_CAP(map); i != cap, i++)
* if (RHMAP_KEY(map, i))
* ------ here map[i] is the value of key RHMAP_KEY(map, i)
*
* -- Set a custom null value (is zeroed by default):
* RHMAP_SETNULLVAL(map, map_null);
* -- now RHMAP_GET_STR(map, "invalid") == map_null
*
* -- Free allocated memory:
* RHMAP_FREE(map);
* -- now map == NULL, RHMAP_LEN(map) == 0, RHMAP_CAP(map) == 0
*
* -- To handle running out of memory:
* bool ran_out_of_memory = !RHMAP_TRYFIT(map, 1000);
* -- before setting an element (with SET, PTR or NULLVAL).
* -- When out of memory, map will stay unmodified.
*
*/
#include <stdlib.h> /* for malloc, realloc */
#include <string.h> /* for memcpy, memset */
#include <stddef.h> /* for ptrdiff_t, size_t */
#include <stdint.h> /* for uint32_t */
#define RHMAP_LEN(b) ((b) ? RHMAP__HDR(b)->len : 0)
#define RHMAP_MAX(b) ((b) ? RHMAP__HDR(b)->maxlen : 0)
#define RHMAP_CAP(b) ((b) ? RHMAP__HDR(b)->maxlen + 1 : 0)
#define RHMAP_KEY(b, idx) (RHMAP__HDR(b)->keys[idx])
#define RHMAP_KEY_STR(b, idx) (RHMAP__HDR(b)->key_strs[idx])
#define RHMAP_SETNULLVAL(b, val) (RHMAP__FIT1(b), b[-1] = (val))
#define RHMAP_CLEAR(b) ((b) ? (memset(RHMAP__HDR(b)->keys, 0, RHMAP_CAP(b) * sizeof(uint32_t)), RHMAP__HDR(b)->len = 0) : 0)
#define RHMAP_FREE(b) ((b) ? (rhmap__free(RHMAP__HDR(b)), (b) = NULL) : 0)
#define RHMAP_FIT(b, n) ((!(n) || ((b) && (size_t)(n) * 2 <= RHMAP_MAX(b))) ? 0 : RHMAP__GROW(b, n))
#define RHMAP_TRYFIT(b, n) (RHMAP_FIT((b), (n)), (!(n) || ((b) && (size_t)(n) * 2 <= RHMAP_MAX(b))))
#define RHMAP_SET(b, key, val) RHMAP_SET_FULL(b, key, NULL, val)
#define RHMAP_GET(b, key) RHMAP_GET_FULL(b, key, NULL)
#define RHMAP_HAS(b, key) RHMAP_HAS_FULL(b, key, NULL)
#define RHMAP_DEL(b, key) RHMAP_DEL_FULL(b, key, NULL)
#define RHMAP_PTR(b, key) RHMAP_PTR_FULL(b, key, NULL)
#define RHMAP_IDX(b, key) RHMAP_IDX_FULL(b, key, NULL)
#ifdef __GNUC__
#define RHMAP__UNUSED __attribute__((__unused__))
#else
#define RHMAP__UNUSED
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4505) //unreferenced local function has been removed
#endif
#define RHMAP_SET_FULL(b, key, str, val) (RHMAP__FIT1(b), b[rhmap__idx(RHMAP__HDR(b), (key), (str), 1, 0)] = (val))
#define RHMAP_GET_FULL(b, key, str) (RHMAP__FIT1(b), b[rhmap__idx(RHMAP__HDR(b), (key), (str), 0, 0)])
#define RHMAP_HAS_FULL(b, key, str) ((b) ? rhmap__idx(RHMAP__HDR(b), (key), (str), 0, 0) != -1 : 0)
#define RHMAP_DEL_FULL(b, key, str) ((b) ? rhmap__idx(RHMAP__HDR(b), (key), (str), 0, sizeof(*(b))) != -1 : 0)
#define RHMAP_PTR_FULL(b, key, str) (RHMAP__FIT1(b), &b[rhmap__idx(RHMAP__HDR(b), (key), (str), 1, 0)])
#define RHMAP_IDX_FULL(b, key, str) ((b) ? rhmap__idx(RHMAP__HDR(b), (key), (str), 0, 0) : -1)
#define RHMAP_SET_STR(b, string_key, val) RHMAP_SET_FULL(b, rhmap_hash_string(string_key), string_key, val)
#define RHMAP_GET_STR(b, string_key) RHMAP_GET_FULL(b, rhmap_hash_string(string_key), string_key)
#define RHMAP_HAS_STR(b, string_key) RHMAP_HAS_FULL(b, rhmap_hash_string(string_key), string_key)
#define RHMAP_DEL_STR(b, string_key) RHMAP_DEL_FULL(b, rhmap_hash_string(string_key), string_key)
#define RHMAP_PTR_STR(b, string_key) RHMAP_PTR_FULL(b, rhmap_hash_string(string_key), string_key)
#define RHMAP_IDX_STR(b, string_key) RHMAP_IDX_FULL(b, rhmap_hash_string(string_key), string_key)
RHMAP__UNUSED static uint32_t rhmap_hash_string(const char* str)
{
unsigned char c;
uint32_t hash = (uint32_t)0x811c9dc5;
while ((c = (unsigned char)*(str++)) != '\0')
hash = ((hash * (uint32_t)0x01000193) ^ (uint32_t)c);
return (hash ? hash : 1);
}
struct rhmap__hdr { size_t len, maxlen; uint32_t *keys; char** key_strs; };
#define RHMAP__HDR(b) (((struct rhmap__hdr *)&(b)[-1])-1)
#define RHMAP__GROW(b, n) (*(void**)(&(b)) = rhmap__grow(RHMAP__HDR(b), (void*)(b), sizeof(*(b)), (size_t)(n)))
#define RHMAP__FIT1(b) ((b) && RHMAP_LEN(b) * 2 <= RHMAP_MAX(b) ? 0 : RHMAP__GROW(b, 0))
RHMAP__UNUSED static void* rhmap__grow(struct rhmap__hdr *old_hdr, void* old_ptr, size_t elem_size, size_t reserve)
{
struct rhmap__hdr *new_hdr;
char *new_vals;
size_t new_max = (old_ptr ? old_hdr->maxlen * 2 + 1 : 15);
while (new_max && new_max / 2 <= reserve)
if (!(new_max = new_max * 2 + 1))
return old_ptr; /* overflow */
new_hdr = (struct rhmap__hdr *)malloc(sizeof(struct rhmap__hdr) + (new_max + 2) * elem_size);
if (!new_hdr)
return old_ptr; /* out of memory */
new_hdr->maxlen = new_max;
new_hdr->keys = (uint32_t *)calloc(new_max + 1, sizeof(uint32_t));
if (!new_hdr->keys)
{
/* out of memory */
free(new_hdr);
return old_ptr;
}
new_hdr->key_strs = (char**)calloc(new_max + 1, sizeof(char*));
if (!new_hdr->key_strs)
{
/* out of memory */
free(new_hdr->keys);
free(new_hdr);
return old_ptr;
}
new_vals = ((char*)(new_hdr + 1)) + elem_size;
if (old_ptr)
{
size_t i;
char* old_vals = ((char*)(old_hdr + 1)) + elem_size;
for (i = 0; i <= old_hdr->maxlen; i++)
{
uint32_t key, j;
if (!old_hdr->keys[i])
continue;
for (key = old_hdr->keys[i], j = key;; j++)
{
if (!new_hdr->keys[j &= new_hdr->maxlen])
{
new_hdr->keys[j] = key;
new_hdr->key_strs[j] = old_hdr->key_strs[i];
memcpy(new_vals + j * elem_size, old_vals + i * elem_size, elem_size);
break;
}
}
}
memcpy(new_vals - elem_size, old_vals - elem_size, elem_size);
new_hdr->len = old_hdr->len;
free(old_hdr->keys);
free(old_hdr->key_strs);
free(old_hdr);
}
else
{
memset(new_vals - elem_size, 0, elem_size);
new_hdr->len = 0;
}
return new_vals;
}
RHMAP__UNUSED static ptrdiff_t rhmap__idx(struct rhmap__hdr* hdr, uint32_t key, const char * str, int add, size_t del)
{
uint32_t i;
if (!key)
return (ptrdiff_t)-1;
for (i = key;; i++)
{
if (hdr->keys[i &= hdr->maxlen] == key && (!hdr->key_strs[i] || !str || !strcmp(hdr->key_strs[i], str)))
{
if (del)
{
hdr->len--;
hdr->keys[i] = 0;
free(hdr->key_strs[i]);
hdr->key_strs[i] = NULL;
while ((key = hdr->keys[i = (i + 1) & hdr->maxlen]) != 0)
{
if ((key = (uint32_t)rhmap__idx(hdr, key, str, 1, 0)) == i) continue;
hdr->len--;
hdr->keys[i] = 0;
free(hdr->key_strs[i]);
hdr->key_strs[i] = NULL;
memcpy(((char*)(hdr + 1)) + (key + 1) * del,
((char*)(hdr + 1)) + (i + 1) * del, del);
}
}
return (ptrdiff_t)i;
}
if (!hdr->keys[i])
{
if (add) { hdr->len++; hdr->keys[i] = key; if (str) hdr->key_strs[i] = strdup(str); return (ptrdiff_t)i; }
return (ptrdiff_t)-1;
}
}
}
RHMAP__UNUSED static void rhmap__free(struct rhmap__hdr* hdr)
{
size_t i;
for (i=0;i<hdr->maxlen+1;i++)
{
free(hdr->key_strs[i]);
}
free(hdr->key_strs);
free(hdr->keys);
free(hdr);
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif

View file

@ -0,0 +1,73 @@
/* Copyright (C) 2010-2021 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (cocoa_defines.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 __COCOA_COMMON_DEFINES_H
#define __COCOA_COMMON_DEFINES_H
#include <AvailabilityMacros.h>
#ifndef MAC_OS_X_VERSION_10_12
#define MAC_OS_X_VERSION_10_12 101200
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define NSEventModifierFlagCommand NSCommandKeyMask
#define NSEventModifierFlagControl NSControlKeyMask
#define NSEventModifierFlagHelp NSHelpKeyMask
#define NSEventModifierFlagNumericPad NSNumericPadKeyMask
#define NSEventModifierFlagOption NSAlternateKeyMask
#define NSEventModifierFlagShift NSShiftKeyMask
#define NSCompositingOperationSourceOver NSCompositeSourceOver
#define NSEventMaskApplicationDefined NSApplicationDefinedMask
#define NSEventTypeApplicationDefined NSApplicationDefined
#define NSEventTypeCursorUpdate NSCursorUpdate
#define NSEventTypeMouseMoved NSMouseMoved
#define NSEventTypeMouseEntered NSMouseEntered
#define NSEventTypeMouseExited NSMouseExited
#define NSEventTypeLeftMouseDown NSLeftMouseDown
#define NSEventTypeRightMouseDown NSRightMouseDown
#define NSEventTypeOtherMouseDown NSOtherMouseDown
#define NSEventTypeLeftMouseUp NSLeftMouseUp
#define NSEventTypeRightMouseUp NSRightMouseUp
#define NSEventTypeOtherMouseUp NSOtherMouseUp
#define NSEventTypeLeftMouseDragged NSLeftMouseDragged
#define NSEventTypeRightMouseDragged NSRightMouseDragged
#define NSEventTypeOtherMouseDragged NSOtherMouseDragged
#define NSEventTypeScrollWheel NSScrollWheel
#define NSEventTypeKeyDown NSKeyDown
#define NSEventTypeKeyUp NSKeyUp
#define NSEventTypeFlagsChanged NSFlagsChanged
#define NSEventMaskAny NSAnyEventMask
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#define NSWindowStyleMaskClosable NSClosableWindowMask
#define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
#define NSWindowStyleMaskResizable NSResizableWindowMask
#define NSWindowStyleMaskTitled NSTitledWindowMask
#define NSAlertStyleCritical NSCriticalAlertStyle
#define NSAlertStyleInformational NSInformationalAlertStyle
#define NSAlertStyleWarning NSWarningAlertStyle
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
#define NSControlSizeRegular NSRegularControlSize
#endif
#endif

View file

@ -0,0 +1,92 @@
/* Copyright (C) 2010-2021 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (d3d_defines.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 D3DVIDEO_DEFINES_H
#define D3DVIDEO_DEFINES_H
#if defined(DEBUG) || defined(_DEBUG)
#define D3D_DEBUG_INFO
#endif
#if defined(HAVE_D3D9)
/* Direct3D 9 */
#if 0
#include <d3d9.h>
#endif
#if 0
#define LPDIRECT3D LPDIRECT3D9
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE9
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE9
#define LPDIRECT3DCUBETEXTURE LPDIRECT3DCUBETEXTURE9
#define LPDIRECT3DVERTEXBUFFER LPDIRECT3DVERTEXBUFFER9
#define LPDIRECT3DVERTEXSHADER LPDIRECT3DVERTEXSHADER9
#define LPDIRECT3DPIXELSHADER LPDIRECT3DPIXELSHADER9
#define LPDIRECT3DSURFACE LPDIRECT3DSURFACE9
#define LPDIRECT3DVERTEXDECLARATION LPDIRECT3DVERTEXDECLARATION9
#define LPDIRECT3DVOLUMETEXTURE LPDIRECT3DVOLUMETEXTURE9
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE9
#define D3DVERTEXELEMENT D3DVERTEXELEMENT9
#define D3DVIEWPORT D3DVIEWPORT9
#endif
#ifndef D3DCREATE_SOFTWARE_VERTEXPROCESSING
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0
#endif
#elif defined(HAVE_D3D8)
#if 0
#ifdef _XBOX
#include <xtl.h>
#else
#include "../gfx/include/d3d8/d3d8.h"
#endif
#endif
/* Direct3D 8 */
#if 0
#define LPDIRECT3D LPDIRECT3D8
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE8
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE8
#define LPDIRECT3DCUBETEXTURE LPDIRECT3DCUBETEXTURE8
#define LPDIRECT3DVOLUMETEXTURE LPDIRECT3DVOLUMETEXTURE8
#define LPDIRECT3DVERTEXBUFFER LPDIRECT3DVERTEXBUFFER8
#define LPDIRECT3DVERTEXDECLARATION (void*)
#define LPDIRECT3DSURFACE LPDIRECT3DSURFACE8
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE8
#define D3DVERTEXELEMENT D3DVERTEXELEMENT8
#define D3DVIEWPORT D3DVIEWPORT8
#endif
#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX)
#define D3DLOCK_NOSYSLOCK (0)
#endif
#if 0
#define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU
#define D3DSAMP_ADDRESSV D3DTSS_ADDRESSV
#define D3DSAMP_MAGFILTER D3DTSS_MAGFILTER
#define D3DSAMP_MINFILTER D3DTSS_MINFILTER
#endif
#endif
#endif

View file

@ -0,0 +1,96 @@
/* Copyright (C) 2010-2021 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (gx_defines.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 _GX_DEFINES_H
#define _GX_DEFINES_H
#ifdef GEKKO
#define SYSMEM1_SIZE 0x01800000
#define _SHIFTL(v, s, w) ((uint32_t) (((uint32_t)(v) & ((0x01 << (w)) - 1)) << (s)))
#define _SHIFTR(v, s, w) ((uint32_t)(((uint32_t)(v) >> (s)) & ((0x01 << (w)) - 1)))
#define OSThread lwp_t
#define OSCond lwpq_t
#define OSThreadQueue lwpq_t
#define OSInitMutex(mutex) LWP_MutexInit(mutex, 0)
#define OSLockMutex(mutex) LWP_MutexLock(mutex)
#define OSUnlockMutex(mutex) LWP_MutexUnlock(mutex)
#define OSTryLockMutex(mutex) LWP_MutexTryLock(mutex)
#define OSInitCond(cond) LWP_CondInit(cond)
#define OSSignalCond(cond) LWP_ThreadSignal(cond)
#define OSWaitCond(cond, mutex) LWP_CondWait(cond, mutex)
#define OSInitThreadQueue(queue) LWP_InitQueue(queue)
#define OSCloseThreadQueue(queue) LWP_CloseQueue(queue)
#define OSSleepThread(queue) LWP_ThreadSleep(queue)
#define OSJoinThread(thread, val) LWP_JoinThread(thread, val)
#define OSCreateThread(thread, func, intarg, ptrarg, stackbase, stacksize, priority, attrs) LWP_CreateThread(thread, func, ptrarg, stackbase, stacksize, priority)
#define BLIT_LINE_16(off) \
{ \
const uint32_t *tmp_src = src; \
uint32_t *tmp_dst = dst; \
for (unsigned x = 0; x < width2 >> 1; x++, tmp_src += 2, tmp_dst += 8) \
{ \
tmp_dst[ 0 + off] = BLIT_LINE_16_CONV(tmp_src[0]); \
tmp_dst[ 1 + off] = BLIT_LINE_16_CONV(tmp_src[1]); \
} \
src += tmp_pitch; \
}
#define BLIT_LINE_32(off) \
{ \
const uint16_t *tmp_src = src; \
uint16_t *tmp_dst = dst; \
for (unsigned x = 0; x < width2 >> 3; x++, tmp_src += 8, tmp_dst += 32) \
{ \
tmp_dst[ 0 + off] = tmp_src[0] | 0xFF00; \
tmp_dst[ 16 + off] = tmp_src[1]; \
tmp_dst[ 1 + off] = tmp_src[2] | 0xFF00; \
tmp_dst[ 17 + off] = tmp_src[3]; \
tmp_dst[ 2 + off] = tmp_src[4] | 0xFF00; \
tmp_dst[ 18 + off] = tmp_src[5]; \
tmp_dst[ 3 + off] = tmp_src[6] | 0xFF00; \
tmp_dst[ 19 + off] = tmp_src[7]; \
} \
src += tmp_pitch; \
}
#define CHUNK_FRAMES 64
#define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t))
#define BLOCKS 16
#define AIInit AUDIO_Init
#define AIInitDMA AUDIO_InitDMA
#define AIStartDMA AUDIO_StartDMA
#define AIStopDMA AUDIO_StopDMA
#define AIRegisterDMACallback AUDIO_RegisterDMACallback
#define AISetDSPSampleRate AUDIO_SetDSPSampleRate
#endif
#endif

View file

@ -0,0 +1,704 @@
/* Copyright (C) 2010-2021 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (ps3_defines.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 _PS3_DEFINES_H
#define _PS3_DEFINES_H
/*============================================================
AUDIO PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <audio/audio.h>
#include <sys/thread.h>
#include <sys/event_queue.h>
#include <lv2/mutex.h>
#include <lv2/cond.h>
/*forward decl. for audioAddData */
extern int audioAddData(uint32_t portNum, float *data,
uint32_t frames, float volume);
#define PS3_SYS_NO_TIMEOUT 0
#define param_attrib attrib
#else
#include <sdk_version.h>
#include <cell/audio.h>
#include <sys/event.h>
#include <sys/synchronization.h>
#define numChannels nChannel
#define numBlocks nBlock
#define param_attrib attr
#define audioQuit cellAudioQuit
#define audioInit cellAudioInit
#define audioPortStart cellAudioPortStart
#define audioPortOpen cellAudioPortOpen
#define audioPortClose cellAudioPortClose
#define audioPortStop cellAudioPortStop
#define audioPortParam CellAudioPortParam
#define audioPortOpen cellAudioPortOpen
#define audioAddData cellAudioAddData
/* event queue functions */
#define sysEventQueueReceive sys_event_queue_receive
#define audioSetNotifyEventQueue cellAudioSetNotifyEventQueue
#define audioRemoveNotifyEventQueue cellAudioRemoveNotifyEventQueue
#define audioCreateNotifyEventQueue cellAudioCreateNotifyEventQueue
#define sysLwCondCreate sys_lwcond_create
#define sysLwCondDestroy sys_lwcond_destroy
#define sysLwCondWait sys_lwcond_wait
#define sysLwCondSignal sys_lwcond_signal
#define sysLwMutexDestroy sys_lwmutex_destroy
#define sysLwMutexLock sys_lwmutex_lock
#define sysLwMutexUnlock sys_lwmutex_unlock
#define sysLwMutexCreate sys_lwmutex_create
#define AUDIO_BLOCK_SAMPLES CELL_AUDIO_BLOCK_SAMPLES
#define SYSMODULE_NET CELL_SYSMODULE_NET
#define PS3_SYS_NO_TIMEOUT SYS_NO_TIMEOUT
#define sys_lwmutex_attr_t sys_lwmutex_attribute_t
#define sys_lwcond_attr_t sys_lwcond_attribute_t
#define sys_sem_t sys_semaphore_t
#define sysGetSystemTime sys_time_get_system_time
#define sysModuleLoad cellSysmoduleLoadModule
#define sysModuleUnload cellSysmoduleUnloadModule
#define netInitialize sys_net_initialize_network
#endif
/*============================================================
INPUT PAD PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <io/pad.h>
#define CELL_PAD_CAPABILITY_SENSOR_MODE 4
#define CELL_PAD_SETTING_SENSOR_ON 4
#define CELL_PAD_STATUS_ASSIGN_CHANGES 2
#define CELL_PAD_BTN_OFFSET_DIGITAL1 2
#define CELL_PAD_BTN_OFFSET_DIGITAL2 3
#define CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X 4
#define CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y 5
#define CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X 6
#define CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y 7
#define CELL_PAD_BTN_OFFSET_PRESS_RIGHT 8
#define CELL_PAD_BTN_OFFSET_PRESS_LEFT 9
#define CELL_PAD_BTN_OFFSET_PRESS_UP 10
#define CELL_PAD_BTN_OFFSET_PRESS_DOWN 11
#define CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE 12
#define CELL_PAD_BTN_OFFSET_PRESS_CIRCLE 13
#define CELL_PAD_BTN_OFFSET_PRESS_CROSS 14
#define CELL_PAD_BTN_OFFSET_PRESS_SQUARE 15
#define CELL_PAD_BTN_OFFSET_PRESS_L1 16
#define CELL_PAD_BTN_OFFSET_PRESS_R1 17
#define CELL_PAD_BTN_OFFSET_PRESS_L2 18
#define CELL_PAD_BTN_OFFSET_PRESS_R2 19
#define CELL_PAD_BTN_OFFSET_SENSOR_X 20
#define CELL_PAD_BTN_OFFSET_SENSOR_Y 21
#define CELL_PAD_BTN_OFFSET_SENSOR_Z 22
#define CELL_PAD_BTN_OFFSET_SENSOR_G 23
#define CELL_PAD_CTRL_LEFT (128)
#define CELL_PAD_CTRL_DOWN (64)
#define CELL_PAD_CTRL_RIGHT (32)
#define CELL_PAD_CTRL_UP (16)
#define CELL_PAD_CTRL_START (8)
#define CELL_PAD_CTRL_R3 (4)
#define CELL_PAD_CTRL_L3 (2)
#define CELL_PAD_CTRL_SELECT (1)
#define CELL_PAD_CTRL_SQUARE (128)
#define CELL_PAD_CTRL_CROSS (64)
#define CELL_PAD_CTRL_CIRCLE (32)
#define CELL_PAD_CTRL_TRIANGLE (16)
#define CELL_PAD_CTRL_R1 (8)
#define CELL_PAD_CTRL_L1 (4)
#define CELL_PAD_CTRL_R2 (2)
#define CELL_PAD_CTRL_L2 (1)
#define CELL_PAD_CTRL_LDD_PS (1)
#define CELL_PAD_STATUS_CONNECTED (1)
#define CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN
#define CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS (1)
#define CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE (0)
#define now_connect connected
#define CellPadActParam padActParam
#define cellPadSetPortSetting ioPadSetPortSetting
#define cellSysutilGetSystemParamInt sysUtilGetSystemParamInt
#define cellPadSetActDirect ioPadSetActDirect
#define CellPadInfo2 padInfo2
#define cellPadGetInfo2 ioPadGetInfo2
#define CellPadData padData
#define cellPadGetData ioPadGetData
#define cellPadInit ioPadInit
#define cellPadEnd ioPadEnd
#else
#include <cell/pad.h>
#define padInfo2 CellPadInfo2
#define padData CellPadData
#define ioPadGetInfo2 cellPadGetInfo2
#define ioPadGetData cellPadGetData
#define ioPadInit cellPadInit
#define ioPadEnd cellPadEnd
#endif
/*============================================================
INPUT MOUSE PROTOTYPES
============================================================ */
#ifdef HAVE_MOUSE
#ifdef __PSL1GHT__
#include <io/mouse.h>
/* define ps3 mouse structs */
#define CellMouseInfo mouseInfo
#define CellMouseData mouseData
/* define all the ps3 mouse functions */
#define cellMouseInit ioMouseInit
#define cellMouseGetData ioMouseGetData
#define cellMouseEnd ioMouseEnd
#define cellMouseGetInfo ioMouseGetInfo
/* PSL1GHT does not define these in its header */
#define CELL_MOUSE_BUTTON_1 (UINT64_C(1) << 0) /* Button 1 */
#define CELL_MOUSE_BUTTON_2 (UINT64_C(1) << 1) /* Button 2 */
#define CELL_MOUSE_BUTTON_3 (UINT64_C(1) << 2) /* Button 3 */
#define CELL_MOUSE_BUTTON_4 (UINT64_C(1) << 3) /* Button 4 */
#define CELL_MOUSE_BUTTON_5 (UINT64_C(1) << 4) /* Button 5 */
#define CELL_MOUSE_BUTTON_6 (UINT64_C(1) << 5) /* Button 6 */
#define CELL_MOUSE_BUTTON_7 (UINT64_C(1) << 6) /* Button 7 */
#define CELL_MOUSE_BUTTON_8 (UINT64_C(1) << 7) /* Button 8 */
#else
#include <cell/mouse.h>
#endif
#endif
/*============================================================
OSK PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <sysutil/osk.h>
/* define all the OSK functions */
#define pOskLoadAsync oskLoadAsync
#define pOskSetLayoutMode oskSetLayoutMode
#define pOskSetKeyLayoutOption oskSetKeyLayoutOption
#define pOskGetSize oskGetSize
#define pOskDisableDimmer oskDisableDimmer
#define pOskAbort oskAbort
#define pOskUnloadAsync oskUnloadAsync
/* define OSK structs / types */
#define sys_memory_container_t sys_mem_container_t
#define CellOskDialogPoint oskPoint
#define CellOskDialogInputFieldInfo oskInputFieldInfo
#define CellOskDialogCallbackReturnParam oskCallbackReturnParam
#define CellOskDialogParam oskParam
#define osk_allowed_panels allowedPanels
#define osk_prohibit_flags prohibitFlags
#define osk_inputfield_message message
#define osk_inputfield_starttext startText
#define osk_inputfield_max_length maxLength
#define osk_callback_return_param res
#define osk_callback_num_chars len
#define osk_callback_return_string str
/* define the OSK defines */
#define CELL_OSKDIALOG_10KEY_PANEL OSK_10KEY_PANEL
#define CELL_OSKDIALOG_FULLKEY_PANEL OSK_FULLKEY_PANEL
#define CELL_OSKDIALOG_LAYOUTMODE_X_ALIGN_CENTER OSK_LAYOUTMODE_HORIZONTAL_ALIGN_CENTER
#define CELL_OSKDIALOG_LAYOUTMODE_Y_ALIGN_TOP OSK_LAYOUTMODE_VERTICAL_ALIGN_TOP
#define CELL_OSKDIALOG_PANELMODE_NUMERAL OSK_PANEL_TYPE_NUMERAL
#define CELL_OSKDIALOG_PANELMODE_NUMERAL_FULL_WIDTH OSK_PANEL_TYPE_NUMERAL_FULL_WIDTH
#define CELL_OSKDIALOG_PANELMODE_ALPHABET OSK_PANEL_TYPE_ALPHABET
#define CELL_OSKDIALOG_PANELMODE_ENGLISH OSK_PANEL_TYPE_ENGLISH
#define CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK (0)
#define CELL_OSKDIALOG_INPUT_FIELD_RESULT_CANCELED (1)
#define CELL_OSKDIALOG_INPUT_FIELD_RESULT_ABORT (2)
#define CELL_OSKDIALOG_INPUT_FIELD_RESULT_NO_INPUT_TEXT (3)
#define CELL_OSKDIALOG_STRING_SIZE (512)
#else
#include <sysutil/sysutil_oskdialog.h>
/* define all the OSK functions */
#define pOskLoadAsync cellOskDialogLoadAsync
#define pOskSetLayoutMode cellOskDialogSetLayoutMode
#define pOskSetKeyLayoutOption cellOskDialogSetKeyLayoutOption
#define pOskGetSize cellOskDialogGetSize
#define pOskDisableDimmer cellOskDialogDisableDimmer
#define pOskAbort cellOskDialogAbort
#define pOskUnloadAsync cellOskDialogUnloadAsync
/* define OSK structs / types */
#define osk_allowed_panels allowOskPanelFlg
#define osk_prohibit_flags prohibitFlgs
#define osk_inputfield_message message
#define osk_inputfield_starttext init_text
#define osk_inputfield_max_length limit_length
#define osk_callback_return_param result
#define osk_callback_num_chars numCharsResultString
#define osk_callback_return_string pResultString
#endif
/*============================================================
JPEG/PNG DECODING/ENCODING PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#define spu_enable enable
#define stream_select stream
#define color_alpha alpha
#define color_space space
#define output_mode mode
#define output_bytes_per_line bytes_per_line
#define output_width width
#define output_height height
#define CELL_OK 0
#define PTR_NULL 0
#else
/* define the JPEG/PNG struct member names */
#define spu_enable spuThreadEnable
#define ppu_prio ppuThreadPriority
#define spu_prio spuThreadPriority
#define malloc_func cbCtrlMallocFunc
#define malloc_arg cbCtrlMallocArg
#define free_func cbCtrlFreeFunc
#define free_arg cbCtrlFreeArg
#define stream_select srcSelect
#define file_name fileName
#define file_offset fileOffset
#define file_size fileSize
#define stream_ptr streamPtr
#define stream_size streamSize
#define down_scale downScale
#define color_alpha outputColorAlpha
#define color_space outputColorSpace
#define cmd_ptr commandPtr
#define quality method
#define output_mode outputMode
#define output_bytes_per_line outputBytesPerLine
#define output_width outputWidth
#define output_height outputHeight
#define bit_depth outputBitDepth
#define pack_flag outputPackFlag
#define alpha_select outputAlphaSelect
#define PTR_NULL NULL
#endif
/*============================================================
TIMER PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#define sys_timer_usleep usleep
#endif
/*============================================================
THREADING PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <sys/thread.h>
/* FIXME - not sure if this is correct -> FIXED! 1 and not 0 */
#define SYS_THREAD_CREATE_JOINABLE THREAD_JOINABLE
#else
#include <sys/ppu_thread.h>
#define SYS_PROCESS_SPAWN_STACK_SIZE_1M SYS_PROCESS_PRIMARY_STACK_SIZE_1M
#define SYS_THREAD_CREATE_JOINABLE SYS_PPU_THREAD_CREATE_JOINABLE
#define sysThreadCreate sys_ppu_thread_create
#define sysThreadJoin sys_ppu_thread_join
#define sysThreadExit sys_ppu_thread_exit
#define sysProcessExit sys_process_exit
#define sysProcessExitSpawn2 sys_game_process_exitspawn
#endif
/*============================================================
MEMORY PROTOTYPES
============================================================ */
#ifndef __PSL1GHT__
#define sysMemContainerCreate sys_memory_container_create
#define sysMemContainerDestroy sys_memory_container_destroy
#endif
/*============================================================
RSX PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <sysutil/video.h>
#define CELL_GCM_FALSE GCM_FALSE
#define CELL_GCM_TRUE GCM_TRUE
#define CELL_GCM_ONE GCM_ONE
#define CELL_GCM_ZERO GCM_ZERO
#define CELL_GCM_ALWAYS GCM_ALWAYS
#define CELL_GCM_LOCATION_LOCAL GCM_LOCATION_RSX
#define CELL_GCM_LOCATION_MAIN GCM_LOCATION_CELL
#define CELL_GCM_MAX_RT_DIMENSION (4096)
#define CELL_GCM_TEXTURE_LINEAR_NEAREST GCM_TEXTURE_LINEAR_MIPMAP_NEAREST
#define CELL_GCM_TEXTURE_LINEAR_LINEAR GCM_TEXTURE_LINEAR_MIPMAP_LINEAR
#define CELL_GCM_TEXTURE_NEAREST_LINEAR GCM_TEXTURE_NEAREST_MIPMAP_LINEAR
#define CELL_GCM_TEXTURE_NEAREST_NEAREST GCM_TEXTURE_NEAREST_MIPMAP_NEAREST
#define CELL_GCM_TEXTURE_NEAREST GCM_TEXTURE_NEAREST
#define CELL_GCM_TEXTURE_LINEAR GCM_TEXTURE_LINEAR
#define CELL_GCM_TEXTURE_A8R8G8B8 GCM_TEXTURE_FORMAT_A8R8G8B8
#define CELL_GCM_TEXTURE_R5G6B5 GCM_TEXTURE_FORMAT_R5G6B5
#define CELL_GCM_TEXTURE_A1R5G5B5 GCM_TEXTURE_FORMAT_A1R5G5B5
#define CELL_GCM_TEXTURE_CLAMP_TO_EDGE GCM_TEXTURE_CLAMP_TO_EDGE
#define CELL_GCM_TEXTURE_MAX_ANISO_1 GCM_TEXTURE_MAX_ANISO_1
#define CELL_GCM_TEXTURE_CONVOLUTION_QUINCUNX GCM_TEXTURE_CONVOLUTION_QUINCUNX
#define CELL_GCM_TEXTURE_ZFUNC_NEVER GCM_TEXTURE_ZFUNC_NEVER
#define CELL_GCM_DISPLAY_HSYNC GCM_FLIP_HSYNC
#define CELL_GCM_DISPLAY_VSYNC GCM_FLIP_VSYNC
#define CELL_GCM_CLEAR_R GCM_CLEAR_R
#define CELL_GCM_CLEAR_G GCM_CLEAR_G
#define CELL_GCM_CLEAR_B GCM_CLEAR_B
#define CELL_GCM_CLEAR_A GCM_CLEAR_A
#define CELL_GCM_FUNC_ADD GCM_FUNC_ADD
#define CELL_GCM_SMOOTH (0x1D01)
#define CELL_GCM_DEBUG_LEVEL2 2
#define CELL_GCM_COMPMODE_DISABLED 0
#define CELL_GCM_TRANSFER_LOCAL_TO_LOCAL 0
#define CELL_GCM_TEXTURE_REMAP_ORDER_XYXY (0)
#define CELL_GCM_TEXTURE_REMAP_ORDER_XXXY (1)
#define CELL_GCM_TEXTURE_UNSIGNED_REMAP_NORMAL (0)
#define CELL_GCM_TEXTURE_REMAP_FROM_A (0)
#define CELL_GCM_TEXTURE_REMAP_FROM_R (1)
#define CELL_GCM_TEXTURE_REMAP_FROM_G (2)
#define CELL_GCM_TEXTURE_REMAP_FROM_B (3)
#define CELL_GCM_TEXTURE_REMAP_ZERO (0)
#define CELL_GCM_TEXTURE_REMAP_ONE (1)
#define CELL_GCM_TEXTURE_REMAP_REMAP (2)
#define CELL_GCM_MAX_TEXIMAGE_COUNT (16)
#define CELL_GCM_TEXTURE_WRAP (1)
#define CELL_GCM_TEXTURE_NR (0x00)
#define CELL_GCM_TEXTURE_LN (0x20)
#define CELL_GCM_TEXTURE_B8 (0x81)
#define CELL_RESC_720x480 RESC_720x480
#define CELL_RESC_720x576 RESC_720x576
#define CELL_RESC_1280x720 RESC_1280x720
#define CELL_RESC_1920x1080 RESC_1920x1080
#define CELL_RESC_FULLSCREEN RESC_FULLSCREEN
#define CELL_RESC_PANSCAN RESC_PANSCAN
#define CELL_RESC_LETTERBOX RESC_LETTERBOX
#define CELL_RESC_CONSTANT_VRAM RESC_CONSTANT_VRAM
#define CELL_RESC_MINIMUM_GPU_LOAD RESC_MINIMUM_GPU_LOAD
#define CELL_RESC_PAL_50 RESC_PAL_50
#define CELL_RESC_PAL_60_DROP RESC_PAL_60_DROP
#define CELL_RESC_PAL_60_INTERPOLATE RESC_PAL_60_INTERPOLATE
#define CELL_RESC_PAL_60_INTERPOLATE_30_DROP RESC_PAL_60_INTERPOLATE_30_DROP
#define CELL_RESC_PAL_60_INTERPOLATE_DROP_FLEXIBLE RESC_PAL_60_INTERPOLATE_DROP_FLEXIBLE
#define CELL_RESC_INTERLACE_FILTER RESC_INTERLACE_FILTER
#define CELL_RESC_NORMAL_BILINEAR RESC_NORMAL_BILINEAR
#define CELL_RESC_ELEMENT_HALF RESC_ELEMENT_HALF
#define CELL_VIDEO_OUT_ASPECT_AUTO VIDEO_ASPECT_AUTO
#define CELL_VIDEO_OUT_ASPECT_4_3 VIDEO_ASPECT_4_3
#define CELL_VIDEO_OUT_ASPECT_16_9 VIDEO_ASPECT_16_9
#define CELL_VIDEO_OUT_RESOLUTION_480 VIDEO_RESOLUTION_480
#define CELL_VIDEO_OUT_RESOLUTION_576 VIDEO_RESOLUTION_576
#define CELL_VIDEO_OUT_RESOLUTION_720 VIDEO_RESOLUTION_720
#define CELL_VIDEO_OUT_RESOLUTION_1080 VIDEO_RESOLUTION_1080
#define CELL_VIDEO_OUT_RESOLUTION_960x1080 VIDEO_RESOLUTION_960x1080
#define CELL_VIDEO_OUT_RESOLUTION_1280x1080 VIDEO_RESOLUTION_1280x1080
#define CELL_VIDEO_OUT_RESOLUTION_1440x1080 VIDEO_RESOLUTION_1440x1080
#define CELL_VIDEO_OUT_RESOLUTION_1600x1080 VIDEO_RESOLUTION_1600x1080
#define CELL_VIDEO_OUT_SCAN_MODE_PROGRESSIVE VIDEO_SCANMODE_PROGRESSIVE
#define CELL_VIDEO_OUT_PRIMARY VIDEO_PRIMARY
#define CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8 VIDEO_BUFFER_FORMAT_XRGB
#define CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_R16G16B16X16_FLOAT VIDEO_BUFFER_FORMAT_FLOAT
#define CellGcmSurface gcmSurface
#define CellGcmTexture gcmTexture
#define CellGcmContextData _gcmCtxData
#define CellGcmConfig gcmConfiguration
#define CellVideoOutConfiguration videoConfiguration
#define CellVideoOutResolution videoResolution
#define CellVideoOutState videoState
#define CellRescInitConfig rescInitConfig
#define CellRescSrc rescSrc
#define CellRescBufferMode rescBufferMode
#define resolutionId resolution
#define memoryFrequency memoryFreq
#define coreFrequency coreFreq
#define cellGcmFinish rsxFinish
#define cellGcmGetFlipStatus gcmGetFlipStatus
#define cellGcmResetFlipStatus gcmResetFlipStatus
#define cellGcmSetWaitFlip gcmSetWaitFlip
#define cellGcmSetDebugOutputLevel gcmSetDebugOutputLevel
#define cellGcmSetDisplayBuffer gcmSetDisplayBuffer
#define cellGcmSetGraphicsHandler gcmSetGraphicsHandler
#define cellGcmSetFlipHandler gcmSetFlipHandler
#define cellGcmSetVBlankHandler gcmSetVBlankHandler
#define cellGcmGetConfiguration gcmGetConfiguration
#define cellGcmSetJumpCommand rsxSetJumpCommand
#define cellGcmFlush rsxFlushBuffer
#define cellGcmSetFlipMode gcmSetFlipMode
#define cellGcmSetFlip gcmSetFlip
#define cellGcmGetLabelAddress gcmGetLabelAddress
#define cellGcmUnbindTile gcmUnbindTile
#define cellGcmBindTile gcmBindTile
#define cellGcmSetTileInfo gcmSetTileInfo
#define cellGcmAddressToOffset gcmAddressToOffset
#define cellRescCreateInterlaceTable rescCreateInterlaceTable
#define cellRescSetDisplayMode rescSetDisplayMode
#define cellRescGetNumColorBuffers rescGetNumColorBuffers
#define cellRescGetBufferSize rescGetBufferSize
#define cellRescSetBufferAddress rescSetBufferAddress
#define cellRescGetFlipStatus rescGetFlipStatus
#define cellRescResetFlipStatus rescResetFlipStatus
#define cellRescSetConvertAndFlip rescSetConvertAndFlip
#define cellRescSetVBlankHandler rescSetVBlankHandler
#define cellRescSetFlipHandler rescSetFlipHandler
#define cellRescAdjustAspectRatio rescAdjustAspectRatio
#define cellRescSetWaitFlip rescSetWaitFlip
#define cellRescSetSrc rescSetSrc
#define cellRescInit rescInit
#define cellRescExit rescExit
#define cellVideoOutConfigure videoConfigure
#define cellVideoOutGetState videoGetState
#define cellVideoOutGetResolution videoGetResolution
#define cellVideoOutGetResolutionAvailability videoGetResolutionAvailability
#define cellGcmSetViewportInline rsxSetViewport
#define cellGcmSetReferenceCommandInline rsxSetReferenceCommand
#define cellGcmSetBlendEquationInline rsxSetBlendEquation
#define cellGcmSetWriteBackEndLabelInline rsxSetWriteBackendLabel
#define cellGcmSetWaitLabelInline rsxSetWaitLabel
#define cellGcmSetDepthTestEnableInline rsxSetDepthTestEnable
#define cellGcmSetScissorInline rsxSetScissor
#define cellGcmSetBlendEnableInline rsxSetBlendEnable
#define cellGcmSetClearColorInline rsxSetClearColor
#define cellGcmSetBlendFuncInline rsxSetBlendFunc
#define cellGcmSetBlendColorInline rsxSetBlendColor
#define cellGcmSetTextureFilterInline rsxTextureFilter
#define cellGcmSetTextureControlInline rsxTextureControl
#define cellGcmSetCullFaceEnableInline rsxSetCullFaceEnable
#define cellGcmSetShadeModeInline rsxSetShadeModel
#define cellGcmSetTransferImage rsxSetTransferImage
#define cellGcmSetBlendColor rsxSetBlendColor
#define cellGcmSetBlendEquation rsxSetBlendEquation
#define cellGcmSetBlendFunc rsxSetBlendFunc
#define cellGcmSetClearColor rsxSetClearColor
#define cellGcmSetScissor rsxSetScissor
#define celGcmSetInvalidateVertexCache(fifo) rsxInvalidateTextureCache(fifo, GCM_INVALIDATE_VERTEX_TEXTURE)
#else
#define cellGcmSetTransferImage cellGcmSetTransferImageInline
#define celGcmSetInvalidateVertexCache cellGcmSetInvalidateVertexCacheInline
#endif
/*============================================================
NETWORK PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <net/netctl.h>
#define cellNetCtlInit netCtlInit
#define cellNetCtlGetState netCtlGetState
#define cellNetCtlTerm netCtlTerm
#define CELL_NET_CTL_STATE_IPObtained NET_CTL_STATE_IPObtained
#else
#define netCtlInit cellNetCtlInit
#define netCtlGetState cellNetCtlGetState
#define netCtlTerm cellNetCtlTerm
#define NET_CTL_STATE_IPObtained CELL_NET_CTL_STATE_IPObtained
#endif
/*============================================================
NET PROTOTYPES
============================================================ */
#if defined(HAVE_NETWORKING)
#ifdef __PSL1GHT__
#include <net/net.h>
#define socketselect select
#define socketclose close
#define sys_net_initialize_network netInitialize
#define sys_net_finalize_network netFinalizeNetwork
#else
#include <netex/net.h>
#include <np.h>
#include <np/drm.h>
#define netInitialize sys_net_initialize_network
#define netFinalizeNetwork sys_net_finalize_network
#endif
#endif
/*============================================================
SYSUTIL PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#include <sysutil/game.h>
#define CellGameContentSize sysGameContentSize
#define cellGameContentPermit sysGameContentPermit
#define cellGameBootCheck sysGameBootCheck
#define CELL_GAME_ATTRIBUTE_APP_HOME (UINT64_C(1) <<1) /* boot from / app_home/PS3_GAME */
#define CELL_GAME_DIRNAME_SIZE 32
#define CELL_GAME_GAMETYPE_SYS 0
#define CELL_GAME_GAMETYPE_DISC 1
#define CELL_GAME_GAMETYPE_HDD 2
#define CELL_GAME_GAMETYPE_GAMEDATA 3
#define CELL_GAME_GAMETYPE_HOME 4
#endif
#if defined(HAVE_SYSUTILS)
#ifdef __PSL1GHT__
#include <sysutil/sysutil.h>
#define CELL_SYSUTIL_REQUEST_EXITGAME SYSUTIL_EXIT_GAME
#define cellSysutilRegisterCallback sysUtilRegisterCallback
#define cellSysutilCheckCallback sysUtilCheckCallback
#else
#include <sysutil/sysutil_screenshot.h>
#include <sysutil/sysutil_common.h>
#include <sysutil/sysutil_gamecontent.h>
#endif
#endif
#if(CELL_SDK_VERSION > 0x340000)
#include <sysutil/sysutil_bgmplayback.h>
#endif
/*============================================================
SYSMODULE PROTOTYPES
============================================================ */
#if defined(HAVE_SYSMODULES)
#ifdef __PSL1GHT__
#include <sysmodule/sysmodule.h>
#define CELL_SYSMODULE_IO SYSMODULE_IO
#define CELL_SYSMODULE_FS SYSMODULE_FS
#define CELL_SYSMODULE_NET SYSMODULE_NET
#define CELL_SYSMODULE_SYSUTIL_NP SYSMODULE_SYSUTIL_NP
#define CELL_SYSMODULE_JPGDEC SYSMODULE_JPGDEC
#define CELL_SYSMODULE_PNGDEC SYSMODULE_PNGDEC
#define cellSysmoduleLoadModule sysModuleLoad
#define cellSysmoduleUnloadModule sysModuleUnload
#else
#include <cell/sysmodule.h>
#define sysModuleLoad cellSysmoduleLoadModule
#define sysModuleUnload cellSysmoduleUnloadModule
#define SYSMODULE_NET CELL_SYSMODULE_NET
#endif
#endif
/*============================================================
FS PROTOTYPES
============================================================ */
#define FS_SUCCEEDED 0
#define FS_TYPE_DIR 1
#ifdef __PSL1GHT__
#include <lv2/sysfs.h>
#define O_RDONLY SYS_O_RDONLY
#define O_WRONLY SYS_O_WRONLY
#define O_CREAT SYS_O_CREAT
#define O_TRUNC SYS_O_TRUNC
#define O_RDWR SYS_O_RDWR
#else
#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
#define sysFsStat cellFsStat
#define sysFSStat CellFsStat
#define sysFSDirent CellFsDirent
#define sysFsOpendir cellFsOpendir
#define sysFsReaddir cellFsReaddir
#define sysFSDirent CellFsDirent
#define sysFsClosedir cellFsClosedir
#endif
#endif

View file

@ -0,0 +1,145 @@
/* Copyright (C) 2010-2021 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (psp_defines.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 _PSP_DEFINES_H
#define _PSP_DEFINES_H
/*============================================================
ERROR PROTOTYPES
============================================================ */
#ifndef SCE_OK
#define SCE_OK 0
#endif
/*============================================================
DISPLAY PROTOTYPES
============================================================ */
#if defined(SN_TARGET_PSP2) || defined(VITA)
#ifdef VITA
int sceClibPrintf ( const char * format, ... );
#define printf sceClibPrintf
#define PSP_DISPLAY_PIXEL_FORMAT_8888 (SCE_DISPLAY_PIXELFORMAT_A8B8G8R8)
#else
#define PSP_DISPLAY_PIXEL_FORMAT_8888 (SCE_DISPLAY_PIXELFORMAT_A8B8G8R8)
#endif
#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, sync)
#define PSP_FB_WIDTH 960
#define PSP_FB_HEIGHT 544
#define PSP_PITCH_PIXELS 1024
// Memory left to the system for threads and other internal stuffs
#ifdef SCE_LIBC_SIZE
#define RAM_THRESHOLD 0x2000000 + SCE_LIBC_SIZE
#else
#define RAM_THRESHOLD 0x2000000
#endif
#elif defined(PSP)
#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync)
#define SCE_DISPLAY_UPDATETIMING_NEXTVSYNC 1
#define PSP_FB_WIDTH 512
#define PSP_FB_HEIGHT 512
#define PSP_PITCH_PIXELS 512
#endif
/*============================================================
INPUT PROTOTYPES
============================================================ */
#if defined(SN_TARGET_PSP2) || defined(VITA)
#define STATE_BUTTON(state) ((state).buttons)
#define STATE_ANALOGLX(state) ((state).lx)
#define STATE_ANALOGLY(state) ((state).ly)
#define STATE_ANALOGRX(state) ((state).rx)
#define STATE_ANALOGRY(state) ((state).ry)
#if defined(VITA)
#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_ANALOG)
#define PSP_CTRL_LEFT SCE_CTRL_LEFT
#define PSP_CTRL_DOWN SCE_CTRL_DOWN
#define PSP_CTRL_RIGHT SCE_CTRL_RIGHT
#define PSP_CTRL_UP SCE_CTRL_UP
#define PSP_CTRL_START SCE_CTRL_START
#define PSP_CTRL_SELECT SCE_CTRL_SELECT
#define PSP_CTRL_TRIANGLE SCE_CTRL_TRIANGLE
#define PSP_CTRL_SQUARE SCE_CTRL_SQUARE
#define PSP_CTRL_CROSS SCE_CTRL_CROSS
#define PSP_CTRL_CIRCLE SCE_CTRL_CIRCLE
#define PSP_CTRL_L SCE_CTRL_L1
#define PSP_CTRL_R SCE_CTRL_R1
#define PSP_CTRL_L2 SCE_CTRL_LTRIGGER
#define PSP_CTRL_R2 SCE_CTRL_RTRIGGER
#define PSP_CTRL_L3 SCE_CTRL_L3
#define PSP_CTRL_R3 SCE_CTRL_R3
#else
#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG)
#define PSP_CTRL_LEFT SCE_CTRL_LEFT
#define PSP_CTRL_DOWN SCE_CTRL_DOWN
#define PSP_CTRL_RIGHT SCE_CTRL_RIGHT
#define PSP_CTRL_UP SCE_CTRL_UP
#define PSP_CTRL_START SCE_CTRL_START
#define PSP_CTRL_SELECT SCE_CTRL_SELECT
#define PSP_CTRL_TRIANGLE SCE_CTRL_TRIANGLE
#define PSP_CTRL_SQUARE SCE_CTRL_SQUARE
#define PSP_CTRL_CROSS SCE_CTRL_CROSS
#define PSP_CTRL_CIRCLE SCE_CTRL_CIRCLE
#define PSP_CTRL_L SCE_CTRL_L
#define PSP_CTRL_R SCE_CTRL_R
#endif
#if defined(VITA)
#define CtrlSetSamplingMode(mode) sceCtrlSetSamplingModeExt(mode)
#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositiveExt2(port, pad_data, bufs)
#else
#define CtrlSetSamplingMode(mode) sceCtrlSetSamplingMode(mode)
#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(port, pad_data, bufs)
#endif
#elif defined(PSP)
#define PSP_CTRL_L PSP_CTRL_LTRIGGER
#define PSP_CTRL_R PSP_CTRL_RTRIGGER
#define STATE_BUTTON(state) ((state).Buttons)
#define STATE_ANALOGLX(state) ((state).Lx)
#define STATE_ANALOGLY(state) ((state).Ly)
#define STATE_ANALOGRX(state) ((state).Rx)
#define STATE_ANALOGRY(state) ((state).Ry)
#define DEFAULT_SAMPLING_MODE (PSP_CTRL_MODE_ANALOG)
#define CtrlSetSamplingMode(mode) sceCtrlSetSamplingMode(mode)
#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(pad_data, bufs)
#endif
#endif

View file

@ -55,6 +55,7 @@ struct config_file
{
char *path;
char *reference;
struct config_entry_list **entries_map;
struct config_entry_list *entries;
struct config_entry_list *tail;
struct config_entry_list *last;

View file

@ -1378,6 +1378,16 @@ enum retro_mod
* call will target the newly initialized driver.
*/
#define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64
/* const struct retro_fastforwarding_override * --
* Used by a libretro core to override the current
* fastforwarding mode of the frontend.
* If NULL is passed to this function, the frontend
* will return true if fastforwarding override
* functionality is supported (no change in
* fastforwarding state will occur in this case).
*/
/* VFS functionality */
/* File paths:
@ -2938,6 +2948,47 @@ struct retro_framebuffer
Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
};
/* Used by a libretro core to override the current
* fastforwarding mode of the frontend */
struct retro_fastforwarding_override
{
/* Specifies the runtime speed multiplier that
* will be applied when 'fastforward' is true.
* For example, a value of 5.0 when running 60 FPS
* content will cap the fast-forward rate at 300 FPS.
* Note that the target multiplier may not be achieved
* if the host hardware has insufficient processing
* power.
* Setting a value of 0.0 (or greater than 0.0 but
* less than 1.0) will result in an uncapped
* fast-forward rate (limited only by hardware
* capacity).
* If the value is negative, it will be ignored
* (i.e. the frontend will use a runtime speed
* multiplier of its own choosing) */
float ratio;
/* If true, fastforwarding mode will be enabled.
* If false, fastforwarding mode will be disabled. */
bool fastforward;
/* If true, and if supported by the frontend, an
* on-screen notification will be displayed while
* 'fastforward' is true.
* If false, and if supported by the frontend, any
* on-screen fast-forward notifications will be
* suppressed */
bool notification;
/* If true, the core will have sole control over
* when fastforwarding mode is enabled/disabled;
* the frontend will not be able to change the
* state set by 'fastforward' until either
* 'inhibit_toggle' is set to false, or the core
* is unloaded */
bool inhibit_toggle;
};
/* Callbacks */
/* Environment callback. Gives implementations a way of performing

298
include/lists/linked_list.h Normal file
View file

@ -0,0 +1,298 @@
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (linked_list.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_LINKED_LIST_H
#define __LIBRETRO_SDK_LINKED_LIST_H
#include <retro_common_api.h>
#include <boolean.h>
#include <stddef.h>
RETRO_BEGIN_DECLS
/**
* Represents a linked list. Contains any number of elements.
*/
typedef struct linked_list linked_list_t;
/**
* Represents an iterator for iterating over a linked list. The iterator can
* go through the linked list forwards or backwards.
*/
typedef struct linked_list_iterator linked_list_iterator_t;
/**
* Creates a new linked list with no elements.
*
* @return New linked list
*/
linked_list_t *linked_list_new(void);
/**
* @brief frees the memory used by the linked list
*
* Frees all of the memory used by this linked list. The values of all
* remaining elements are freed using the "free_value" function. Does
* nothing if "list" is NULL.
*
* @param list linked list to free
* @param free_value function to use to free remaining values
*/
void linked_list_free(linked_list_t *list, void (*free_value)(void *value));
/**
* @brief adds an element to the linked list
*
* Add a new element to the end of this linked list. Does nothing if
* "list" is NULL.
*
* @param list list to add the element to
* @param value new value to add to the linked list
*/
void linked_list_add(linked_list_t *list, void *value);
/**
* @brief inserts a value into the linked list
*
* Inserts a value into the linked list at the specified index. Does
* nothing if "list" is NULL.
*
* @param list list to insert the value into
* @param index index where the value should be inserted at (can be equal to list size)
* @param value value to insert into the linked list
*/
void linked_list_insert(linked_list_t *list, size_t index, void *value);
/**
* @brief Get the value in the linked list at the provided index.
*
* Return the value vstored in the linked list at the provided index. Does
* nothing if "list" is NULL.
*
* @param list list to get the value from
* @param index index of the value to return
* @return value in the list at the provided index
*/
void *linked_list_get(linked_list_t *list, size_t index);
/**
* @brief Get the first value that is matched by the provided function
*
* Return the first value that the function matches. The matches function
* parameters are value from the linked list and the provided state.
*
* @param list list to get the value from
* @param matches function to test the values with
* @param usrptr user data to pass to the matches function
* @return first value that matches otherwise NULL
*/
void *linked_list_get_first_matching(linked_list_t *list, bool (*matches)(void *item, void *usrptr), void *usrptr);
/**
* @brief Get the last value that is matched by the provided function
*
* Return the last value that the function matches. The matches function
* parameters are value from the linked list and the provided state.
*
* @param list list to get the value from
* @param matches function to test the values with
* @param usrptr user data to pass to the matches function
* @return last value that matches otherwise NULL
*/
void *linked_list_get_last_matching(linked_list_t *list, bool (*matches)(void *item, void *usrptr), void *usrptr);
/**
* @brief Remove the element at the provided index
*
* Removes the element of the linked list at the provided index.
*
* @param list linked list to remove the element from
* @param index index of the element to remove
* @return value of the element that was removed, NULL if list is NULL or
* index is invalid
*/
void *linked_list_remove_at(linked_list_t *list, size_t index);
/**
* @brief Remove the first element with the provided value
*
* Removes the first element with a value equal to the provided value.
* Does nothing if "list" is NULL.
*
* @param list linked list to remove the element from
* @param value value of the element to remove
* @return value if a matching element was removed
*/
void *linked_list_remove_first(linked_list_t *list, void *value);
/**
* @brief Remove the last element with the provided value
*
* Removes the last element with a value equal to the provided value.
* Does nothing if "list" is NULL.
*
* @param list linked list to remove the element from
* @param value value of the element to remove
* @return value if a matching element was removed
*/
void *linked_list_remove_last(linked_list_t *list, void *value);
/**
* @brief Remove all elements with the provided value
*
* Removes all elements with a value equal to the provided value.
* Does nothing if "list" is NULL.
*
* @param list linked list to remove the elements from
* @param value value of the elements to remove
* @return value if any matching element(s) where removed
*/
void *linked_list_remove_all(linked_list_t *list, void *value);
/**
* @brief Remove the first matching element
*
* Removes the first matching element from the linked list. The "matches" function
* is used to test for matching element values. Does nothing if "list" is NULL.
*
* @param list linked list to remove the element from
* @param matches function to use for testing element values for a match
* @return value if a matching element was removed
*/
void *linked_list_remove_first_matching(linked_list_t *list, bool (*matches)(void *value));
/**
* @brief Remove the last matching element
*
* Removes the last matching element from the linked list. The "matches" function
* is used to test for matching element values.
*
* @param list linked list to remove the element from
* @param matches function to use for testing element value for a match
* @return value if a matching element was removed
*/
void *linked_list_remove_last_matching(linked_list_t *list, bool (*matches)(void *value));
/**
* @brief Remove all matching elements
*
* Removes all matching elements from the linked list. The "matches" function
* is used to test for matching element values. Does nothing if "list" is NULL.
*
* @param list linked list to remove the elements from
* @param matches function to use for testing element values for a match
*/
void linked_list_remove_all_matching(linked_list_t *list, bool (*matches)(void *value));
/**
* @brief Replace the value of the element at the provided index
*
* Replaces the value of the element at the provided index. The linked list must
* contain an element at the index.
*
* @param list linked list to replace the value in
* @param index index of the element to replace the value of
* @param value new value for the selected element
* @return whether an element was updated
*/
bool linked_list_set_at(linked_list_t *list, size_t index, void *value);
/**
* @brief Get the size of the linked list
*
* Returns the number of elements in the linked list.
*
* @param linked list to get the size of
* @return number of elements in the linked list, 0 if linked list is NULL
*/
size_t linked_list_size(linked_list_t *list);
/**
* @brief Get an iterator for the linked list
*
* Returns a new iterator for the linked list. Can be either a forward or backward
* iterator.
*
* @param list linked list to iterate over
* @param forward true for a forward iterator, false for backwards
* @return new iterator for the linked list in the specified direction, NULL if
* "list" is NULL
*/
linked_list_iterator_t *linked_list_iterator(linked_list_t *list, bool forward);
/**
* @brief Move to the next element in the linked list
*
* Moves the iterator to the next element in the linked list. The direction is
* specified when retrieving a new iterator.
*
* @param iterator iterator for the current element
* @return iterator for the next element, NULL if iterator is NULL or "iterator"
* is at the last element
*/
linked_list_iterator_t *linked_list_iterator_next(linked_list_iterator_t *iterator);
/**
* @brief Get the value of the element for the iterator
*
* Returns the value of the element that the iterator is at.
*
* @param iterator iterator for the current element
* @return value of the element for the iterator
*/
void *linked_list_iterator_value(linked_list_iterator_t *iterator);
/**
* @brief Remove the element that the iterator is at
*
* Removes the element that the iterator is at. The iterator is updated to the
* next element.
*
* @param iterator iterator for the current element
* @return updated iterator or NULL if the last element was removed
*/
linked_list_iterator_t *linked_list_iterator_remove(linked_list_iterator_t *iterator);
/**
* @brief Release the memory for the iterator
*
* Frees the memory for the provided iterator. Does nothing if "iterator" is NULL.
*
* @param iterator iterator to free
*/
void linked_list_iterator_free(linked_list_iterator_t *iterator);
/**
* @brief Apply the provided function to all values in the linked list
*
* Apply the provied function to all values in the linked list. The values are applied
* in the forward direction. Does nothing if "list" is NULL.
*
* @param list linked list to apply the function to
* @param fn function to apply to all elements
*/
void linked_list_foreach(linked_list_t *list, void (*fn)(size_t index, void *value));
RETRO_END_DECLS
#endif

View file

@ -0,0 +1,208 @@
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (generic_queue.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_GENERIC_QUEUE_H
#define __LIBRETRO_SDK_GENERIC_QUEUE_H
#include <retro_common_api.h>
#include <boolean.h>
#include <stddef.h>
RETRO_BEGIN_DECLS
/**
* Represents a generic queue. Can contain any number of elements. Each element contains
* a value of type "void *". Can be used as a FIFO or LIFO queue.
*/
typedef struct generic_queue generic_queue_t;
/**
* Represents an iterator for iterating over a queue.
*/
typedef struct generic_queue_iterator generic_queue_iterator_t;
/**
* Creates a new queue with no elements.
*
* @return New queue
*/
generic_queue_t *generic_queue_new(void);
/**
* @brief frees the memory used by the queue
*
* Frees all of the memory used by this queue. The values of all
* remaining elements are freed using the "free_value" function. Does
* nothing if "queue" is NULL.
*
* @param queue queue to free
* @param free_value function to use to free remaining values
*/
void generic_queue_free(generic_queue_t *queue, void (*free_value)(void *value));
/**
* @brief Push a new value onto the queue
*
* Pushes a new value onto the end of the queue. Does nothing if "queue"
* is NULL.
*
* @param queue queue to the push the value onto
* @param value value to push onto the queue
*/
void generic_queue_push(generic_queue_t *queue, void *value);
/**
* @brief Remove the last value from the queue
*
* Removes the last element from the queue. Does nothing if the queue is
* NULL.
*
* @param queue queue to get the value from
* @return value of the last element, NULL if queue is empty or NULL
*/
void *generic_queue_pop(generic_queue_t *queue);
/**
* @brief Get the last value from the queue
*
* Returns the value of the last element in the queue. Returns NULL if the
* queue is NULL or empty.
*
* @param queue queue to get the last value from
* @return value of the last element or NULL
*/
void *generic_queue_peek(generic_queue_t *queue);
/**
* @brief Get the first value from the queue
*
* Returns the value of the first element in the queue. Returns NULL if the
* queue is NULL or empty.
*
* @param queue queue to get the first value from
* @return value of the first element or NULL
*/
void *generic_queue_peek_first(generic_queue_t *queue);
/**
* @brief Push a new value onto the front of the queue
*
* Pushes a new value onto the front of the queue. Does nothing if "queue"
* is NULL.
*
* @param queue queue to the push the value onto
* @param value value to push onto the queue
*/
void generic_queue_shift(generic_queue_t *queue, void *value);
/**
* @brief Remove the first value from the queue
*
* Removes the first element from the queue. Does nothing if the queue is
* NULL.
*
* @param queue queue to get the value from
* @return value of the last element, NULL if queue is empty or NULL
*/
void *generic_queue_unshift(generic_queue_t *queue);
/**
* @brief Get the size of the queue
*
* Returns the number of elements in the queue.
*
* @param queue queue to get the size of
* @return number of elements in the queue, 0 if queue is NULL
*/
size_t generic_queue_length(generic_queue_t *queue);
/**
* @brief Remove the first element in the queue with the provided value
*
* Removes the first element with a value matching the provided value. Does
* nothing if queue is NULL.
*
* @param queue queue to remove the element from
* @param value value to look for in the queue
* @return the value of the element removed, NULL if no element was removed
*/
void *generic_queue_remove(generic_queue_t *queue, void *value);
/**
* @brief Get an iterator for the queue
*
* Returns a new iterator for the queue. Can be either a forward or backward
* iterator.
*
* @param queue queue to iterate over
* @param forward true for a forward iterator, false for backwards
* @return new iterator for the queue in the specified direction, NULL if
* "queue" is NULL
*/
generic_queue_iterator_t *generic_queue_iterator(generic_queue_t *queue, bool forward);
/**
* @brief Move to the next element in the queue
*
* Moves the iterator to the next element in the queue. The direction is
* specified when retrieving a new iterator.
*
* @param iterator iterator for the current element
* @return iterator for the next element, NULL if iterator is NULL or "iterator"
* is at the last element
*/
generic_queue_iterator_t *generic_queue_iterator_next(generic_queue_iterator_t *iterator);
/**
* @brief Get the value of the element for the iterator
*
* Returns the value of the element that the iterator is at.
*
* @param iterator iterator for the current element
* @return value of the element for the iterator
*/
void *generic_queue_iterator_value(generic_queue_iterator_t *iterator);
/**
* @brief Remove the element that the iterator is at
*
* Removes the element that the iterator is at. The iterator is updated to the
* next element.
*
* @param iterator iterator for the current element
* @return updated iterator or NULL if the last element was removed
*/
generic_queue_iterator_t *generic_queue_iterator_remove(generic_queue_iterator_t *iterator);
/**
* @brief Release the memory for the iterator
*
* Frees the memory for the provided iterator. Does nothing if "iterator" is NULL.
*
* @param iterator iterator to free
*/
void generic_queue_iterator_free(generic_queue_iterator_t *iterator);
RETRO_END_DECLS
#endif

View file

@ -521,10 +521,11 @@ int filestream_close(RFILE *stream)
* @path : path to file.
* @buf : buffer to allocate and read the contents of the
* file into. Needs to be freed manually.
* @len : optional output integer containing bytes read.
*
* Read the contents of a file into @buf.
*
* Returns: number of items read, -1 on error.
* Returns: non zero on success.
*/
int64_t filestream_read_file(const char *path, void **buf, int64_t *len)
{

View file

@ -130,9 +130,12 @@
#include <pspkernel.h>
#endif
#if defined(__PS3__) || defined(__PSL1GHT__)
#include "defines/ps3_defines.h"
#if defined(__PSL1GHT__)
#include <lv2/sysfs.h>
#endif
#endif
#if defined(VITA)
#define FIO_S_ISDIR SCE_S_ISDIR