Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Externals/libretro-common/include/boolean.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Copyright (C) 2010-2020 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) && _MSC_VER < 1800 && !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
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ enum retro_language
RETRO_LANGUAGE_GALICIAN = 33,
RETRO_LANGUAGE_NORWEGIAN = 34,
RETRO_LANGUAGE_IRISH = 35,
RETRO_LANGUAGE_THAI = 36,
RETRO_LANGUAGE_LAST,

/** Defined to ensure that <tt>sizeof(retro_language) == sizeof(int)</tt>. Do not use. */
Expand Down Expand Up @@ -519,6 +520,9 @@ enum retro_language
/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
#define RETRO_MEMORY_VIDEO_RAM 3

/* ROM lets a frontend peek into a game systems ROM. */
#define RETRO_MEMORY_ROM 4

/** @} */

/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
Expand Down Expand Up @@ -2587,6 +2591,71 @@ enum retro_mod
*/
#define RETRO_ENVIRONMENT_GET_TARGET_SAMPLE_RATE (81 | RETRO_ENVIRONMENT_EXPERIMENTAL)

/**
* Returns the local player's netplay client index when using frontend-managed
* multiplayer/rollback netplay.
*
* @param[out] data <tt>unsigned *</tt>.
* Pointer to an unsigned integer where the frontend stores the local client index.
* 0 indicates host. Values > 0 indicate connected clients.
* @return \\c true if the environment call is available and value was written,
* \\c false otherwise.
*/
#define RETRO_ENVIRONMENT_GET_NETPLAY_CLIENT_INDEX (82 | RETRO_ENVIRONMENT_EXPERIMENTAL)

/**
* Allocates a region of executable memory, optionally dual-mapped.
*
* The frontend allocates memory suitable for JIT code generation and returns
* it to the core. The returned mode tells the core how to use the memory:
*
* - \c RETRO_EXEC_MEM_MODE_UNRESTRICTED: The platform has no restrictions
* on executable memory. The core should self-allocate. Do not call
* this environment with a non-zero size in this mode.
* - \c RETRO_EXEC_MEM_MODE_RWX: Single mapping, read-write-execute.
* \c rx and \c rw point to the same region.
* - \c RETRO_EXEC_MEM_MODE_WX_TOGGLE: Single mapping, write XOR execute.
* \c rx and \c rw point to the same region; the core must toggle
* protections itself (e.g. mprotect) before writing or executing.
* - \c RETRO_EXEC_MEM_MODE_DUAL_MAP: Separate read-execute and read-write
* mappings of the same physical pages. The core writes through \c rw
* and executes from \c rx.
*
* Returned memory is page-aligned. The frontend tracks all allocations
* and frees any outstanding ones when the core is unloaded.
*
* The core sets \c version and \c size before calling. The frontend fills
* in \c mode, \c rx, and \c rw on success.
*
* If \c size is 0, this is a probe: the frontend returns \c true and sets
* \c mode to indicate what kind of memory it would provide, but does not
* allocate. \c rx and \c rw will be NULL. Cores can use this to decide
* whether to take a JIT code path before committing to an allocation.
*
* @param[in,out] data <tt>struct retro_exec_mem_alloc *</tt>.
* @return \c true if the allocation succeeded, \c false otherwise.
* If the frontend does not support this call, returns \c false
* and the core should fall back to managing its own executable memory.
* @see retro_exec_mem_alloc
* @see RETRO_ENVIRONMENT_EXEC_MEM_FREE
*/
#define RETRO_ENVIRONMENT_EXEC_MEM_ALLOC 83

/**
* Frees a region of executable memory previously allocated with
* \c RETRO_ENVIRONMENT_EXEC_MEM_ALLOC.
*
* This is optional; the frontend will free all outstanding allocations
* when the core is unloaded. Cores that never need to release memory
* mid-session need not call this.
*
* @param[in] data <tt>struct retro_exec_mem_free *</tt>.
* @return \c true if the memory was freed, \c false otherwise.
* @see retro_exec_mem_free
* @see RETRO_ENVIRONMENT_EXEC_MEM_ALLOC
*/
#define RETRO_ENVIRONMENT_EXEC_MEM_FREE 84

/**@}*/

/**
Expand Down Expand Up @@ -2920,6 +2989,19 @@ typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const cha
*/
typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);

/**
* Gets information about the given file (64-bit size).
*
* @param path The path to the file to query.
* @param[out] size The reported size of the file in bytes.
* May be \c NULL, in which case this value is ignored.
* @return A bitmask of \c RETRO_VFS_STAT flags,
* or 0 if \c path doesn't refer to a valid file.
* @see RETRO_VFS_STAT
* @since VFS API v4
*/
typedef int (RETRO_CALLCONV *retro_vfs_stat_64_t)(const char *path, int64_t *size);

/**
* Creates a directory at the given path.
*
Expand Down Expand Up @@ -3075,6 +3157,10 @@ struct retro_vfs_interface

/** @copydoc retro_vfs_closedir_t */
retro_vfs_closedir_t closedir;

/* VFS API v4 */
/** @copydoc retro_vfs_stat_64_t */
retro_vfs_stat_64_t stat_64;
};

/**
Expand Down Expand Up @@ -4215,6 +4301,9 @@ struct retro_log_callback
/** Indicates CPU support for the ASIMD instruction set. */
#define RETRO_SIMD_ASIMD (1 << 21)

/** Indicates CPU support for the AVX512 instruction set. */
#define RETRO_SIMD_AVX512 (1 << 22)

/** @} */

/**
Expand Down Expand Up @@ -4476,23 +4565,27 @@ enum retro_sensor_action
/* Id values for SENSOR types. */

/**
* Returns the device's acceleration along its local X axis minus the effect of gravity, in m/s^2.
* Returns the device's acceleration along its local X axis, in g (standard gravity, 9.80665 m/s^2).
* Includes the effect of gravity;
* a device at rest on a table will have values close to 0, 0, 1.
*
* Positive values mean that the device is accelerating to the right.
* Positive values mean that the device is accelerating to the right,
* assuming the user is looking at it head-on.
*/
#define RETRO_SENSOR_ACCELEROMETER_X 0

/**
* Returns the device's acceleration along its local Y axis minus the effect of gravity, in m/s^2.
* Returns the device's acceleration along its local Y axis, in g (standard gravity, 9.80665 m/s^2).
* Includes the effect of gravity.
*
* Positive values mean that the device is accelerating upwards,
* assuming the user is looking at it head-on.
*/
#define RETRO_SENSOR_ACCELEROMETER_Y 1

/**
* Returns the the device's acceleration along its local Z axis minus the effect of gravity, in m/s^2.
* Returns the device's acceleration along its local Z axis, in g (standard gravity, 9.80665 m/s^2).
* Includes the effect of gravity.
*
* Positive values indicate forward acceleration towards the user,
* assuming the user is looking at the device head-on.
Expand Down Expand Up @@ -7395,6 +7488,45 @@ struct retro_device_power

/** @} */

/** @defgroup Executable Memory Modes
* Describes how the frontend provisions executable memory.
* @{
*/

#define RETRO_EXEC_MEM_MODE_UNAVAILABLE 0 /**< No executable memory available */
#define RETRO_EXEC_MEM_MODE_UNRESTRICTED 1 /**< No restrictions; core should self-allocate */
#define RETRO_EXEC_MEM_MODE_RWX 2 /**< Single mapping, read-write-execute */
#define RETRO_EXEC_MEM_MODE_WX_TOGGLE 3 /**< Single mapping, write XOR execute (core toggles) */
#define RETRO_EXEC_MEM_MODE_DUAL_MAP 4 /**< Separate R-X and R-W mappings of same pages */

/**
* Parameters for \c RETRO_ENVIRONMENT_EXEC_MEM_ALLOC.
*
* The core fills in \c version and \c size before calling.
* The frontend fills in \c mode, \c rx, and \c rw on success.
* @see RETRO_ENVIRONMENT_EXEC_MEM_ALLOC
*/
struct retro_exec_mem_alloc
{
unsigned version; /**< Set by core (currently 1). */
size_t size; /**< Set by core: requested bytes. */
unsigned mode; /**< Set by frontend: one of \c RETRO_EXEC_MEM_MODE_*. */
void *rx; /**< Set by frontend: execute from this pointer. */
void *rw; /**< Set by frontend: write through this pointer.
Equal to \c rx when mode is RWX or WX_TOGGLE. */
};

/**
* Parameters for \c RETRO_ENVIRONMENT_EXEC_MEM_FREE.
* @see RETRO_ENVIRONMENT_EXEC_MEM_FREE
*/
struct retro_exec_mem_free
{
void *rx; /**< The \c rx pointer returned by a previous alloc call. */
};

/** @} */

/**
* @defgroup Callbacks
* @{
Expand Down
148 changes: 148 additions & 0 deletions Externals/libretro-common/include/retro_common_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* Copyright (C) 2010-2020 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
#define RETRO_BEGIN_DECLS_CXX
#define RETRO_END_DECLS_CXX

#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 }
/* Force C++ linkage for a region inside a header that may be included
* from within a caller's extern "C" { ... } block -- needed when the
* region pulls in a C++ standard library header (e.g. <atomic>). */
#undef RETRO_BEGIN_DECLS_CXX
#undef RETRO_END_DECLS_CXX
#define RETRO_BEGIN_DECLS_CXX extern "C++" {
#define RETRO_END_DECLS_CXX }
#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__) && defined(__APPLE__)
#include <sys/types.h>
#endif

#ifdef _MSC_VER
#if _MSC_VER >= 1800
#include <inttypes.h>
#else
#ifndef PRId64
#define PRId64 "I64d"
#define PRIu64 "I64u"
#define PRIuPTR "Iu"
#endif
#endif
#else
/* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */
/* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */
/* https://github.com/libretro/RetroArch/issues/6009 */
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#endif
#ifndef PRId64
#error "inttypes.h is being screwy"
#endif
#define STRING_REP_INT64 "%" PRId64
#define STRING_REP_UINT64 "%" PRIu64
#define STRING_REP_USIZE "%" PRIuPTR

/* Wrap a declaration in RETRO_DEPRECATED() to produce a compiler warning when
it's used. This is intended for developer machines, so it won't work on ancient
or obscure compilers */
#if defined(_MSC_VER)
#if _MSC_VER >= 1400 /* Visual C 2005 or later */
#define RETRO_DEPRECATED(decl) __declspec(deprecated) decl
#endif
#elif defined(__GNUC__)
#if __GNUC__ >= 3 /* GCC 3 or later */
#define RETRO_DEPRECATED(decl) decl __attribute__((deprecated))
#endif
#elif defined(__clang__)
#if __clang_major__ >= 3 /* clang 3 or later */
#define RETRO_DEPRECATED(decl) decl __attribute__((deprecated))
#endif
#endif
#ifndef RETRO_DEPRECATED /* Unsupported compilers */
#define RETRO_DEPRECATED(decl) decl
#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 they are 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
Loading
Loading