mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 19:21:03 +00:00
Style/indent nits
This commit is contained in:
parent
11866d42f8
commit
8437e4bd2a
@ -677,10 +677,9 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y)
|
||||
case OVERLAY_HITBOX_RECT:
|
||||
return (fabs(x - desc->x) <= desc->range_x_mod) &&
|
||||
(fabs(y - desc->y) <= desc->range_y_mod);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline float clamp(float val, float lower, float upper)
|
||||
@ -689,8 +688,7 @@ static inline float clamp(float val, float lower, float upper)
|
||||
return lower;
|
||||
else if (val > upper)
|
||||
return upper;
|
||||
else
|
||||
return val;
|
||||
return val;
|
||||
}
|
||||
|
||||
void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out,
|
||||
|
@ -49,7 +49,8 @@ static inline void RARCH_LOG(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static inline void RARCH_LOG_OUTPUT_V(const char *tag, const char *fmt, va_list ap)
|
||||
static inline void RARCH_LOG_OUTPUT_V(const char *tag,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
RARCH_LOG_V(tag, fmt, ap);
|
||||
}
|
||||
|
@ -29,9 +29,11 @@ static inline void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
|
||||
{
|
||||
char msg_new[1024], buffer[1024];
|
||||
#ifdef IS_SALAMANDER
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch Salamander: %s%s", tag ? tag : "", fmt);
|
||||
#else
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch: %s%s", tag ? tag : "", fmt);
|
||||
#endif
|
||||
wvsprintf(buffer, msg_new, ap);
|
||||
OutputDebugStringA(buffer);
|
||||
@ -47,7 +49,8 @@ static inline void RARCH_LOG(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static inline void RARCH_LOG_OUTPUT_V(const char *tag, const char *msg, va_list ap)
|
||||
static inline void RARCH_LOG_OUTPUT_V(const char *tag,
|
||||
const char *msg, va_list ap)
|
||||
{
|
||||
RARCH_LOG_V(tag, msg, ap);
|
||||
}
|
||||
@ -64,9 +67,11 @@ static inline void RARCH_WARN_V(const char *tag, const char *fmt, va_list ap)
|
||||
{
|
||||
char msg_new[1024], buffer[1024];
|
||||
#ifdef IS_SALAMANDER
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [WARN] :: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch Salamander [WARN] :: %s%s", tag ? tag : "", fmt);
|
||||
#else
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch [WARN] :: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch [WARN] :: %s%s", tag ? tag : "", fmt);
|
||||
#endif
|
||||
wvsprintf(buffer, msg_new, ap);
|
||||
OutputDebugStringA(buffer);
|
||||
@ -86,9 +91,11 @@ static inline void RARCH_ERR_V(const char *tag, const char *fmt, ...)
|
||||
{
|
||||
char msg_new[1024];
|
||||
#ifdef IS_SALAMANDER
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [ERR] :: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch Salamander [ERR] :: %s%s", tag ? tag : "", fmt);
|
||||
#else
|
||||
snprintf(msg_new, sizeof(msg_new), "RetroArch [ERR] :: %s%s", tag ? tag : "", fmt);
|
||||
snprintf(msg_new, sizeof(msg_new),
|
||||
"RetroArch [ERR] :: %s%s", tag ? tag : "", fmt);
|
||||
#endif
|
||||
OutputDebugStringA(fmt);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
#define __RARCH_STDINT_H
|
||||
|
||||
#if _MSC_VER && (_MSC_VER < 1600)
|
||||
//pre-MSVC 2010 needs an implementation of stdint.h
|
||||
/* pre-MSVC 2010 needs an implementation of stdint.h */
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
@ -40,10 +40,11 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
/* For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
* compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
* or compiler give many errors like this:
|
||||
* error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -52,7 +53,7 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||
/* Define _W64 macros to mark types changing their size, like intptr_t. */
|
||||
#ifndef _W64
|
||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
@ -62,13 +63,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// 7.18.1 Integer types
|
||||
/* 7.18.1 Integer types */
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
/* 7.18.1.1 Exact-width integer types */
|
||||
|
||||
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
// realize that, e.g. char has the same size as __int8
|
||||
// so we give up on __intX for them.
|
||||
/* Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
* realize that, e.g. char has the same size as __int8
|
||||
* so we give up on __intX for them.
|
||||
*/
|
||||
#if (_MSC_VER < 1300)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
@ -88,7 +90,7 @@ typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
/* 7.18.1.2 Minimum-width integer types */
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
@ -98,7 +100,7 @@ typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
/* 7.18.1.3 Fastest minimum-width integer types */
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
@ -108,25 +110,26 @@ typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
/* 7.18.1.4 Integer types capable of holding object pointers */
|
||||
#ifdef _WIN64 /* [ */
|
||||
typedef signed __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
#else /* _WIN64 ][ */
|
||||
typedef _W64 signed int intptr_t;
|
||||
typedef _W64 unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
/* 7.18.1.5 Greatest-width integer types */
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
/* 7.18.2 Limits of specified-width integer types */
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||
/* [ See footnote 220 at page 257 and footnote 221 at page 259 */
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
/* 7.18.2.1 Limits of exact-width integer types */
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
@ -140,7 +143,7 @@ typedef uint64_t uintmax_t;
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
/* 7.18.2.2 Limits of minimum-width integer types */
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
@ -154,7 +157,7 @@ typedef uint64_t uintmax_t;
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
/* 7.18.2.3 Limits of fastest minimum-width integer types */
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
@ -168,23 +171,23 @@ typedef uint64_t uintmax_t;
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
|
||||
#ifdef _WIN64 /* [ */
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
#else /* _WIN64 ][ */
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
#endif /* _WIN64 ] */
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
/* 7.18.2.5 Limits of greatest-width integer types */
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
/* 7.18.3 Limits of other integer types */
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
@ -205,25 +208,25 @@ typedef uint64_t uintmax_t;
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
/* WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> */
|
||||
#ifndef WCHAR_MIN /* [ */
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#endif /* WCHAR_MIN ] */
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
#endif /* WCHAR_MAX ] */
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
#endif /* __STDC_LIMIT_MACROS ] */
|
||||
|
||||
/* 7.18.4 Limits of other integer types */
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
/* [ See footnote 224 at page 260 */
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
/* 7.18.4.1 Macros for minimum-width integer constants */
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
@ -235,14 +238,14 @@ typedef uint64_t uintmax_t;
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
/* 7.18.4.2 Macros for greatest-width integer constants */
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
#endif /* __STDC_CONSTANT_MACROS ] */
|
||||
|
||||
#else
|
||||
//sanity for everything else
|
||||
/* Sanity for everything else */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
@ -19,12 +19,14 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#undef UNICODE // Do not bother with UNICODE at this time.
|
||||
#undef UNICODE /* Do not bother with UNICODE at this time. */
|
||||
#include <direct.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
|
||||
// Python headers defines ssize_t and sets HAVE_SSIZE_T. Cannot duplicate these efforts.
|
||||
/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
|
||||
* Cannot duplicate these efforts.
|
||||
*/
|
||||
#ifndef HAVE_SSIZE_T
|
||||
#if defined(_WIN64)
|
||||
typedef __int64 ssize_t;
|
||||
@ -41,7 +43,7 @@ typedef int ssize_t;
|
||||
#undef strncasecmp
|
||||
#define strncasecmp _strnicmp
|
||||
|
||||
// Disable some of the annoying warnings.
|
||||
/* Disable some of the annoying warnings. */
|
||||
#pragma warning(disable : 4800)
|
||||
#pragma warning(disable : 4805)
|
||||
#pragma warning(disable : 4244)
|
||||
|
51
netplay.c
51
netplay.c
@ -87,17 +87,25 @@ struct netplay
|
||||
struct delta_frame *buffer;
|
||||
size_t buffer_size;
|
||||
|
||||
size_t self_ptr; // Ptr where we are now.
|
||||
size_t other_ptr; // Points to the last reliable state that self ever had.
|
||||
size_t read_ptr; // Ptr to where we are reading. Generally, other_ptr <= read_ptr <= self_ptr.
|
||||
size_t tmp_ptr; // A temporary pointer used on replay.
|
||||
/* Pointer where we are now. */
|
||||
size_t self_ptr;
|
||||
/* Points to the last reliable state that self ever had. */
|
||||
size_t other_ptr;
|
||||
/* Pointer to where we are reading.
|
||||
* Generally, other_ptr <= read_ptr <= self_ptr. */
|
||||
size_t read_ptr;
|
||||
/* A temporary pointer used on replay. */
|
||||
size_t tmp_ptr;
|
||||
|
||||
size_t state_size;
|
||||
|
||||
bool is_replay; // Are we replaying old frames?
|
||||
bool can_poll; // We don't want to poll several times on a frame.
|
||||
/* Are we replaying old frames? */
|
||||
bool is_replay;
|
||||
/* We don't want to poll several times on a frame. */
|
||||
bool can_poll;
|
||||
|
||||
// To compat UDP packet loss we also send old data along with the packets.
|
||||
/* To compat UDP packet loss we also send
|
||||
* old data along with the packets. */
|
||||
uint32_t packet_buffer[UDP_FRAME_PACKETS * 2];
|
||||
uint32_t frame_count;
|
||||
uint32_t read_frame_count;
|
||||
@ -109,7 +117,7 @@ struct netplay
|
||||
|
||||
unsigned timeout_cnt;
|
||||
|
||||
// Spectating.
|
||||
/* Spectating. */
|
||||
bool spectate;
|
||||
bool spectate_client;
|
||||
int spectate_fds[MAX_SPECTATORS];
|
||||
@ -117,11 +125,11 @@ struct netplay
|
||||
size_t spectate_input_ptr;
|
||||
size_t spectate_input_size;
|
||||
|
||||
// Player flipping
|
||||
// Flipping state. If ptr >= flip_frame, we apply the flip.
|
||||
// If not, we apply the opposite, effectively creating a trigger point.
|
||||
// To avoid collition we need to make sure our client/host is synced up
|
||||
// well after flip_frame before allowing another flip.
|
||||
/* Player flipping
|
||||
* Flipping state. If ptr >= flip_frame, we apply the flip.
|
||||
* If not, we apply the opposite, effectively creating a trigger point.
|
||||
* To avoid collition we need to make sure our client/host is synced up
|
||||
* well after flip_frame before allowing another flip. */
|
||||
bool flip;
|
||||
uint32_t flip_frame;
|
||||
};
|
||||
@ -167,11 +175,13 @@ static void warn_hangup(void)
|
||||
|
||||
void input_poll_net(void)
|
||||
{
|
||||
if (!netplay_should_skip(g_extern.netplay) && netplay_can_poll(g_extern.netplay))
|
||||
if (!netplay_should_skip(g_extern.netplay)
|
||||
&& netplay_can_poll(g_extern.netplay))
|
||||
netplay_poll(g_extern.netplay);
|
||||
}
|
||||
|
||||
void video_frame_net(const void *data, unsigned width, unsigned height, size_t pitch)
|
||||
void video_frame_net(const void *data, unsigned width,
|
||||
unsigned height, size_t pitch)
|
||||
{
|
||||
if (!netplay_should_skip(g_extern.netplay))
|
||||
g_extern.netplay->cbs.frame_cb(data, width, height, pitch);
|
||||
@ -190,7 +200,8 @@ size_t audio_sample_batch_net(const int16_t *data, size_t frames)
|
||||
return frames;
|
||||
}
|
||||
|
||||
int16_t input_state_net(unsigned port, unsigned device, unsigned index, unsigned id)
|
||||
int16_t input_state_net(unsigned port, unsigned device,
|
||||
unsigned index, unsigned id)
|
||||
{
|
||||
if (netplay_is_alive(g_extern.netplay))
|
||||
return netplay_input_state(g_extern.netplay, port, device, index, id);
|
||||
@ -614,7 +625,7 @@ static bool get_info(netplay_t *handle)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send SRAM data to our Player 2.
|
||||
/* Send SRAM data to our Player 2. */
|
||||
const void *sram = pretro_get_memory_data(RETRO_MEMORY_SAVE_RAM);
|
||||
unsigned sram_size = pretro_get_memory_size(RETRO_MEMORY_SAVE_RAM);
|
||||
if (!send_all(handle->fd, sram, sram_size))
|
||||
@ -682,7 +693,8 @@ static bool bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||
uint32_t in_crc = swap_if_big32(header[CRC_INDEX]);
|
||||
if (in_crc != g_extern.content_crc)
|
||||
{
|
||||
RARCH_ERR("CRC32 mismatch, got 0x%x, expected 0x%x.\n", in_crc, g_extern.content_crc);
|
||||
RARCH_ERR("CRC32 mismatch, got 0x%x, expected 0x%x.\n", in_crc,
|
||||
g_extern.content_crc);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1134,13 +1146,14 @@ static bool netplay_get_cmd(netplay_t *handle)
|
||||
{
|
||||
case NETPLAY_CMD_FLIP_PLAYERS:
|
||||
{
|
||||
uint32_t flip_frame;
|
||||
|
||||
if (cmd_size != sizeof(uint32_t))
|
||||
{
|
||||
RARCH_ERR("CMD_FLIP_PLAYERS has unexpected command size.\n");
|
||||
return netplay_cmd_nak(handle);
|
||||
}
|
||||
|
||||
uint32_t flip_frame;
|
||||
if (!recv_all(handle->fd, &flip_frame, sizeof(flip_frame)))
|
||||
{
|
||||
RARCH_ERR("Failed to receive CMD_FLIP_PLAYERS argument.\n");
|
||||
|
@ -85,7 +85,8 @@ unsigned perf_ptr_libretro;
|
||||
|
||||
void rarch_perf_register(struct retro_perf_counter *perf)
|
||||
{
|
||||
if (!g_extern.perfcnt_enable || perf->registered || perf_ptr_rarch >= MAX_COUNTERS)
|
||||
if (!g_extern.perfcnt_enable || perf->registered
|
||||
|| perf_ptr_rarch >= MAX_COUNTERS)
|
||||
return;
|
||||
|
||||
perf_counters_rarch[perf_ptr_rarch++] = perf;
|
||||
@ -107,7 +108,8 @@ void retro_perf_clear(void)
|
||||
memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro));
|
||||
}
|
||||
|
||||
static void log_counters(const struct retro_perf_counter **counters, unsigned num)
|
||||
static void log_counters(
|
||||
const struct retro_perf_counter **counters, unsigned num)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < num; i++)
|
||||
@ -116,7 +118,8 @@ static void log_counters(const struct retro_perf_counter **counters, unsigned nu
|
||||
{
|
||||
RARCH_LOG(PERF_LOG_FMT,
|
||||
counters[i]->ident,
|
||||
(unsigned long long)counters[i]->total / (unsigned long long)counters[i]->call_cnt,
|
||||
(unsigned long long)counters[i]->total /
|
||||
(unsigned long long)counters[i]->call_cnt,
|
||||
(unsigned long long)counters[i]->call_cnt);
|
||||
}
|
||||
}
|
||||
@ -147,7 +150,8 @@ retro_perf_tick_t rarch_get_perf_counter(void)
|
||||
#elif defined(__linux__) || defined(__QNX__)
|
||||
struct timespec tv;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
|
||||
time = (retro_perf_tick_t)tv.tv_sec * 1000000000 + (retro_perf_tick_t)tv.tv_nsec;
|
||||
time = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
|
||||
(retro_perf_tick_t)tv.tv_nsec;
|
||||
else
|
||||
time = 0;
|
||||
|
||||
@ -194,7 +198,8 @@ retro_time_t rarch_get_time_usec(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
static LARGE_INTEGER freq;
|
||||
if (!freq.QuadPart && !QueryPerformanceFrequency(&freq)) // Frequency is guaranteed to not change.
|
||||
/* Frequency is guaranteed to not change. */
|
||||
if (!freq.QuadPart && !QueryPerformanceFrequency(&freq))
|
||||
return 0;
|
||||
|
||||
LARGE_INTEGER count;
|
||||
@ -205,7 +210,8 @@ retro_time_t rarch_get_time_usec(void)
|
||||
return sys_time_get_system_time();
|
||||
#elif defined(GEKKO)
|
||||
return ticks_to_microsecs(gettime());
|
||||
#elif defined(__MACH__) // OSX doesn't have clock_gettime ...
|
||||
#elif defined(__MACH__)
|
||||
/* OSX doesn't have clock_gettime. */
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
@ -239,8 +245,8 @@ retro_time_t rarch_get_time_usec(void)
|
||||
#ifdef CPU_X86
|
||||
static void x86_cpuid(int func, int flags[4])
|
||||
{
|
||||
// On Android, we compile RetroArch with PIC, and we are not allowed to clobber the ebx
|
||||
// register.
|
||||
/* On Android, we compile RetroArch with PIC, and we
|
||||
* are not allowed to clobber the ebx register. */
|
||||
#ifdef __x86_64__
|
||||
#define REG_b "rbx"
|
||||
#define REG_S "rsi"
|
||||
@ -264,18 +270,21 @@ static void x86_cpuid(int func, int flags[4])
|
||||
#endif
|
||||
}
|
||||
|
||||
// Only runs on i686 and above. Needs to be conditionally run.
|
||||
/* Only runs on i686 and above. Needs to be conditionally run. */
|
||||
static uint64_t xgetbv_x86(uint32_t index)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
uint32_t eax, edx;
|
||||
asm volatile (
|
||||
// Older GCC versions (Apple's GCC for example) do not understand xgetbv instruction.
|
||||
// Stamp out the machine code directly.
|
||||
/* Older GCC versions (Apple's GCC for example) do
|
||||
* not understand xgetbv instruction.
|
||||
* Stamp out the machine code directly.
|
||||
*/
|
||||
".byte 0x0f, 0x01, 0xd0\n"
|
||||
: "=a"(eax), "=d"(edx) : "c"(index));
|
||||
return ((uint64_t)edx << 32) | eax;
|
||||
#elif _MSC_FULL_VER >= 160040219 // Intrinsic only works on 2010 SP1 and above.
|
||||
#elif _MSC_FULL_VER >= 160040219
|
||||
/* Intrinsic only works on 2010 SP1 and above. */
|
||||
return _xgetbv(index);
|
||||
#else
|
||||
RARCH_WARN("Unknown compiler. Cannot check xgetbv bits.\n");
|
||||
@ -287,15 +296,16 @@ static uint64_t xgetbv_x86(uint32_t index)
|
||||
#if defined(__ARM_NEON__)
|
||||
static void arm_enable_runfast_mode(void)
|
||||
{
|
||||
// RunFast mode. Enables flush-to-zero and some floating point optimizations.
|
||||
/* RunFast mode. Enables flush-to-zero and some
|
||||
* floating point optimizations. */
|
||||
static const unsigned x = 0x04086060;
|
||||
static const unsigned y = 0x03000000;
|
||||
int r;
|
||||
asm volatile(
|
||||
"fmrx %0, fpscr \n\t" // r0 = FPSCR
|
||||
"and %0, %0, %1 \n\t" // r0 = r0 & 0x04086060
|
||||
"orr %0, %0, %2 \n\t" // r0 = r0 | 0x03000000
|
||||
"fmxr fpscr, %0 \n\t" // FPSCR = r0
|
||||
"fmrx %0, fpscr \n\t" /* r0 = FPSCR */
|
||||
"and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */
|
||||
"orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */
|
||||
"fmxr fpscr, %0 \n\t" /* FPSCR = r0 */
|
||||
: "=r"(r)
|
||||
: "r"(x), "r"(y)
|
||||
);
|
||||
@ -304,7 +314,8 @@ static void arm_enable_runfast_mode(void)
|
||||
|
||||
unsigned rarch_get_cpu_cores(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(_XBOX) // Win32
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
/* Win32 */
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
@ -312,13 +323,15 @@ unsigned rarch_get_cpu_cores(void)
|
||||
return android_getCpuCount();
|
||||
#elif defined(GEKKO)
|
||||
return 1;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN) // Linux, most unix-likes.
|
||||
#elif defined(_SC_NPROCESSORS_ONLN)
|
||||
/* Linux, most UNIX-likes. */
|
||||
long ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (ret <= 0)
|
||||
return (unsigned)1;
|
||||
return ret;
|
||||
#elif defined(BSD) || defined(__APPLE__) // BSD
|
||||
// Copypasta from stackoverflow, dunno if it works.
|
||||
#elif defined(BSD) || defined(__APPLE__)
|
||||
/* BSD */
|
||||
/* Copypasta from stackoverflow, dunno if it works. */
|
||||
int num_cpu = 0;
|
||||
int mib[4];
|
||||
size_t len = sizeof(num_cpu);
|
||||
@ -337,7 +350,7 @@ unsigned rarch_get_cpu_cores(void)
|
||||
#elif defined(_XBOX360)
|
||||
return 3;
|
||||
#else
|
||||
// No idea, assume single core.
|
||||
/* No idea, assume single core. */
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
@ -356,7 +369,7 @@ uint64_t rarch_get_cpu_features(void)
|
||||
RARCH_LOG("[CPUID]: Vendor: %s\n", vendor);
|
||||
|
||||
unsigned max_flag = flags[0];
|
||||
if (max_flag < 1) // Does CPUID not support func = 1? (unlikely ...)
|
||||
if (max_flag < 1) /* Does CPUID not support func = 1? (unlikely ...) */
|
||||
return 0;
|
||||
|
||||
x86_cpuid(1, flags);
|
||||
@ -366,7 +379,7 @@ uint64_t rarch_get_cpu_features(void)
|
||||
|
||||
if (flags[3] & (1 << 25))
|
||||
{
|
||||
// SSE also implies MMXEXT (according to FFmpeg source).
|
||||
/* SSE also implies MMXEXT (according to FFmpeg source). */
|
||||
cpu |= RETRO_SIMD_SSE;
|
||||
cpu |= RETRO_SIMD_MMXEXT;
|
||||
}
|
||||
@ -390,8 +403,11 @@ uint64_t rarch_get_cpu_features(void)
|
||||
cpu |= RETRO_SIMD_AES;
|
||||
|
||||
const int avx_flags = (1 << 27) | (1 << 28);
|
||||
// Must only perform xgetbv check if we have AVX CPU support (guaranteed to have at least i686).
|
||||
if (((flags[2] & avx_flags) == avx_flags) && ((xgetbv_x86(0) & 0x6) == 0x6))
|
||||
|
||||
/* Must only perform xgetbv check if we have
|
||||
* AVX CPU support (guaranteed to have at least i686). */
|
||||
if (((flags[2] & avx_flags) == avx_flags)
|
||||
&& ((xgetbv_x86(0) & 0x6) == 0x6))
|
||||
cpu |= RETRO_SIMD_AVX;
|
||||
|
||||
if (max_flag >= 7)
|
||||
|
Loading…
x
Reference in New Issue
Block a user