Skip to content

Commit 17c6a8a

Browse files
committed
Move from Externals/libretro to libretro-common
1 parent 86d366b commit 17c6a8a

15 files changed

Lines changed: 668 additions & 5 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Copyright (C) 2010-2020 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (boolean.h).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#ifndef __LIBRETRO_SDK_BOOLEAN_H
24+
#define __LIBRETRO_SDK_BOOLEAN_H
25+
26+
#ifndef __cplusplus
27+
28+
#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
29+
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
30+
#define bool unsigned char
31+
#define true 1
32+
#define false 0
33+
#else
34+
#include <stdbool.h>
35+
#endif
36+
37+
#endif
38+
39+
#endif

Externals/Libretro/Include/libretro.h renamed to Externals/libretro-common/include/libretro.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,19 @@ typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const cha
29202920
*/
29212921
typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);
29222922

2923+
/**
2924+
* Gets information about the given file (64-bit size).
2925+
*
2926+
* @param path The path to the file to query.
2927+
* @param[out] size The reported size of the file in bytes.
2928+
* May be \c NULL, in which case this value is ignored.
2929+
* @return A bitmask of \c RETRO_VFS_STAT flags,
2930+
* or 0 if \c path doesn't refer to a valid file.
2931+
* @see RETRO_VFS_STAT
2932+
* @since VFS API v4
2933+
*/
2934+
typedef int (RETRO_CALLCONV *retro_vfs_stat_64_t)(const char *path, int64_t *size);
2935+
29232936
/**
29242937
* Creates a directory at the given path.
29252938
*
@@ -3075,6 +3088,10 @@ struct retro_vfs_interface
30753088

30763089
/** @copydoc retro_vfs_closedir_t */
30773090
retro_vfs_closedir_t closedir;
3091+
3092+
/* VFS API v4 */
3093+
/** @copydoc retro_vfs_stat_64_t */
3094+
retro_vfs_stat_64_t stat_64;
30783095
};
30793096

30803097
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/* Copyright (C) 2010-2020 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (retro_common_api.h).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_API_H
24+
#define _LIBRETRO_COMMON_RETRO_COMMON_API_H
25+
26+
/*
27+
This file is designed to normalize the libretro-common compiling environment
28+
for public API headers. This should be leaner than a normal compiling environment,
29+
since it gets #included into other project's sources.
30+
*/
31+
32+
/* ------------------------------------ */
33+
34+
/*
35+
Ordinarily we want to put #ifdef __cplusplus extern "C" in C library
36+
headers to enable them to get used by c++ sources.
37+
However, we want to support building this library as C++ as well, so a
38+
special technique is called for.
39+
*/
40+
41+
#define RETRO_BEGIN_DECLS
42+
#define RETRO_END_DECLS
43+
44+
#ifdef __cplusplus
45+
46+
#ifdef CXX_BUILD
47+
/* build wants everything to be built as c++, so no extern "C" */
48+
#else
49+
#undef RETRO_BEGIN_DECLS
50+
#undef RETRO_END_DECLS
51+
#define RETRO_BEGIN_DECLS extern "C" {
52+
#define RETRO_END_DECLS }
53+
#endif
54+
55+
#else
56+
57+
/* header is included by a C source file, so no extern "C" */
58+
59+
#endif
60+
61+
/*
62+
IMO, this non-standard ssize_t should not be used.
63+
However, it's a good example of how to handle something like this.
64+
*/
65+
#ifdef _MSC_VER
66+
#ifndef HAVE_SSIZE_T
67+
#define HAVE_SSIZE_T
68+
#if defined(_WIN64)
69+
typedef __int64 ssize_t;
70+
#elif defined(_WIN32)
71+
typedef int ssize_t;
72+
#endif
73+
#endif
74+
#elif defined(__MACH__)
75+
#include <sys/types.h>
76+
#endif
77+
78+
#ifdef _MSC_VER
79+
#if _MSC_VER >= 1800
80+
#include <inttypes.h>
81+
#else
82+
#ifndef PRId64
83+
#define PRId64 "I64d"
84+
#define PRIu64 "I64u"
85+
#define PRIuPTR "Iu"
86+
#endif
87+
#endif
88+
#else
89+
/* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */
90+
/* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */
91+
/* https://github.com/libretro/RetroArch/issues/6009 */
92+
#ifndef __STDC_FORMAT_MACROS
93+
#define __STDC_FORMAT_MACROS 1
94+
#endif
95+
#include <inttypes.h>
96+
#endif
97+
#ifndef PRId64
98+
#error "inttypes.h is being screwy"
99+
#endif
100+
#define STRING_REP_INT64 "%" PRId64
101+
#define STRING_REP_UINT64 "%" PRIu64
102+
#define STRING_REP_USIZE "%" PRIuPTR
103+
104+
/* Wrap a declaration in RETRO_DEPRECATED() to produce a compiler warning when
105+
it's used. This is intended for developer machines, so it won't work on ancient
106+
or obscure compilers */
107+
#if defined(_MSC_VER)
108+
#if _MSC_VER >= 1400 /* Visual C 2005 or later */
109+
#define RETRO_DEPRECATED(decl) __declspec(deprecated) decl
110+
#endif
111+
#elif defined(__GNUC__)
112+
#if __GNUC__ >= 3 /* GCC 3 or later */
113+
#define RETRO_DEPRECATED(decl) decl __attribute__((deprecated))
114+
#endif
115+
#elif defined(__clang__)
116+
#if __clang_major__ >= 3 /* clang 3 or later */
117+
#define RETRO_DEPRECATED(decl) decl __attribute__((deprecated))
118+
#endif
119+
#endif
120+
#ifndef RETRO_DEPRECATED /* Unsupported compilers */
121+
#define RETRO_DEPRECATED(decl) decl
122+
#endif
123+
124+
/*
125+
I would like to see retro_inline.h moved in here; possibly boolean too.
126+
127+
rationale: these are used in public APIs, and it is easier to find problems
128+
and write code that works the first time portably when they are included uniformly
129+
than to do the analysis from scratch each time you think you need it, for each feature.
130+
131+
Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h,
132+
then you should pay the price everywhere, so you can see how much grief it will cause.
133+
134+
Of course, another school of thought is that you should do as little damage as possible
135+
in as few places as possible...
136+
*/
137+
138+
/* _LIBRETRO_COMMON_RETRO_COMMON_API_H */
139+
#endif
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* Copyright (C) 2010-2020 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (retro_environment.h).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#ifndef __LIBRETRO_SDK_ENVIRONMENT_H
24+
#define __LIBRETRO_SDK_ENVIRONMENT_H
25+
26+
/*
27+
This file is designed to create a normalized environment for compiling
28+
libretro-common's private implementations, or any other sources which might
29+
enjoy use of it's environment (RetroArch for instance).
30+
This should be an elaborately crafted environment so that sources don't
31+
need to be full of platform-specific workarounds.
32+
*/
33+
34+
#if defined (__cplusplus)
35+
/* The expected values would be
36+
* 199711L, for ISO/IEC 14882:1998 or 14882:2003
37+
*/
38+
39+
#elif defined(__STDC__)
40+
/* This is standard C. */
41+
42+
#if (__STDC__ == 1)
43+
/* The implementation is ISO-conforming. */
44+
#define __STDC_ISO__
45+
#else
46+
/* The implementation is not ISO-conforming. */
47+
#endif
48+
49+
#if defined(__STDC_VERSION__)
50+
#if (__STDC_VERSION__ >= 201112L)
51+
/* This is C11. */
52+
#define __STDC_C11__
53+
#elif (__STDC_VERSION__ >= 199901L)
54+
/* This is C99. */
55+
#define __STDC_C99__
56+
#elif (__STDC_VERSION__ >= 199409L)
57+
/* This is C89 with amendment 1. */
58+
#define __STDC_C89__
59+
#define __STDC_C89_AMENDMENT_1__
60+
#else
61+
/* This is C89 without amendment 1. */
62+
#define __STDC_C89__
63+
#endif
64+
#else /* !defined(__STDC_VERSION__) */
65+
/* This is C89. __STDC_VERSION__ is not defined. */
66+
#define __STDC_C89__
67+
#endif
68+
69+
#else /* !defined(__STDC__) */
70+
/* This is not standard C. __STDC__ is not defined. */
71+
#endif
72+
73+
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
74+
/* Try to find out if we're compiling for WinRT or non-WinRT */
75+
#if defined(_MSC_VER) && defined(__has_include)
76+
#if __has_include(<winapifamily.h>)
77+
#define HAVE_WINAPIFAMILY_H 1
78+
#else
79+
#define HAVE_WINAPIFAMILY_H 0
80+
#endif
81+
82+
/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
83+
#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
84+
#define HAVE_WINAPIFAMILY_H 1
85+
#else
86+
#define HAVE_WINAPIFAMILY_H 0
87+
#endif
88+
89+
#if HAVE_WINAPIFAMILY_H
90+
#include <winapifamily.h>
91+
#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
92+
#else
93+
#define WINAPI_FAMILY_WINRT 0
94+
#endif /* HAVE_WINAPIFAMILY_H */
95+
96+
#if WINAPI_FAMILY_WINRT
97+
#undef __WINRT__
98+
#define __WINRT__ 1
99+
#endif
100+
101+
/* MSVC obviously has to have some non-standard constants... */
102+
#if _M_IX86_FP == 1
103+
#define __SSE__ 1
104+
#elif _M_IX86_FP == 2 || (defined(_M_AMD64) || defined(_M_X64))
105+
#define __SSE__ 1
106+
#define __SSE2__ 1
107+
#endif
108+
109+
#endif
110+
111+
#endif

0 commit comments

Comments
 (0)