Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge libretro stuff, bump to 0.3 version" #124

Merged
merged 1 commit into from
May 26, 2024
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.9)

project(chdr VERSION 0.3 LANGUAGES C)
project(chdr VERSION 0.2 LANGUAGES C)

if(CMAKE_PROJECT_NAME STREQUAL "chdr")
option(BUILD_SHARED_LIBS "Build libchdr also as a shared library" ON)
Expand Down
38 changes: 2 additions & 36 deletions include/libchdr/coretypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <stdint.h>
#include <stdio.h>

#ifdef __LIBRETRO__
#include <streams/file_stream.h>
#ifdef USE_LIBRETRO_VFS
#include <streams/file_stream_transforms.h>
#endif

#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
Expand All @@ -29,39 +29,6 @@ typedef int32_t INT32;
typedef int16_t INT16;
typedef int8_t INT8;

#ifdef __LIBRETRO__
#define core_file RFILE
#define core_fopen(file) rfopen(file, "rb")
#define core_fseek rfseek
#define core_ftell rftell
#define core_fread(fc, buff, len) rfread(buff, 1, len, fc)
#define core_fclose rfclose

#ifdef __cplusplus
extern "C" {
#endif

RFILE* rfopen(const char *path, const char *mode);
extern int64_t rfseek(RFILE* stream, int64_t offset, int origin);
extern int64_t rftell(RFILE* stream);
extern int64_t rfread(void* buffer,
size_t elem_size, size_t elem_count, RFILE* stream);
extern int rfclose(RFILE* stream);

#ifdef __cplusplus
}
#endif

static INLINE UINT64 core_fsize(core_file *f)
{
UINT64 rv;
UINT64 p = core_ftell(f);
core_fseek(f, 0, SEEK_END);
rv = core_ftell(f);
core_fseek(f, p, SEEK_SET);
return rv;
}
#else
typedef struct chd_core_file {
/*
* arbitrary pointer to data the implementation uses to implement the below functions
Expand Down Expand Up @@ -107,6 +74,5 @@ static inline UINT64 core_fsize(core_file *fp)
{
return fp->fsize(fp);
}
#endif

#endif
2 changes: 1 addition & 1 deletion src/libchdr_chd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ static core_file *core_stdio_fopen(char const *path) {
getting file size with stdio
-------------------------------------------------*/
static UINT64 core_stdio_fsize(core_file *file) {
#if defined __LIBRETRO__
#if defined USE_LIBRETRO_VFS
#define core_stdio_fseek_impl fseek
#define core_stdio_ftell_impl ftell
#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WIN64__)
Expand Down