mirror of
https://github.com/libretro/libretro-common.git
synced 2025-04-02 10:31:51 -04:00
Updates for NT 3.51
This commit is contained in:
parent
1d7364379e
commit
40176b498f
12 changed files with 83 additions and 17 deletions
|
@ -57,4 +57,14 @@ int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...)
|
|||
|
||||
return count;
|
||||
}
|
||||
|
||||
int c89_vscprintf_retro__(const char *format, va_list pargs)
|
||||
{
|
||||
int retval;
|
||||
va_list argcopy;
|
||||
va_copy(argcopy, pargs);
|
||||
retval = vsnprintf(NULL, 0, format, argcopy);
|
||||
va_end(argcopy);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <encodings/crc32.h>
|
||||
|
||||
static const uint32_t crc32_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
|
|
|
@ -136,8 +136,12 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
|
|||
{
|
||||
retro_perf_tick_t time_ticks = 0;
|
||||
#if defined(_WIN32)
|
||||
long tv_sec, tv_usec;
|
||||
static const unsigned __int64 epoch = 11644473600000000ULL;
|
||||
long tv_sec, tv_usec;
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
||||
static const unsigned __int64 epoch = 11644473600000000;
|
||||
#else
|
||||
static const unsigned __int64 epoch = 11644473600000000ULL;
|
||||
#endif
|
||||
FILETIME file_time;
|
||||
SYSTEMTIME system_time;
|
||||
ULARGE_INTEGER ularge;
|
||||
|
|
|
@ -362,11 +362,13 @@ bool path_is_compressed_file(const char* path)
|
|||
* Returns: true (1) if file already exists, otherwise false (0).
|
||||
*/
|
||||
bool path_file_exists(const char *path)
|
||||
{
|
||||
{
|
||||
FILE *dummy;
|
||||
|
||||
if (!path || !*path)
|
||||
return false;
|
||||
|
||||
FILE *dummy = fopen(path, "rb");
|
||||
dummy = fopen(path, "rb");
|
||||
|
||||
if (!dummy)
|
||||
return false;
|
||||
|
|
|
@ -201,7 +201,7 @@ void sha256_hash(char *s, const uint8_t *in, size_t size)
|
|||
|
||||
#ifndef HAVE_ZLIB
|
||||
/* Zlib CRC32. */
|
||||
static const uint32_t crc32_table[256] = {
|
||||
static const uint32_t crc32_hash_table[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
|
@ -249,7 +249,7 @@ static const uint32_t crc32_table[256] = {
|
|||
|
||||
uint32_t crc32_adjust(uint32_t checksum, uint8_t input)
|
||||
{
|
||||
return ((checksum >> 8) & 0x00ffffff) ^ crc32_table[(checksum ^ input) & 0xff];
|
||||
return ((checksum >> 8) & 0x00ffffff) ^ crc32_hash_table[(checksum ^ input) & 0xff];
|
||||
}
|
||||
|
||||
uint32_t crc32_calculate(const uint8_t *data, size_t length)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */
|
||||
#if _MSC_VER < 1900
|
||||
#include <stdlib.h>
|
||||
|
@ -86,10 +86,38 @@ typedef int ssize_t;
|
|||
#pragma warning(disable : 4723)
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
/* roundf is available since MSVC 2013 */
|
||||
/* roundf and va_copy is available since MSVC 2013 */
|
||||
#if _MSC_VER < 1800
|
||||
#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
|
||||
#define va_copy(x, y) ((x) = (y))
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1200
|
||||
#ifndef __cplusplus
|
||||
/* VC6 math.h doesn't define some functions when in C mode.
|
||||
* Trying to define a prototype gives "undefined reference".
|
||||
* But providing an implementation then gives "function already has body".
|
||||
* So the equivalent of the implementations from math.h are used as
|
||||
* defines here instead, and it seems to work.
|
||||
*/
|
||||
#define cosf(x) ((float)cos((double)x))
|
||||
#define powf(x, y) ((float)pow((double)x, (double)y))
|
||||
#define sinf(x) ((float)sin((double)x))
|
||||
#define ceilf(x) ((float)ceil((double)x))
|
||||
#define floorf(x) ((float)floor((double)x))
|
||||
#define sqrtf(x) ((float)sqrt((double)x))
|
||||
#endif
|
||||
|
||||
#ifndef _vscprintf
|
||||
#define _vscprintf c89_vscprintf_retro__
|
||||
int c89_vscprintf_retro__(const char *format, va_list pargs);
|
||||
#endif
|
||||
|
||||
#ifndef _strtoui64
|
||||
#define _strtoui64(x, y, z) (_atoi64(x))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX _MAX_PATH
|
||||
|
|
|
@ -47,7 +47,11 @@
|
|||
* error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if _MSC_VER <= 1200
|
||||
extern "C++" {
|
||||
#else
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
|
||||
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1200
|
||||
#define SWAP16 _byteswap_ushort
|
||||
#define SWAP32 _byteswap_ulong
|
||||
#else
|
||||
|
@ -42,7 +42,18 @@
|
|||
(((uint32_t)(x) & 0xff000000) >> 24) \
|
||||
))
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
||||
#define SWAP64(val) \
|
||||
((((uint64_t)(val) & 0x00000000000000ff) << 56) \
|
||||
| (((uint64_t)(val) & 0x000000000000ff00) << 40) \
|
||||
| (((uint64_t)(val) & 0x0000000000ff0000) << 24) \
|
||||
| (((uint64_t)(val) & 0x00000000ff000000) << 8) \
|
||||
| (((uint64_t)(val) & 0x000000ff00000000) >> 8) \
|
||||
| (((uint64_t)(val) & 0x0000ff0000000000) >> 24) \
|
||||
| (((uint64_t)(val) & 0x00ff000000000000) >> 40) \
|
||||
| (((uint64_t)(val) & 0xff00000000000000) >> 56))
|
||||
#else
|
||||
#define SWAP64(val) \
|
||||
((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
|
||||
| (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
|
||||
|
@ -52,6 +63,7 @@
|
|||
| (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
|
||||
| (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
|
||||
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* is_little_endian:
|
||||
|
|
|
@ -49,7 +49,7 @@ enum
|
|||
RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
|
||||
};
|
||||
|
||||
long long int filestream_get_size(RFILE *stream);
|
||||
int64_t filestream_get_size(RFILE *stream);
|
||||
|
||||
void filestream_set_size(RFILE *stream);
|
||||
|
||||
|
|
|
@ -159,7 +159,9 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata)
|
|||
bool thread_created = false;
|
||||
struct thread_data *data = NULL;
|
||||
sthread_t *thread = (sthread_t*)calloc(1, sizeof(*thread));
|
||||
|
||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT <= 0x0410
|
||||
DWORD thread_id = 0;
|
||||
#endif
|
||||
if (!thread)
|
||||
return NULL;
|
||||
|
||||
|
@ -171,7 +173,11 @@ sthread_t *sthread_create(void (*thread_func)(void*), void *userdata)
|
|||
data->userdata = userdata;
|
||||
|
||||
#ifdef USE_WIN32_THREADS
|
||||
thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, NULL);
|
||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT <= 0x0410
|
||||
thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, &thread_id);
|
||||
#else
|
||||
thread->thread = CreateThread(NULL, 0, thread_wrap, data, 0, NULL);
|
||||
#endif
|
||||
thread_created = !!thread->thread;
|
||||
#else
|
||||
#if defined(VITA)
|
||||
|
|
|
@ -69,7 +69,7 @@ struct RFILE
|
|||
{
|
||||
unsigned hints;
|
||||
char *ext;
|
||||
long long int size;
|
||||
int64_t size;
|
||||
#if defined(PSP)
|
||||
SceUID fd;
|
||||
#else
|
||||
|
@ -111,7 +111,7 @@ const char *filestream_get_ext(RFILE *stream)
|
|||
return stream->ext;
|
||||
}
|
||||
|
||||
long long int filestream_get_size(RFILE *stream)
|
||||
int64_t filestream_get_size(RFILE *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue