Fix compilation errors.

This commit is contained in:
Themaister 2011-12-01 21:54:42 +01:00
parent 647b1ba53c
commit e7f1526942
6 changed files with 45 additions and 14 deletions

View File

@ -43,11 +43,11 @@ INCDIRS = -I. -Icommon
MAKE_FSELF_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_fself_npdrm MAKE_FSELF_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_fself_npdrm
MAKE_PACKAGE_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_package_npdrm MAKE_PACKAGE_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_package_npdrm
OBJ = ps3/buffer.o ps3/ps3_audio.o ps3/resampler.o ps3/ps3_input.o ps3/pad_input.o getopt.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o ps3/ps3_video_psgl.o gfx/shader_cg.o gfx/snes_state.o ups.o bps.o strl.o screenshot.o audio/hermite.o OBJ = ps3/buffer.o ps3/ps3_audio.o ps3/resampler.o ps3/ps3_input.o ps3/pad_input.o getopt.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o ps3/ps3_video_psgl.o gfx/shader_cg.o gfx/snes_state.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o
LIBS = -ldbgfont -lPSGL -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysmodule_stub -laudio_stub -lnet_stub -lpthread LIBS = -ldbgfont -lPSGL -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysmodule_stub -laudio_stub -lnet_stub -lpthread
DEFINES = -DHAVE_OPENGL=1 -DHAVE_CG=1 -DHAVE_FBO=1 -D__CELLOS_LV2__ -DPACKAGE_VERSION=\".0.9.2\" DEFINES = -DHAVE_OPENGL=1 -DHAVE_CG=1 -DHAVE_FBO=1 -D__CELLOS_LV2__ -DPACKAGE_VERSION=\"0.9.2\"
# Wrap it up, son! # Wrap it up, son!
#LIBS += -Wl,-wrap,fopen -Wl,-wrap,fclose -Wl,-wrap,fwrite -Wl,-wrap,fread -Wl,-wrap,fseek -Wl,-wrap,ftell -Wl,-wrap,fflush -Wl,-wrap,rewind -Wl,-wrap,fgetpos -Wl,-wrap,fsetpos -Wl,-wrap,setbuf -Wl,-wrap,setvbuf -Wl,-wrap,ungetc -Wl,-wrap,feof #LIBS += -Wl,-wrap,fopen -Wl,-wrap,fclose -Wl,-wrap,fwrite -Wl,-wrap,fread -Wl,-wrap,fseek -Wl,-wrap,ftell -Wl,-wrap,fflush -Wl,-wrap,rewind -Wl,-wrap,fgetpos -Wl,-wrap,fsetpos -Wl,-wrap,setbuf -Wl,-wrap,setvbuf -Wl,-wrap,ungetc -Wl,-wrap,feof

View File

@ -162,6 +162,7 @@ void uninit_drivers(void)
static void init_dsp_plugin(void) static void init_dsp_plugin(void)
{ {
#ifdef HAVE_DYLIB
if (!(*g_settings.audio.dsp_plugin)) if (!(*g_settings.audio.dsp_plugin))
return; return;
@ -214,15 +215,18 @@ error:
dylib_close(g_extern.audio_data.dsp_lib); dylib_close(g_extern.audio_data.dsp_lib);
g_extern.audio_data.dsp_plugin = NULL; g_extern.audio_data.dsp_plugin = NULL;
g_extern.audio_data.dsp_lib = NULL; g_extern.audio_data.dsp_lib = NULL;
#endif
} }
static void deinit_dsp_plugin(void) static void deinit_dsp_plugin(void)
{ {
#ifdef HAVE_DYLIB
if (g_extern.audio_data.dsp_lib && g_extern.audio_data.dsp_plugin) if (g_extern.audio_data.dsp_lib && g_extern.audio_data.dsp_plugin)
{ {
g_extern.audio_data.dsp_plugin->free(g_extern.audio_data.dsp_handle); g_extern.audio_data.dsp_plugin->free(g_extern.audio_data.dsp_handle);
dylib_close(g_extern.audio_data.dsp_lib); dylib_close(g_extern.audio_data.dsp_lib);
} }
#endif
} }
static void adjust_audio_input_rate(void) static void adjust_audio_input_rate(void)
@ -405,7 +409,6 @@ static void init_filter(void)
g_extern.filter.colormap[i] = (r << 16) | (g << 8) | (b << 0); g_extern.filter.colormap[i] = (r << 16) | (g << 8) | (b << 0);
} }
} }
#endif
static void deinit_filter(void) static void deinit_filter(void)
{ {
@ -418,6 +421,7 @@ static void deinit_filter(void)
free(g_extern.filter.colormap); free(g_extern.filter.colormap);
} }
} }
#endif
#ifdef HAVE_XML #ifdef HAVE_XML
static void init_shader_dir(void) static void init_shader_dir(void)
@ -546,7 +550,9 @@ void uninit_video_input(void)
if (driver.video_data && driver.video) if (driver.video_data && driver.video)
driver.video->free(driver.video_data); driver.video->free(driver.video_data);
#ifdef HAVE_DYLIB
deinit_filter(); deinit_filter();
#endif
#ifdef HAVE_XML #ifdef HAVE_XML
deinit_shader_dir(); deinit_shader_dir();

View File

@ -27,13 +27,19 @@
#include "libsnes.hpp" #include "libsnes.hpp"
#if defined(HAVE_DYLIB) || defined(HAVE_DYNAMIC)
#define HAVE_DYNAMIC_LOAD
#endif
#ifdef HAVE_DYNAMIC_LOAD
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#endif
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC_LOAD
#define DLSYM(lib, x) dylib_proc(lib, #x) #define DLSYM(lib, x) dylib_proc(lib, #x)
#define SYM(type, x) do { \ #define SYM(type, x) do { \
@ -96,11 +102,11 @@ unsigned (*psnes_get_memory_size)(unsigned);
void (*psnes_unload_cartridge)(void); void (*psnes_unload_cartridge)(void);
void (*psnes_term)(void); void (*psnes_term)(void);
#ifdef HAVE_DYLIB #ifdef HAVE_DYNAMIC_LOAD
static void set_environment(void); static void set_environment(void);
#endif #endif
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC_LOAD
static void load_dynamic(void) static void load_dynamic(void)
{ {
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes); SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes);
@ -150,7 +156,7 @@ static void load_dynamic(void)
p##x = x; \ p##x = x; \
} while (0) } while (0)
#ifndef HAVE_DYNAMIC #ifndef HAVE_DYNAMIC_LOAD
static void set_statics(void) static void set_statics(void)
{ {
SSYM(snes_init); SSYM(snes_init);
@ -185,12 +191,11 @@ static void set_statics(void)
void init_dlsym(void) void init_dlsym(void)
{ {
#ifdef HAVE_DYNAMIC_LOAD
// Guarantee that we can do "dirty" casting. // Guarantee that we can do "dirty" casting.
// Every OS that this program supports should pass this ... // Every OS that this program supports should pass this ...
assert(sizeof(void*) == sizeof(void (*)(void))); assert(sizeof(void*) == sizeof(void (*)(void)));
#ifdef HAVE_DYNAMIC
// Try to verify that -lsnes was not linked in from other modules // Try to verify that -lsnes was not linked in from other modules
// since loading it dynamically and with -l will fail hard. // since loading it dynamically and with -l will fail hard.
function_t sym = dylib_proc(NULL, "snes_init"); function_t sym = dylib_proc(NULL, "snes_init");
@ -218,19 +223,20 @@ void init_dlsym(void)
set_statics(); set_statics();
#endif #endif
#ifdef HAVE_DYLIB #ifdef HAVE_DYNAMIC_LOAD
set_environment(); set_environment();
#endif #endif
} }
void uninit_dlsym(void) void uninit_dlsym(void)
{ {
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC_LOAD
if (lib_handle) if (lib_handle)
dylib_close(lib_handle); dylib_close(lib_handle);
#endif #endif
} }
#ifdef HAVE_DYNAMIC_LOAD
// Platform independent dylib loading. // Platform independent dylib loading.
dylib_t dylib_load(const char *path) dylib_t dylib_load(const char *path)
{ {
@ -240,7 +246,9 @@ dylib_t dylib_load(const char *path)
return dlopen(path, RTLD_LAZY); return dlopen(path, RTLD_LAZY);
#endif #endif
} }
#endif
#ifdef HAVE_DYNAMIC_LOAD
function_t dylib_proc(dylib_t lib, const char *proc) function_t dylib_proc(dylib_t lib, const char *proc)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -266,7 +274,9 @@ function_t dylib_proc(dylib_t lib, const char *proc)
return sym; return sym;
} }
#endif
#ifdef HAVE_DYNAMIC_LOAD
void dylib_close(dylib_t lib) void dylib_close(dylib_t lib)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -275,7 +285,9 @@ void dylib_close(dylib_t lib)
dlclose(lib); dlclose(lib);
#endif #endif
} }
#endif
#ifdef HAVE_DYNAMIC_LOAD
static bool environment_cb(unsigned cmd, void *data) static bool environment_cb(unsigned cmd, void *data)
{ {
switch (cmd) switch (cmd)
@ -322,7 +334,6 @@ static bool environment_cb(unsigned cmd, void *data)
return true; return true;
} }
#ifdef HAVE_DYLIB
// Assume SNES as defaults. // Assume SNES as defaults.
static void set_environment_defaults(void) static void set_environment_defaults(void)
{ {
@ -354,4 +365,3 @@ static void set_environment(void)
} }
#endif #endif

4
file.c
View File

@ -361,6 +361,8 @@ static void dump_to_file_desperate(const void *data, size_t size, int type)
{ {
#ifdef _WIN32 #ifdef _WIN32
const char *base = getenv("APPDATA"); const char *base = getenv("APPDATA");
#elif defined(__CELLOS_LV2__)
const char *base = NULL;
#else #else
const char *base = getenv("HOME"); const char *base = getenv("HOME");
#endif #endif
@ -929,6 +931,8 @@ bool path_is_directory(const char *path)
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, buf, MAXPATHLEN) == 0) if (MultiByteToWideChar(CP_UTF8, 0, path, -1, buf, MAXPATHLEN) == 0)
return false; return false;
return PathIsDirectoryW(buf) == FILE_ATTRIBUTE_DIRECTORY; return PathIsDirectoryW(buf) == FILE_ATTRIBUTE_DIRECTORY;
#elif defined(__CELLOS_LV2__)
return false; // STUB
#else #else
struct stat buf; struct stat buf;
if (stat(path, &buf) < 0) if (stat(path, &buf) < 0)

View File

@ -32,6 +32,17 @@ void gfx_window_title_reset(void)
gl_frames = 0; gl_frames = 0;
} }
#ifdef __CELLOS_LV2__
#include <sys/sys_time.h>
static void gettimeofday(struct timeval *val, void *dummy)
{
(void)dummy;
uint64_t usec = sys_time_get_system_time();
val->tv_sec = usec / 1000000;
val->tv_usec = usec % 1000000;
}
#endif
bool gfx_window_title(char *buf, size_t size) bool gfx_window_title(char *buf, size_t size)
{ {
static struct timeval tv; static struct timeval tv;

View File

@ -93,7 +93,7 @@ static void *event_loop(void *data)
return NULL; return NULL;
} }
static void* __ps3_init(const char* device, int rate, int latency) static void* __ps3_init(const char* device, unsigned rate, unsigned latency)
{ {
(void)latency; (void)latency;
(void)device; (void)device;