mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Move dylib.c to libretro-common
This commit is contained in:
parent
4665f2d17a
commit
87d9834d06
12 changed files with 180 additions and 168 deletions
|
@ -124,7 +124,7 @@ OBJ += frontend/frontend.o \
|
||||||
configuration.o \
|
configuration.o \
|
||||||
settings_list.o \
|
settings_list.o \
|
||||||
settings.o \
|
settings.o \
|
||||||
dylib.o \
|
libretro-common/dynamic/dylib.o \
|
||||||
dynamic.o \
|
dynamic.o \
|
||||||
dynamic_dummy.o \
|
dynamic_dummy.o \
|
||||||
libretro-common/queues/message_queue.o \
|
libretro-common/queues/message_queue.o \
|
||||||
|
|
94
dylib.c
94
dylib.c
|
@ -1,94 +0,0 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "dylib.h"
|
|
||||||
|
|
||||||
#ifdef NEED_DYNAMIC
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dylib_load:
|
|
||||||
* @path : Path to libretro core library.
|
|
||||||
*
|
|
||||||
* Platform independent dylib loading.
|
|
||||||
*
|
|
||||||
* Returns: library handle on success, otherwise NULL.
|
|
||||||
**/
|
|
||||||
dylib_t dylib_load(const char *path)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
dylib_t lib = LoadLibrary(path);
|
|
||||||
#else
|
|
||||||
dylib_t lib = dlopen(path, RTLD_LAZY);
|
|
||||||
#endif
|
|
||||||
return lib;
|
|
||||||
}
|
|
||||||
|
|
||||||
function_t dylib_proc(dylib_t lib, const char *proc)
|
|
||||||
{
|
|
||||||
function_t sym;
|
|
||||||
void *ptr_sym = NULL;
|
|
||||||
|
|
||||||
(void)ptr_sym;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
sym = (function_t)GetProcAddress(lib ?
|
|
||||||
(HMODULE)lib : GetModuleHandle(NULL), proc);
|
|
||||||
#else
|
|
||||||
if (lib)
|
|
||||||
ptr_sym = dlsym(lib, proc);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
void *handle = dlopen(NULL, RTLD_LAZY);
|
|
||||||
if (handle)
|
|
||||||
{
|
|
||||||
ptr_sym = dlsym(handle, proc);
|
|
||||||
dlclose(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dirty hack to workaround the non-legality of
|
|
||||||
* (void*) -> fn-pointer casts. */
|
|
||||||
memcpy(&sym, &ptr_sym, sizeof(void*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return sym;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dylib_close:
|
|
||||||
* @lib : Library handle.
|
|
||||||
*
|
|
||||||
* Frees library handle.
|
|
||||||
**/
|
|
||||||
void dylib_close(dylib_t lib)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
FreeLibrary((HMODULE)lib);
|
|
||||||
#else
|
|
||||||
#ifndef NO_DLCLOSE
|
|
||||||
dlclose(lib);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
66
dylib.h
66
dylib.h
|
@ -1,66 +0,0 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __DYLIB_H
|
|
||||||
#define __DYLIB_H
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
|
||||||
#define NEED_DYNAMIC
|
|
||||||
#else
|
|
||||||
#undef NEED_DYNAMIC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void *dylib_t;
|
|
||||||
typedef void (*function_t)(void);
|
|
||||||
|
|
||||||
#ifdef NEED_DYNAMIC
|
|
||||||
/**
|
|
||||||
* dylib_load:
|
|
||||||
* @path : Path to libretro core library.
|
|
||||||
*
|
|
||||||
* Platform independent dylib loading.
|
|
||||||
*
|
|
||||||
* Returns: library handle on success, otherwise NULL.
|
|
||||||
**/
|
|
||||||
dylib_t dylib_load(const char *path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dylib_close:
|
|
||||||
* @lib : Library handle.
|
|
||||||
*
|
|
||||||
* Frees library handle.
|
|
||||||
**/
|
|
||||||
void dylib_close(dylib_t lib);
|
|
||||||
|
|
||||||
function_t dylib_proc(dylib_t lib, const char *proc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dylib.h"
|
#include <dynamic/dylib.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include "../frontend_driver.h"
|
#include "../frontend_driver.h"
|
||||||
#include "../../dylib.h"
|
#include <dynamic/dylib.h>
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../dylib.h"
|
#include <dynamic/dylib.h>
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
static void d3d_calculate_rect(d3d_video_t *d3d,
|
static void d3d_calculate_rect(d3d_video_t *d3d,
|
||||||
|
|
|
@ -548,7 +548,7 @@ FILTERS
|
||||||
/*============================================================
|
/*============================================================
|
||||||
DYNAMIC
|
DYNAMIC
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../dylib.c"
|
#include "../libretro-common/dynamic/dylib.c"
|
||||||
#include "../dynamic.c"
|
#include "../dynamic.c"
|
||||||
#include "../dynamic_dummy.c"
|
#include "../dynamic_dummy.c"
|
||||||
#include "../gfx/video_filter.c"
|
#include "../gfx/video_filter.c"
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#define BUILDING_BTDYNAMIC
|
#define BUILDING_BTDYNAMIC
|
||||||
#include "btstack_hid.h"
|
#include "btstack_hid.h"
|
||||||
#include "../../dylib.h"
|
#include <dynamic/dylib.h>
|
||||||
#include "../connect/joypad_connection.h"
|
#include "../connect/joypad_connection.h"
|
||||||
|
|
||||||
typedef struct btstack_hid
|
typedef struct btstack_hid
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "../input_autodetect.h"
|
#include "../input_autodetect.h"
|
||||||
#include "../input_common.h"
|
#include "../input_common.h"
|
||||||
|
|
||||||
#include "../../dylib.h"
|
#include <dynamic/dylib.h>
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
|
|
100
libretro-common/dynamic/dylib.c
Normal file
100
libretro-common/dynamic/dylib.c
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (dylib.c).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <dynamic/dylib.h>
|
||||||
|
|
||||||
|
#ifdef NEED_DYNAMIC
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dylib_load:
|
||||||
|
* @path : Path to libretro core library.
|
||||||
|
*
|
||||||
|
* Platform independent dylib loading.
|
||||||
|
*
|
||||||
|
* Returns: library handle on success, otherwise NULL.
|
||||||
|
**/
|
||||||
|
dylib_t dylib_load(const char *path)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
dylib_t lib = LoadLibrary(path);
|
||||||
|
#else
|
||||||
|
dylib_t lib = dlopen(path, RTLD_LAZY);
|
||||||
|
#endif
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
function_t dylib_proc(dylib_t lib, const char *proc)
|
||||||
|
{
|
||||||
|
function_t sym;
|
||||||
|
void *ptr_sym = NULL;
|
||||||
|
|
||||||
|
(void)ptr_sym;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
sym = (function_t)GetProcAddress(lib ?
|
||||||
|
(HMODULE)lib : GetModuleHandle(NULL), proc);
|
||||||
|
#else
|
||||||
|
if (lib)
|
||||||
|
ptr_sym = dlsym(lib, proc);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
void *handle = dlopen(NULL, RTLD_LAZY);
|
||||||
|
if (handle)
|
||||||
|
{
|
||||||
|
ptr_sym = dlsym(handle, proc);
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dirty hack to workaround the non-legality of
|
||||||
|
* (void*) -> fn-pointer casts. */
|
||||||
|
memcpy(&sym, &ptr_sym, sizeof(void*));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dylib_close:
|
||||||
|
* @lib : Library handle.
|
||||||
|
*
|
||||||
|
* Frees library handle.
|
||||||
|
**/
|
||||||
|
void dylib_close(dylib_t lib)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
FreeLibrary((HMODULE)lib);
|
||||||
|
#else
|
||||||
|
#ifndef NO_DLCLOSE
|
||||||
|
dlclose(lib);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
72
libretro-common/include/dynamic/dylib.h
Normal file
72
libretro-common/include/dynamic/dylib.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (dylib.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __DYLIB_H
|
||||||
|
#define __DYLIB_H
|
||||||
|
|
||||||
|
#include <boolean.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
||||||
|
#define NEED_DYNAMIC
|
||||||
|
#else
|
||||||
|
#undef NEED_DYNAMIC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void *dylib_t;
|
||||||
|
typedef void (*function_t)(void);
|
||||||
|
|
||||||
|
#ifdef NEED_DYNAMIC
|
||||||
|
/**
|
||||||
|
* dylib_load:
|
||||||
|
* @path : Path to libretro core library.
|
||||||
|
*
|
||||||
|
* Platform independent dylib loading.
|
||||||
|
*
|
||||||
|
* Returns: library handle on success, otherwise NULL.
|
||||||
|
**/
|
||||||
|
dylib_t dylib_load(const char *path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dylib_close:
|
||||||
|
* @lib : Library handle.
|
||||||
|
*
|
||||||
|
* Frees library handle.
|
||||||
|
**/
|
||||||
|
void dylib_close(dylib_t lib);
|
||||||
|
|
||||||
|
function_t dylib_proc(dylib_t lib, const char *proc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "retroarch-joyconfig.c"
|
#include "retroarch-joyconfig.c"
|
||||||
|
|
||||||
#include "../dylib.c"
|
#include "../libretro-common/dynamic/dylib.c"
|
||||||
|
|
||||||
#if defined(__linux) && !defined(ANDROID)
|
#if defined(__linux) && !defined(ANDROID)
|
||||||
#include "../input/drivers/linuxraw_input.c"
|
#include "../input/drivers/linuxraw_input.c"
|
||||||
|
|
Loading…
Add table
Reference in a new issue