* port ecore_plugin to windows
* add comments after some #endif * speed up the compilation on windows * remove some trailing spaces in ecore_path.c SVN revision: 31890
This commit is contained in:
parent
2c2ca77d5f
commit
a8ebdc324c
|
@ -1,6 +1,10 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
# include <winsock2.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -11,10 +15,10 @@
|
|||
#define FIX_HZ 1
|
||||
|
||||
#ifdef FIX_HZ
|
||||
#include <sys/param.h>
|
||||
#ifndef HZ
|
||||
#define HZ 100
|
||||
#endif
|
||||
# include <sys/param.h>
|
||||
# ifndef HZ
|
||||
# define HZ 100
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "ecore_private.h"
|
||||
|
@ -344,7 +348,7 @@ _ecore_main_select(double timeout)
|
|||
}
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get()) return -1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
ret = select(max_fd + 1, &rfds, &wfds, &exfds, t);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -456,7 +460,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
MSG msg;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
double next_time;
|
||||
int have_event = 0;
|
||||
int have_signal;
|
||||
|
@ -475,7 +479,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
#ifndef _WIN32
|
||||
/* process signals into events .... */
|
||||
while (_ecore_signal_count_get()) _ecore_signal_call();
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
if (_ecore_event_exist())
|
||||
{
|
||||
int ret;
|
||||
|
@ -498,7 +502,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (ret > 0) have_event = 1;
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if (have_signal || have_event)
|
||||
goto process_events;
|
||||
|
@ -530,7 +534,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if ((t1 > 0.0) && (t2 > 0.0))
|
||||
_ecore_fps_debug_runtime_add(t2 - t1);
|
||||
}
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
start_loop:
|
||||
if (do_quit)
|
||||
{
|
||||
|
@ -554,7 +558,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (ret > 0) have_event = 1;
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
/* idlers */
|
||||
else
|
||||
|
@ -569,7 +573,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (ret > 0) have_event = 1;
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
if (have_event || have_signal) break;
|
||||
next_time = _ecore_timer_next_get();
|
||||
if (next_time >= 0) goto start_loop;
|
||||
|
@ -589,7 +593,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (ret > 0) have_event = 1;
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
/* idlers */
|
||||
else
|
||||
|
@ -605,7 +609,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (ret > 0) have_event = 1;
|
||||
#ifndef _WIN32
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
if ((have_event) || (have_signal)) break;
|
||||
cur_time = ecore_time_get();
|
||||
t = ecore_time_get() - cur_time;
|
||||
|
@ -622,7 +626,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
{
|
||||
t1 = ecore_time_get();
|
||||
}
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
/* we came out of our "wait state" so idle has exited */
|
||||
if (!once_only)
|
||||
_ecore_idle_exiter_call();
|
||||
|
@ -636,7 +640,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
#ifndef _WIN32
|
||||
/* process signals into events .... */
|
||||
while (_ecore_signal_count_get()) _ecore_signal_call();
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* handle events ... */
|
||||
_ecore_event_call();
|
||||
|
@ -649,7 +653,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
if (once_only) _ecore_idle_enterer_call();
|
||||
in_main_loop--;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ ecore_path_group_available(int group_id)
|
|||
/**
|
||||
* Retrieves a list of all available plugins in the given path.
|
||||
* @param group_id The identifier for the given path.
|
||||
* @return A pointer to a newly allocated list of all plugins found in the
|
||||
* @return A pointer to a newly allocated list of all plugins found in the
|
||||
* paths identified by @p group_id. @c NULL otherwise.
|
||||
* @ingroup Ecore_Plugin
|
||||
*/
|
||||
|
@ -313,7 +313,7 @@ ecore_plugin_available_get(int group_id)
|
|||
{
|
||||
char ppath[PATH_MAX];
|
||||
char *ext;
|
||||
|
||||
|
||||
if (*d->d_name == '.')
|
||||
continue;
|
||||
|
||||
|
@ -330,7 +330,7 @@ ecore_plugin_available_get(int group_id)
|
|||
ecore_strlcpy(ppath, d->d_name, sizeof(ppath));
|
||||
ext = strrchr(ppath, '.');
|
||||
*ext = '\0';
|
||||
|
||||
|
||||
if (!ecore_hash_get(plugins, ppath))
|
||||
{
|
||||
char *key;
|
||||
|
|
|
@ -1,10 +1,93 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <dlfcn.h>
|
||||
# include "ecore_private.h"
|
||||
# include "Ecore_Data.h"
|
||||
#else
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "ecore_private.h"
|
||||
#include "Ecore_Data.h"
|
||||
|
||||
/* FIXME: that hack is a temporary one. That code will be in MinGW soon */
|
||||
#ifdef _WIN32
|
||||
|
||||
# define RTLD_LAZY 1 /* lazy function call binding */
|
||||
# define RTLD_NOW 2 /* immediate function call binding */
|
||||
# define RTLD_GLOBAL 4 /* symbols in this dlopen'ed obj are visible
|
||||
to other dlopen'ed objs */
|
||||
|
||||
static char *dlerr_ptr;
|
||||
static char dlerr_data[80];
|
||||
|
||||
void *dlopen (const char *file, int mode)
|
||||
{
|
||||
HMODULE hmodule;
|
||||
|
||||
hmodule = LoadLibrary(file);
|
||||
if (hmodule == NULL)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = GetLastError();
|
||||
sprintf(dlerr_data, "LoadLibraryEx returned %d.", error);
|
||||
dlerr_ptr = dlerr_data;
|
||||
}
|
||||
return hmodule;
|
||||
}
|
||||
|
||||
int dlclose (void *handle)
|
||||
{
|
||||
if (FreeLibrary(handle))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int error;
|
||||
|
||||
error = GetLastError();
|
||||
sprintf(dlerr_data, "FreeLibrary returned %d.", error);
|
||||
dlerr_ptr = dlerr_data;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void *dlsym (void *handle, const char *name)
|
||||
{
|
||||
FARPROC fp;
|
||||
|
||||
fp = GetProcAddress(handle, name);
|
||||
if (fp == NULL)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = GetLastError();
|
||||
sprintf(dlerr_data, "GetProcAddress returned %d.", error);
|
||||
dlerr_ptr = dlerr_data;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
char *dlerror (void)
|
||||
{
|
||||
if (dlerr_ptr != NULL)
|
||||
{
|
||||
dlerr_ptr = NULL;
|
||||
return dlerr_data;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
static Ecore_List *loaded_plugins = NULL;
|
||||
|
||||
|
@ -35,19 +118,29 @@ ecore_plugin_load(int group_id, const char *plugin_name, const char *version)
|
|||
|
||||
CHECK_PARAM_POINTER_RETURN("plugin_name", plugin_name, NULL);
|
||||
|
||||
#ifndef _WIN32
|
||||
if (!version || *version == '\0')
|
||||
snprintf(temp, sizeof(temp), "%s.so", plugin_name);
|
||||
else
|
||||
snprintf(temp, sizeof(temp), "%s.so.%s", plugin_name, version);
|
||||
#else
|
||||
if (!version || *version == '\0')
|
||||
snprintf(temp, sizeof(temp), "%s.dll", plugin_name);
|
||||
else
|
||||
snprintf(temp, sizeof(temp), "%s-%s.dll", plugin_name, version);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
path = ecore_path_group_find(group_id, temp);
|
||||
|
||||
#ifndef _WIN32
|
||||
if (!path && version)
|
||||
{
|
||||
/* if this file doesn't exist try a different order */
|
||||
snprintf(temp, sizeof(temp), "%s.%s.so", plugin_name, version);
|
||||
path = ecore_path_group_find(group_id, temp);
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
|
@ -134,4 +227,3 @@ ecore_plugin_symbol_get(Ecore_Plugin *plugin, const char *symbol_name)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue